[PATCH] D79114: [lld-macho] Dylib symbols should always replace undefined symbols

Shoaib Meenai via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 29 19:29:31 PDT 2020


smeenai added a comment.

Not this diff, but it appears ld64 always prefers symbols from object files over symbols from dylibs. For example:

  $ cat f1.c
  int f() { return 1; }
  
  $ cat f2.c:
  int f() { return 2; }
  
  $ cat main.c
  int f(void);
  int main() { return f(); }
  
  $ clang -fPIC -dynamiclib -o libf1.dylib f1.c
  $ clang -c f2.c
  $ clang -c main.c
  
  $ ld libf1.dylib main.o f2.o -lSystem
  $ ./a.out; echo $?
  2
  
  $ ld main.o libf1.dylib f2.o -lSystem
  $ ./a.out; echo $?
  2
  
  # sanity check
  $ ld main.o libf1.dylib -lSystem

I believe we should already be implementing this behavior, courtesy of a Defined replacing any other symbol, but it's worth adding a test.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79114





More information about the llvm-commits mailing list