summaryrefslogtreecommitdiffstats
path: root/lib/libelf
diff options
context:
space:
mode:
authorkaiw <kaiw@FreeBSD.org>2010-07-21 09:20:40 +0000
committerkaiw <kaiw@FreeBSD.org>2010-07-21 09:20:40 +0000
commitfbd45b20c30db99fedc41b36dfb0d325d0c2cec3 (patch)
treef597cca38e3ebd44f1c22074128a87bd09b49231 /lib/libelf
parentd52f6374a8ac2ed4442c862b5c27e12e7921db39 (diff)
downloadFreeBSD-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
Diffstat (limited to 'lib/libelf')
-rw-r--r--lib/libelf/elf_update.c4
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)
OpenPOWER on IntegriCloud