[PATCH] D125074: [ELF] Change (NOLOAD) type mismatch to use the specified type instead of SHT_PROGBITS
Fangrui Song via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu May 5 21:14:07 PDT 2022
MaskRay created this revision.
MaskRay added a reviewer: peter.smith.
Herald added subscribers: StephenFan, arichardson, emaste.
Herald added a project: All.
MaskRay requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
Placing a non-SHT_NOBITS input section in an output section specified with
(NOLOAD) is fishy but used by some projects. D118840 <https://reviews.llvm.org/D118840> changed the output type to
SHT_PROGBITS, but using the specified type seems to make more sense and improve
GNU ld compatibility: `(NOLOAD)` seems to change the output section type
regardless of input.
I think we should keep the current type mismatch warning as it does indicate an
error-prone usage.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D125074
Files:
lld/ELF/OutputSections.cpp
lld/test/ELF/linkerscript/custom-section-type.s
lld/test/ELF/linkerscript/noload.s
Index: lld/test/ELF/linkerscript/noload.s
===================================================================
--- lld/test/ELF/linkerscript/noload.s
+++ lld/test/ELF/linkerscript/noload.s
@@ -24,7 +24,7 @@
# WARN: warning: section type mismatch for .data_noload_a
# CHECK2: Name Type Address Off Size
-# CHECK2: .data_noload_a PROGBITS 0000000000000000 [[OFF:[0-9a-f]+]] 001001
+# CHECK2: .data_noload_a NOBITS 0000000000000000 [[OFF:[0-9a-f]+]] 001001
#--- asm
.section .text,"ax", at progbits
Index: lld/test/ELF/linkerscript/custom-section-type.s
===================================================================
--- lld/test/ELF/linkerscript/custom-section-type.s
+++ lld/test/ELF/linkerscript/custom-section-type.s
@@ -37,7 +37,7 @@
## Mismatched progbits and expr are changed to SHT_PROGBITS.
# MISMATCH: progbits PROGBITS
# MISMATCH: note NOTE
-# MISMATCH: expr PROGBITS
+# MISMATCH: expr 0x42: <unknown>
# RUN: not ld.lld -T %t/unknown1.lds %t/a.o -o /dev/null 2>&1 | FileCheck %s --check-prefix=UNKNOWN1
# UNKNOWN1: error: {{.*}}.lds:1: symbol not found: foo
Index: lld/ELF/OutputSections.cpp
===================================================================
--- lld/ELF/OutputSections.cpp
+++ lld/ELF/OutputSections.cpp
@@ -123,7 +123,8 @@
"\n>>> output section " + name + ": " +
getELFSectionTypeName(config->emachine, type));
}
- type = SHT_PROGBITS;
+ if (!typeIsSet)
+ type = SHT_PROGBITS;
} else {
type = isec->type;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D125074.427528.patch
Type: text/x-patch
Size: 1613 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220506/60937d5f/attachment.bin>
More information about the llvm-commits
mailing list