[PATCH] D119506: [lld-macho] Set FinalDefinitionInLinkageUnit on most LTO externs

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 15 11:16:42 PDT 2022


MaskRay accepted this revision as: MaskRay.
MaskRay added a comment.
This revision is now accepted and ready to land.

Looks great!

In D119506#3383201 <https://reviews.llvm.org/D119506#3383201>, @int3 wrote:

>> I think the condition can be removed, but perhaps there is some Mach-O thing that I haven't thought about.
>
> Weak symbol lookups in Mach-O essentially happen in a flat namespace, so I think they should never be treated as final definitions. Also, this lookup occurs at runtime regardless of whether we are building an executable or dylib, and regardless of whether the symbol is a Defined or a DylibSymbol. Does ELF behave differently?

Ah, I see. On ELF, a weak definition is equivalent to a non-weak definition: if the executable defines a weak symbol, references to the symbol will bind to this definition.
(This is followed by glibc and musl. Some *BSD systems deviated: https://maskray.me/blog/2021-08-22-freebsd-src-browsing-on-linux-and-my-rtld-contribution#stb_weak-in-symbol-lookup)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119506



More information about the llvm-commits mailing list