This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH 5/9] Gccgo port to s390[x] -- part I

This optional cleanup patch fixes some sloppy programming in the
x86 libgo/go/debug/elf library that had given me a very hard time
to debug and fix when porting the code to s390[x].  See commit
comment for details.

2014-09-05  Dominik Vogt  <>

        * libgo/go/debug/elf/file.go (applyRelocationsAMD64):
        Fix the calculation of some relocations; do not assume that the symbol
        value is always zero.


Dominik ^_^  ^_^


Dominik Vogt
IBM Germany
>From 4fce3090be0efb0160cef859e1df6e06196b24e0 Mon Sep 17 00:00:00 2001
From: Dominik Vogt <>
Date: Fri, 5 Sep 2014 07:30:48 +0100
Subject: [PATCH 5/9] LIBGO: Fix some relocations in libgo/elf for amd64.

Adding sym.Value is not really necessary on amd64 as it's always 0 there.  But
on one hand this may change in the future, breaking this code, and on the other
soemone might copy this code for a different platform where sym.Value is not 0.
 libgo/go/debug/elf/file.go | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libgo/go/debug/elf/file.go b/libgo/go/debug/elf/file.go
index 38269aa..c70c7b3 100644
--- a/libgo/go/debug/elf/file.go
+++ b/libgo/go/debug/elf/file.go
@@ -562,12 +562,12 @@ func (f *File) applyRelocationsAMD64(dst []byte, rels []byte) error {
 			if rela.Off+8 >= uint64(len(dst)) || rela.Addend < 0 {
-			f.ByteOrder.PutUint64(dst[rela.Off:rela.Off+8], uint64(rela.Addend))
+			f.ByteOrder.PutUint64(dst[rela.Off:rela.Off+8], uint64(rela.Addend) + uint64(sym.Value))
 		case R_X86_64_32:
 			if rela.Off+4 >= uint64(len(dst)) || rela.Addend < 0 {
-			f.ByteOrder.PutUint32(dst[rela.Off:rela.Off+4], uint32(rela.Addend))
+			f.ByteOrder.PutUint32(dst[rela.Off:rela.Off+4], uint32(rela.Addend) + uint32(sym.Value))

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]