[PATCH] D136125: [MC][COFF] Add COFF section flag "Info"
chenglin.bi via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Oct 17 20:25:02 PDT 2022
bcl5980 created this revision.
bcl5980 added reviewers: efriedma, MaskRay, mstorsjo.
Herald added subscribers: StephenFan, hiraditya, kristof.beyls.
Herald added a project: All.
bcl5980 requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
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`
https://reviews.llvm.org/D136125
Files:
llvm/lib/MC/MCParser/COFFAsmParser.cpp
llvm/lib/MC/MCSectionCOFF.cpp
llvm/test/MC/COFF/section.s
Index: llvm/test/MC/COFF/section.s
===================================================================
--- llvm/test/MC/COFF/section.s
+++ llvm/test/MC/COFF/section.s
@@ -37,6 +37,7 @@
.section s_w,"w"; .long 1
.section s_x,"x"; .long 1
.section s_y,"y"; .long 1
+.section s_y,"i"; .long 1
// CHECK: Section {
// CHECK: Name: s
@@ -143,6 +144,13 @@
// CHECK-NEXT: IMAGE_SCN_ALIGN_1BYTES
// CHECK-NEXT: ]
// CHECK: }
+// CHECK: Section {
+// CHECK: Name: s_y
+// CHECK: Characteristics [
+// CHECK-NEXT: IMAGE_SCN_ALIGN_1BYTES
+// CHECK-NEXT: IMAGE_SCN_LNK_INFO
+// CHECK-NEXT: ]
+// CHECK: }
// w makes read-only to readable
.section s_rw,"rw"; .long 1
Index: llvm/lib/MC/MCSectionCOFF.cpp
===================================================================
--- llvm/lib/MC/MCSectionCOFF.cpp
+++ llvm/lib/MC/MCSectionCOFF.cpp
@@ -63,6 +63,8 @@
if ((getCharacteristics() & COFF::IMAGE_SCN_MEM_DISCARDABLE) &&
!isImplicitlyDiscardable(getName()))
OS << 'D';
+ if (getCharacteristics() & COFF::IMAGE_SCN_LNK_INFO)
+ OS << 'i';
OS << '"';
if (getCharacteristics() & COFF::IMAGE_SCN_LNK_COMDAT) {
Index: llvm/lib/MC/MCParser/COFFAsmParser.cpp
===================================================================
--- llvm/lib/MC/MCParser/COFFAsmParser.cpp
+++ llvm/lib/MC/MCParser/COFFAsmParser.cpp
@@ -159,16 +159,17 @@
bool COFFAsmParser::ParseSectionFlags(StringRef SectionName,
StringRef FlagsString, unsigned *Flags) {
enum {
- None = 0,
- Alloc = 1 << 0,
- Code = 1 << 1,
- Load = 1 << 2,
- InitData = 1 << 3,
- Shared = 1 << 4,
- NoLoad = 1 << 5,
- NoRead = 1 << 6,
- NoWrite = 1 << 7,
+ None = 0,
+ Alloc = 1 << 0,
+ Code = 1 << 1,
+ Load = 1 << 2,
+ InitData = 1 << 3,
+ Shared = 1 << 4,
+ NoLoad = 1 << 5,
+ NoRead = 1 << 6,
+ NoWrite = 1 << 7,
Discardable = 1 << 8,
+ Info = 1 << 9,
};
bool ReadOnlyRemoved = false;
@@ -238,6 +239,10 @@
SecFlags |= NoRead | NoWrite;
break;
+ case 'i': // info
+ SecFlags |= Info;
+ break;
+
default:
return TokError("unknown flag");
}
@@ -265,6 +270,8 @@
*Flags |= COFF::IMAGE_SCN_MEM_WRITE;
if (SecFlags & Shared)
*Flags |= COFF::IMAGE_SCN_MEM_SHARED;
+ if (SecFlags & Info)
+ *Flags |= COFF::IMAGE_SCN_LNK_INFO;
return false;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D136125.468401.patch
Type: text/x-patch
Size: 2521 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221018/f71220d7/attachment.bin>
More information about the llvm-commits
mailing list