aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Object/WasmObjectFile.cpp
diff options
context:
space:
mode:
authorNico Weber <thakis@chromium.org>2021-10-14 18:32:10 -0400
committerNico Weber <thakis@chromium.org>2021-10-15 13:24:47 -0400
commit4e572db0c2ec4e96f8ddfade7384e8ee8ad97384 (patch)
tree027855d84cf02a401672a62020f942fbcd50bd8f /llvm/lib/Object/WasmObjectFile.cpp
parentbacddf47a8381f52baebaaa41a2c482c156b6f01 (diff)
downloadllvm-4e572db0c2ec4e96f8ddfade7384e8ee8ad97384.zip
llvm-4e572db0c2ec4e96f8ddfade7384e8ee8ad97384.tar.gz
llvm-4e572db0c2ec4e96f8ddfade7384e8ee8ad97384.tar.bz2
[lld/mac] Mark private externs with GOT relocs as LOCAL in indirect symbtab
prepareSymbolRelocation() in Writer.cpp adds both symbols that need binding and symbols relocated with a pointer relocation to the got. Pointer relocations are emitted for non-movq GOTPCREL(%rip) loads. (movqs become GOT_LOADs so that the linker knows they can be relaxed to leaqs, while others, such as addq, become just GOT -- a pointer relocation -- since they can't be relaxed in that way). For example, this C file produces a private_extern GOT relocation when compiled with -O2 with clang: extern const char kString[]; const char* g(int a) { return kString + a; } Linkers need to put pointer-relocated symbols into the GOT, but ld64 marks them as LOCAL in the indirect symbol table. This matters, since `strip -x` looks at the indirect symbol table when deciding what to strip. The indirect symtab emitting code was assuming that only symbols that need binding are in the GOT, but pointer relocations where there too. Hence, the code needs to explicitly check if a symbol is a private extern. Fixes https://crbug.com/1242638, which has some more information in comments 14 and 15. With this patch, the output of `nm -U` on Chromium Framework after stripping now contains just two symbols when using lld, just like with ld64. Differential Revision: https://reviews.llvm.org/D111852
Diffstat (limited to 'llvm/lib/Object/WasmObjectFile.cpp')
0 files changed, 0 insertions, 0 deletions