[PATCH][gdb] Fix gdb.dwarf2/amd64-entry-value-param.exp with -fPIE/-pie

Tom Tromey tom@tromey.com
Fri Aug 9 18:16:00 GMT 2019

>>>>> "Tom" == Tom de Vries <tdevries@suse.de> writes:

Tom> Fix this by eliminating baseaddr from read_call_site_scope, and handling the
Tom> relocation offset at the use sites in call_site_for_pc and
Tom> call_site_to_target_addr.

I like this approach, since it represents some small progress on the
objfile splitting project.

Tom> +    {
Tom> +      struct obj_section *sec;
Tom> +      sec = find_pc_section (pc);
Tom> +      if (sec != NULL)
Tom> +	{
Tom> +	  struct objfile *objfile = sec->objfile;
Tom> +	  CORE_ADDR baseaddr
Tom> +	    = ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));

Why SECT_OFF_TEXT rather than the section "sec"?

Tom> +	  CORE_ADDR pc_unrelocated
Tom> +	    = gdbarch_adjust_dwarf2_addr (gdbarch, pc - baseaddr);

I am not sure gdbarch_adjust_dwarf2_addr can be used "bidirectionally"
like this.  It is probably fine in practice but I wonder about the
documented contract.

Tom> +	CORE_ADDR baseaddr
Tom> +	  = ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));

I guess this assumes the text section - but then can the call to
find_pc_section give anything else?  Maybe it's just something to
comment and move on.

Tom> -  pc = attr_value_as_address (attr) + baseaddr;
Tom> -  pc = gdbarch_adjust_dwarf2_addr (gdbarch, pc);
Tom> +  pc = attr_value_as_address (attr);

The approach taken elsewhere in dwarf2read.c is to bias, adjust, then

      CORE_ADDR low
	= (gdbarch_adjust_dwarf2_addr (gdbarch, best_lowpc + baseaddr)
	   - baseaddr);

Maybe this would be better here as well, or at least consistent.


More information about the Gdb-patches mailing list