Thanks Benjamin for the upstream pointer. I tested the debugedit workaround from comment 3 of the upstream bug (ELF_C_RDWR_MMAP, plus marking section 0 and every section header dirty) on debugedit 1:5.3-4 in a stonking container:
* debugedit builds, and its testsuite passes (58/58). * With the original (Ubuntu delta) dh_strip and no other workaround, fortran-testdrive 0.6.1-1 builds. The patchelf'd libtest-drive-gnu.so.0 is valid, keeps its SONAME, and gets a dbgsym. So it fixes the dh_strip --build-id-seed case for the fortran stack too. * Build-id-only rewrite of the patchelf'd file: the section table stays identical, only the build-id changes. On a normal .so the output is byte-identical to the unpatched debugedit, including with -b/-d. However, it introduces a new failure. Running debugedit with -b/-d (debug path rewriting) on a patchelf'd file now fails: debugedit: Failed to write file: cannot write data to file and leaves the file corrupted (all section headers NULL). The unpatched debugedit handles that case correctly: once a debug section changes size, it repositions the unallocated sections after the last allocated one, which avoids the bad layout. With ELF_C_RDWR_MMAP that path now fails. Mark Wielaard warned about exactly this area in comment 2 of the upstream bug. So: * as a temporary Ubuntu workaround, it fixes what dh_strip does (build-id with a seed, no -b/-d); debhelper's dh_strip never calls debugedit with -b/-d; * but it regresses "debugedit -b/-d" on patchelf'd files, which is what RPM's find-debuginfo and the debugedit-based tools use. If we carry it, it should be limited to the build-id case (e.g. only use ELF_C_RDWR_MMAP when no -b/-d rewrite is requested), or wait for the libelf fix Mark is working on (fill_file equivalent of fill_mmap). Reproducer for the regression (patched debugedit; p.so = any shared library after "patchelf --set-soname longername"): cp p.so m.so; debugedit -b $PWD -d /usr/src/x m.so; readelf -SW m.so -> all NULL, rc=1 same command with debugedit 1:5.3-4 -> fine, comp_dir rewritten ** Bug watch added: Sourceware.org Bugzilla #21199 https://sourceware.org/bugzilla/show_bug.cgi?id=21199 -- 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
