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

Mark Wielaard mjw at redhat.com
Sun Apr 10 13:33:24 PDT 2011


Hi Jan,

On Sun, 2011-04-10 at 21:56 +0200, Jan Kratochvil wrote:
> 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?

I interpreted this as both attributes should be omitted based on the
sentence "If an entity has no associated machine code, none of these
attributes are specified." in "2.17 Code Addresses and Ranges". I have
submitted a patch for GCC to no longer emit them for the CU in that
case: http://gcc.gnu.org/ml/gcc-patches/2011-03/msg02286.html

DWARF section [26] '.debug_info' at offset 0x83d:
 [Offset]
 Compilation unit at offset 0:
 Version: 2, Abbreviation section offset: 0, Address size: 8, Offset size: 4
 [     b]  compile_unit
           producer             (strp) "GNU C 4.7.0 20110407 (experimental)"
           language             (data1) ISO C89 (1)
           comp_dir             (strp) "/home/mark"
           stmt_list            (data4) 0
 [    19]    variable
             name                 (string) "x"
             decl_file            (data1) 1
             decl_line            (data1) 1
             type                 (ref4) [    2d]
             external             (flag) Yes
             location             (block1)               [   0] addr 0x6007f8 <x>
 [    2d]    base_type
             byte_size            (data1) 4
             encoding             (data1) signed (5)
             name                 (string) "int"

Cheers,

Mark




More information about the Dwarf-Discuss mailing list