Load .symtab and .strtab sections before .debug_info to deduplicate

PUBLIC records.

For chrome, the symbol file size dropped from 661 MB to 577 MB.
The number of PUBLIC records dropped from 559416 to 91930.

Change-Id: I7f703d619f2acc7c83f002e6f588f6a6569e5c87
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/2916731
Reviewed-by: Lei Zhang <thestig@chromium.org>
This commit is contained in:
Zequan Wu 2021-06-02 13:41:31 -07:00 committed by Lei Zhang
parent a524a1e24b
commit dbbdf05740

View file

@ -702,32 +702,6 @@ bool LoadSymbols(const string& obj_file,
} }
#endif // NO_STABS_SUPPORT #endif // NO_STABS_SUPPORT
// Look for DWARF debugging information, and load it if present.
const Shdr* dwarf_section =
FindElfSectionByName<ElfClass>(".debug_info", SHT_PROGBITS,
sections, names, names_end,
elf_header->e_shnum);
// .debug_info section type is SHT_PROGBITS for mips on pnacl toolchains,
// but MIPS_DWARF for regular gnu toolchains, so both need to be checked
if (elf_header->e_machine == EM_MIPS && !dwarf_section) {
dwarf_section =
FindElfSectionByName<ElfClass>(".debug_info", SHT_MIPS_DWARF,
sections, names, names_end,
elf_header->e_shnum);
}
if (dwarf_section) {
found_debug_info_section = true;
found_usable_info = true;
info->LoadedSection(".debug_info");
if (!LoadDwarf<ElfClass>(obj_file, elf_header, big_endian,
options.handle_inter_cu_refs, module)) {
fprintf(stderr, "%s: \".debug_info\" section found, but failed to load "
"DWARF debugging information\n", obj_file.c_str());
}
}
// See if there are export symbols available. // See if there are export symbols available.
const Shdr* symtab_section = const Shdr* symtab_section =
FindElfSectionByName<ElfClass>(".symtab", SHT_SYMTAB, FindElfSectionByName<ElfClass>(".symtab", SHT_SYMTAB,
@ -785,6 +759,34 @@ bool LoadSymbols(const string& obj_file,
found_usable_info = found_usable_info || result; found_usable_info = found_usable_info || result;
} }
} }
// Only Load .debug_info after loading symbol table to avoid duplicate
// PUBLIC records.
// Look for DWARF debugging information, and load it if present.
const Shdr* dwarf_section =
FindElfSectionByName<ElfClass>(".debug_info", SHT_PROGBITS,
sections, names, names_end,
elf_header->e_shnum);
// .debug_info section type is SHT_PROGBITS for mips on pnacl toolchains,
// but MIPS_DWARF for regular gnu toolchains, so both need to be checked
if (elf_header->e_machine == EM_MIPS && !dwarf_section) {
dwarf_section =
FindElfSectionByName<ElfClass>(".debug_info", SHT_MIPS_DWARF,
sections, names, names_end,
elf_header->e_shnum);
}
if (dwarf_section) {
found_debug_info_section = true;
found_usable_info = true;
info->LoadedSection(".debug_info");
if (!LoadDwarf<ElfClass>(obj_file, elf_header, big_endian,
options.handle_inter_cu_refs, module)) {
fprintf(stderr, "%s: \".debug_info\" section found, but failed to load "
"DWARF debugging information\n", obj_file.c_str());
}
}
} }
if (options.symbol_data != NO_CFI) { if (options.symbol_data != NO_CFI) {