[ELF][MIPS] Do not emit DT_REL[A]COUNT for MIPS targets

It looks like MIPS dynamic loader does not support RELCOUNT tag.
Both gold/bfd linkers does not emit this tag on MIPS. I will investigate
the problem further but for now it is better to behave like GNU linkers.

llvm-svn: 280630
This commit is contained in:
Simon Atanasyan 2016-09-04 17:40:12 +00:00
parent c228f5c195
commit 65b2461cfd
2 changed files with 13 additions and 7 deletions

View File

@ -671,10 +671,15 @@ template <class ELFT> void DynamicSection<ELFT>::finalize() {
Add({IsRela ? DT_RELAENT : DT_RELENT,
uintX_t(IsRela ? sizeof(Elf_Rela) : sizeof(Elf_Rel))});
// MIPS dynamic loader does not support RELCOUNT tag.
// The problem is in the tight relation between dynamic
// relocations and GOT. So do not emit this tag on MIPS.
if (Config->EMachine != EM_MIPS) {
size_t NumRelativeRels = Out<ELFT>::RelaDyn->getRelativeRelocCount();
if (Config->ZCombreloc && NumRelativeRels)
Add({IsRela ? DT_RELACOUNT : DT_RELCOUNT, NumRelativeRels});
}
}
if (Out<ELFT>::RelaPlt && Out<ELFT>::RelaPlt->hasRelocs()) {
Add({DT_JMPREL, Out<ELFT>::RelaPlt});
Add({DT_PLTRELSZ, Out<ELFT>::RelaPlt->getSize()});

View File

@ -56,6 +56,7 @@ v2:
# REL: Tag Type Name/Value
# REL: 0x00000012 RELSZ 16 (bytes)
# REL: 0x00000013 RELENT 8 (bytes)
# REL-NOT: 0x6FFFFFFA RELCOUNT
# REL: Primary GOT {
# REL-NEXT: Canonical gp value: