mirror of
https://github.com/golang/go
synced 2024-11-20 09:34:52 -07:00
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
This commit is contained in:
parent
cb2f6cb05d
commit
78ad19f214
@ -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;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user