[PATCH] debugedit: Update section headers if section headers are not at end of ELF

Mark Wielaard mark@klomp.org
Wed Oct 28 19:05:32 GMT 2026


Hi,

On Mon, 2026-10-26 at 17:44 +0100, Mark Wielaard wrote:
> elfutils libelf elf_update might overwrite the section headers if the
> section headers are in the middle of the file (between sections)
> instead of at the end. So trigger an section layout update, which will
> put the section headers at the end, if we detect the shdrs not being
> at the end.
> 
> https://sourceware.org/bugzilla/show_bug.cgi?id=34468
> 
> 	* tools/debugedit.c (struct DSO): Remove (unused) lastscn
> 	field. Add end_offset field.
> 	(fdopen_dso): Track and set DSO end_offset.
> 	(main): Set need_update if phnum != 0 and e_shoff < end_offset.

I pushed this and would like to do a debugedit 5.4 release tomorrow
with this and all the other fixes that went in since 5.3:

Benjamin Drung (1):
  debugedit: correct spelling mistake of encoding

Mark Wielaard (13):
  tests: check eu-elflint works before testing --check-elf
  debugedit-classify-ar: Break early for found_debug
  debugedit-classify-ar: Close elf after elf_getarhdr fail in
                        classify_ar_elf
  debugedit-classify-ar: Use strtol to parse -m argument
  debugedit-classify-ar: Check while elf_begin loop failed or succeeded
  debugedit: Use ELF_F_PERMISSIVE when using ELF_F_LAYOUT
  debugedit: Add CU sanity check to edit_info
  debugedit: Don't use alloca and sanity check line table dir/file
counts
  debugedit: Add terminator checks for .debug_str and .debug_line_str
  debugedit: Sanity check .debug_str_offsets index
  debugedit: Guard that .debug_abbrev ends in a zero byte
  debugedit: Handle CUs that aren't zero terminated
  debugedit: Update section headers if section headers are not at end
            of ELF

Cheers,

Mark


More information about the Debugedit mailing list