[PATCH] D133825: [lld-macho] Add support for N_INDR symbols

Jez Ng via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 14 12:32:13 PDT 2022


int3 marked an inline comment as done.
int3 added a comment.

So, as per Vincent's suggestion, I wrote some tests to see if/when aliases could overwrite other aliases. And I realize that I had gotten it wrong... in fact, alias symbols are always treated as strongly-defined symbols, even if the aliased symbol is weak. I.e. if we have two definitions of `_a`, either one (or both) an alias to a weak def `_b`, we will still encounter a dup symbol error for the two `_a`s.

That said, I'm not sure the implementation complexity of emulating this behavior is worth it... we would essentially have to put `AliasSymbol`s into the global SymbolTable. Which means that every `addDefined`, `addLazy`



================
Comment at: lld/test/MachO/symbol-aliases.s:24-31
+# RUN: %lld -lSystem -dead_strip %t/aliases.o %t/definitions.o -o %t/dead-stripped
+# RUN: llvm-objdump --macho --syms %t/dead-stripped | FileCheck %s --check-prefix=STRIPPED
+
+# STRIPPED:      SYMBOL TABLE:
+# STRIPPED-NEXT: g     F __TEXT,__text _main
+# STRIPPED-NEXT: g     F __TEXT,__text __mh_execute_header
+# STRIPPED-NEXT:         *UND* dyld_stub_binder
----------------
> Oh, maybe worth adding an alias to the dead stripping test (to make sure alias insertion happens before dead stripping).

@thakis I think these lines already cover that case


================
Comment at: lld/test/MachO/symbol-aliases.s:73
+
+_extern_alias_to_weak = _weak
+
----------------
I messed up here. I thought that this second definition of `_extern_alias_to_weak` was demonstrating that we could have two separate aliases of the same name w/o a dup symbol error, but actually MC doesn't even generate an alias at all here since `_weak` is defined in the same file -- references to `_extern_alias_to_weak` are automatically emitted as references to `_weak`


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D133825/new/

https://reviews.llvm.org/D133825



More information about the llvm-commits mailing list