aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@gcc.gnu.org>2017-06-21 22:39:36 +0000
committerIan Lance Taylor <ian@gcc.gnu.org>2017-06-21 22:39:36 +0000
commitfbe457feb7091d5a75374b8eec4695bf13c7819a (patch)
treea0442ebbad6120db14eb2d83374b1304e57b286e
parent36f1a35f6931f67f7daec5aa7803a6475e8087ca (diff)
downloadgcc-fbe457feb7091d5a75374b8eec4695bf13c7819a.zip
gcc-fbe457feb7091d5a75374b8eec4695bf13c7819a.tar.gz
gcc-fbe457feb7091d5a75374b8eec4695bf13c7819a.tar.bz2
debug/elf: handle Alpha relocs
Patch by Uros Bizjak. Reviewed-on: https://go-review.googlesource.com/46391 From-SVN: r249487
-rw-r--r--gcc/go/gofrontend/MERGE2
-rw-r--r--libgo/go/debug/elf/file.go51
2 files changed, 52 insertions, 1 deletions
diff --git a/gcc/go/gofrontend/MERGE b/gcc/go/gofrontend/MERGE
index f6f0c68..96cf627 100644
--- a/gcc/go/gofrontend/MERGE
+++ b/gcc/go/gofrontend/MERGE
@@ -1,4 +1,4 @@
-0b93af68feb0a4135e83dd9e6c11df1563d862a9
+dac4bb4f4ed8e7f2939d45439048dec2f6db14cf
The first line of this file holds the git revision number of the last
merge done from the gofrontend repository.
diff --git a/libgo/go/debug/elf/file.go b/libgo/go/debug/elf/file.go
index 8eeab65..c493f2a 100644
--- a/libgo/go/debug/elf/file.go
+++ b/libgo/go/debug/elf/file.go
@@ -602,6 +602,8 @@ func (f *File) applyRelocations(dst []byte, rels []byte) error {
return f.applyRelocationss390x(dst, rels)
case f.Class == ELFCLASS64 && f.Machine == EM_SPARCV9:
return f.applyRelocationsSPARC64(dst, rels)
+ case f.Class == ELFCLASS64 && f.Machine == EM_ALPHA:
+ return f.applyRelocationsALPHA(dst, rels)
default:
return errors.New("applyRelocations: not implemented")
}
@@ -1049,6 +1051,55 @@ func (f *File) applyRelocationsSPARC64(dst []byte, rels []byte) error {
return nil
}
+func (f *File) applyRelocationsALPHA(dst []byte, rels []byte) error {
+ // 24 is the size of Rela64.
+ if len(rels)%24 != 0 {
+ return errors.New("length of relocation section is not a multiple of 24")
+ }
+
+ symbols, _, err := f.getSymbols(SHT_SYMTAB)
+ if err != nil {
+ return err
+ }
+
+ b := bytes.NewReader(rels)
+ var rela Rela64
+
+ for b.Len() > 0 {
+ binary.Read(b, f.ByteOrder, &rela)
+ symNo := rela.Info >> 32
+ t := R_ALPHA(rela.Info & 0xffff)
+
+ if symNo == 0 || symNo > uint64(len(symbols)) {
+ continue
+ }
+ sym := &symbols[symNo-1]
+ if SymType(sym.Info&0xf) != STT_SECTION {
+ // We don't handle non-section relocations for now.
+ continue
+ }
+
+ // There are relocations, so this must be a normal
+ // object file, and we only look at section symbols,
+ // so we assume that the symbol value is 0.
+
+ switch t {
+ case R_ALPHA_REFQUAD:
+ if rela.Off+8 >= uint64(len(dst)) || rela.Addend < 0 {
+ continue
+ }
+ f.ByteOrder.PutUint64(dst[rela.Off:rela.Off+8], uint64(rela.Addend))
+ case R_ALPHA_REFLONG:
+ if rela.Off+4 >= uint64(len(dst)) || rela.Addend < 0 {
+ continue
+ }
+ f.ByteOrder.PutUint32(dst[rela.Off:rela.Off+4], uint32(rela.Addend))
+ }
+ }
+
+ return nil
+}
+
func (f *File) DWARF() (*dwarf.Data, error) {
// sectionData gets the data for s, checks its size, and
// applies any applicable relations.