[PATCH] D73228: [AsmPrinter][ELF] Define local aliases (.Lfoo$local) for GlobalObjects

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 28 12:11:25 PST 2020


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

In D73228#1845102 <https://reviews.llvm.org/D73228#1845102>, @peter.smith wrote:

> To make sure I understand, this is adding a local alias as at assembly time that can be used as a fixup target. This is necessary as at assembly time all we have is a global default visibility symbol which we have to assume can be interposed, even if the code-generator has already assumed it. Are there other uses that I'm missing?


Yes. `STV_DEFAULT` `STB_GLOBAL` preemptivity depends on whether the link uses -no-pie/-pie (executable) or -shared (shared object). Referencing a local alias makes -shared similar to the executable case.

(`STV_PROTECTED`/`STV_INTERNAL`/`STV_HIDDEN`) `STB_GLOBAL` does not need a local alias. But for simplicity, leave it to the linker.

> As it stands this sounds reasonable to me, I'm trying to think if there are any other alternatives and what the trade-offs would be. For example is there no way that the assembler could find out the information at assembly time, or is that more complex than adding local aliases?

The downside is that textual assembly output will be slightly larger, but it is acceptable. Object assembly output can only be smaller because of elimination of certain relocations. `.L` symbols do not take space.

An alternative is to make the assembler aware of executable/shared use cases. For example, gas RISC-V has two directives `.option nopic` and `.option pic`. I believe that is a wrong direction.

The compiler has had to know the eventual use case (-fno-pic / -fpie / -fpic). The linker has to know the use case (-no-pie / -pie / -shared). The combinations already provide sufficient flexibility that makes a mode switch on the assembler side unnecessary.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73228





More information about the llvm-commits mailing list