diff options
-rw-r--r-- | lld/ELF/OutputSections.cpp | 11 | ||||
-rw-r--r-- | lld/test/ELF/mips-32.s | 9 |
2 files changed, 13 insertions, 7 deletions
diff --git a/lld/ELF/OutputSections.cpp b/lld/ELF/OutputSections.cpp index 36de1e446ca..f2451209023 100644 --- a/lld/ELF/OutputSections.cpp +++ b/lld/ELF/OutputSections.cpp @@ -671,9 +671,14 @@ template <class ELFT> void DynamicSection<ELFT>::finalize() { Add({IsRela ? DT_RELAENT : DT_RELENT, uintX_t(IsRela ? sizeof(Elf_Rela) : sizeof(Elf_Rel))}); - size_t NumRelativeRels = Out<ELFT>::RelaDyn->getRelativeRelocCount(); - if (Config->ZCombreloc && NumRelativeRels) - Add({IsRela ? DT_RELACOUNT : DT_RELCOUNT, NumRelativeRels}); + // 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}); diff --git a/lld/test/ELF/mips-32.s b/lld/test/ELF/mips-32.s index 7875c48d64d..8801bcf91f4 100644 --- a/lld/test/ELF/mips-32.s +++ b/lld/test/ELF/mips-32.s @@ -52,10 +52,11 @@ v2: # REL-NEXT: } # REL-NEXT: ] -# REL: DynamicSection [ -# REL: Tag Type Name/Value -# REL: 0x00000012 RELSZ 16 (bytes) -# REL: 0x00000013 RELENT 8 (bytes) +# REL: DynamicSection [ +# 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: |