[lld] r268024 - [ELF][MIPS] Accept MIPS 64-bit binaries

Rui Ueyama via llvm-commits llvm-commits at lists.llvm.org
Fri Apr 29 10:45:27 PDT 2016


Nice, but is this everything? I wonder if you want to implement MIPS64
relocations.

On Fri, Apr 29, 2016 at 3:39 AM, Simon Atanasyan via llvm-commits <
llvm-commits at lists.llvm.org> wrote:

> Author: atanasyan
> Date: Fri Apr 29 05:39:17 2016
> New Revision: 268024
>
> URL: http://llvm.org/viewvc/llvm-project?rev=268024&view=rev
> Log:
> [ELF][MIPS] Accept MIPS 64-bit binaries
>
> LLD accepts MIPS 64-bit binaries, supports corresponding eulation (-m)
> arguments and emits 64-bit specific ELF flags.
>
> Modified:
>     lld/trunk/ELF/Driver.cpp
>     lld/trunk/ELF/InputFiles.cpp
>     lld/trunk/ELF/Target.cpp
>     lld/trunk/ELF/Writer.cpp
>     lld/trunk/test/ELF/emulation.s
>
> Modified: lld/trunk/ELF/Driver.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Driver.cpp?rev=268024&r1=268023&r2=268024&view=diff
>
> ==============================================================================
> --- lld/trunk/ELF/Driver.cpp (original)
> +++ lld/trunk/ELF/Driver.cpp Fri Apr 29 05:39:17 2016
> @@ -57,6 +57,10 @@ static std::pair<ELFKind, uint16_t> pars
>      return {ELF32BEKind, EM_MIPS};
>    if (S == "elf32ltsmip")
>      return {ELF32LEKind, EM_MIPS};
> +  if (S == "elf64btsmip")
> +    return {ELF64BEKind, EM_MIPS};
> +  if (S == "elf64ltsmip")
> +    return {ELF64LEKind, EM_MIPS};
>    if (S == "elf32ppc")
>      return {ELF32BEKind, EM_PPC};
>    if (S == "elf64ppc")
> @@ -312,6 +316,9 @@ void LinkerDriver::readConfigs(opt::Inpu
>      Config->Emulation = S;
>    }
>
> +  if (Config->EMachine == EM_MIPS && Config->EKind == ELF64LEKind)
> +    Config->Mips64EL = true;
> +
>    Config->AllowMultipleDefinition =
> Args.hasArg(OPT_allow_multiple_definition);
>    Config->Bsymbolic = Args.hasArg(OPT_Bsymbolic);
>    Config->BsymbolicFunctions = Args.hasArg(OPT_Bsymbolic_functions);
>
> Modified: lld/trunk/ELF/InputFiles.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/InputFiles.cpp?rev=268024&r1=268023&r2=268024&view=diff
>
> ==============================================================================
> --- lld/trunk/ELF/InputFiles.cpp (original)
> +++ lld/trunk/ELF/InputFiles.cpp Fri Apr 29 05:39:17 2016
> @@ -616,6 +616,8 @@ static std::unique_ptr<InputFile> create
>    if (Config->EKind == ELFNoneKind) {
>      Config->EKind = Ret->getELFKind();
>      Config->EMachine = Ret->getEMachine();
> +    if (Config->EMachine == EM_MIPS && Config->EKind == ELF64LEKind)
> +      Config->Mips64EL = true;
>    }
>
>    return std::move(Ret);
>
> Modified: lld/trunk/ELF/Target.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Target.cpp?rev=268024&r1=268023&r2=268024&view=diff
>
> ==============================================================================
> --- lld/trunk/ELF/Target.cpp (original)
> +++ lld/trunk/ELF/Target.cpp Fri Apr 29 05:39:17 2016
> @@ -198,6 +198,10 @@ TargetInfo *createTarget() {
>        return new MipsTargetInfo<ELF32LE>();
>      case ELF32BEKind:
>        return new MipsTargetInfo<ELF32BE>();
> +    case ELF64LEKind:
> +      return new MipsTargetInfo<ELF64LE>();
> +    case ELF64BEKind:
> +      return new MipsTargetInfo<ELF64BE>();
>      default:
>        fatal("unsupported MIPS target");
>      }
>
> Modified: lld/trunk/ELF/Writer.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Writer.cpp?rev=268024&r1=268023&r2=268024&view=diff
>
> ==============================================================================
> --- lld/trunk/ELF/Writer.cpp (original)
> +++ lld/trunk/ELF/Writer.cpp Fri Apr 29 05:39:17 2016
> @@ -1760,10 +1760,13 @@ template <class ELFT> void Writer<ELFT>:
>    }
>  }
>
> -static uint32_t getMipsEFlags() {
> +static uint32_t getMipsEFlags(bool Is64Bits) {
>    // FIXME: In fact ELF flags depends on ELF flags of input object files
>    // and selected emulation. For now just use hard coded values.
> -  uint32_t V = EF_MIPS_ABI_O32 | EF_MIPS_CPIC | EF_MIPS_ARCH_32R2;
> +  if (Is64Bits)
> +    return EF_MIPS_CPIC | EF_MIPS_PIC | EF_MIPS_ARCH_64R2;
> +
> +  uint32_t V = EF_MIPS_CPIC | EF_MIPS_ABI_O32 | EF_MIPS_ARCH_32R2;
>    if (Config->Shared)
>      V |= EF_MIPS_PIC;
>    return V;
> @@ -1844,7 +1847,7 @@ template <class ELFT> void Writer<ELFT>:
>    EHdr->e_shstrndx = Out<ELFT>::ShStrTab->SectionIndex;
>
>    if (Config->EMachine == EM_MIPS)
> -    EHdr->e_flags = getMipsEFlags();
> +    EHdr->e_flags = getMipsEFlags(ELFT::Is64Bits);
>
>    if (!Config->Relocatable) {
>      EHdr->e_phoff = sizeof(Elf_Ehdr);
>
> Modified: lld/trunk/test/ELF/emulation.s
> URL:
> http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/emulation.s?rev=268024&r1=268023&r2=268024&view=diff
>
> ==============================================================================
> --- lld/trunk/test/ELF/emulation.s (original)
> +++ lld/trunk/test/ELF/emulation.s Fri Apr 29 05:39:17 2016
> @@ -178,6 +178,60 @@
>  # MIPSEL-NEXT:     EF_MIPS_CPIC
>  # MIPSEL-NEXT:   ]
>
> +# RUN: llvm-mc -filetype=obj -triple=mips64-unknown-linux %s -o %tmips64
> +# RUN: ld.lld -m elf64btsmip -e _start %tmips64 -o %t2mips64
> +# RUN: llvm-readobj -file-headers %t2mips64 | FileCheck
> --check-prefix=MIPS64 %s
> +# RUN: ld.lld %tmips64 -e _start -o %t3mips64
> +# RUN: llvm-readobj -file-headers %t3mips64 | FileCheck
> --check-prefix=MIPS64 %s
> +# MIPS64:      ElfHeader {
> +# MIPS64-NEXT:   Ident {
> +# MIPS64-NEXT:     Magic: (7F 45 4C 46)
> +# MIPS64-NEXT:     Class: 64-bit (0x2)
> +# MIPS64-NEXT:     DataEncoding: BigEndian (0x2)
> +# MIPS64-NEXT:     FileVersion: 1
> +# MIPS64-NEXT:     OS/ABI: SystemV (0x0)
> +# MIPS64-NEXT:     ABIVersion: 0
> +# MIPS64-NEXT:     Unused: (00 00 00 00 00 00 00)
> +# MIPS64-NEXT:   }
> +# MIPS64-NEXT:   Type: Executable (0x2)
> +# MIPS64-NEXT:   Machine: EM_MIPS (0x8)
> +# MIPS64-NEXT:   Version: 1
> +# MIPS64-NEXT:   Entry:
> +# MIPS64-NEXT:   ProgramHeaderOffset: 0x40
> +# MIPS64-NEXT:   SectionHeaderOffset:
> +# MIPS64-NEXT:   Flags [
> +# MIPS64-NEXT:     EF_MIPS_ARCH_64R2
> +# MIPS64-NEXT:     EF_MIPS_CPIC
> +# MIPS64-NEXT:     EF_MIPS_PIC
> +# MIPS64-NEXT:   ]
> +
> +# RUN: llvm-mc -filetype=obj -triple=mips64el-unknown-linux %s -o
> %tmips64el
> +# RUN: ld.lld -m elf64ltsmip -e _start %tmips64el -o %t2mips64el
> +# RUN: llvm-readobj -file-headers %t2mips64el | FileCheck
> --check-prefix=MIPS64EL %s
> +# RUN: ld.lld %tmips64el -e _start -o %t3mips64el
> +# RUN: llvm-readobj -file-headers %t3mips64el | FileCheck
> --check-prefix=MIPS64EL %s
> +# MIPS64EL:      ElfHeader {
> +# MIPS64EL-NEXT:   Ident {
> +# MIPS64EL-NEXT:     Magic: (7F 45 4C 46)
> +# MIPS64EL-NEXT:     Class: 64-bit (0x2)
> +# MIPS64EL-NEXT:     DataEncoding: LittleEndian (0x1)
> +# MIPS64EL-NEXT:     FileVersion: 1
> +# MIPS64EL-NEXT:     OS/ABI: SystemV (0x0)
> +# MIPS64EL-NEXT:     ABIVersion: 0
> +# MIPS64EL-NEXT:     Unused: (00 00 00 00 00 00 00)
> +# MIPS64EL-NEXT:   }
> +# MIPS64EL-NEXT:   Type: Executable (0x2)
> +# MIPS64EL-NEXT:   Machine: EM_MIPS (0x8)
> +# MIPS64EL-NEXT:   Version: 1
> +# MIPS64EL-NEXT:   Entry:
> +# MIPS64EL-NEXT:   ProgramHeaderOffset: 0x40
> +# MIPS64EL-NEXT:   SectionHeaderOffset:
> +# MIPS64EL-NEXT:   Flags [
> +# MIPS64EL-NEXT:     EF_MIPS_ARCH_64R2
> +# MIPS64EL-NEXT:     EF_MIPS_CPIC
> +# MIPS64EL-NEXT:     EF_MIPS_PIC
> +# MIPS64EL-NEXT:   ]
> +
>  # RUN: llvm-mc -filetype=obj -triple=aarch64-unknown-linux %s -o %taarch64
>  # RUN: ld.lld -m aarch64linux %taarch64 -o %t2aarch64
>  # RUN: llvm-readobj -file-headers %t2aarch64 | FileCheck
> --check-prefix=AARCH64 %s
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160429/ba5076ea/attachment.html>


More information about the llvm-commits mailing list