diff options
author | Mikkel Krautz <mikkel@krautz.dk> | 2011-10-18 16:31:03 -0400 |
---|---|---|
committer | Russ Cox <rsc@golang.org> | 2011-10-18 16:31:03 -0400 |
commit | 78ad19f214394a1cb1e96d448bacb84011204452 (patch) | |
tree | 90e1c70e9a03ba74757f42397317e075dededc93 | |
parent | cb2f6cb05d205a6b55ac1a4055a66de4178e3d53 (diff) | |
download | go-78ad19f214394a1cb1e96d448bacb84011204452.tar.gz go-78ad19f214394a1cb1e96d448bacb84011204452.zip |
ld: modify macho linkedit segment to enable OS X code signing
Move string table to the end of the __LINKEDIT segment.
This change allows Apple's codesign(1) utility to successfully sign
Go binaries, as long as they don't contain DWARF data (-w flag to
8l/6l). This is because codesign(1) expects the string table to be
the last part of the file.
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/5271050
-rw-r--r-- | src/cmd/ld/macho.c | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/src/cmd/ld/macho.c b/src/cmd/ld/macho.c index efcbe0325b..05638f7254 100644 --- a/src/cmd/ld/macho.c +++ b/src/cmd/ld/macho.c @@ -413,9 +413,9 @@ asmbmacho(void) // must match domacholink below s1 = lookup(".dynsym", 0); - s2 = lookup(".dynstr", 0); - s3 = lookup(".linkedit.plt", 0); - s4 = lookup(".linkedit.got", 0); + s2 = lookup(".linkedit.plt", 0); + s3 = lookup(".linkedit.got", 0); + s4 = lookup(".dynstr", 0); ms = newMachoSeg("__LINKEDIT", 0); ms->vaddr = va+v+rnd(segdata.len, INITRND); @@ -428,8 +428,8 @@ asmbmacho(void) ml = newMachoLoad(2, 4); /* LC_SYMTAB */ ml->data[0] = linkoff; /* symoff */ ml->data[1] = s1->size / (macho64 ? 16 : 12); /* nsyms */ - ml->data[2] = linkoff + s1->size; /* stroff */ - ml->data[3] = s2->size; /* strsize */ + ml->data[2] = linkoff + s1->size + s2->size + s3->size; /* stroff */ + ml->data[3] = s4->size; /* strsize */ ml = newMachoLoad(11, 18); /* LC_DYSYMTAB */ ml->data[0] = 0; /* ilocalsym */ @@ -444,8 +444,8 @@ asmbmacho(void) ml->data[9] = 0; /* nmodtab */ ml->data[10] = 0; /* extrefsymoff */ ml->data[11] = 0; /* nextrefsyms */ - ml->data[12] = linkoff + s1->size + s2->size; /* indirectsymoff */ - ml->data[13] = (s3->size + s4->size) / 4; /* nindirectsyms */ + ml->data[12] = linkoff + s1->size; /* indirectsymoff */ + ml->data[13] = (s2->size + s3->size) / 4; /* nindirectsyms */ ml->data[14] = 0; /* extreloff */ ml->data[15] = 0; /* nextrel */ ml->data[16] = 0; /* locreloff */ @@ -495,12 +495,12 @@ domacholink(void) // write data that will be linkedit section s1 = lookup(".dynsym", 0); relocsym(s1); - s2 = lookup(".dynstr", 0); - s3 = lookup(".linkedit.plt", 0); - s4 = lookup(".linkedit.got", 0); + s2 = lookup(".linkedit.plt", 0); + s3 = lookup(".linkedit.got", 0); + s4 = lookup(".dynstr", 0); - while(s2->size%4) - adduint8(s2, 0); + while(s4->size%4) + adduint8(s4, 0); size = s1->size + s2->size + s3->size + s4->size; |