I'd like to ask for some clarification relating to DW_AT_entry_pc.  Here
is the relevant section from the DWARF-5 spec for reference:


  2.18 Entry Address
  
  The entry or first executable instruction generated for an entity, if
  applicable, is often the lowest addressed instruction of a contiguous
  range of instructions. In other cases, the entry address needs to be
  specified explicitly.  Any debugging information entry describing an
  entity that has a range of code addresses, which includes compilation
  units, module initialization, subroutines, lexical blocks, try/catch
  blocks, and the like, may have a DW_AT_entry_pc attribute to indicate
  the entry address which is the address of the instruction where
  execution begins within that range of addresses. If the value of the
  DW_AT_entry_pc attribute is of class address that address is the entry
  address; or, if it is of class constant, the value is an unsigned
  integer offset which, when added to the base address of the function,
  gives the entry address.
  
  If no DW_AT_entry_pc attribute is present, then the entry address is
  assumed to be the same as the base address of the containing scope.

I am slightly confused by two parts of this.  First, this:

  "...if it is of class constant, the value is an unsigned integer
  offset which, when added to the base address of the function, gives
  the entry address."

What does 'of the function' mean in this context?  I wonder if this
possibly means the base address of the DIE which contains the
DW_AT_entry_pc itself?  Or should I be looking up the DIE hierarchy some
specific DIE type?

Next this:

  "If no DW_AT_entry_pc attribute is present, then the entry address is
  assumed to be the same as the base address of the containing scope."

My very literal reading of this is that "containing scope" must be the
DIE which contains the DIE which is missing the DW_AT_entry_pc, i.e. the
parent of the DIE we are currently looking at.  I got there because
DW_AT_entry_pc is missing, so nothing contains it.  Therefore the only
thing that can be contained is the DIE we are currently considering.

However, I suspect this might not be the intended meaning.  My less
literal interpretation is that we should use the base address of the DIE
which is missing the DW_AT_entry_pc.

Any guidance is gratefully received.

Thanks,
Andrew

-- 
Dwarf-discuss mailing list
Dwarf-discuss@lists.dwarfstd.org
https://lists.dwarfstd.org/mailman/listinfo/dwarf-discuss

Reply via email to