[PATCH] D106565: [lld/mac] Fix bug in interaction of -dead_strip and -undefined dynamic_lookup
Nico Weber via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 22 16:31:14 PDT 2021
This revision was automatically updated to reflect the committed changes.
Closed by commit rG5ae39d4f9773: [lld/mac] Fix bug in interaction of -dead_strip and -undefined dynamic_lookup (authored by thakis).
Herald added a project: LLVM.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D106565/new/
https://reviews.llvm.org/D106565
Files:
lld/MachO/Symbols.h
lld/MachO/Writer.cpp
lld/test/MachO/dead-strip.s
Index: lld/test/MachO/dead-strip.s
===================================================================
--- lld/test/MachO/dead-strip.s
+++ lld/test/MachO/dead-strip.s
@@ -173,6 +173,18 @@
# RUN: %lld -lSystem -dead_strip %t/strip-dylib-ref.o %t/dylib.dylib \
# RUN: -o %t/strip-dylib-ref -U _ref_undef_fun
+## Check that referenced undefs are kept with -undefined dynamic_lookup.
+# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-macos \
+# RUN: %t/ref-undef.s -o %t/ref-undef.o
+# RUN: %lld -lSystem -dead_strip %t/ref-undef.o \
+# RUN: -o %t/ref-undef -undefined dynamic_lookup
+# RUN: llvm-objdump --syms --lazy-bind %t/ref-undef | \
+# RUN: FileCheck --check-prefix=STRIPDYNLOOKUP %s
+# STRIPDYNLOOKUP: SYMBOL TABLE:
+# STRIPDYNLOOKUP: *UND* _ref_undef_fun
+# STRIPDYNLOOKUP: Lazy bind table:
+# STRIPDYNLOOKUP: __DATA __la_symbol_ptr {{.*}} flat-namespace _ref_undef_fun
+
## S_ATTR_LIVE_SUPPORT tests.
# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-macos \
# RUN: %t/live-support.s -o %t/live-support.o
@@ -812,3 +824,9 @@
.quad L._bar4
.subsections_via_symbols
+
+#--- ref-undef.s
+.globl _main
+_main:
+ callq _ref_undef_fun
+.subsections_via_symbols
Index: lld/MachO/Writer.cpp
===================================================================
--- lld/MachO/Writer.cpp
+++ lld/MachO/Writer.cpp
@@ -611,6 +611,7 @@
static void prepareSymbolRelocation(Symbol *sym, const InputSection *isec,
const Reloc &r) {
+ assert(sym->isLive());
const RelocAttrs &relocAttrs = target->getRelocAttrs(r.type);
if (relocAttrs.hasAttr(RelocAttrBits::BRANCH)) {
Index: lld/MachO/Symbols.h
===================================================================
--- lld/MachO/Symbols.h
+++ lld/MachO/Symbols.h
@@ -306,8 +306,10 @@
"Not a Symbol");
bool isUsedInRegularObj = s->isUsedInRegularObj;
+ bool used = s->used;
T *sym = new (s) T(std::forward<ArgT>(arg)...);
sym->isUsedInRegularObj |= isUsedInRegularObj;
+ sym->used |= used;
return sym;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D106565.361026.patch
Type: text/x-patch
Size: 2059 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210722/a61e065a/attachment.bin>
More information about the llvm-commits
mailing list