[ELF] --gdb-index: support --icf={safe,all}
authorFangrui Song <i@maskray.me>
Mon, 19 Oct 2020 23:45:56 +0000 (16:45 -0700)
committerFangrui Song <i@maskray.me>
Tue, 20 Oct 2020 16:35:32 +0000 (09:35 -0700)
commit38b632c16e0fdfd5f5a69bcfd4aecf6f69ea0186
tree2f07259ea67d12d369529478102c1299cf41f6e1
parentcc07fbe37dc82eeb3e6261a4c54f44b22cbb531d
[ELF] --gdb-index: support --icf={safe,all}

The combination has not been tested before. In the case of ICF,
`e.section->getVA(0)` equals the start address of the output section.

This can cause incorrect overlapping with the actual function at the
start of the output section and potentially trigger a GDB internal error
in `dw2_find_pc_sect_compunit_symtab` (presumably because:
if a short address range incorrectly starts at the start address of the
output section, GDB may pick it instead of the correct longer address
range. When mapping an address within the long address range but
out of the scope of the short address range, the routine may find
nothing - while the code asserts that it can find something).

Note that in the case of ICF there may be duplicate address range entries,
but GDB appears to be fine with them.

Reviewed By: grimar

Differential Revision: https://reviews.llvm.org/D89751
lld/ELF/SyntheticSections.cpp
lld/test/ELF/gdb-index-icf.s [new file with mode: 0644]