diff options
| author | David Anderson <danderson@google.com> | 2011-07-12 17:49:55 -0700 |
|---|---|---|
| committer | Russ Cox <rsc@golang.org> | 2011-07-12 17:49:55 -0700 |
| commit | f1df07bf6a37bc291f293fd5cdfc9203dd22b31f (patch) | |
| tree | 29ace000141082271efae375dd09950bfb9b69bf /src/cmd/5l | |
| parent | 75780f99f4c310877e5343b4e8b2fe01b4b00b51 (diff) | |
| download | go-f1df07bf6a37bc291f293fd5cdfc9203dd22b31f.tar.xz | |
5l, 6l, 8l: Add a PT_LOAD PHDR entry for the PHDR.
Per the TIS ELF spec, if a PHDR entry is present in the
program header table, it must be part of the memory image of
the program. Failure to do this makes elflint complain, and
causes some tools that manipulate ELF to crash.
R=iant, rsc
CC=dave, golang-dev
https://golang.org/cl/4650067
Diffstat (limited to 'src/cmd/5l')
| -rw-r--r-- | src/cmd/5l/asm.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/cmd/5l/asm.c b/src/cmd/5l/asm.c index 2c9e50d00e..28de6255a6 100644 --- a/src/cmd/5l/asm.c +++ b/src/cmd/5l/asm.c @@ -294,6 +294,7 @@ asmb(void) ElfPhdr *ph, *pph; ElfShdr *sh; Section *sect; + int o; if(debug['v']) Bprint(&bso, "%5.2f asmb\n", cputime()); @@ -462,6 +463,17 @@ asmb(void) pph->paddr = INITTEXT - HEADR + pph->off; pph->align = INITRND; + /* + * PHDR must be in a loaded segment. Adjust the text + * segment boundaries downwards to include it. + */ + o = segtext.vaddr - pph->vaddr; + segtext.vaddr -= o; + segtext.len += o; + o = segtext.fileoff - pph->off; + segtext.fileoff -= o; + segtext.filelen += o; + if(!debug['d']) { /* interpreter for dynamic linking */ sh = newElfShdr(elfstr[ElfStrInterp]); |
