[PATCH] D77248: [llvm][IR] Add dso_local_equivalent Constant

Peter Collingbourne via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 1 15:46:36 PDT 2020


pcc added inline comments.


================
Comment at: llvm/docs/LangRef.rst:3784
+  may need to be emitted explicitly.
+- If the global is a variable or alias to a variable, this can be implemented
+  by copying the contents
----------------
rjmccall wrote:
> pcc wrote:
> > I would make this specific to functions. I don't think this can be made to work with globals at least with existing ELF linkers because I don't think you can get the copy relocation behavior without the symbol's value being overridden by the linkage unit with the copy relocation, and it doesn't make sense to have more than one linkage unit override the address of the same global.
> Oh, does ELF's copy relocation necessarily steal the symbol so that it resolves into the copying linkage unit?  I thought it might be separable so that you could just get a local copy of the data without changing symbol resolution.  That would be a much more generically useful feature.
I think the behaviors may be separable at the binary level (i.e. you could hand-craft an executable that only copies but doesn't override), but at the linker level the copying and overriding happen at the same time when the linker sees a non-GOT-generating relocation pointing to the symbol.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77248



More information about the llvm-commits mailing list