[Dwarf-Discuss] DW_AT_low_pc/DW_AT_high_pc for empty compilation units

Ron Brender ron.brender@charter.net
Sun Apr 10 20:54:11 GMT 2011


DWARF V4, 2.17, page 37 is rather explicit:

    "If an entity has no associated machine code, none of these
     attributes are specified."

This suggests that the presence of a DW_AT_low_pc/_high_pc pair that 
indicates a zero length range (same low and high values) should be 
considered inappropriate.

OTOH, it seems like an explicit zero length range is a perfectly natural 
extension that has little, if any, potential for being misunderstood by 
a consumer--even it not checked for. Further, there are numerous cases 
in DWARF where an implicit and an explicit representation of the same 
information is allowed and defined to mean the same thing. This would be 
reasonable here.

Finally, the committee has been loath to adopt rules which might require 
a "normal" linkage editor to be able to understand and be able to 
rewrite DWARF sections (adding/removing DIEs and/or attributes, etc) 
related to "simple" linkage optimizations. Yet another reason to not be 
strict about disallowing a DW_AT_low_pc/_high_pc pair that indicates a 
zero length range.

Bottom line: while the current wording does seem to preclude an explicit 
zero length code range, I  would support a change to make it clearly 
allowed, and equivalent to the absence of any code address attribute(s).

Ron

p.s. Whether the _low_pc and _high_pc values are both (absolute) zero or 
the same relocated value should make no difference.

-------------------------------------------
On 4/10/2011 3:56 PM, Jan Kratochvil wrote:
> Hi,
>
> for the 'int x;' compilation unit there exists no code.
>
> echo 'int x;' | cc -c -x c - -g; echo 'main(){}' | cc 1.o -x c -; readelf -wi a.out
> ->
>   <0><b>: Abbrev Number: 1 (DW_TAG_compile_unit)
>      <  c>    DW_AT_producer    : (indirect string, offset: 0x11): GNU C 4.5.1 20100924 (Red Hat 4.5.1-4)	
> [...]
>      <19>    DW_AT_low_pc      : 0x400454	
>      <21>    DW_AT_high_pc     : 0x400454	
>
> Should be DW_AT_low_pc == DW_AT_high_pc as is with GCC or should be both
> attributes omitted at all?
>
> Appendix A states the list of tag-attribute pairs is not binding in any way.
>
> Some my interpretations of DWARF-4 statements can be found in:
> 	[patch] Fix empty PC range psymtab<->symtab discrepancy
> 	http://sourceware.org/ml/gdb-patches/2011-03/msg00739.html
>
>
> There is a related issue with both attributes being 0 by the GNU toolchain for
> functions discarded during linking.  I guess the whole DIE(s) should have been
> also discarded instead as it violates DWARF this way:
>
>   <1><12ff>: Abbrev Number: 58 (DW_TAG_subprogram)
>      <1300>    DW_AT_external    : 1
>      <1301>    DW_AT_name        : (indirect string, offset: 0x381): bus_activation_ref
> [...]
>      <130d>    DW_AT_low_pc      : 0x0
>      <1315>    DW_AT_high_pc     : 0x0
> [...]
>
>
> Thanks,
> Jan
> _______________________________________________
> Dwarf-Discuss mailing list
> Dwarf-Discuss at lists.dwarfstd.org
> http://lists.dwarfstd.org/listinfo.cgi/dwarf-discuss-dwarfstd.org
>
>






More information about the Dwarf-discuss mailing list