[Dwarf-discuss] rnglists and loclists and their base addresses
David Anderson
davea42@linuxmail.org
Thu Dec 19 23:21:14 GMT 2024
# Overview `.debug_loclists[.dwo]` and `.debug_rnglists[.dwo]`
A view from the consumer side.
Uses of `DW_AT_rnglistx` and `DW_AT_loclistx` and of the other
reated 'x' FORMS is a bit complicated.
The issue is that one must find the correct part
of the target loclists/rnglists section.
We will focus on loclists here, but the
rangelists involve essentially identical
usages. With all the names shown below changed....
## Evaluating `DW_AT_location`
The addition of `DW_FORM_loclistx` in DWARF5
creates new tasks in DWARF readers to find
the applicable location list.
### `DW_AT_location` `DW_FORM_sec_offset`
With this FORM it is like DWARF2 to DWARF4
and the value of the form refers to a `.debug_loclists`
offset table which is local to a specific
set of loclists. The offset table is used by
values of form `DW_FORM_loclistx`
### `DW_AT_location` `DW_FORM_loclistx`
With this FORM we do not know where the
appropriate loclistx is in .debug_loclists.
So we use additional data to find the correct
set of loclists.
The first two here
base address
`.debug_cu_index and .`debug_tu_index.dwo``
could be checked in either order.
### base address
`DW_AT_loclists_base`, if present in the CU DIE,
is the connector. Its value is the global offset,
in `.debug_loclists[.dwo]` of the offset table
of the relavent loclist.
If it is missing something else must be used.
### `.debug_cu_index.dwo` and .`debug_tu_index.dwo`
For `.debug_info.dwo` these can provide the connection.
If the unit_type is `DW_UT_split_compile`
the reader does a lookup in `.debug_cu_index` based
on the compilation unit hash (signature).
If found and
if the `DW_SECT_LOCLISTS` table identifier does not represent an empty
value then we have a global offset into the `.debug_loclists`
section, The global offset is the base
address, equivalent to `DW_AT_loclists_base`.
[sec 7.3.5.3 Page 193]
If the unit_type is `DW_UT_split_type`
we look into `.debug_tu_index.dwo`.
### If Missing Base Address
Gcc, and Clang sometimes fail to emit either
a `DW_AT_loclists_base` or a `DW_cu_index.dwo` section
(with `DW_SECT_LOCLISTS` filled in)
the compiler simply assumes that there is
a base address of first-byte-after-initial-loclists-header
Similarly for rnglists
This is dwarfstd.org issue 240618.2
More information about the Dwarf-discuss
mailing list