This is an archive of the discontinued LLVM Phabricator instance.

[lld] [coff] Fix the characteristics of some sections like ".voltbl".
Needs ReviewPublic

Authored by gmh5225 on Jan 1 2022, 5:03 AM.

Details

Reviewers
aganea
mstorsjo
rnk
Group Reviewers
lld
Summary

Fix the characteristics of some sections like ".voltbl". Or the program will be crash sometimes.

Diff Detail

Event Timeline

gmh5225 requested review of this revision.Jan 1 2022, 5:03 AM
gmh5225 created this revision.
Herald added a project: Restricted Project. · View Herald TranscriptJan 1 2022, 5:03 AM

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).

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).

Thanks sir. I need some time to do some test cases

gmh5225 updated this revision to Diff 396856.Jan 1 2022, 6:36 AM

Only fix ".voltbl"

gmh5225 updated this revision to Diff 396861.Jan 1 2022, 7:50 AM

clang-foramt

mstorsjo added inline comments.Jan 1 2022, 3:19 PM
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.

rnk added a comment.Jan 4 2022, 2:49 PM

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.

Herald added a project: Restricted Project. · View Herald TranscriptApr 14 2022, 11:17 PM