1
0
mirror of https://github.com/golang/go synced 2024-11-18 01:04:48 -07:00

cmd/link: look at the R_AARCH64_RELATIVE relocs to find the gcdata on arm64

Change-Id: I5a1864a27ad917aa65c8e65a133f6cc0a980d05f
Reviewed-on: https://go-review.googlesource.com/13998
Reviewed-by: Russ Cox <rsc@golang.org>
This commit is contained in:
Michael Hudson-Doyle 2015-07-02 11:37:51 +12:00
parent 3a9bc571b0
commit 712ffc0861
3 changed files with 41 additions and 5 deletions

View File

@ -110,6 +110,14 @@ func decodetype_gcprog(s *LSym) []byte {
}
func decodetype_gcprog_shlib(s *LSym) uint64 {
if Thearch.Thechar == '7' {
for _, shlib := range Ctxt.Shlibs {
if shlib.Path == s.File {
return shlib.gcdata_addresses[s]
}
}
return 0
}
return decode_inuxi(s.P[2*int32(Thearch.Ptrsize)+8+1*int32(Thearch.Ptrsize):], Thearch.Ptrsize)
}

View File

@ -1400,6 +1400,7 @@ func ldshlibsyms(shlib string) {
Diag("cannot read symbols from shared library: %s", libpath)
return
}
gcdata_locations := make(map[uint64]*LSym)
for _, elfsym := range syms {
if elf.ST_TYPE(elfsym.Info) == elf.STT_NOTYPE || elf.ST_TYPE(elfsym.Info) == elf.STT_SECTION {
continue
@ -1428,6 +1429,32 @@ func ldshlibsyms(shlib string) {
// the type data.
if strings.HasPrefix(lsym.Name, "type.") && !strings.HasPrefix(lsym.Name, "type..") {
lsym.P = readelfsymboldata(f, &elfsym)
gcdata_locations[elfsym.Value+2*uint64(Thearch.Ptrsize)+8+1*uint64(Thearch.Ptrsize)] = lsym
}
}
}
gcdata_addresses := make(map[*LSym]uint64)
if Thearch.Thechar == '7' {
for _, sect := range f.Sections {
if sect.Type == elf.SHT_RELA {
var rela elf.Rela64
rdr := sect.Open()
for {
err := binary.Read(rdr, f.ByteOrder, &rela)
if err == io.EOF {
break
} else if err != nil {
Diag("reading relocation failed %v", err)
return
}
t := elf.R_AARCH64(rela.Info & 0xffff)
if t != elf.R_AARCH64_RELATIVE {
continue
}
if lsym, ok := gcdata_locations[rela.Off]; ok {
gcdata_addresses[lsym] = uint64(rela.Addend)
}
}
}
}
}
@ -1459,7 +1486,7 @@ func ldshlibsyms(shlib string) {
Ctxt.Etextp = last
}
Ctxt.Shlibs = append(Ctxt.Shlibs, Shlib{Path: libpath, Hash: hash, Deps: deps, File: f})
Ctxt.Shlibs = append(Ctxt.Shlibs, Shlib{Path: libpath, Hash: hash, Deps: deps, File: f, gcdata_addresses: gcdata_addresses})
}
func mywhatsys() {

View File

@ -124,10 +124,11 @@ type Auto struct {
}
type Shlib struct {
Path string
Hash []byte
Deps []string
File *elf.File
Path string
Hash []byte
Deps []string
File *elf.File
gcdata_addresses map[*LSym]uint64
}
type Link struct {