[Dwarf-Discuss] DW_AT_segment and relocation

Ron Brender ron.brender at gmail.com
Thu Sep 26 04:52:13 PDT 2019


Jayvee,

Your question seems quite clear. I hope this response is equally so.

First off, the segment attribute names a register, whose contents is added
to the address value computed by the other address expression. So in a real
sense, a pair of attributes like DW_AT_segment and DW_AT_pc forms "just an
address". Whether that address can vary at runtime is a property of the
underlying hardware together with the applicable compiler technology. Just
because an address expression can describe changing segments does not mean
that capability is actually used, usable or useful.

Second, DW_AT_segment computes a register name, much like other register
location descriptions (DW_OP_reg0). Just as you can't add one to the
register name R0 and expect it to "compute" the register name R1, you can't
do arithmetic on segment names and expect to get a different segment name.
You can select among different segment names at different points in a
program.

Relocations, of course, are not part of DWARF as such. They are a
compilation tool mechanism used to create the ultimate DWARF seen and used
during program execution. DW_AT_segment is "inspired" by the x86 segment
registers of course, although potentially usable for other architectures.
In the case of the x86, I doubt it would ever be meaningful to use a
relocation to change the allocation of segment registers at load time.
Thus, for that architecture, I can't imagine that the operand of the
DW_AT_segment register would ever be anything other than a simple
unrelocated segment register name.

This is not because other expressions (whether affected by relocations or
not) could not be meaningful ever for any architecture but because they are
not useful on the x86 specifically.

Hope that helps,
Ron Brender
DWARF Committee Member

On Thu, Sep 26, 2019 at 6:33 AM Jayvee Neumann via Dwarf-Discuss <
dwarf-discuss at lists.dwarfstd.org> wrote:

> Dear DWARF experts,
>
> I have a question regarding the attribute DW_AT_segment. I do not quite
> understand how to handle it, yet.
> It can appear in a DIE (or its parent) whenever DW_AT_low_pc,
> DW_AT_high_pc, DW_AT_ranges, DW_AT_entry_pc, or a location description that
> evaluates to an Address are used.
> It can contain a location expression itself. So it can depend not only on
> compile-time information but also on run-time information.
>
> Assume, I have an attribute DW_AT_low_pc. If there is no DW_AT_segment,
> this attribute is simply the low_pc as it was determined during
> compile-time. While debugging, this value has to be relocated if the image
> had been relocated. If there is a DW_AT_segment expression is relocation
> still necessary? Evaluating the expression could also incorporate the usage
> of run-time information and relocated addresses (i.e. the DS/CS/SS
> registers).
>
> I hope I was able to articulate my question well, English is not my native
> language.
>
> Kind Regards
> Jayvee
> _______________________________________________
> Dwarf-Discuss mailing list
> Dwarf-Discuss at lists.dwarfstd.org
> http://lists.dwarfstd.org/listinfo.cgi/dwarf-discuss-dwarfstd.org
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.dwarfstd.org/pipermail/dwarf-discuss-dwarfstd.org/attachments/20190926/ad6f71ae/attachment.html>


More information about the Dwarf-Discuss mailing list