diff options
author | kaiw <kaiw@FreeBSD.org> | 2011-05-07 11:04:36 +0000 |
---|---|---|
committer | kaiw <kaiw@FreeBSD.org> | 2011-05-07 11:04:36 +0000 |
commit | f98c5772c97ff15ef39562d77c23cdd904c0a5db (patch) | |
tree | 032e88dcc018db73050ad071b1d733762cb027f4 /lib | |
parent | 1e9a5e20c49a0e2c25a7b2b7cffea79882ebccbf (diff) | |
download | FreeBSD-src-f98c5772c97ff15ef39562d77c23cdd904c0a5db.zip FreeBSD-src-f98c5772c97ff15ef39562d77c23cdd904c0a5db.tar.gz |
For zero-sized sections, set the `d_buf` field of the `Elf_Data`
descriptor returned by `elf_rawdata()` to NULL.
Obtained from: elftoolchain
Diffstat (limited to 'lib')
-rw-r--r-- | lib/libelf/elf_data.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/lib/libelf/elf_data.c b/lib/libelf/elf_data.c index b8c10de..c34c4ad 100644 --- a/lib/libelf/elf_data.c +++ b/lib/libelf/elf_data.c @@ -225,7 +225,8 @@ elf_rawdata(Elf_Scn *s, Elf_Data *d) if ((d = _libelf_allocate_data(s)) == NULL) return (NULL); - d->d_buf = sh_type == SHT_NOBITS ? NULL : e->e_rawfile + sh_offset; + d->d_buf = (sh_type == SHT_NOBITS || sh_size == 0) ? NULL : + e->e_rawfile + sh_offset; d->d_off = 0; d->d_align = sh_align; d->d_size = sh_size; |