[PATCH] D116838: [ELF] -Map --why-extract=: print despite errors
Fangrui Song via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Jan 12 10:39:49 PST 2022
MaskRay updated this revision to Diff 399379.
MaskRay edited the summary of this revision.
MaskRay added a comment.
rebase
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D116838/new/
https://reviews.llvm.org/D116838
Files:
lld/ELF/Writer.cpp
lld/test/ELF/map-file.s
lld/test/ELF/why-extract.s
Index: lld/test/ELF/why-extract.s
===================================================================
--- lld/test/ELF/why-extract.s
+++ lld/test/ELF/why-extract.s
@@ -5,6 +5,7 @@
# RUN: llvm-mc -filetype=obj -triple=x86_64 %t/a.s -o %t/a.o
# RUN: llvm-mc -filetype=obj -triple=x86_64 %t/a_b.s -o %t/a_b.o
# RUN: llvm-mc -filetype=obj -triple=x86_64 %t/b.s -o %t/b.o
+# RUN: llvm-mc -filetype=obj -triple=x86_64 %t/err.s -o %t/err.o
# RUN: llvm-ar rc %t/a.a %t/a.o
# RUN: llvm-ar rc %t/a_b.a %t/a_b.o
# RUN: llvm-ar rc %t/b.a %t/b.o
@@ -21,6 +22,10 @@
# RUN: ld.lld main.o a_b.a b.a -o /dev/null --why-extract=why2.txt
# RUN: FileCheck %s --input-file=why2.txt --check-prefix=CHECK2 --match-full-lines --strict-whitespace
+## A relocation error does not suppress the output.
+# RUN: rm -f why2.txt && not ld.lld main.o a_b.a b.a err.o -o /dev/null --why-extract=why2.txt
+# RUN: FileCheck %s --input-file=why2.txt --check-prefix=CHECK2 --match-full-lines --strict-whitespace
+
# CHECK2:reference extracted symbol
# CHECK2-NEXT:main.o a_b.a(a_b.o) a
# CHECK2-NEXT:a_b.a(a_b.o) b.a(b.o) b()
@@ -84,3 +89,6 @@
#--- a.lds
a = _Z1bv;
+
+#--- err.s
+.reloc ., R_X86_64_RELATIVE, 0
Index: lld/test/ELF/map-file.s
===================================================================
--- lld/test/ELF/map-file.s
+++ lld/test/ELF/map-file.s
@@ -6,6 +6,7 @@
# RUN: echo '.global baz; baz: ret' | llvm-mc -filetype=obj -triple=x86_64 - -o %t4.o
# RUN: llvm-mc -filetype=obj -triple=x86_64 %p/Inputs/map-file5.s -o %t5.o
# RUN: echo '.global hey; hey: ret' | llvm-mc -filetype=obj -triple=x86_64 - -o %t6.o
+# RUN: echo '.reloc ., R_X86_64_RELATIVE, 0' | llvm-mc -filetype=obj -triple=x86_64 - -o %t7.o
# RUN: ld.lld -shared %t5.o -o %t5.so -soname dso
# RUN: rm -f %t4.a
# RUN: llvm-ar rc %t4.a %t4.o
@@ -16,6 +17,9 @@
# RUN: ld.lld %t1.o %t2.o %t3.o %t4.a %t5.so %t6.a -o %t -Map=%t.map
# RUN: FileCheck -match-full-lines -strict-whitespace %s < %t.map
+## A relocation error does not suppress the output.
+# RUN: not ld.lld %t1.o %t2.o %t3.o %t4.a %t5.so %t6.a %t7.o -o /dev/null -M | FileCheck --strict-whitespace --check-prefix=CHECK2 %s
+
.global _start
_start:
.cfi_startproc
@@ -102,6 +106,12 @@
# CHECK-NEXT: 0 0 71 1 .strtab
# CHECK-NEXT: 0 0 71 1 <internal>:(.strtab)
+# CHECK2: VMA LMA Size Align Out In Symbol
+# CHECK2-NEXT: 200200 200200 78 8 .dynsym
+# CHECK2-NEXT: 200200 200200 78 8 <internal>:(.dynsym)
+# CHECK2-NEXT: 200278 200278 2c 8 .gnu.hash
+# CHECK2-NEXT: 200278 200278 2c 8 <internal>:(.gnu.hash)
+
# RUN: not ld.lld %t1.o %t2.o %t3.o %t4.a -o /dev/null -Map=/ 2>&1 \
# RUN: | FileCheck --check-prefix=FAIL %s
# FAIL: cannot open map file /
Index: lld/ELF/Writer.cpp
===================================================================
--- lld/ELF/Writer.cpp
+++ lld/ELF/Writer.cpp
@@ -538,8 +538,6 @@
// finalizeSections does that.
finalizeSections();
checkExecuteOnly();
- if (errorCount())
- return;
// If --compressed-debug-sections is specified, compress .debug_* sections.
// Do it right now because it changes the size of output sections.
@@ -1998,10 +1996,6 @@
}
}
- // Do not proceed if there was an undefined symbol.
- if (errorCount())
- return;
-
if (in.mipsGot)
in.mipsGot->build();
@@ -2134,6 +2128,8 @@
// sometimes using forward symbol declarations. We want to set the correct
// values. They also might change after adding the thunks.
finalizeAddressDependentContent();
+
+ // All information needed for OutputSection part of Map file is available.
if (errorCount())
return;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D116838.399379.patch
Type: text/x-patch
Size: 3876 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220112/62989c4f/attachment.bin>
More information about the llvm-commits
mailing list