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

Rafael EspĂ­ndola via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 6 09:18:23 PDT 2016


"does not support" sounds like it would just ignore the tag, which is
fine. Do you mean that it refuses to load DSOs with the tag present?

Cheers,
Rafael


On 4 September 2016 at 13:40, Simon Atanasyan via llvm-commits
<llvm-commits at lists.llvm.org> wrote:
> Author: atanasyan
> Date: Sun Sep  4 12:40:12 2016
> New Revision: 280630
>
> URL: http://llvm.org/viewvc/llvm-project?rev=280630&view=rev
> Log:
> [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.
>
> Modified:
>     lld/trunk/ELF/OutputSections.cpp
>     lld/trunk/test/ELF/mips-32.s
>
> Modified: lld/trunk/ELF/OutputSections.cpp
> URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/OutputSections.cpp?rev=280630&r1=280629&r2=280630&view=diff
> ==============================================================================
> --- lld/trunk/ELF/OutputSections.cpp (original)
> +++ lld/trunk/ELF/OutputSections.cpp Sun Sep  4 12:40:12 2016
> @@ -671,9 +671,14 @@ template <class ELFT> void DynamicSectio
>      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});
>
> Modified: lld/trunk/test/ELF/mips-32.s
> URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/mips-32.s?rev=280630&r1=280629&r2=280630&view=diff
> ==============================================================================
> --- lld/trunk/test/ELF/mips-32.s (original)
> +++ lld/trunk/test/ELF/mips-32.s Sun Sep  4 12:40:12 2016
> @@ -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:
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits


More information about the llvm-commits mailing list