diff options
author | Simon Atanasyan <simon@atanasyan.com> | 2016-02-25 05:03:52 +0000 |
---|---|---|
committer | Simon Atanasyan <simon@atanasyan.com> | 2016-02-25 05:03:52 +0000 |
commit | 49bc69b9bbafd026aaa44cbc3ac1c671152f3507 (patch) | |
tree | d27d5ffafd22d99e1f8b23951b9b556587180018 | |
parent | 2b972dfebb2e0e987c33fcf432cdfc0f8c9bbc1b (diff) | |
download | bcm5719-llvm-49bc69b9bbafd026aaa44cbc3ac1c671152f3507.tar.gz bcm5719-llvm-49bc69b9bbafd026aaa44cbc3ac1c671152f3507.zip |
[ELF][MIPS] Enumerate absolute MIPS relocations in the isRelRelative
This commit does two related thing. At first, it enumerates supported
absolute MIPS relocations in the `MipsTargetInfo<ELFT>::isRelRelative`
method. In that case the code is shorter and the case switch does not
tend to grow. At second, it prevents R_MIPS_COPY and PLT creation for
relative relocations. For almost all relative MIPS relocations like
R_MIPS_PC19_S2, R_MIPS_PCHI16 etc it does not have a sence. The only
exception is R_MIPS_PC32. GNU linker creates a copy relocation or PLT
entry for it. But I could not find any real test case uses R_MIPS_PC32
with DSO defined symbol as a target. So for now I prefer to skip this
case to simplify the LLD code.
llvm-svn: 261822
-rw-r--r-- | lld/ELF/Target.cpp | 21 | ||||
-rw-r--r-- | lld/test/ELF/mips-plt-copy.s | 6 |
2 files changed, 12 insertions, 15 deletions
diff --git a/lld/ELF/Target.cpp b/lld/ELF/Target.cpp index 77090369927..eb89dfba3de 100644 --- a/lld/ELF/Target.cpp +++ b/lld/ELF/Target.cpp @@ -1700,7 +1700,7 @@ void MipsTargetInfo<ELFT>::writePlt(uint8_t *Buf, uint64_t GotEntryAddr, template <class ELFT> bool MipsTargetInfo<ELFT>::needsCopyRelImpl(uint32_t Type) const { - return Type == R_MIPS_HI16 || Type == R_MIPS_LO16 || isRelRelative(Type); + return !isRelRelative(Type); } template <class ELFT> @@ -1716,9 +1716,8 @@ bool MipsTargetInfo<ELFT>::needsPltImpl(uint32_t Type, return false; if (Type == R_MIPS_26 && canBePreempted(&S, false)) return true; - if (Type == R_MIPS_HI16 || Type == R_MIPS_LO16 || isRelRelative(Type)) - if (S.isShared()) - return true; + if (!isRelRelative(Type) && S.isShared()) + return true; return false; } @@ -1826,15 +1825,13 @@ template <class ELFT> bool MipsTargetInfo<ELFT>::isRelRelative(uint32_t Type) const { switch (Type) { default: - return false; - case R_MIPS_PC16: - case R_MIPS_PC19_S2: - case R_MIPS_PC21_S2: - case R_MIPS_PC26_S2: - case R_MIPS_PC32: - case R_MIPS_PCHI16: - case R_MIPS_PCLO16: return true; + case R_MIPS_26: + case R_MIPS_32: + case R_MIPS_64: + case R_MIPS_HI16: + case R_MIPS_LO16: + return false; } } diff --git a/lld/test/ELF/mips-plt-copy.s b/lld/test/ELF/mips-plt-copy.s index ed29fe9ca9c..e4c24f6d846 100644 --- a/lld/test/ELF/mips-plt-copy.s +++ b/lld/test/ELF/mips-plt-copy.s @@ -80,6 +80,6 @@ loc: gd: .word 0 ld: - .word data1+8-. # R_MIPS_PC32 requires COPY rel for DSO defined data. - .word foo1+8-. # R_MIPS_PC32 requires JUMP_SLOT/PLT entry - # for DSO defined func. + .word data1+8 # R_MIPS_32 requires REL32 dnamic relocation + # for DSO defined data. For now we generate COPY one. + .word foo1+8 # R_MIPS_32 requires PLT entry for DSO defined func. |