[PATCH] D101334: [llvm-objcopy] Always check for indirect symbol references before stripping
Jez Ng via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Apr 26 17:25:02 PDT 2021
int3 created this revision.
int3 added reviewers: smeenai, alexshap, jhenderson, rmaz.
Herald added a reviewer: rupprecht.
Herald added a subscriber: abrachet.
int3 requested review of this revision.
Herald added subscribers: llvm-commits, MaskRay.
Herald added a project: LLVM.
Previously, we only checked for those references when doing
`--strip-all`, but not when doing `--discard-all`. I believe that this
didn't cause issues with ld64-generated binaries as they did not create
indirect symbol references to local symbols (which `--discard-all`
removes). However LLD does emit these, exposing the issue.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D101334
Files:
llvm/test/tools/llvm-objcopy/MachO/discard-all.test
llvm/tools/llvm-objcopy/MachO/MachOObjcopy.cpp
Index: llvm/tools/llvm-objcopy/MachO/MachOObjcopy.cpp
===================================================================
--- llvm/tools/llvm-objcopy/MachO/MachOObjcopy.cpp
+++ llvm/tools/llvm-objcopy/MachO/MachOObjcopy.cpp
@@ -361,9 +361,7 @@
return E;
// Mark symbols to determine which symbols are still needed.
- if (Config.StripAll)
- markSymbols(Config, Obj);
-
+ markSymbols(Config, Obj);
updateAndRemoveSymbols(Config, Obj);
if (Config.StripAll)
Index: llvm/test/tools/llvm-objcopy/MachO/discard-all.test
===================================================================
--- llvm/test/tools/llvm-objcopy/MachO/discard-all.test
+++ llvm/test/tools/llvm-objcopy/MachO/discard-all.test
@@ -17,6 +17,10 @@
# RUN: llvm-strip -x %t
# RUN: cmp %t2 %t
+## FIXME: We should also check that we don't discard symbols that are referenced
+## by the indirect symbol table. However, yaml2obj currently lacks support for
+## the indirect symbol table.
+
# CHECK: Symbols [
# CHECK-NEXT: Symbol {
# CHECK-NEXT: Name: _b (1)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D101334.340697.patch
Type: text/x-patch
Size: 1062 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210427/00d13321/attachment.bin>
More information about the llvm-commits
mailing list