[PATCH] D45440: [ELF] - Do not crash when trying to order --defsym/linker script symbols.
George Rimar via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Apr 10 02:48:48 PDT 2018
This revision was automatically updated to reflect the committed changes.
Closed by commit rL329678: [ELF] - Do not crash when trying to order --defsym/linker script symbols. (authored by grimar, committed by ).
Changed prior to commit:
https://reviews.llvm.org/D45440?vs=141639&id=141812#toc
Repository:
rL LLVM
https://reviews.llvm.org/D45440
Files:
lld/trunk/ELF/Writer.cpp
lld/trunk/test/ELF/linkerscript/symbol-ordering-file2.s
Index: lld/trunk/test/ELF/linkerscript/symbol-ordering-file2.s
===================================================================
--- lld/trunk/test/ELF/linkerscript/symbol-ordering-file2.s
+++ lld/trunk/test/ELF/linkerscript/symbol-ordering-file2.s
@@ -0,0 +1,16 @@
+# REQUIRES: x86
+# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o
+
+## Check we do not crash when trying to order linker script symbol.
+
+# RUN: echo "bar" > %t.ord
+# RUN: echo "SECTIONS { bar = 1; }" > %t.script
+# RUN: ld.lld --symbol-ordering-file %t.ord %t.o --script %t.script \
+# RUN: -o %t.out 2>&1 | FileCheck %s
+# CHECK: warning: <internal>: unable to order absolute symbol: bar
+
+## Check we do not crash when trying to order --defsym symbol.
+
+# RUN: echo "bar" > %t.ord
+# RUN: ld.lld --symbol-ordering-file %t.ord %t.o -defsym=bar=1 \
+# RUN: -o %t.out 2>&1 | FileCheck %s
Index: lld/trunk/ELF/Writer.cpp
===================================================================
--- lld/trunk/ELF/Writer.cpp
+++ lld/trunk/ELF/Writer.cpp
@@ -1057,16 +1057,16 @@
auto *D = dyn_cast<Defined>(&Sym);
InputFile *File = Sym.File;
if (Sym.isUndefined())
- warn(File->getName() +
+ warn(toString(File) +
": unable to order undefined symbol: " + Sym.getName());
else if (Sym.isShared())
- warn(File->getName() +
+ warn(toString(File) +
": unable to order shared symbol: " + Sym.getName());
else if (D && !D->Section)
- warn(File->getName() +
+ warn(toString(File) +
": unable to order absolute symbol: " + Sym.getName());
else if (D && !D->Section->Live)
- warn(File->getName() +
+ warn(toString(File) +
": unable to order discarded symbol: " + Sym.getName());
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D45440.141812.patch
Type: text/x-patch
Size: 1817 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180410/6d6a01cf/attachment.bin>
More information about the llvm-commits
mailing list