forked from OSchip/llvm-project
[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
This commit is contained in:
parent
2b972dfebb
commit
49bc69b9bb
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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.
|
||||
|
|
Loading…
Reference in New Issue