Commit 3b37ff45 authored by erifan01's avatar erifan01 Committed by Ian Lance Taylor

cmd/link: increase the reserved space for ELF relocations

Currently the offset values of ELF relocations and Macho relocations
are 256 and 512 respectively, which means that the space reserved for
ELF relocations is only 256. But AARCH64 has more than 256 ELF relocation
types, in fact the maximum AARCH64 ELF relocation type recorded in file
src/debug/elf/elf.go is 1032 currently. So this CL increases the offset
of Macho relocations to 2048 to leave enough space for AARCH64 ELF
relocations.

Change-Id: I784ac38aeb3e102ac7825f6d621086849c8d3146
Reviewed-on: https://go-review.googlesource.com/c/go/+/172497
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: default avatarIan Lance Taylor <iant@golang.org>
parent b5946ed4
...@@ -34,6 +34,11 @@ var ( ...@@ -34,6 +34,11 @@ var (
Version = version Version = version
) )
const (
ElfRelocOffset = 256
MachoRelocOffset = 2048 // reserve enough space for ELF relocations
)
func goarm() int { func goarm() int {
switch v := envOr("GOARM", defaultGOARM); v { switch v := envOr("GOARM", defaultGOARM); v {
case "5": case "5":
......
...@@ -103,13 +103,13 @@ func adddynrel(ctxt *ld.Link, s *sym.Symbol, r *sym.Reloc) bool { ...@@ -103,13 +103,13 @@ func adddynrel(ctxt *ld.Link, s *sym.Symbol, r *sym.Reloc) bool {
switch r.Type { switch r.Type {
default: default:
if r.Type >= 256 { if r.Type >= objabi.ElfRelocOffset {
ld.Errorf(s, "unexpected relocation type %d (%s)", r.Type, sym.RelocName(ctxt.Arch, r.Type)) ld.Errorf(s, "unexpected relocation type %d (%s)", r.Type, sym.RelocName(ctxt.Arch, r.Type))
return false return false
} }
// Handle relocations found in ELF object files. // Handle relocations found in ELF object files.
case 256 + objabi.RelocType(elf.R_X86_64_PC32): case objabi.ElfRelocOffset + objabi.RelocType(elf.R_X86_64_PC32):
if targ.Type == sym.SDYNIMPORT { if targ.Type == sym.SDYNIMPORT {
ld.Errorf(s, "unexpected R_X86_64_PC32 relocation for dynamic symbol %s", targ.Name) ld.Errorf(s, "unexpected R_X86_64_PC32 relocation for dynamic symbol %s", targ.Name)
} }
...@@ -122,7 +122,7 @@ func adddynrel(ctxt *ld.Link, s *sym.Symbol, r *sym.Reloc) bool { ...@@ -122,7 +122,7 @@ func adddynrel(ctxt *ld.Link, s *sym.Symbol, r *sym.Reloc) bool {
r.Add += 4 r.Add += 4
return true return true
case 256 + objabi.RelocType(elf.R_X86_64_PC64): case objabi.ElfRelocOffset + objabi.RelocType(elf.R_X86_64_PC64):
if targ.Type == sym.SDYNIMPORT { if targ.Type == sym.SDYNIMPORT {
ld.Errorf(s, "unexpected R_X86_64_PC64 relocation for dynamic symbol %s", targ.Name) ld.Errorf(s, "unexpected R_X86_64_PC64 relocation for dynamic symbol %s", targ.Name)
} }
...@@ -133,7 +133,7 @@ func adddynrel(ctxt *ld.Link, s *sym.Symbol, r *sym.Reloc) bool { ...@@ -133,7 +133,7 @@ func adddynrel(ctxt *ld.Link, s *sym.Symbol, r *sym.Reloc) bool {
r.Add += 8 r.Add += 8
return true return true
case 256 + objabi.RelocType(elf.R_X86_64_PLT32): case objabi.ElfRelocOffset + objabi.RelocType(elf.R_X86_64_PLT32):
r.Type = objabi.R_PCREL r.Type = objabi.R_PCREL
r.Add += 4 r.Add += 4
if targ.Type == sym.SDYNIMPORT { if targ.Type == sym.SDYNIMPORT {
...@@ -144,7 +144,9 @@ func adddynrel(ctxt *ld.Link, s *sym.Symbol, r *sym.Reloc) bool { ...@@ -144,7 +144,9 @@ func adddynrel(ctxt *ld.Link, s *sym.Symbol, r *sym.Reloc) bool {
return true return true
case 256 + objabi.RelocType(elf.R_X86_64_GOTPCREL), 256 + objabi.RelocType(elf.R_X86_64_GOTPCRELX), 256 + objabi.RelocType(elf.R_X86_64_REX_GOTPCRELX): case objabi.ElfRelocOffset + objabi.RelocType(elf.R_X86_64_GOTPCREL),
objabi.ElfRelocOffset + objabi.RelocType(elf.R_X86_64_GOTPCRELX),
objabi.ElfRelocOffset + objabi.RelocType(elf.R_X86_64_REX_GOTPCRELX):
if targ.Type != sym.SDYNIMPORT { if targ.Type != sym.SDYNIMPORT {
// have symbol // have symbol
if r.Off >= 2 && s.P[r.Off-2] == 0x8b { if r.Off >= 2 && s.P[r.Off-2] == 0x8b {
...@@ -167,7 +169,7 @@ func adddynrel(ctxt *ld.Link, s *sym.Symbol, r *sym.Reloc) bool { ...@@ -167,7 +169,7 @@ func adddynrel(ctxt *ld.Link, s *sym.Symbol, r *sym.Reloc) bool {
r.Add += int64(targ.Got()) r.Add += int64(targ.Got())
return true return true
case 256 + objabi.RelocType(elf.R_X86_64_64): case objabi.ElfRelocOffset + objabi.RelocType(elf.R_X86_64_64):
if targ.Type == sym.SDYNIMPORT { if targ.Type == sym.SDYNIMPORT {
ld.Errorf(s, "unexpected R_X86_64_64 relocation for dynamic symbol %s", targ.Name) ld.Errorf(s, "unexpected R_X86_64_64 relocation for dynamic symbol %s", targ.Name)
} }
...@@ -175,9 +177,9 @@ func adddynrel(ctxt *ld.Link, s *sym.Symbol, r *sym.Reloc) bool { ...@@ -175,9 +177,9 @@ func adddynrel(ctxt *ld.Link, s *sym.Symbol, r *sym.Reloc) bool {
return true return true
// Handle relocations found in Mach-O object files. // Handle relocations found in Mach-O object files.
case 512 + ld.MACHO_X86_64_RELOC_UNSIGNED*2 + 0, case objabi.MachoRelocOffset + ld.MACHO_X86_64_RELOC_UNSIGNED*2 + 0,
512 + ld.MACHO_X86_64_RELOC_SIGNED*2 + 0, objabi.MachoRelocOffset + ld.MACHO_X86_64_RELOC_SIGNED*2 + 0,
512 + ld.MACHO_X86_64_RELOC_BRANCH*2 + 0: objabi.MachoRelocOffset + ld.MACHO_X86_64_RELOC_BRANCH*2 + 0:
// TODO: What is the difference between all these? // TODO: What is the difference between all these?
r.Type = objabi.R_ADDR r.Type = objabi.R_ADDR
...@@ -186,7 +188,7 @@ func adddynrel(ctxt *ld.Link, s *sym.Symbol, r *sym.Reloc) bool { ...@@ -186,7 +188,7 @@ func adddynrel(ctxt *ld.Link, s *sym.Symbol, r *sym.Reloc) bool {
} }
return true return true
case 512 + ld.MACHO_X86_64_RELOC_BRANCH*2 + 1: case objabi.MachoRelocOffset + ld.MACHO_X86_64_RELOC_BRANCH*2 + 1:
if targ.Type == sym.SDYNIMPORT { if targ.Type == sym.SDYNIMPORT {
addpltsym(ctxt, targ) addpltsym(ctxt, targ)
r.Sym = ctxt.Syms.Lookup(".plt", 0) r.Sym = ctxt.Syms.Lookup(".plt", 0)
...@@ -196,11 +198,11 @@ func adddynrel(ctxt *ld.Link, s *sym.Symbol, r *sym.Reloc) bool { ...@@ -196,11 +198,11 @@ func adddynrel(ctxt *ld.Link, s *sym.Symbol, r *sym.Reloc) bool {
} }
fallthrough fallthrough
case 512 + ld.MACHO_X86_64_RELOC_UNSIGNED*2 + 1, case objabi.MachoRelocOffset + ld.MACHO_X86_64_RELOC_UNSIGNED*2 + 1,
512 + ld.MACHO_X86_64_RELOC_SIGNED*2 + 1, objabi.MachoRelocOffset + ld.MACHO_X86_64_RELOC_SIGNED*2 + 1,
512 + ld.MACHO_X86_64_RELOC_SIGNED_1*2 + 1, objabi.MachoRelocOffset + ld.MACHO_X86_64_RELOC_SIGNED_1*2 + 1,
512 + ld.MACHO_X86_64_RELOC_SIGNED_2*2 + 1, objabi.MachoRelocOffset + ld.MACHO_X86_64_RELOC_SIGNED_2*2 + 1,
512 + ld.MACHO_X86_64_RELOC_SIGNED_4*2 + 1: objabi.MachoRelocOffset + ld.MACHO_X86_64_RELOC_SIGNED_4*2 + 1:
r.Type = objabi.R_PCREL r.Type = objabi.R_PCREL
if targ.Type == sym.SDYNIMPORT { if targ.Type == sym.SDYNIMPORT {
...@@ -208,7 +210,7 @@ func adddynrel(ctxt *ld.Link, s *sym.Symbol, r *sym.Reloc) bool { ...@@ -208,7 +210,7 @@ func adddynrel(ctxt *ld.Link, s *sym.Symbol, r *sym.Reloc) bool {
} }
return true return true
case 512 + ld.MACHO_X86_64_RELOC_GOT_LOAD*2 + 1: case objabi.MachoRelocOffset + ld.MACHO_X86_64_RELOC_GOT_LOAD*2 + 1:
if targ.Type != sym.SDYNIMPORT { if targ.Type != sym.SDYNIMPORT {
// have symbol // have symbol
// turn MOVQ of GOT entry into LEAQ of symbol itself // turn MOVQ of GOT entry into LEAQ of symbol itself
...@@ -223,7 +225,7 @@ func adddynrel(ctxt *ld.Link, s *sym.Symbol, r *sym.Reloc) bool { ...@@ -223,7 +225,7 @@ func adddynrel(ctxt *ld.Link, s *sym.Symbol, r *sym.Reloc) bool {
} }
fallthrough fallthrough
case 512 + ld.MACHO_X86_64_RELOC_GOT*2 + 1: case objabi.MachoRelocOffset + ld.MACHO_X86_64_RELOC_GOT*2 + 1:
if targ.Type != sym.SDYNIMPORT { if targ.Type != sym.SDYNIMPORT {
ld.Errorf(s, "unexpected GOT reloc for non-dynamic symbol %s", targ.Name) ld.Errorf(s, "unexpected GOT reloc for non-dynamic symbol %s", targ.Name)
} }
...@@ -333,7 +335,7 @@ func adddynrel(ctxt *ld.Link, s *sym.Symbol, r *sym.Reloc) bool { ...@@ -333,7 +335,7 @@ func adddynrel(ctxt *ld.Link, s *sym.Symbol, r *sym.Reloc) bool {
rela.AddUint64(ctxt.Arch, ld.ELF64_R_INFO(uint32(targ.Dynid), uint32(elf.R_X86_64_32))) rela.AddUint64(ctxt.Arch, ld.ELF64_R_INFO(uint32(targ.Dynid), uint32(elf.R_X86_64_32)))
} }
rela.AddUint64(ctxt.Arch, uint64(r.Add)) rela.AddUint64(ctxt.Arch, uint64(r.Add))
r.Type = 256 // ignore during relocsym r.Type = objabi.ElfRelocOffset // ignore during relocsym
return true return true
} }
...@@ -359,7 +361,7 @@ func adddynrel(ctxt *ld.Link, s *sym.Symbol, r *sym.Reloc) bool { ...@@ -359,7 +361,7 @@ func adddynrel(ctxt *ld.Link, s *sym.Symbol, r *sym.Reloc) bool {
s.Value = got.Size s.Value = got.Size
got.AddUint64(ctxt.Arch, 0) got.AddUint64(ctxt.Arch, 0)
ctxt.Syms.Lookup(".linkedit.got", 0).AddUint32(ctxt.Arch, uint32(targ.Dynid)) ctxt.Syms.Lookup(".linkedit.got", 0).AddUint32(ctxt.Arch, uint32(targ.Dynid))
r.Type = 256 // ignore during relocsym r.Type = objabi.ElfRelocOffset // ignore during relocsym
return true return true
} }
} }
......
...@@ -120,13 +120,13 @@ func adddynrel(ctxt *ld.Link, s *sym.Symbol, r *sym.Reloc) bool { ...@@ -120,13 +120,13 @@ func adddynrel(ctxt *ld.Link, s *sym.Symbol, r *sym.Reloc) bool {
switch r.Type { switch r.Type {
default: default:
if r.Type >= 256 { if r.Type >= objabi.ElfRelocOffset {
ld.Errorf(s, "unexpected relocation type %d (%s)", r.Type, sym.RelocName(ctxt.Arch, r.Type)) ld.Errorf(s, "unexpected relocation type %d (%s)", r.Type, sym.RelocName(ctxt.Arch, r.Type))
return false return false
} }
// Handle relocations found in ELF object files. // Handle relocations found in ELF object files.
case 256 + objabi.RelocType(elf.R_ARM_PLT32): case objabi.ElfRelocOffset + objabi.RelocType(elf.R_ARM_PLT32):
r.Type = objabi.R_CALLARM r.Type = objabi.R_CALLARM
if targ.Type == sym.SDYNIMPORT { if targ.Type == sym.SDYNIMPORT {
...@@ -137,11 +137,11 @@ func adddynrel(ctxt *ld.Link, s *sym.Symbol, r *sym.Reloc) bool { ...@@ -137,11 +137,11 @@ func adddynrel(ctxt *ld.Link, s *sym.Symbol, r *sym.Reloc) bool {
return true return true
case 256 + objabi.RelocType(elf.R_ARM_THM_PC22): // R_ARM_THM_CALL case objabi.ElfRelocOffset + objabi.RelocType(elf.R_ARM_THM_PC22): // R_ARM_THM_CALL
ld.Exitf("R_ARM_THM_CALL, are you using -marm?") ld.Exitf("R_ARM_THM_CALL, are you using -marm?")
return false return false
case 256 + objabi.RelocType(elf.R_ARM_GOT32): // R_ARM_GOT_BREL case objabi.ElfRelocOffset + objabi.RelocType(elf.R_ARM_GOT32): // R_ARM_GOT_BREL
if targ.Type != sym.SDYNIMPORT { if targ.Type != sym.SDYNIMPORT {
addgotsyminternal(ctxt, targ) addgotsyminternal(ctxt, targ)
} else { } else {
...@@ -153,7 +153,7 @@ func adddynrel(ctxt *ld.Link, s *sym.Symbol, r *sym.Reloc) bool { ...@@ -153,7 +153,7 @@ func adddynrel(ctxt *ld.Link, s *sym.Symbol, r *sym.Reloc) bool {
r.Add += int64(targ.Got()) r.Add += int64(targ.Got())
return true return true
case 256 + objabi.RelocType(elf.R_ARM_GOT_PREL): // GOT(nil) + A - nil case objabi.ElfRelocOffset + objabi.RelocType(elf.R_ARM_GOT_PREL): // GOT(nil) + A - nil
if targ.Type != sym.SDYNIMPORT { if targ.Type != sym.SDYNIMPORT {
addgotsyminternal(ctxt, targ) addgotsyminternal(ctxt, targ)
} else { } else {
...@@ -165,19 +165,19 @@ func adddynrel(ctxt *ld.Link, s *sym.Symbol, r *sym.Reloc) bool { ...@@ -165,19 +165,19 @@ func adddynrel(ctxt *ld.Link, s *sym.Symbol, r *sym.Reloc) bool {
r.Add += int64(targ.Got()) + 4 r.Add += int64(targ.Got()) + 4
return true return true
case 256 + objabi.RelocType(elf.R_ARM_GOTOFF): // R_ARM_GOTOFF32 case objabi.ElfRelocOffset + objabi.RelocType(elf.R_ARM_GOTOFF): // R_ARM_GOTOFF32
r.Type = objabi.R_GOTOFF r.Type = objabi.R_GOTOFF
return true return true
case 256 + objabi.RelocType(elf.R_ARM_GOTPC): // R_ARM_BASE_PREL case objabi.ElfRelocOffset + objabi.RelocType(elf.R_ARM_GOTPC): // R_ARM_BASE_PREL
r.Type = objabi.R_PCREL r.Type = objabi.R_PCREL
r.Sym = ctxt.Syms.Lookup(".got", 0) r.Sym = ctxt.Syms.Lookup(".got", 0)
r.Add += 4 r.Add += 4
return true return true
case 256 + objabi.RelocType(elf.R_ARM_CALL): case objabi.ElfRelocOffset + objabi.RelocType(elf.R_ARM_CALL):
r.Type = objabi.R_CALLARM r.Type = objabi.R_CALLARM
if targ.Type == sym.SDYNIMPORT { if targ.Type == sym.SDYNIMPORT {
addpltsym(ctxt, targ) addpltsym(ctxt, targ)
...@@ -187,13 +187,13 @@ func adddynrel(ctxt *ld.Link, s *sym.Symbol, r *sym.Reloc) bool { ...@@ -187,13 +187,13 @@ func adddynrel(ctxt *ld.Link, s *sym.Symbol, r *sym.Reloc) bool {
return true return true
case 256 + objabi.RelocType(elf.R_ARM_REL32): // R_ARM_REL32 case objabi.ElfRelocOffset + objabi.RelocType(elf.R_ARM_REL32): // R_ARM_REL32
r.Type = objabi.R_PCREL r.Type = objabi.R_PCREL
r.Add += 4 r.Add += 4
return true return true
case 256 + objabi.RelocType(elf.R_ARM_ABS32): case objabi.ElfRelocOffset + objabi.RelocType(elf.R_ARM_ABS32):
if targ.Type == sym.SDYNIMPORT { if targ.Type == sym.SDYNIMPORT {
ld.Errorf(s, "unexpected R_ARM_ABS32 relocation for dynamic symbol %s", targ.Name) ld.Errorf(s, "unexpected R_ARM_ABS32 relocation for dynamic symbol %s", targ.Name)
} }
...@@ -201,7 +201,7 @@ func adddynrel(ctxt *ld.Link, s *sym.Symbol, r *sym.Reloc) bool { ...@@ -201,7 +201,7 @@ func adddynrel(ctxt *ld.Link, s *sym.Symbol, r *sym.Reloc) bool {
return true return true
// we can just ignore this, because we are targeting ARM V5+ anyway // we can just ignore this, because we are targeting ARM V5+ anyway
case 256 + objabi.RelocType(elf.R_ARM_V4BX): case objabi.ElfRelocOffset + objabi.RelocType(elf.R_ARM_V4BX):
if r.Sym != nil { if r.Sym != nil {
// R_ARM_V4BX is ABS relocation, so this symbol is a dummy symbol, ignore it // R_ARM_V4BX is ABS relocation, so this symbol is a dummy symbol, ignore it
r.Sym.Type = 0 r.Sym.Type = 0
...@@ -210,8 +210,8 @@ func adddynrel(ctxt *ld.Link, s *sym.Symbol, r *sym.Reloc) bool { ...@@ -210,8 +210,8 @@ func adddynrel(ctxt *ld.Link, s *sym.Symbol, r *sym.Reloc) bool {
r.Sym = nil r.Sym = nil
return true return true
case 256 + objabi.RelocType(elf.R_ARM_PC24), case objabi.ElfRelocOffset + objabi.RelocType(elf.R_ARM_PC24),
256 + objabi.RelocType(elf.R_ARM_JUMP24): objabi.ElfRelocOffset + objabi.RelocType(elf.R_ARM_JUMP24):
r.Type = objabi.R_CALLARM r.Type = objabi.R_CALLARM
if targ.Type == sym.SDYNIMPORT { if targ.Type == sym.SDYNIMPORT {
addpltsym(ctxt, targ) addpltsym(ctxt, targ)
......
...@@ -162,7 +162,7 @@ func relocsym(ctxt *Link, s *sym.Symbol) { ...@@ -162,7 +162,7 @@ func relocsym(ctxt *Link, s *sym.Symbol) {
} }
} }
if r.Type >= 256 { if r.Type >= objabi.ElfRelocOffset {
continue continue
} }
if r.Siz == 0 { // informational relocation - no work to do if r.Siz == 0 { // informational relocation - no work to do
...@@ -636,7 +636,7 @@ func dynrelocsym(ctxt *Link, s *sym.Symbol) { ...@@ -636,7 +636,7 @@ func dynrelocsym(ctxt *Link, s *sym.Symbol) {
continue continue
} }
if r.Sym != nil && r.Sym.Type == sym.SDYNIMPORT || r.Type >= 256 { if r.Sym != nil && r.Sym.Type == sym.SDYNIMPORT || r.Type >= objabi.ElfRelocOffset {
if r.Sym != nil && !r.Sym.Attr.Reachable() { if r.Sym != nil && !r.Sym.Attr.Reachable() {
Errorf(s, "dynamic relocation to unreachable symbol %s", r.Sym.Name) Errorf(s, "dynamic relocation to unreachable symbol %s", r.Sym.Name)
} }
......
...@@ -1401,7 +1401,7 @@ func addPEBaseRelocSym(ctxt *Link, s *sym.Symbol, rt *peBaseRelocTable) { ...@@ -1401,7 +1401,7 @@ func addPEBaseRelocSym(ctxt *Link, s *sym.Symbol, rt *peBaseRelocTable) {
if !r.Sym.Attr.Reachable() { if !r.Sym.Attr.Reachable() {
continue continue
} }
if r.Type >= 256 { if r.Type >= objabi.ElfRelocOffset {
continue continue
} }
if r.Siz == 0 { // informational relocation if r.Siz == 0 { // informational relocation
......
...@@ -923,7 +923,7 @@ func Load(arch *sys.Arch, syms *sym.Symbols, f *bio.Reader, pkg string, length i ...@@ -923,7 +923,7 @@ func Load(arch *sys.Arch, syms *sym.Symbols, f *bio.Reader, pkg string, length i
rp.Sym = elfsym.sym rp.Sym = elfsym.sym
} }
rp.Type = 256 + objabi.RelocType(info) rp.Type = objabi.ElfRelocOffset + objabi.RelocType(info)
rp.Siz, err = relSize(arch, pn, uint32(info)) rp.Siz, err = relSize(arch, pn, uint32(info))
if err != nil { if err != nil {
return nil, 0, err return nil, 0, err
......
...@@ -771,7 +771,7 @@ func Load(arch *sys.Arch, syms *sym.Symbols, f *bio.Reader, pkg string, length i ...@@ -771,7 +771,7 @@ func Load(arch *sys.Arch, syms *sym.Symbols, f *bio.Reader, pkg string, length i
// handle reference to __IMPORT/__pointers. // handle reference to __IMPORT/__pointers.
// how much worse can this get? // how much worse can this get?
// why are we supporting 386 on the mac anyway? // why are we supporting 386 on the mac anyway?
rp.Type = 512 + MACHO_FAKE_GOTPCREL rp.Type = objabi.MachoRelocOffset + MACHO_FAKE_GOTPCREL
// figure out which pointer this is a reference to. // figure out which pointer this is a reference to.
k = int(uint64(ks.res1) + (uint64(rel.value)-ks.addr)/4) k = int(uint64(ks.res1) + (uint64(rel.value)-ks.addr)/4)
...@@ -805,7 +805,7 @@ func Load(arch *sys.Arch, syms *sym.Symbols, f *bio.Reader, pkg string, length i ...@@ -805,7 +805,7 @@ func Load(arch *sys.Arch, syms *sym.Symbols, f *bio.Reader, pkg string, length i
} }
rp.Siz = rel.length rp.Siz = rel.length
rp.Type = 512 + (objabi.RelocType(rel.type_) << 1) + objabi.RelocType(rel.pcrel) rp.Type = objabi.MachoRelocOffset + (objabi.RelocType(rel.type_) << 1) + objabi.RelocType(rel.pcrel)
rp.Off = int32(rel.addr) rp.Off = int32(rel.addr)
// Handle X86_64_RELOC_SIGNED referencing a section (rel->extrn == 0). // Handle X86_64_RELOC_SIGNED referencing a section (rel->extrn == 0).
......
...@@ -95,7 +95,7 @@ func genplt(ctxt *ld.Link) { ...@@ -95,7 +95,7 @@ func genplt(ctxt *ld.Link) {
for _, s := range ctxt.Textp { for _, s := range ctxt.Textp {
for i := range s.R { for i := range s.R {
r := &s.R[i] r := &s.R[i]
if r.Type != 256+objabi.RelocType(elf.R_PPC64_REL24) || r.Sym.Type != sym.SDYNIMPORT { if r.Type != objabi.ElfRelocOffset+objabi.RelocType(elf.R_PPC64_REL24) || r.Sym.Type != sym.SDYNIMPORT {
continue continue
} }
...@@ -275,13 +275,13 @@ func addelfdynrel(ctxt *ld.Link, s *sym.Symbol, r *sym.Reloc) bool { ...@@ -275,13 +275,13 @@ func addelfdynrel(ctxt *ld.Link, s *sym.Symbol, r *sym.Reloc) bool {
switch r.Type { switch r.Type {
default: default:
if r.Type >= 256 { if r.Type >= objabi.ElfRelocOffset {
ld.Errorf(s, "unexpected relocation type %d (%s)", r.Type, sym.RelocName(ctxt.Arch, r.Type)) ld.Errorf(s, "unexpected relocation type %d (%s)", r.Type, sym.RelocName(ctxt.Arch, r.Type))
return false return false
} }
// Handle relocations found in ELF object files. // Handle relocations found in ELF object files.
case 256 + objabi.RelocType(elf.R_PPC64_REL24): case objabi.ElfRelocOffset + objabi.RelocType(elf.R_PPC64_REL24):
r.Type = objabi.R_CALLPOWER r.Type = objabi.R_CALLPOWER
// This is a local call, so the caller isn't setting // This is a local call, so the caller isn't setting
...@@ -298,7 +298,7 @@ func addelfdynrel(ctxt *ld.Link, s *sym.Symbol, r *sym.Reloc) bool { ...@@ -298,7 +298,7 @@ func addelfdynrel(ctxt *ld.Link, s *sym.Symbol, r *sym.Reloc) bool {
return true return true
case 256 + objabi.RelocType(elf.R_PPC_REL32): case objabi.ElfRelocOffset + objabi.RelocType(elf.R_PPC_REL32):
r.Type = objabi.R_PCREL r.Type = objabi.R_PCREL
r.Add += 4 r.Add += 4
...@@ -308,7 +308,7 @@ func addelfdynrel(ctxt *ld.Link, s *sym.Symbol, r *sym.Reloc) bool { ...@@ -308,7 +308,7 @@ func addelfdynrel(ctxt *ld.Link, s *sym.Symbol, r *sym.Reloc) bool {
return true return true
case 256 + objabi.RelocType(elf.R_PPC64_ADDR64): case objabi.ElfRelocOffset + objabi.RelocType(elf.R_PPC64_ADDR64):
r.Type = objabi.R_ADDR r.Type = objabi.R_ADDR
if targ.Type == sym.SDYNIMPORT { if targ.Type == sym.SDYNIMPORT {
// These happen in .toc sections // These happen in .toc sections
...@@ -318,54 +318,54 @@ func addelfdynrel(ctxt *ld.Link, s *sym.Symbol, r *sym.Reloc) bool { ...@@ -318,54 +318,54 @@ func addelfdynrel(ctxt *ld.Link, s *sym.Symbol, r *sym.Reloc) bool {
rela.AddAddrPlus(ctxt.Arch, s, int64(r.Off)) rela.AddAddrPlus(ctxt.Arch, s, int64(r.Off))
rela.AddUint64(ctxt.Arch, ld.ELF64_R_INFO(uint32(targ.Dynid), uint32(elf.R_PPC64_ADDR64))) rela.AddUint64(ctxt.Arch, ld.ELF64_R_INFO(uint32(targ.Dynid), uint32(elf.R_PPC64_ADDR64)))
rela.AddUint64(ctxt.Arch, uint64(r.Add)) rela.AddUint64(ctxt.Arch, uint64(r.Add))
r.Type = 256 // ignore during relocsym r.Type = objabi.ElfRelocOffset // ignore during relocsym
} }
return true return true
case 256 + objabi.RelocType(elf.R_PPC64_TOC16): case objabi.ElfRelocOffset + objabi.RelocType(elf.R_PPC64_TOC16):
r.Type = objabi.R_POWER_TOC r.Type = objabi.R_POWER_TOC
r.Variant = sym.RV_POWER_LO | sym.RV_CHECK_OVERFLOW r.Variant = sym.RV_POWER_LO | sym.RV_CHECK_OVERFLOW
return true return true
case 256 + objabi.RelocType(elf.R_PPC64_TOC16_LO): case objabi.ElfRelocOffset + objabi.RelocType(elf.R_PPC64_TOC16_LO):
r.Type = objabi.R_POWER_TOC r.Type = objabi.R_POWER_TOC
r.Variant = sym.RV_POWER_LO r.Variant = sym.RV_POWER_LO
return true return true
case 256 + objabi.RelocType(elf.R_PPC64_TOC16_HA): case objabi.ElfRelocOffset + objabi.RelocType(elf.R_PPC64_TOC16_HA):
r.Type = objabi.R_POWER_TOC r.Type = objabi.R_POWER_TOC
r.Variant = sym.RV_POWER_HA | sym.RV_CHECK_OVERFLOW r.Variant = sym.RV_POWER_HA | sym.RV_CHECK_OVERFLOW
return true return true
case 256 + objabi.RelocType(elf.R_PPC64_TOC16_HI): case objabi.ElfRelocOffset + objabi.RelocType(elf.R_PPC64_TOC16_HI):
r.Type = objabi.R_POWER_TOC r.Type = objabi.R_POWER_TOC
r.Variant = sym.RV_POWER_HI | sym.RV_CHECK_OVERFLOW r.Variant = sym.RV_POWER_HI | sym.RV_CHECK_OVERFLOW
return true return true
case 256 + objabi.RelocType(elf.R_PPC64_TOC16_DS): case objabi.ElfRelocOffset + objabi.RelocType(elf.R_PPC64_TOC16_DS):
r.Type = objabi.R_POWER_TOC r.Type = objabi.R_POWER_TOC
r.Variant = sym.RV_POWER_DS | sym.RV_CHECK_OVERFLOW r.Variant = sym.RV_POWER_DS | sym.RV_CHECK_OVERFLOW
return true return true
case 256 + objabi.RelocType(elf.R_PPC64_TOC16_LO_DS): case objabi.ElfRelocOffset + objabi.RelocType(elf.R_PPC64_TOC16_LO_DS):
r.Type = objabi.R_POWER_TOC r.Type = objabi.R_POWER_TOC
r.Variant = sym.RV_POWER_DS r.Variant = sym.RV_POWER_DS
return true return true
case 256 + objabi.RelocType(elf.R_PPC64_REL16_LO): case objabi.ElfRelocOffset + objabi.RelocType(elf.R_PPC64_REL16_LO):
r.Type = objabi.R_PCREL r.Type = objabi.R_PCREL
r.Variant = sym.RV_POWER_LO r.Variant = sym.RV_POWER_LO
r.Add += 2 // Compensate for relocation size of 2 r.Add += 2 // Compensate for relocation size of 2
return true return true
case 256 + objabi.RelocType(elf.R_PPC64_REL16_HI): case objabi.ElfRelocOffset + objabi.RelocType(elf.R_PPC64_REL16_HI):
r.Type = objabi.R_PCREL r.Type = objabi.R_PCREL
r.Variant = sym.RV_POWER_HI | sym.RV_CHECK_OVERFLOW r.Variant = sym.RV_POWER_HI | sym.RV_CHECK_OVERFLOW
r.Add += 2 r.Add += 2
return true return true
case 256 + objabi.RelocType(elf.R_PPC64_REL16_HA): case objabi.ElfRelocOffset + objabi.RelocType(elf.R_PPC64_REL16_HA):
r.Type = objabi.R_PCREL r.Type = objabi.R_PCREL
r.Variant = sym.RV_POWER_HA | sym.RV_CHECK_OVERFLOW r.Variant = sym.RV_POWER_HA | sym.RV_CHECK_OVERFLOW
r.Add += 2 r.Add += 2
......
...@@ -107,30 +107,30 @@ func adddynrel(ctxt *ld.Link, s *sym.Symbol, r *sym.Reloc) bool { ...@@ -107,30 +107,30 @@ func adddynrel(ctxt *ld.Link, s *sym.Symbol, r *sym.Reloc) bool {
switch r.Type { switch r.Type {
default: default:
if r.Type >= 256 { if r.Type >= objabi.ElfRelocOffset {
ld.Errorf(s, "unexpected relocation type %d", r.Type) ld.Errorf(s, "unexpected relocation type %d", r.Type)
return false return false
} }
// Handle relocations found in ELF object files. // Handle relocations found in ELF object files.
case 256 + objabi.RelocType(elf.R_390_12), case objabi.ElfRelocOffset + objabi.RelocType(elf.R_390_12),
256 + objabi.RelocType(elf.R_390_GOT12): objabi.ElfRelocOffset + objabi.RelocType(elf.R_390_GOT12):
ld.Errorf(s, "s390x 12-bit relocations have not been implemented (relocation type %d)", r.Type-256) ld.Errorf(s, "s390x 12-bit relocations have not been implemented (relocation type %d)", r.Type-objabi.ElfRelocOffset)
return false return false
case 256 + objabi.RelocType(elf.R_390_8), case objabi.ElfRelocOffset + objabi.RelocType(elf.R_390_8),
256 + objabi.RelocType(elf.R_390_16), objabi.ElfRelocOffset + objabi.RelocType(elf.R_390_16),
256 + objabi.RelocType(elf.R_390_32), objabi.ElfRelocOffset + objabi.RelocType(elf.R_390_32),
256 + objabi.RelocType(elf.R_390_64): objabi.ElfRelocOffset + objabi.RelocType(elf.R_390_64):
if targ.Type == sym.SDYNIMPORT { if targ.Type == sym.SDYNIMPORT {
ld.Errorf(s, "unexpected R_390_nn relocation for dynamic symbol %s", targ.Name) ld.Errorf(s, "unexpected R_390_nn relocation for dynamic symbol %s", targ.Name)
} }
r.Type = objabi.R_ADDR r.Type = objabi.R_ADDR
return true return true
case 256 + objabi.RelocType(elf.R_390_PC16), case objabi.ElfRelocOffset + objabi.RelocType(elf.R_390_PC16),
256 + objabi.RelocType(elf.R_390_PC32), objabi.ElfRelocOffset + objabi.RelocType(elf.R_390_PC32),
256 + objabi.RelocType(elf.R_390_PC64): objabi.ElfRelocOffset + objabi.RelocType(elf.R_390_PC64):
if targ.Type == sym.SDYNIMPORT { if targ.Type == sym.SDYNIMPORT {
ld.Errorf(s, "unexpected R_390_PCnn relocation for dynamic symbol %s", targ.Name) ld.Errorf(s, "unexpected R_390_PCnn relocation for dynamic symbol %s", targ.Name)
} }
...@@ -143,14 +143,14 @@ func adddynrel(ctxt *ld.Link, s *sym.Symbol, r *sym.Reloc) bool { ...@@ -143,14 +143,14 @@ func adddynrel(ctxt *ld.Link, s *sym.Symbol, r *sym.Reloc) bool {
r.Add += int64(r.Siz) r.Add += int64(r.Siz)
return true return true
case 256 + objabi.RelocType(elf.R_390_GOT16), case objabi.ElfRelocOffset + objabi.RelocType(elf.R_390_GOT16),
256 + objabi.RelocType(elf.R_390_GOT32), objabi.ElfRelocOffset + objabi.RelocType(elf.R_390_GOT32),
256 + objabi.RelocType(elf.R_390_GOT64): objabi.ElfRelocOffset + objabi.RelocType(elf.R_390_GOT64):
ld.Errorf(s, "unimplemented S390x relocation: %v", r.Type-256) ld.Errorf(s, "unimplemented S390x relocation: %v", r.Type-objabi.ElfRelocOffset)
return true return true
case 256 + objabi.RelocType(elf.R_390_PLT16DBL), case objabi.ElfRelocOffset + objabi.RelocType(elf.R_390_PLT16DBL),
256 + objabi.RelocType(elf.R_390_PLT32DBL): objabi.ElfRelocOffset + objabi.RelocType(elf.R_390_PLT32DBL):
r.Type = objabi.R_PCREL r.Type = objabi.R_PCREL
r.Variant = sym.RV_390_DBL r.Variant = sym.RV_390_DBL
r.Add += int64(r.Siz) r.Add += int64(r.Siz)
...@@ -161,8 +161,8 @@ func adddynrel(ctxt *ld.Link, s *sym.Symbol, r *sym.Reloc) bool { ...@@ -161,8 +161,8 @@ func adddynrel(ctxt *ld.Link, s *sym.Symbol, r *sym.Reloc) bool {
} }
return true return true
case 256 + objabi.RelocType(elf.R_390_PLT32), case objabi.ElfRelocOffset + objabi.RelocType(elf.R_390_PLT32),
256 + objabi.RelocType(elf.R_390_PLT64): objabi.ElfRelocOffset + objabi.RelocType(elf.R_390_PLT64):
r.Type = objabi.R_PCREL r.Type = objabi.R_PCREL
r.Add += int64(r.Siz) r.Add += int64(r.Siz)
if targ.Type == sym.SDYNIMPORT { if targ.Type == sym.SDYNIMPORT {
...@@ -172,37 +172,37 @@ func adddynrel(ctxt *ld.Link, s *sym.Symbol, r *sym.Reloc) bool { ...@@ -172,37 +172,37 @@ func adddynrel(ctxt *ld.Link, s *sym.Symbol, r *sym.Reloc) bool {
} }
return true return true
case 256 + objabi.RelocType(elf.R_390_COPY): case objabi.ElfRelocOffset + objabi.RelocType(elf.R_390_COPY):
ld.Errorf(s, "unimplemented S390x relocation: %v", r.Type-256) ld.Errorf(s, "unimplemented S390x relocation: %v", r.Type-objabi.ElfRelocOffset)
return false return false
case 256 + objabi.RelocType(elf.R_390_GLOB_DAT): case objabi.ElfRelocOffset + objabi.RelocType(elf.R_390_GLOB_DAT):
ld.Errorf(s, "unimplemented S390x relocation: %v", r.Type-256) ld.Errorf(s, "unimplemented S390x relocation: %v", r.Type-objabi.ElfRelocOffset)
return false return false
case 256 + objabi.RelocType(elf.R_390_JMP_SLOT): case objabi.ElfRelocOffset + objabi.RelocType(elf.R_390_JMP_SLOT):
ld.Errorf(s, "unimplemented S390x relocation: %v", r.Type-256) ld.Errorf(s, "unimplemented S390x relocation: %v", r.Type-objabi.ElfRelocOffset)
return false return false
case 256 + objabi.RelocType(elf.R_390_RELATIVE): case objabi.ElfRelocOffset + objabi.RelocType(elf.R_390_RELATIVE):
ld.Errorf(s, "unimplemented S390x relocation: %v", r.Type-256) ld.Errorf(s, "unimplemented S390x relocation: %v", r.Type-objabi.ElfRelocOffset)
return false return false
case 256 + objabi.RelocType(elf.R_390_GOTOFF): case objabi.ElfRelocOffset + objabi.RelocType(elf.R_390_GOTOFF):
if targ.Type == sym.SDYNIMPORT { if targ.Type == sym.SDYNIMPORT {
ld.Errorf(s, "unexpected R_390_GOTOFF relocation for dynamic symbol %s", targ.Name) ld.Errorf(s, "unexpected R_390_GOTOFF relocation for dynamic symbol %s", targ.Name)
} }
r.Type = objabi.R_GOTOFF r.Type = objabi.R_GOTOFF
return true return true
case 256 + objabi.RelocType(elf.R_390_GOTPC): case objabi.ElfRelocOffset + objabi.RelocType(elf.R_390_GOTPC):
r.Type = objabi.R_PCREL r.Type = objabi.R_PCREL
r.Sym = ctxt.Syms.Lookup(".got", 0) r.Sym = ctxt.Syms.Lookup(".got", 0)
r.Add += int64(r.Siz) r.Add += int64(r.Siz)
return true return true
case 256 + objabi.RelocType(elf.R_390_PC16DBL), case objabi.ElfRelocOffset + objabi.RelocType(elf.R_390_PC16DBL),
256 + objabi.RelocType(elf.R_390_PC32DBL): objabi.ElfRelocOffset + objabi.RelocType(elf.R_390_PC32DBL):
r.Type = objabi.R_PCREL r.Type = objabi.R_PCREL
r.Variant = sym.RV_390_DBL r.Variant = sym.RV_390_DBL
r.Add += int64(r.Siz) r.Add += int64(r.Siz)
...@@ -211,14 +211,14 @@ func adddynrel(ctxt *ld.Link, s *sym.Symbol, r *sym.Reloc) bool { ...@@ -211,14 +211,14 @@ func adddynrel(ctxt *ld.Link, s *sym.Symbol, r *sym.Reloc) bool {
} }
return true return true
case 256 + objabi.RelocType(elf.R_390_GOTPCDBL): case objabi.ElfRelocOffset + objabi.RelocType(elf.R_390_GOTPCDBL):
r.Type = objabi.R_PCREL r.Type = objabi.R_PCREL
r.Variant = sym.RV_390_DBL r.Variant = sym.RV_390_DBL
r.Sym = ctxt.Syms.Lookup(".got", 0) r.Sym = ctxt.Syms.Lookup(".got", 0)
r.Add += int64(r.Siz) r.Add += int64(r.Siz)
return true return true
case 256 + objabi.RelocType(elf.R_390_GOTENT): case objabi.ElfRelocOffset + objabi.RelocType(elf.R_390_GOTENT):
addgotsym(ctxt, targ) addgotsym(ctxt, targ)
r.Type = objabi.R_PCREL r.Type = objabi.R_PCREL
......
...@@ -57,8 +57,8 @@ func RelocName(arch *sys.Arch, r objabi.RelocType) string { ...@@ -57,8 +57,8 @@ func RelocName(arch *sys.Arch, r objabi.RelocType) string {
// Uncomment code when we include those in bootstrap code. // Uncomment code when we include those in bootstrap code.
switch { switch {
case r >= 512: // Mach-O case r >= objabi.MachoRelocOffset: // Mach-O
// nr := (r - 512)>>1 // nr := (r - objabi.MachoRelocOffset)>>1
// switch ctxt.Arch.Family { // switch ctxt.Arch.Family {
// case sys.AMD64: // case sys.AMD64:
// return macho.RelocTypeX86_64(nr).String() // return macho.RelocTypeX86_64(nr).String()
...@@ -71,8 +71,8 @@ func RelocName(arch *sys.Arch, r objabi.RelocType) string { ...@@ -71,8 +71,8 @@ func RelocName(arch *sys.Arch, r objabi.RelocType) string {
// default: // default:
// panic("unreachable") // panic("unreachable")
// } // }
case r >= 256: // ELF case r >= objabi.ElfRelocOffset: // ELF
nr := r - 256 nr := r - objabi.ElfRelocOffset
switch arch.Family { switch arch.Family {
case sys.AMD64: case sys.AMD64:
return elf.R_X86_64(nr).String() return elf.R_X86_64(nr).String()
......
...@@ -172,13 +172,13 @@ func adddynrel(ctxt *ld.Link, s *sym.Symbol, r *sym.Reloc) bool { ...@@ -172,13 +172,13 @@ func adddynrel(ctxt *ld.Link, s *sym.Symbol, r *sym.Reloc) bool {
switch r.Type { switch r.Type {
default: default:
if r.Type >= 256 { if r.Type >= objabi.ElfRelocOffset {
ld.Errorf(s, "unexpected relocation type %d (%s)", r.Type, sym.RelocName(ctxt.Arch, r.Type)) ld.Errorf(s, "unexpected relocation type %d (%s)", r.Type, sym.RelocName(ctxt.Arch, r.Type))
return false return false
} }
// Handle relocations found in ELF object files. // Handle relocations found in ELF object files.
case 256 + objabi.RelocType(elf.R_386_PC32): case objabi.ElfRelocOffset + objabi.RelocType(elf.R_386_PC32):
if targ.Type == sym.SDYNIMPORT { if targ.Type == sym.SDYNIMPORT {
ld.Errorf(s, "unexpected R_386_PC32 relocation for dynamic symbol %s", targ.Name) ld.Errorf(s, "unexpected R_386_PC32 relocation for dynamic symbol %s", targ.Name)
} }
...@@ -191,7 +191,7 @@ func adddynrel(ctxt *ld.Link, s *sym.Symbol, r *sym.Reloc) bool { ...@@ -191,7 +191,7 @@ func adddynrel(ctxt *ld.Link, s *sym.Symbol, r *sym.Reloc) bool {
r.Add += 4 r.Add += 4
return true return true
case 256 + objabi.RelocType(elf.R_386_PLT32): case objabi.ElfRelocOffset + objabi.RelocType(elf.R_386_PLT32):
r.Type = objabi.R_PCREL r.Type = objabi.R_PCREL
r.Add += 4 r.Add += 4
if targ.Type == sym.SDYNIMPORT { if targ.Type == sym.SDYNIMPORT {
...@@ -202,7 +202,8 @@ func adddynrel(ctxt *ld.Link, s *sym.Symbol, r *sym.Reloc) bool { ...@@ -202,7 +202,8 @@ func adddynrel(ctxt *ld.Link, s *sym.Symbol, r *sym.Reloc) bool {
return true return true
case 256 + objabi.RelocType(elf.R_386_GOT32), 256 + objabi.RelocType(elf.R_386_GOT32X): case objabi.ElfRelocOffset + objabi.RelocType(elf.R_386_GOT32),
objabi.ElfRelocOffset + objabi.RelocType(elf.R_386_GOT32X):
if targ.Type != sym.SDYNIMPORT { if targ.Type != sym.SDYNIMPORT {
// have symbol // have symbol
if r.Off >= 2 && s.P[r.Off-2] == 0x8b { if r.Off >= 2 && s.P[r.Off-2] == 0x8b {
...@@ -233,31 +234,31 @@ func adddynrel(ctxt *ld.Link, s *sym.Symbol, r *sym.Reloc) bool { ...@@ -233,31 +234,31 @@ func adddynrel(ctxt *ld.Link, s *sym.Symbol, r *sym.Reloc) bool {
r.Add += int64(targ.Got()) r.Add += int64(targ.Got())
return true return true
case 256 + objabi.RelocType(elf.R_386_GOTOFF): case objabi.ElfRelocOffset + objabi.RelocType(elf.R_386_GOTOFF):
r.Type = objabi.R_GOTOFF r.Type = objabi.R_GOTOFF
return true return true
case 256 + objabi.RelocType(elf.R_386_GOTPC): case objabi.ElfRelocOffset + objabi.RelocType(elf.R_386_GOTPC):
r.Type = objabi.R_PCREL r.Type = objabi.R_PCREL
r.Sym = ctxt.Syms.Lookup(".got", 0) r.Sym = ctxt.Syms.Lookup(".got", 0)
r.Add += 4 r.Add += 4
return true return true
case 256 + objabi.RelocType(elf.R_386_32): case objabi.ElfRelocOffset + objabi.RelocType(elf.R_386_32):
if targ.Type == sym.SDYNIMPORT { if targ.Type == sym.SDYNIMPORT {
ld.Errorf(s, "unexpected R_386_32 relocation for dynamic symbol %s", targ.Name) ld.Errorf(s, "unexpected R_386_32 relocation for dynamic symbol %s", targ.Name)
} }
r.Type = objabi.R_ADDR r.Type = objabi.R_ADDR
return true return true
case 512 + ld.MACHO_GENERIC_RELOC_VANILLA*2 + 0: case objabi.MachoRelocOffset + ld.MACHO_GENERIC_RELOC_VANILLA*2 + 0:
r.Type = objabi.R_ADDR r.Type = objabi.R_ADDR
if targ.Type == sym.SDYNIMPORT { if targ.Type == sym.SDYNIMPORT {
ld.Errorf(s, "unexpected reloc for dynamic symbol %s", targ.Name) ld.Errorf(s, "unexpected reloc for dynamic symbol %s", targ.Name)
} }
return true return true
case 512 + ld.MACHO_GENERIC_RELOC_VANILLA*2 + 1: case objabi.MachoRelocOffset + ld.MACHO_GENERIC_RELOC_VANILLA*2 + 1:
if targ.Type == sym.SDYNIMPORT { if targ.Type == sym.SDYNIMPORT {
addpltsym(ctxt, targ) addpltsym(ctxt, targ)
r.Sym = ctxt.Syms.Lookup(".plt", 0) r.Sym = ctxt.Syms.Lookup(".plt", 0)
...@@ -269,7 +270,7 @@ func adddynrel(ctxt *ld.Link, s *sym.Symbol, r *sym.Reloc) bool { ...@@ -269,7 +270,7 @@ func adddynrel(ctxt *ld.Link, s *sym.Symbol, r *sym.Reloc) bool {
r.Type = objabi.R_PCREL r.Type = objabi.R_PCREL
return true return true
case 512 + ld.MACHO_FAKE_GOTPCREL: case objabi.MachoRelocOffset + ld.MACHO_FAKE_GOTPCREL:
if targ.Type != sym.SDYNIMPORT { if targ.Type != sym.SDYNIMPORT {
// have symbol // have symbol
// turn MOVL of GOT entry into LEAL of symbol itself // turn MOVL of GOT entry into LEAL of symbol itself
...@@ -342,7 +343,7 @@ func adddynrel(ctxt *ld.Link, s *sym.Symbol, r *sym.Reloc) bool { ...@@ -342,7 +343,7 @@ func adddynrel(ctxt *ld.Link, s *sym.Symbol, r *sym.Reloc) bool {
s.Value = got.Size s.Value = got.Size
got.AddUint32(ctxt.Arch, 0) got.AddUint32(ctxt.Arch, 0)
ctxt.Syms.Lookup(".linkedit.got", 0).AddUint32(ctxt.Arch, uint32(targ.Dynid)) ctxt.Syms.Lookup(".linkedit.got", 0).AddUint32(ctxt.Arch, uint32(targ.Dynid))
r.Type = 256 // ignore during relocsym r.Type = objabi.ElfRelocOffset // ignore during relocsym
return true return true
} }
} }
......
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