Follow-up for debugedit 1:5.3-4ubuntu1: the uploaded patch (switching
unconditionally to ELF_C_RDWR_MMAP) makes "debugedit -b/-d" (debug path
rewriting) fail on patchelf'd files, see comment #6. dh_strip doesn't
use -b/-d, so Ubuntu package builds are fine, but find-debuginfo-style
users are affected.
Narrowing the writer switch to build-id-only edits avoids that
regression:
--- a/tools/debugedit.c
+++ b/tools/debugedit.c
@@ -3580,7 +3580,9 @@
if (dest_dir == NULL && (!do_build_id || no_recompute_build_id))
elf = elf_begin (fd, ELF_C_READ, NULL);
else
- elf = elf_begin (fd, ELF_C_RDWR, NULL);
+ /* mmap writer only for build-id-only edits, see elfutils #34468;
+ debug path rewriting (-b/-d) still needs the read/write writer. */
+ elf = elf_begin (fd, dest_dir == NULL ? ELF_C_RDWR_MMAP : ELF_C_RDWR,
NULL);
if (elf == NULL)
{
error (0, 0, "cannot open ELF file: %s", elf_errmsg (-1));
@@ -4079,6 +4081,11 @@
}
/* Now adjust any sizes and offsets for the unallocated sections. */
+ {
+ Elf_Scn *zscn = elf_getscn (elf, 0);
+ if (zscn != NULL)
+ elf_flagshdr (zscn, ELF_C_SET, ELF_F_DIRTY);
+ }
scn = NULL;
while ((scn = elf_nextscn (elf, scn)) != NULL)
{
@@ -4087,6 +4094,8 @@
if (shdr == NULL)
error (1, 0, "Couldn't get shdr: %s", elf_errmsg (-1));
+ elf_flagshdr (scn, ELF_C_SET, ELF_F_DIRTY);
+
/* A bug in elfutils before 0.169 means we have to write out
all section data, even when nothing changed.
https://sourceware.org/bugzilla/show_bug.cgi?id=21199 */
Tested in a stonking container (debugedit 1:5.3-4 + this diff):
* debugedit testsuite: All 58 tests were successful
* patchelf'd .so, --build-id --build-id-seed only: valid, section table
unchanged
* patchelf'd .so, -b/-d with and without --build-id: valid, comp_dir rewritten
(fails with 1:5.3-4ubuntu1)
* fortran-testdrive 0.6.1-1 with the unmodified Ubuntu dh_strip: builds,
libtest-drive-gnu.so.0 valid, dbgsym generated
The -b/-d path keeps the read/write writer, as in 1:5.3-4. That writer
still has the libelf gap bug, but there debugedit repositions the
unallocated sections once a debug section changes size, which avoids the
bad layout (it worked in my tests). Either way, this can be dropped once
libelf is fixed upstream (sourceware #34468).
--
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/2169676
Title:
libelf elf_update(ELF_C_WRITE) with ELF_F_LAYOUT corrupts section
headers when the section header table is not at the end of the file
(patchelf output); breaks debugedit
To manage notifications about this bug go to:
https://bugs.launchpad.net/elfutils/+bug/2169676/+subscriptions
--
ubuntu-bugs mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs