+1999-07-02 Mark Mitchell <mark@codesourcery.com>
+
+ * dwarf2.c (parse_comp_unit): Add ABBREV_LENGTH parameter.
+ (_bfd_dwarf2_find_nearest_line): Add ADDR_SIZE parameter.
+ * elf.c (_bfd_elf_find_nearest_line): Pass it.
+ * elf32-arm.h (elf32_arm_find_nearest_line): Likewise.
+ * elf32-mips.c (ABI_64_P): New macro.
+ (IRIX_COMPAT): We are IRIX6-compatible if ABI_64_P.
+ (_bfd_mips_elf_find_nearest_line): Adjust call to
+ _bfd_dwarf2_find_nearest_line.
+ * libbfd-in.h (_bfd_dwarf2_find_nearest_line): Update prototype.
+ * libbfd.h: Regenerated.
+
1999-07-02 Ian Lance Taylor <ian@zembu.com>
* config.bfd: Add * at the end of i[3456]86-*-unixware.
-/* Parse a DWARF2 compilation unit starting at INFO_PTR. This includes
- the compilation unit header that proceeds the DIE's, but does not
- include the length field that preceeds each compilation unit header.
- END_PTR points one past the end of this comp unit.
+/* Parse a DWARF2 compilation unit starting at INFO_PTR. This
+ includes the compilation unit header that proceeds the DIE's, but
+ does not include the length field that preceeds each compilation
+ unit header. END_PTR points one past the end of this comp unit.
+ If ABBREV_LENGTH is 0, then the length of the abbreviation offset
+ is assumed to be four bytes. Otherwise, it it is the size given.
This routine does not read the whole compilation unit; only enough
to get to the line number information for the compilation unit. */
static struct comp_unit *
-parse_comp_unit (abfd, info_ptr, end_ptr)
+parse_comp_unit (abfd, info_ptr, end_ptr, abbrev_length)
bfd* abfd;
char* info_ptr;
char* end_ptr;
+ unsigned int abbrev_length;
{
struct comp_unit* unit;
version = read_2_bytes (abfd, info_ptr);
info_ptr += 2;
- abbrev_offset = read_4_bytes (abfd, info_ptr);
- info_ptr += 4;
+ BFD_ASSERT (abbrev_length == 0
+ || abbrev_length == 4
+ || abbrev_length == 8);
+ if (abbrev_length == 0 || abbrev_length == 4)
+ abbrev_offset = read_4_bytes (abfd, info_ptr);
+ else if (abbrev_length == 8)
+ abbrev_offset = read_8_bytes (abfd, info_ptr);
+ info_ptr += abbrev_length;
addr_size = read_1_byte (abfd, info_ptr);
info_ptr += 1;
return line_p || func_p;
}
-/* The DWARF2 version of find_nearest line.
- Return true if the line is found without error. */
+/* The DWARF2 version of find_nearest line. Return true if the line
+ is found without error. ADDR_SIZE is the number of bytes in the
+ initial .debug_info length field and in the abbreviation offset.
+ You may use zero to indicate that the default value should be
+ used. */
boolean
_bfd_dwarf2_find_nearest_line (abfd, section, symbols, offset,
- filename_ptr, functionname_ptr, linenumber_ptr)
+ filename_ptr, functionname_ptr,
+ linenumber_ptr,
+ addr_size)
bfd *abfd;
asection *section;
asymbol **symbols;
const char **filename_ptr;
const char **functionname_ptr;
unsigned int *linenumber_ptr;
+ unsigned int addr_size;
{
/* Read each compilation unit from the section .debug_info, and check
to see if it contains the address we are searching for. If yes,
*functionname_ptr = NULL;
*linenumber_ptr = 0;
+ /* The DWARF2 spec says that the initial length field, and the
+ offset of the abbreviation table, should both be 4-byte values.
+ However, some compilers do things differently. */
+ if (addr_size == 0)
+ addr_size = 4;
+ BFD_ASSERT (addr_size == 4 || addr_size == 8);
+
if (! stash)
{
asection *msec;
while (stash->info_ptr < stash->info_ptr_end)
{
struct comp_unit* each;
- unsigned int length;
+ bfd_vma length;
boolean found;
- length = read_4_bytes (abfd, stash->info_ptr);
- stash->info_ptr += 4;
+ if (addr_size == 4)
+ length = read_4_bytes (abfd, stash->info_ptr);
+ else
+ length = read_8_bytes (abfd, stash->info_ptr);
+ stash->info_ptr += addr_size;
if (length > 0)
{
each = parse_comp_unit (abfd, stash->info_ptr,
- stash->info_ptr + length);
+ stash->info_ptr + length,
+ addr_size);
stash->info_ptr += length;
if (each)
#define ABI_N32_P(abfd) \
((elf_elfheader (abfd)->e_flags & EF_MIPS_ABI2) != 0)
+/* Nonzero if ABFD is using the 64-bit ABI. FIXME: This is never
+ true, yet. */
+#define ABI_64_P(abfd) \
+ ((elf_elfheader (abfd)->e_ident[EI_CLASS] == ELFCLASS64) != 0)
+
/* What version of Irix we are trying to be compatible with. FIXME:
At the moment, we never generate "normal" MIPS ELF ABI executables;
we always use some version of Irix. */
#define IRIX_COMPAT(abfd) \
- (ABI_N32_P (abfd) ? ict_irix6 : ict_irix5)
+ ((ABI_N32_P (abfd) || ABI_64_P (abfd)) ? ict_irix6 : ict_irix5)
/* Whether we are trying to be compatible with IRIX at all. */
if (_bfd_dwarf2_find_nearest_line (abfd, section, symbols, offset,
filename_ptr, functionname_ptr,
- line_ptr))
+ line_ptr,
+ ABI_64_P (abfd) ? 8 : 0))
return true;
msec = bfd_get_section_by_name (abfd, ".mdebug");