diff options
author | kaiw <kaiw@FreeBSD.org> | 2010-07-21 09:20:40 +0000 |
---|---|---|
committer | kaiw <kaiw@FreeBSD.org> | 2010-07-21 09:20:40 +0000 |
commit | fbd45b20c30db99fedc41b36dfb0d325d0c2cec3 (patch) | |
tree | f597cca38e3ebd44f1c22074128a87bd09b49231 | |
parent | d52f6374a8ac2ed4442c862b5c27e12e7921db39 (diff) | |
download | FreeBSD-src-fbd45b20c30db99fedc41b36dfb0d325d0c2cec3.zip FreeBSD-src-fbd45b20c30db99fedc41b36dfb0d325d0c2cec3.tar.gz |
Improve compatibility with other implementations of the ELF(3) API:
when an output file has no program headers, set the 'e_phentsize'
field of the ELF executable header to zero.
Obtained from: elftoolchain
MFC after: 1 month
-rw-r--r-- | lib/libelf/elf_update.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/libelf/elf_update.c b/lib/libelf/elf_update.c index 3c7cb0a..fc5f9a3 100644 --- a/lib/libelf/elf_update.c +++ b/lib/libelf/elf_update.c @@ -422,8 +422,8 @@ _libelf_resync_elf(Elf *e) (E)->e_ident[EI_VERSION] = (V); \ (E)->e_ehsize = _libelf_fsize(ELF_T_EHDR, (EC), (V), \ (size_t) 1); \ - (E)->e_phentsize = _libelf_fsize(ELF_T_PHDR, (EC), (V), \ - (size_t) 1); \ + (E)->e_phentsize = (phnum == 0) ? 0 : _libelf_fsize( \ + ELF_T_PHDR, (EC), (V), (size_t) 1); \ (E)->e_shentsize = _libelf_fsize(ELF_T_SHDR, (EC), (V), \ (size_t) 1); \ } while (0) |