]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/ld: support 2 byte relocations
authorAustin Clements <austin@google.com>
Tue, 16 Dec 2014 19:12:01 +0000 (14:12 -0500)
committerAustin Clements <austin@google.com>
Wed, 7 Jan 2015 20:35:13 +0000 (20:35 +0000)
ppc64 has a bunch of these.

Change-Id: I3b93ed2bae378322a8dec036b1681e520b56ff53
Reviewed-on: https://go-review.googlesource.com/2003
Reviewed-by: Russ Cox <rsc@golang.org>
Reviewed-by: Minux Ma <minux@golang.org>
src/cmd/ld/data.c
src/cmd/ld/ldelf.c

index 92c6fb57cea0ac261c37af7178f0bf7f8ae6043e..3cf0bbdfe19118fd1f633466c7b9514d2d2d350e 100644 (file)
@@ -132,6 +132,7 @@ relocsym(LSym *s)
 {
        Reloc *r;
        LSym *rs;
+       int16 i16;
        int32 i, off, siz, fl;
        vlong o;
        uchar *cast;
@@ -317,6 +318,14 @@ relocsym(LSym *s)
                        // TODO(rsc): Remove.
                        s->p[off] = (int8)o;
                        break;
+               case 2:
+                       if(o != (int16)o)
+                               diag("relocation address is too big: %#llx", o);
+                       i16 = o;
+                       cast = (uchar*)&i16;
+                       for(i=0; i<2; i++)
+                               s->p[off+i] = cast[inuxi2[i]];
+                       break;
                case 4:
                        if(r->type == R_PCREL || r->type == R_CALL) {
                                if(o != (int32)o)
index 90da4aeb8ffc512def5ba3a18113b80e7660a36a..f289fb38c7d591f0a322886a530a7bc5c69c69d0 100644 (file)
@@ -721,6 +721,8 @@ ldelf(Biobuf *f, char *pkg, int64 len, char *pn)
                                else
                                        diag("invalid rela size %d", rp->siz);
                        }
+                       if(rp->siz == 2)
+                               rp->add = (int16)rp->add;
                        if(rp->siz == 4)
                                rp->add = (int32)rp->add;
                        //print("rel %s %d %d %s %#llx\n", sect->sym->name, rp->type, rp->siz, rp->sym->name, rp->add);