From: Uros Bizjak <ubizjak@gmail.com>
To: "gcc-patches@gcc.gnu.org" <gcc-patches@gcc.gnu.org>
Cc: "gofrontend-dev@googlegroups.com"
<gofrontend-dev@googlegroups.com>, Ian Taylor <iant@golang.org>
Subject: [PATCH, alpha, go]: Introduce applyRelocationsALPHA
Date: Tue, 20 Jun 2017 19:46:00 -0000 [thread overview]
Message-ID: <CAFULd4aazcegkrwbEXXCmbyj5DgPVOrQmjCq96gBhtWS6RLP+g@mail.gmail.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 221 bytes --]
This patch inroduces applyRelocationsALPHA to solve:
FAIL: TestCgoConsistentResults
FAIL: TestCgoPkgConfig
FAIL: TestCgoHandlesWlORIGIN
gotools errors.
Bootstrapped and regression tested on alphaev68-linux-gnu.
Uros.
[-- Attachment #2: g.diff.txt --]
[-- Type: text/plain, Size: 1948 bytes --]
Index: go/debug/elf/file.go
===================================================================
--- go/debug/elf/file.go (revision 249418)
+++ go/debug/elf/file.go (working copy)
@@ -602,6 +602,8 @@
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 @@
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.
next reply other threads:[~2017-06-20 19:46 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-06-20 19:46 Uros Bizjak [this message]
2017-06-21 22:39 ` Ian Lance Taylor
2017-06-22 7:13 ` Uros Bizjak
2017-06-26 22:47 ` Ian Lance Taylor
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAFULd4aazcegkrwbEXXCmbyj5DgPVOrQmjCq96gBhtWS6RLP+g@mail.gmail.com \
--to=ubizjak@gmail.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=gofrontend-dev@googlegroups.com \
--cc=iant@golang.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).