This is the mail archive of the gdb-patches@sourceware.cygnus.com mailing list for the GDB project.


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

Re: path for gdb/dwarf2read.c, support 16-bit targets in dwarf-2


Hi Andrew,

Andrew Cagney wrote:
> 
> Stephane Carrez wrote:
> >
> > Hi!
> >
> > One part of the patch for dwarf2 correction with 16-bit target has
> > been lost. If you are still not convinced by the fix, have a look
> > at gas/dwarf2dbg.c in out_set_addr() where we obtain the address
> > size in a good way.
> >
> > Can you integrate it?
> 
> FYI,
> 
> My reading of the thread from when this patch was last posted is that it
> wasn't clear that this was a bug and the change was the correct thing to
> do.
> 
For me, it's a bug. The address size specified in dwarf2 is 16 and
because we use arch_size which corresponds to the ELF32/ELF64 size,
gdb stops reading with an error (dwarf2read.c:983):

      if (address_size < address_significant_size)
	{
	  error ("Dwarf Error: bad address size (%ld) in compilation unit header (offset 0x%lx +
11).",
		 (long) cu_header.addr_size,
		 (long) (beg_of_comp_unit - dwarf_info_buffer));


The 'bfd_arch_bits_per_address (bfd)' function was defined for that.
It really returns the size of target address and not the size of ELF
file format.

Here is how we get the address size in GAS (gas/dwarf2dbg.c:307):

  bytes_per_address = bfd_arch_bits_per_address (stdoutput) / 8;

I would expect gdb to do the same. 

> I'm not sure that there is a GDB bug - GDB appears to have been given
> wrong information.
Yes. It is using the wrong information.

> > Is there any reason why s->arch_size isn't 16 in your case?
I can't change 'arch_size' in my port to make it 16. This would mean
defining and using some ELF16.

The arch_size member is filled in bfd/elfcode.h:1530 with the ARCH_SIZE
define. This ARCH_SIZE define is either 32 or 64 and controls the
reading/writing of the ELF sections (header, symbols and so on).

I can't define some ELF16 for two reasons: first because Motorola
spec says to use ELF32, and second because it means that some symbols and
debugging sections would be limited to 64K which I don't want.

So, the best thing is to fix GDB and have it use the good source of info:-)

	Stephane
 
-----------------------------------------------------------------------
         Home                               Office
E-mail: stcarrez@worldnet.fr               Stephane.Carrez@sun.com
WWW:    http://home.worldnet.fr/stcarrez   http://www.sun.com
Mail:   17, rue Foucher Lepelletier        6, avenue Gustave Eiffel
        92130 Issy Les Moulineaux          78182 Saint Quentin en Yvelines
        France

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