[PATCH] D19995: Optimize access to global variable references in PIE mode when linker supports copy relocations for PIE

Reid Kleckner via llvm-commits llvm-commits at lists.llvm.org
Fri May 6 12:31:23 PDT 2016


rnk added a comment.

In http://reviews.llvm.org/D19995#423589, @rjmccall wrote:

> Can you explain how "preemptable" is different from "weak"?


I am assuming "preemtable" means that a preemtable symbol can be rewritten by the dynamic loader to refer to something other than the locally available definition. We should standardize on this term (or "interposable" which I like), but calling this kind of thing a "weak" symbol confuses me.

---

Both preemtable and extern_local sound like great ideas, but how should we tell the compiler to generate copy relocations for a declaration of a GV? That's what this patch is really about. It seems to me that copy relocation generation is really only safe if you know something about the way that the current TU is going to be linked: i.e. it's going into the executable and the linker supports copy relocations. Those seem like properties of the module to me, which is why we were going with module flags. We can invent a new linkage for this instead. Maybe call it `extern_copy`. When using appropriate flags, clang could apply it to all GV declarations. Do people like this better?

It also allows the user to avoid generating copy relocations against certain GVs that might change size. The fact that the size of a GV is part of its ABI in ELF was personally very surprising to me:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68016
https://github.com/google/sanitizers/issues/619


http://reviews.llvm.org/D19995





More information about the llvm-commits mailing list