summaryrefslogtreecommitdiffstats
path: root/libelf/elf32_updatenull.c
Commit message (Collapse)AuthorAgeFilesLines
* libelf: Always update e_version and e_shentsize in elf_update.Mark Wielaard2015-10-051-5/+8
| | | | | | | | | | | When e_version is EV_NONE we should set it to EV_CURRENT like we do for the EI_VERSION and like we set EI_DATA to the correct byte order when set to ELFDATANONE. Likewise we should always set e_shentsize like we do for e_phentsize, not just when ELF_F_LAYOUT isn't set. Add a new elfshphehdr testcase to check the above. Signed-off-by: Mark Wielaard <mjw@redhat.com>
* libelf: If e_phnum is zero then set e_phoff also to zero.Mark Wielaard2015-05-181-0/+8
| | | | | | | | | | If phnum is zero make sure e_phoff is also zero and not some random value. That would cause trouble in update_file. This could happen when ELF_F_LAYOUT is set and the user copied over a ehdr from a bogus ELF file where the phdrs are unreadable. In that case trying to write out the new ELF image would crash trying to follow the bogus e_phdr value. Signed-off-by: Mark Wielaard <mjw@redhat.com>
* libelf: More checking of valid sh_addralign values.Mark Wielaard2015-05-181-0/+5
| | | | | | | | | | | | | | | | | | | | There were two issues with bogus sh_addralign values. First we would only check the individual Elf_Data d_align values were powerof2. But not the actual shdr addralign value. This would cause an issue if the shdr addralign was bigger than all of the individual d_align values. Then we could write out a bogus (! powerof2) shdr addralign value for the sections. Secondly when reading in the Elf_Data we would set the d_align value to the value of the shdr addralign value. But we would not check it was valid at all. In practice there are ELF files with incorrect sh_addralign values (they are a powerof2, but aren't aligned to the ELF image offset). We would try to fix that up in elf_update by adding extra padding. But this could bloat the ELF image a lot for large alignment values. So for too large alignments that are bigger than the offset in the ELF file clamp them to the offset value. This could lead us to reject to write out the data again when the offset was not a powerof2. But this will only happen for aligment values bigger than 64. Which are uncommon in practice. Signed-off-by: Mark Wielaard <mjw@redhat.com>
* libelf: Don't extend ELF file size with SHT_NOBITS sh_offset.Mark Wielaard2015-03-271-4/+3
| | | | | | | | | | | | | | | | | | | | | Don't explicitly extend the file size for SHT_NOBITS sections. Since that could cause a size beyond any actual file content it will cause issues when the underlying ELF file has been mmapped or will extend the file size to increase (writing fill bytes) when not mmapped. The sh_offset value is essentially meaningless for SHT_NOBITS. gabi says that a NOBITS section sh_offset member locates the "conceptual placement" in the file. But it doesn't say this cannot be beyond the enf of the file. When ELF_F_LAYOUT is set we should trust sh_offset as given is what is wanted for an SHT_NOBITS section without extending the file size. https://bugzilla.redhat.com/show_bug.cgi?id=1020842 Buggy binutils ld could generate files where SHT_NOBITS sections have sh_offset outside the file. https://sourceware.org/bugzilla/show_bug.cgi?id=12921 Signed-off-by: Mark Wielaard <mjw@redhat.com>
* libelf: Consider sh_addralign 0 as 1Jan Kratochvil2015-02-071-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently the Koji build for arm32 fails with: extracting debug info from /builddir/build/BUILDROOT/etcd-2.0.0-0.3.rc1.fc22.arm/usr/bin/etcd Failed to write file: invalid section alignment This is because the binary etcd http://people.redhat.com/jkratoch/etcdctl.xz contains: Section Headers: [Nr] Name Type Addr Off Size ES Flg Lk Inf Al [11] .rel.plt REL 00459ee0 449ee0 000088 08 A 13 0 0 ^ which corresponds to golang's code: go/src/cmd/ld/elf.c case EM_X86_64: sh = elfshname(".rela.plt"); sh->addralign = RegSize; default: sh = elfshname(".rel.plt"); <nothing> ELF spec says: Values 0 and 1 mean the section has no alignment constraints. and libelf/elf32_updatenull.c really parses it that way at line 204 ElfW2(LIBELFBITS,Word) sh_align = shdr->sh_addralign ?: 1; but unfortunately the later line being patched no longer does. libelf/ 2015-02-07 Jan Kratochvil <jan.kratochvil@redhat.com> * elf32_updatenull.c (__elfw2(LIBELFBITS,updatenull_wrlock)): Consider sh_addralign 0 as 1. Signed-off-by: Jan Kratochvil <jan.kratochvil@redhat.com>
* Update name, license and contributor policy.Mark Wielaard2012-06-051-40/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Change name from "Red Hat elfutils" to "elfutils". * Update license of standalone tools and test from GPLv2 to GPLv3+. * Change license of libraries from GPLv2+exception to GPLv2/LGPLv3+. * Add Developer Certificate of Origin based contributor policy. top-level: - COPYING: Upgraded from GPLv2 to GPLv3. - CONTRIBUTING, COPYING-GPLv2, COPYING-LGPLv3: New files. - NEWS: Added note about new contribution and license policy. - Makefile.am: Updated to GPLv3, added new files to EXTRA_DIST. - configure.ac: Update to GPLv3, changed AC_INIT name to 'elfutils'. backends, lib, libasm, libcpu, libdw, libdwfl, libebl, libelf: - All files updated to GPLv2/LGPLv3+. Except some very small files (<5 lines) which didn't have any headers at all before, the linker .maps files and the libcpu/defs files which only contain data and libelf/elf.h which comes from glibc and is under LGPLv2+. config: - elfutils.spec.in: Add new License: headers and new %doc files. - Update all license headers to GPLv2/LGPLv3+ for files used by libs. src, tests: - All files updated to GPLv3+. Except for the test bz2 data files, the linker maps and script files and some very small files (<5 lines) that don't have any headers. Signed-off-by: Richard Fontana <rfontana@redhat.com> Signed-off-by: Mark Wielaard <mjw@redhat.com>
* Add elf_getphdrnum, support >65536 phdrs.Roland McGrath2010-01-071-3/+7
|
* Fix commit in updatenull_wrlock wrt to layout resulting from section headerUlrich Drepper2009-01-261-3/+4
| | | | table position and size.
* propagate from branch 'com.redhat.elfutils.roland.pending.libelf-threads' ↵Ulrich Drepper2008-12-041-1/+1
| | | | | | (head fc97c9c202b5d7d7699a3b1d5c53007a2ef37bb1) to branch 'com.redhat.elfutils' (head 67cccb9bfffc1a7fe3d8d355a2d9b6d0e489ff81)
* Fix up bogon and missing log entries from .pmachata.threads branch.Roland McGrath2008-08-251-7/+6
|
* propagate from branch 'com.redhat.elfutils.pmachata.threads' (head ↵Ulrich Drepper2008-08-161-6/+10
| | | | | | 8bd3bc10eb015c96f7bafcc6a22c973620b57dd8) to branch 'com.redhat.elfutils' (head c5a11b6b3329382f1b5ffd0020f0d93c64176f20)
* Lock down libelf and elflint a bit more after import of Roland's changes.Ulrich Drepper2006-12-181-4/+7
|
* propagate from branch 'com.redhat.elfutils' (head ↵Roland McGrath2006-12-171-3/+3
| | | | | | b4944cf70801d9dac056f4f80ef1334e5acb8bdc) to branch 'com.redhat.elfutils.roland.pending' (head e7e402c668fb0670fc5f6b6a522853ae88f32f11)
* merge of 67f3844b544f03a64b3ac896c19f94744923d76aUlrich Drepper2006-07-121-1/+1
| | | | and ba017f6b59b4ad649cf32f4eefdfecca8b31332c
* propagate from branch 'com.redhat.elfutils.roland.pending' (head ↵Ulrich Drepper2006-07-121-1/+1
| | | | | | e5cfdd13aa39dfae16b905fd57ff56ad8a131bb5) to branch 'com.redhat.elfutils' (head 60222fc1981540f15e674b6705fd7a6f628f95a4)
* Adjust for internal_function_def removal.Ulrich Drepper2006-07-121-1/+1
|
* Fix FSF address. No exception for libdwarf.Ulrich Drepper2006-04-041-1/+1
|
* propagate from branch 'com.redhat.elfutils.roland.pending' (head ↵Ulrich Drepper2006-04-041-12/+45
| | | | | | 4f8fc821345feef58624f0aa5b470d4827577d8c) to branch 'com.redhat.elfutils' (head 76e26cb54695fd3b21ee8fb5be3036bd68200633)
* Fix read/write of existing file using mmap and different layout of the ELFUlrich Drepper2006-04-041-2/+12
| | | | file.
* Adjust for monotone.Ulrich Drepper2005-07-261-0/+384