diff options
author | Alex Brainman <alex.brainman@gmail.com> | 2014-10-11 21:34:10 +1100 |
---|---|---|
committer | Alex Brainman <alex.brainman@gmail.com> | 2014-10-11 21:34:10 +1100 |
commit | cc1fecd64d6395d1692b0fc5936353d2e61b9c1c (patch) | |
tree | bbd44191f6f9d4fa4080bd75c7422dd41b28f34d /src | |
parent | a40607efac0d82103032d20bc611d47736546bb7 (diff) | |
download | go-cc1fecd64d6395d1692b0fc5936353d2e61b9c1c.tar.gz |
cmd/ld: correct pe section names if longer then 8 chars
gcc 4.9.1 generates pe sections with names longer then 8 charters.
From IMAGE_SECTION_HEADER definition:
Name
An 8-byte, null-padded UTF-8 string. There is no terminating null character
if the string is exactly eight characters long. For longer names, this
member contains a forward slash (/) followed by an ASCII representation
of a decimal number that is an offset into the string table.
Our current pe object file reader does not read string table when section
names starts with /. Do that, so (issue 8811 example)
c:\go\path\src\isssue8811>go build
# isssue8811
isssue8811/glfw(.text): isssue8811/glfw(/76): not defined
isssue8811/glfw(.text): undefined: isssue8811/glfw(/76)
becomes
c:\go\path\src\isssue8811>go build
# isssue8811
isssue8811/glfw(.text): isssue8811/glfw(.rdata$.refptr._glfwInitialized): not defined
isssue8811/glfw(.text): undefined: isssue8811/glfw(.rdata$.refptr._glfwInitialized)
Small progress to
Update issue 8811
LGTM=iant, jfrederich
R=golang-codereviews, iant, jfrederich
CC=golang-codereviews
https://codereview.appspot.com/154210044
Diffstat (limited to 'src')
-rw-r--r-- | src/cmd/ld/ldpe.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/cmd/ld/ldpe.c b/src/cmd/ld/ldpe.c index 1b0591614..9257c243c 100644 --- a/src/cmd/ld/ldpe.c +++ b/src/cmd/ld/ldpe.c @@ -179,6 +179,15 @@ ldpe(Biobuf *f, char *pkg, int64 len, char *pn) Bseek(f, base+obj->fh.PointerToSymbolTable+sizeof(symbuf)*obj->fh.NumberOfSymbols, 0); if(Bread(f, obj->snames, l) != l) goto bad; + // rewrite section names if they start with / + for(i=0; i < obj->fh.NumberOfSections; i++) { + if(obj->sect[i].name == nil) + continue; + if(obj->sect[i].name[0] != '/') + continue; + l = atoi(obj->sect[i].name + 1); + obj->sect[i].name = (char*)&obj->snames[l]; + } // read symbols obj->pesym = mal(obj->fh.NumberOfSymbols*sizeof obj->pesym[0]); obj->npesym = obj->fh.NumberOfSymbols; |