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