This is an archive of the discontinued LLVM Phabricator instance.

[MC][COFF] Add COFF section flag "Info"
ClosedPublic

Authored by bcl5980 on Oct 17 2022, 8:25 PM.

Details

Summary

For now, we have not parse section flag Info in asm file. When we emit a section with info flag to asm, then compile asm to obj we will lose the Info flag for the section.
The motivation of this change is ARM64EC's hybmp$x section. If we lose the Info flag MSVC link will report a warning:
warning LNK4078: multiple '.hybmp' sections found with different attributes

Diff Detail

Event Timeline

bcl5980 created this revision.Oct 17 2022, 8:25 PM
bcl5980 requested review of this revision.Oct 17 2022, 8:25 PM
Herald added a project: Restricted Project. · View Herald TranscriptOct 17 2022, 8:25 PM
bcl5980 updated this revision to Diff 468402.Oct 17 2022, 8:27 PM

Fix test.

bcl5980 updated this revision to Diff 468454.Oct 18 2022, 2:07 AM

Fix tests failure

This revision is now accepted and ready to land.Oct 18 2022, 10:07 AM
mstorsjo added inline comments.Oct 18 2022, 10:32 AM
llvm/test/MC/COFF/section.s
40

Is this a section flag that GNU as also supports, or is this flag a new invention (which hopefully doesn’t collide with something elder in GNU as)?

efriedma requested changes to this revision.Oct 18 2022, 10:54 AM

Actually, hmm, looking at this again, I think binutils uses "e" for this flag.

This revision now requires changes to proceed.Oct 18 2022, 10:54 AM

Actually, hmm, looking at this again, I think binutils uses "e" for this flag.

It looks in llvm-nm, it use "i" for the flag.
https://github.com/llvm/llvm-project/blob/67957368ae9776ec25db80c69f772e40c75ed690/llvm/tools/llvm-nm/llvm-nm.cpp#L941

So does binutils nm. But binutils as expects "e".

So does binutils nm. But binutils as expects "e".

Can you provider some detail link for that? I try to search IMAGE_SCN_LNK_INFO in git://sourceware.org/git/binutils-gdb.git, but haven't find anything.

efriedma accepted this revision.Oct 18 2022, 4:04 PM

Oh, sorry, I got confused. binutils apparently treats "e" as an alias for "n".

"i" doesn't appear to conflict with any existing usage, so should be fine.

This revision is now accepted and ready to land.Oct 18 2022, 4:04 PM
This revision was automatically updated to reflect the committed changes.
MaskRay added inline comments.Oct 18 2022, 8:00 PM
llvm/test/MC/COFF/section.s
40

How can I configure binutils for Windows to check this?

efriedma added inline comments.Oct 18 2022, 8:31 PM
llvm/test/MC/COFF/section.s
40

Not sure what exactly you're asking, but possible answers:

  • mingw gcc/binutils binary packages are widely available; you don't need to try to build it yourself.
  • binutils source code does not refer to IMAGE_SCN_LNK_INFO anywhere relevant, and none of the documented flags produce it.
  • binutils currently produces an error message if you try to use "i".
mstorsjo added inline comments.Oct 18 2022, 10:09 PM
llvm/test/MC/COFF/section.s
40

Debian/Ubuntu based linux distros provide binutils targeting mingw in packages named e.g. binutils-mingw-w64-x86-64 (and full toolchains pulled in by e.g. gcc-mingw-w64-x86-64). And you can build binutils yourself with e.g. ../binutils-gdb/configure --target=x86_64-w64-mingw32 --disable-werror --disable-gdb.