cmd/ld, cmd/5l, cmd/8l: support new 386/amd64 relocations

Backport of golang.org/cl/16529 to release-branch.go1.4.

I wanted to build go 1.4 packages for Xenial so I did this. It's not enough for
1.4.4 but it may as well be included if we ever find a reason to release that,
so I thought I'd send it in.

Change-Id: I907627586e6c7a0580ae447a349c0e3534d64e3d
Reviewed-on: https://go-review.googlesource.com/21598
Reviewed-by: Russ Cox <rsc@golang.org>
This commit is contained in:
Michael Hudson-Doyle 2016-04-06 21:26:59 +12:00 committed by Russ Cox
parent 50eb39bb23
commit f8c06b1f70
4 changed files with 11 additions and 3 deletions

View File

@ -118,6 +118,8 @@ adddynrel(LSym *s, Reloc *r)
return;
case 256 + R_X86_64_GOTPCREL:
case 256 + R_X86_64_GOTPCRELX:
case 256 + R_X86_64_REX_GOTPCRELX:
if(targ->type != SDYNIMPORT) {
// have symbol
if(r->off >= 2 && s->p[r->off-2] == 0x8b) {

View File

@ -115,6 +115,7 @@ adddynrel(LSym *s, Reloc *r)
return;
case 256 + R_386_GOT32:
case 256 + R_386_GOT32X:
if(targ->type != SDYNIMPORT) {
// have symbol
if(r->off >= 2 && s->p[r->off-2] == 0x8b) {

View File

@ -502,8 +502,9 @@ typedef struct {
#define R_X86_64_DTPOFF32 21 /* Offset in TLS block */
#define R_X86_64_GOTTPOFF 22 /* PC relative offset to IE GOT entry */
#define R_X86_64_TPOFF32 23 /* Offset in static TLS block */
#define R_X86_64_COUNT 24 /* Count of defined relocation types. */
#define R_X86_64_GOTPCRELX 41
#define R_X86_64_REX_GOTPCRELX 42
#define R_X86_64_COUNT 26 /* Count of defined relocation types. */
#define R_ALPHA_NONE 0 /* No reloc */
@ -612,8 +613,9 @@ typedef struct {
#define R_386_TLS_DTPMOD32 35 /* GOT entry containing TLS index */
#define R_386_TLS_DTPOFF32 36 /* GOT entry containing TLS offset */
#define R_386_TLS_TPOFF32 37 /* GOT entry of -ve static TLS offset */
#define R_386_GOT32X 43
#define R_386_COUNT 38 /* Count of defined relocation types. */
#define R_386_COUNT 39 /* Count of defined relocation types. */
#define R_PPC_NONE 0 /* No relocation. */
#define R_PPC_ADDR32 1

View File

@ -888,12 +888,15 @@ reltype(char *pn, int elftype, uchar *siz)
case R('6', R_X86_64_PC32):
case R('6', R_X86_64_PLT32):
case R('6', R_X86_64_GOTPCREL):
case R('6', R_X86_64_GOTPCRELX):
case R('6', R_X86_64_REX_GOTPCRELX):
case R('8', R_386_32):
case R('8', R_386_PC32):
case R('8', R_386_GOT32):
case R('8', R_386_PLT32):
case R('8', R_386_GOTOFF):
case R('8', R_386_GOTPC):
case R('8', R_386_GOT32X):
*siz = 4;
break;
case R('6', R_X86_64_64):