gdb: Handle multiple base address in debug_ranges data.
It is possible to use multiple base addresses within a single address
range series, within the .debug_ranges section. The following is a
simplified example for 32-bit addresses:
.section ".debug_ranges"
.4byte 0xffffffff
.4byte BASE_1
.4byte START_OFFSET_1
.4byte END_OFFSET_1
.4byte START_OFFSET_2
.4byte END_OFFSET_2
.4byte 0xffffffff
.4byte BASE_2
.4byte START_OFFSET_3
.4byte END_OFFSET_3
.4byte 0
.4byte 0
In this example START/END 1 and 2 are relative to BASE_1, while
START/END 3 are relative to BASE_2.
Currently gdb does not correctly parse this DWARF, resulting in
corrupted address range information. This commit fixes this issue, and
adds a new test to cover this case.
In order to support testing of this feature extensions were made to the
testsuite dwarf assembler, additional functionality was added to the
.debug_line generation function, and a new function for generating the
.debug_ranges section was added.
gdb/ChangeLog:
* dwarf2read.c (dwarf2_ranges_read): Unify and fix base address
reading code.
gdb/testsuite/ChangeLog:
* gdb.dwarf2/dw2-ranges-base.c: New file.
* gdb.dwarf2/dw2-ranges-base.exp: New file.
* lib/dwarf.exp (namespace eval Dwarf): Add new variables to
support additional line table, and debug ranges generation.
(Dwarf::ranges): New function, generate .debug_ranges.
(Dwarf::lines): Support generating simple line table programs.
(Dwarf::assemble): Initialise new namespace variables.