[PATCH] D57417: [llvm-objcopy] Skip --localize-symbol for undefined symbols
Jordan Rupprecht via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Jan 31 09:58:32 PST 2019
This revision was automatically updated to reflect the committed changes.
Closed by commit rL352767: [llvm-objcopy] Skip --localize-symbol for undefined symbols (authored by rupprecht, committed by ).
Changed prior to commit:
https://reviews.llvm.org/D57417?vs=184174&id=184539#toc
Repository:
rL LLVM
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D57417/new/
https://reviews.llvm.org/D57417
Files:
llvm/trunk/test/tools/llvm-objcopy/ELF/localize.test
llvm/trunk/tools/llvm-objcopy/ELF/ELFObjcopy.cpp
Index: llvm/trunk/tools/llvm-objcopy/ELF/ELFObjcopy.cpp
===================================================================
--- llvm/trunk/tools/llvm-objcopy/ELF/ELFObjcopy.cpp
+++ llvm/trunk/tools/llvm-objcopy/ELF/ELFObjcopy.cpp
@@ -287,7 +287,9 @@
// them.
if (Obj.SymbolTable) {
Obj.SymbolTable->updateSymbols([&](Symbol &Sym) {
- if (!Sym.isCommon() &&
+ // Common and undefined symbols don't make sense as local symbols, and can
+ // even cause crashes if we localize those, so skip them.
+ if (!Sym.isCommon() && Sym.getShndx() != SHN_UNDEF &&
((Config.LocalizeHidden &&
(Sym.Visibility == STV_HIDDEN || Sym.Visibility == STV_INTERNAL)) ||
is_contained(Config.SymbolsToLocalize, Sym.Name)))
Index: llvm/trunk/test/tools/llvm-objcopy/ELF/localize.test
===================================================================
--- llvm/trunk/test/tools/llvm-objcopy/ELF/localize.test
+++ llvm/trunk/test/tools/llvm-objcopy/ELF/localize.test
@@ -1,6 +1,7 @@
# RUN: yaml2obj %s > %t
# RUN: llvm-objcopy \
# RUN: --localize-symbol Global \
+# RUN: -L GlobalUndef \
# RUN: -L Local \
# RUN: -L Weak \
# RUN: -L GlobalCommon \
@@ -45,6 +46,8 @@
Size: 8
Section: .text
Value: 0x1010
+ - Name: GlobalUndef
+ Type: STT_FUNC
- Name: GlobalCommon
Type: STT_OBJECT
Index: SHN_COMMON
@@ -89,6 +92,15 @@
#CHECK-NEXT: Section: .text
#CHECK-NEXT: }
#CHECK-NEXT: Symbol {
+#CHECK-NEXT: Name: GlobalUndef
+#CHECK-NEXT: Value:
+#CHECK-NEXT: Size:
+#CHECK-NEXT: Binding: Global
+#CHECK-NEXT: Type: Function
+#CHECK-NEXT: Other:
+#CHECK-NEXT: Section: Undefined
+#CHECK-NEXT: }
+#CHECK-NEXT: Symbol {
#CHECK-NEXT: Name: GlobalCommon
#CHECK-NEXT: Value: 0x2006
#CHECK-NEXT: Size: 2
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D57417.184539.patch
Type: text/x-patch
Size: 1870 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190131/313460a7/attachment.bin>
More information about the llvm-commits
mailing list