This is the mail archive of the binutils@sourceware.cygnus.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]

Re: patch for bfd/dwarf2.c, support for 16-bit addresses in DWARF-2


Hi Stephane,

: 2000-02-22  Stephane Carrez  <stcarrez@worldnet.fr>
: 
: 	* dwarf2.c (parse_comp_unit): Accept addr_size == 2.
: 	(read_address): Recognize addr_size == 2 for 16-bits targets.

I have a couple of comments on this patch:

:    if (unit->addr_size == 4)
:      {
:        retval = bfd_get_32 (unit->abfd, (bfd_byte *) buf);
: -    } else {
: +    }
: +  else if (unit->addr_size == 8)
: +    {
:        retval = bfd_get_64 (unit->abfd, (bfd_byte *) buf);
:      }
: +  else
: +    {
: +      retval = bfd_get_16 (unit->abfd, (bfd_byte *) buf);
: +    }
:    return retval;
:  }

This would probably be simpler to code as a switch statement, like
this:

  switch (unit->addr_size)
    {
    case 8:
      return bfd_get_64 (unit->abfd, (bfd_byte *) buf);
    case 4:
      return bfd_get_32 (unit->abfd, (bfd_byte *) buf);
    case 2:
      return bfd_get_16 (unit->abfd, (bfd_byte *) buf);
    default:
      abort ();
    }

This also prevents the function from silently doing the wrong thing.

There is code in _bfd_dwarf2_find_nearest_line () that also checks to
see if addr_size is 4 or 8.  Why have you not patched this function
as well ?

Cheers
	Nick


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