Fix the characteristics of some sections like ".voltbl". Or the program will be crash sometimes.
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
This would need a test case for it to be commitable.
I don’t want the linker to blindly change the characteristics bits for any section that have the bits set to zero - if this is needed for a specific section in some case, then please limit the workaround to exactly that section name and nothing else. It would be good to give more context about what tool that produces such faulty sections, and ideally that tool would be fixed too. If possible, it could be good to limit the workaround to mingw mode, if that’s where this occurs.
Also, when uploading diffs, please create the diffs with extra context (git diff -U999).
lld/COFF/Writer.cpp | ||
---|---|---|
1505 | I'd prefer to have this either be sec->name == ".voltbl" or sec->name.startswith(".voltbl") instead, to make it a bit more strict still. |
I think the linker is supposed to treat these as metadata sections, similar to .gfids, which do not appear in the output. See this old issue:
https://bugs.llvm.org/show_bug.cgi?id=45111
The MSVC CRT includes objects with some of these sections, and the MSVC linker does not include these sections in the output, or if it does, it has builtin rules to merge them into existing sections like .rdata.
I think a better fix would be to discard both of these sections (.00cfg and .voltbl) until we understand what they are for.
.00cfg is for "Control Flow Guard", there's a pretty good explanation in the answers: [1] (and if you follow the links as well)
.voltbl is for "Volatile Metadata" for x86 emulation on ARM64, see [2]. Also thread in [3], and [4] and [5].
[1] https://reverseengineering.stackexchange.com/questions/19593/00cfg-section-in-the-pe-file
[2] https://devblogs.microsoft.com/cppblog/msvc-backend-updates-in-visual-studio-2019-version-16-10-preview-2/
[3] https://twitter.com/ericbrumer/status/1422305190414217244
[4] https://github.com/ocaml/ocaml/commit/0ac73587579bb6648dac6aee2b58fb873bd652a6
[5] https://github.com/alainfrisch/flexdll/commit/bd49188b437c60dfdbc7cbed992efac03dc8303f
I'd prefer to have this either be sec->name == ".voltbl" or sec->name.startswith(".voltbl") instead, to make it a bit more strict still.