Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
debugedit: Support String/Line table rewriting for larger/smaller paths.
debugedit --base to --dest rewriting of debug source file paths only supported dest paths that were smaller or equal than the base path (and the size should differ more than 1 character for correct debug lines). All paths were changed "in place". Which could in theory mess up debug str sharing. This rewrite supports base and dest strings of any size (some limitations, see below). This is done by reconstructing the debug_str and debug_line tables and updating the references in the debug_info attributes pointing to these tables. Plus, if necessary (only for ET_REL kernel modules), updating any relocations for the debug_info and debug_line sections. This has the nice benefit of merging any duplicate strings in the debug_str table which might resulting on slightly smaller files. kernel modules are ET_REL files that often contain a lot of duplicate strings. The rewrite uses elfutils (either libebl or libdw) to reconstruct the debug_str table. Since we are changing some section sizes now we cannot just use mmap and rawdata to poke the values, but need to read in and write out the changed sections. This does take a bit more memory because we now also need to keep track of all string/line references. There are still some limitations (already in the original debugedit) not fixed by this rewrite: - DW_AT_comp_dir in .debug_info using DW_FORM_string can not be made larger. We only warn about that now instead of failing. The only producer of DW_FORM_string comp_dirs is binutils gas. It seems simpler to fix gas than to try to support resizing the debug_info section. - A DW_AT_name on a DW_TAG_compile_unit is only rewritten for DW_FORM_strp not for DW_FORM_string. Probably no problem in practice since this wasn't supported originally either. - The debug_line program isn't scanned for DW_LNE_define_file which could in theory define an absolute path that might need rewriting. Again probably not a problem because this wasn't supported before and there are no know producers for this construct. To support the upcoming DWARFv5 in gcc 7 (not on by default), we will need to add support for the new debug_line format and scan the new debug_macro section that can have references to the debug_str table. Signed-off-by: Mark Wielaard <mark@klomp.org>
- Loading branch information