Commit 585a0b03 authored by Vladimir Stefanovic's avatar Vladimir Stefanovic Committed by Brad Fitzpatrick

cmd/link/internal/ld: add support for GOARCH=mips{,le}

Change-Id: Ida214ccc5858969ea60abb0787f4d98bab4336d6
Reviewed-on: https://go-review.googlesource.com/31480
TryBot-Result: Gobot Gobot <gobot@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: default avatarCherry Zhang <cherryyz@google.com>
parent 5bfafff0
...@@ -946,18 +946,22 @@ func Elfinit(ctxt *Link) { ...@@ -946,18 +946,22 @@ func Elfinit(ctxt *Link) {
ehdr.shentsize = ELF64SHDRSIZE /* Must be ELF64SHDRSIZE */ ehdr.shentsize = ELF64SHDRSIZE /* Must be ELF64SHDRSIZE */
// 32-bit architectures // 32-bit architectures
case sys.ARM: case sys.ARM, sys.MIPS:
// we use EABI on linux/arm, freebsd/arm, netbsd/arm. if SysArch.Family == sys.ARM {
if Headtype == obj.Hlinux || Headtype == obj.Hfreebsd || Headtype == obj.Hnetbsd { // we use EABI on linux/arm, freebsd/arm, netbsd/arm.
// We set a value here that makes no indication of which if Headtype == obj.Hlinux || Headtype == obj.Hfreebsd || Headtype == obj.Hnetbsd {
// float ABI the object uses, because this is information // We set a value here that makes no indication of which
// used by the dynamic linker to compare executables and // float ABI the object uses, because this is information
// shared libraries -- so it only matters for cgo calls, and // used by the dynamic linker to compare executables and
// the information properly comes from the object files // shared libraries -- so it only matters for cgo calls, and
// produced by the host C compiler. parseArmAttributes in // the information properly comes from the object files
// ldelf.go reads that information and updates this field as // produced by the host C compiler. parseArmAttributes in
// appropriate. // ldelf.go reads that information and updates this field as
ehdr.flags = 0x5000002 // has entry point, Version5 EABI // appropriate.
ehdr.flags = 0x5000002 // has entry point, Version5 EABI
}
} else if SysArch.Family == sys.MIPS {
ehdr.flags = 0x50000000 /* MIPS 32 */
} }
fallthrough fallthrough
default: default:
......
...@@ -546,6 +546,12 @@ func ldelf(ctxt *Link, f *bio.Reader, pkg string, length int64, pn string) { ...@@ -546,6 +546,12 @@ func ldelf(ctxt *Link, f *bio.Reader, pkg string, length int64, pn string) {
Errorf(nil, "%s: elf %s unimplemented", pn, SysArch.Name) Errorf(nil, "%s: elf %s unimplemented", pn, SysArch.Name)
return return
case sys.MIPS:
if elfobj.machine != ElfMachMips || hdr.Ident[4] != ElfClass32 {
Errorf(nil, "%s: elf object but not mips", pn)
return
}
case sys.MIPS64: case sys.MIPS64:
if elfobj.machine != ElfMachMips || hdr.Ident[4] != ElfClass64 { if elfobj.machine != ElfMachMips || hdr.Ident[4] != ElfClass64 {
Errorf(nil, "%s: elf object but not mips64", pn) Errorf(nil, "%s: elf object but not mips64", pn)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment