[PATCH] D89152: [lld][WebAssembly] Add support for -Bsymbolic

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 12 17:10:59 PDT 2020


MaskRay added inline comments.


================
Comment at: lld/wasm/Driver.cpp:496
+  if (config->bsymbolic && (!config->pie && !config->shared)) {
+    warn("-Bsymbolic is only meaningful when combined with -shared, or -pie");
+  }
----------------
MaskRay wrote:
> sbc100 wrote:
> > sbc100 wrote:
> > > MaskRay wrote:
> > > > In ELF, -Bsymbolic is redundant for executables (-no-pie or -pie).
> > > > 
> > > Interesting, so you are saying the `-Bsymbolic` is basically the default for executable?
> > > 
> > > Wouldn't that mean that, for example, LD_PRELOAD would not work for symbols in the main executable?    My understanding is that `-Bsymbolic` would prevent `LD_PRELOAD` from overriding symbols because they would be bound locally.  Although I guess I am wrong?
> > Indeed you are right, it looks like LD_PRELOAD as no effect on the main executable itself.  TIL!
> -Bsymbolic is basically the default for executable.
> The symbol resolution order: exe, preloaded, needed
> 
> In preloaded, the LD_PRELOADed library is listed in a breadth-first search order.
> needed is similar.
> 
> 
I was wrong about the symbol resolution order.

In musl, LD_PRELOAD libraries are prepended to the DT_NEEDED list. The resolution order is a breadth-first search order starting from the executable, i.e. the order may be:
`exe, preload0, preload1, needed0, needed1, needd0_of_preload0, needed1_of_preload0, needd0_of_needed0, ...`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89152



More information about the llvm-commits mailing list