[PATCH] D126898: [COFF] Check table ptr more thoroughly and ignore empty sections

Martin Storsjö via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 10 00:48:58 PDT 2022


mstorsjo added a comment.

In D126898#3572344 <https://reviews.llvm.org/D126898#3572344>, @glandium wrote:

> So, looking a little bit deeper, the resource editor in NSIS doesn't handle relocations, and the .reloc section is right after the .rsrc section that the resource editor will grow... So they actually have a build rule to pass /FIXED to link.exe when building their stubs with MSVC. I suppose mingw-binutils defaults to non-relocatable .exes (because the problem doesn't appear when building with mingw-gcc/mingw-binutils), and we only end up with relocatable .exes because we're building with mingw-clang/lld and lld defaults to relocatable .exes.

Actually, binutils 2.36 and newer also create a reloc section by default now, since this commit: https://sourceware.org/git/?p=binutils-gdb.git;a=commitdiff;h=514b4e191d5f46de8e142fe216e677a35fa9c4bb;hp=f2e5245f4169c2a1849ba998872e245c1b303950

It can be disabled by passing `-Wl,--disable-reloc-section` though.

In D126898#3572414 <https://reviews.llvm.org/D126898#3572414>, @glandium wrote:

> Passing `-Wl,/fixed` as a linker flag when building the NSIS stubs fixes the issue, FWIW.

It seems like we should implement the `--disable-reloc-section` in the LLD mingw linker layer then, and pass it onto the lld-link interface as `/fixed`.

(I'm somewhat amazed that you can pass options directly via the mingw linker layer to the lld-link layer like that. The mingw options interface considers `/fixed` as an input path name and just passes it on to lld-link, which then considers it an option. The kosher way of doing it is `-Wl,-Xlink=/fixed` (or `-Wl,-Xlink=-fixed` if you prefer that form), but that's a bit unwieldy and clumsy. And for any case where one really wants to pass such options outside of just one off testing, we should add a proper mingw linker option for it.)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D126898/new/

https://reviews.llvm.org/D126898



More information about the llvm-commits mailing list