This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [RFA] Perform relocations in dwarf2.c


On Thu, Oct 24, 2002 at 02:45:05AM +0200, Michal Ludvig wrote:
> Hi all,
> when running following command:
> $ objdump -S something.o
> on rela-type dwarf2 platforms it didn't show source lines, because 
> _bfd_dwarf2_find_nearest_line() didn't perform relocations of symbols 
> and thus returned wrong results.
> Also there was a problem when parsing .debug_info on 64b paltforms - as 
> far as I have seen, offsets in this section are always 32b (and 
> specification says it as well), regardless whether on 64b or on 32b 
> platform. There was some strange magic in 
> _bfd_dwarf2_find_nearest_line() to find out the right offset size, but 
> it didn't work anyway.
> 
> Can someone approve or comment it, please?

Um, no.

> @@ -1664,6 +1677,18 @@ parse_comp_unit (abfd, stash, unit_lengt
>        return 0;
>      }
>  
> +  if(a->flags & SEC_RELOC)
> +  {
> +    relsize = bfd_get_reloc_upper_bound (abfd, a);
> +    if (relsize > 0)
> +    {
> +  	  relpp = (arelent **) xmalloc (relsize);
> +  	  relcount = bfd_canonicalize_reloc (abfd, a, relpp, syms);
> +  	  if (relcount < 0)
> +  		  return NULL;
> +    }
> +  }
> +
>    amt = sizeof (struct comp_unit);
>    unit = (struct comp_unit*) bfd_zalloc (abfd, amt);
>    unit->abfd = abfd;

First of all, you just appear to slurp the relocations and look for
ones with the right offset, and use their addend.  That only works for
relocations against sections.  PPC, for instance, will have relocations
against symbols.

There's code in bfd/simple.c you can use to relocate a section if
that's what you want.

> @@ -1981,28 +2002,14 @@ _bfd_dwarf2_find_nearest_line (abfd, sec
>      {
>        bfd_vma length;
>        boolean found;
> -      unsigned int offset_size = addr_size;
> -
> -      if (addr_size == 4)
> -	{
> -	  length = read_4_bytes (abfd, stash->info_ptr);
> -	  if (length == 0xffffffff)
> -	    {
> -	      offset_size = 8;
> -	      length = read_8_bytes (abfd, stash->info_ptr + 4);
> -	      stash->info_ptr += 8;
> -	    }
> -	  else if (length == 0)
> -	    {
> -	      /* Handle (non-standard) 64-bit DWARF2 formats.  */
> -	      offset_size = 8;
> -	      length = read_4_bytes (abfd, stash->info_ptr + 4);
> -	      stash->info_ptr += 4;
> -	    }
> -	}
> -      else
> -	length = read_8_bytes (abfd, stash->info_ptr);
> -      stash->info_ptr += addr_size;
> +      /* All checked 64b platforms use 32b offsets in .debug_info. 
> +       * 32b platforms use this size as well, of course. Seems to be 
> +       * safe to hardcode it here.
> +       * Checked on x86-64, alpha, ia64, sparc64 -- mludvig */
> +      unsigned int offset_size = 4;
> +      
> +      length = read_4_bytes (abfd, stash->info_ptr);
> +      stash->info_ptr += offset_size;
>  
>        if (length > 0)
>  	{

Come on.  Look at the CVS history for this file; two people have
changed it in the past year.  One branch is for ELF64 and the other is
for some SGI format, I believe.  You shouldn't be casually deleting
code like this if you don't even know what platforms it is for.

The list archives would be glad to tell you.

-- 
Daniel Jacobowitz
MontaVista Software                         Debian GNU/Linux Developer


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]