diff options
author | Fangrui Song <maskray@google.com> | 2019-06-07 03:47:22 +0000 |
---|---|---|
committer | Fangrui Song <maskray@google.com> | 2019-06-07 03:47:22 +0000 |
commit | c841b9abf039ec0457752cd96f7e4716c1c7a323 (patch) | |
tree | a558859d69f1d7ca178ae98bef83ee729ce2facd /llvm/lib/MC/ELFObjectWriter.cpp | |
parent | 0bddef79019a23ab14fcdb27028e55e484674c88 (diff) | |
download | bcm5719-llvm-c841b9abf039ec0457752cd96f7e4716c1c7a323.tar.gz bcm5719-llvm-c841b9abf039ec0457752cd96f7e4716c1c7a323.zip |
[MC][ELF] Don't create relocations with section symbols for STB_LOCAL ifunc
We should keep the symbol type (STT_GNU_IFUNC) for a local ifunc because
it may result in an IRELATIVE reloc that the dynamic loader will use to
resolve the address at startup time.
There is another problem that is not fixed by this patch: a PC relative
relocation should also create a relocation with the ifunc symbol.
llvm-svn: 362767
Diffstat (limited to 'llvm/lib/MC/ELFObjectWriter.cpp')
-rw-r--r-- | llvm/lib/MC/ELFObjectWriter.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/llvm/lib/MC/ELFObjectWriter.cpp b/llvm/lib/MC/ELFObjectWriter.cpp index 95b0e274526..99cab4e8c5d 100644 --- a/llvm/lib/MC/ELFObjectWriter.cpp +++ b/llvm/lib/MC/ELFObjectWriter.cpp @@ -1373,6 +1373,12 @@ bool ELFObjectWriter::shouldRelocateWithSymbol(const MCAssembler &Asm, return true; } + // Keep symbol type for a local ifunc because it may result in an IRELATIVE + // reloc that the dynamic loader will use to resolve the address at startup + // time. + if (Sym->getType() == ELF::STT_GNU_IFUNC) + return true; + // If a relocation points to a mergeable section, we have to be careful. // If the offset is zero, a relocation with the section will encode the // same information. With a non-zero offset, the situation is different. |