2005-04-03 Fred Fish <fnf@specifixinc.com>
* dwarf2.c (struct dwarf2_debug): Add dwarf_ranges_buffer and
dwarf_ranges_size members.
(struct comp_unit): Add base_address member.
(struct funcinfo): Replace low/high members with an arange.
(arange_add): Replace incoming "unit" parameter with "abfd" and
"first_arange" pointers. Reorganize/rewrite function body.
(decode_line_info): Change arange_add call to pass bfd and arange
pointers.
(lookup_address_in_line_info_table): Use arange list instead of
individual low/high members. Walk function's arange list to find
lowest PC in list, to test for overlapping functions.
(read_debug_ranges): New function, reads the debug_ranges section.
(lookup_address_in_function_table): Use arange list instead of
individual low/high members. Rewrite to find smallest range that
matches.
(read_rangelist): Read a given rangelist from debug_ranges.
(scan_unit_for_functions): Use arange list instead of individual
low/high members. Handle a DW_AT_ranges attribute.
(parse_comp_unit): Use arange list instead of individual low/high
members. Save comp unit base address. Handle a DW_AT_ranges
attribute.
2005-03-29 Fred Fish <fnf@specifixinc.com>
* dwarf2.c (struct comp_unit): Fix typo.
(scan_unit_for_functions): Remove unused local variable "name"
and dead code that set it.
* dwarf2.c (dwarf2_debug): Move info_ptr_unit to ...
(comp_unit): Here.
(read_unsigned_leb128): Removed.
(read_signed_leb128): Removed.
(find_abstract_instance_name): Updated.
(parse_comp_unit): Accept info_ptr_unit.
(_bfd_dwarf2_find_nearest_line): Set info_ptr_unit for each
comp unit and pass it to parse_comp_unit.
* elf-eh-frame.c (read_unsigned_leb128): Moved to ...
(read_signed_leb128): Moved to ...
* libbfd.c: Here.
* libbfd-in.h (read_unsigned_leb128): New prototype.
(read_signed_leb128): Likewise.
* libbfd.h: Regenerated.
* dwarf2.c (_bfd_dwarf2_find_nearest_line): Add output section
vma and output offset to address.
* simple.c (simple_save_output_info): Only set output section
and offset for debug sections, or those not already set up by
the linker.
(bfd_simple_get_relocated_section_contents): Update comment.
ld/testsuite/
* ld-elfvsb/elfvsb.exp: Remove file name from "undefined ref" string.
parameter symbol_table. Optionally use it instead of the symbol
table from the bfd. Save and restore output offsets and output
sections around bfd_get_relocated_section_contents. Fix a memory
leak.
(simple_save_output_info, simple_restore_output_info): New
functions.
* bfd-in2.h: Regenerate.
* dwarf2.c (read_abbrevs): Use
bfd_simple_get_relocated_section_contents instead of
bfd_get_section_contents.
(decode_line_info): Likewise.
(_bfd_dwarf2_find_nearest_line): Likewise. Don't call
find_rela_addend.
(find_rela_addend): Remove.
* elfxx-ia64.c (elfNN_ia64_reloc): Weaken sanity check for
debugging sections.
(elfNN_ia64_hash_table_create): Create the hash table with malloc,
not bfd_zalloc.
unsigned int. Cast RELOC_BASE10, RELOC_BASE13 and RELOC_BASE22 to
unsigned int.
(NAME(aout,final_link)): Cast enum used in assignment.
(aout_link_write_symbols): Cast enums in comparisons, int values to
boolean, enums in assignments to int.
(aout_link_input_section_std): Cast rel->r_index to unsigned int.
(aout_link_input_section_ext): Likewise. Cast enums used in comparisons
with unsigned ints.
(aout_link_reloc_link_order): Cast enum to int in assignment.
* archive.c (_bfd_generic_read_ar_hdr_mag): Cast result of memchr
calls to char *.
* bfd-in.h (bfd_set_section_vma): Cast enum true to unsigned int in
assignment.
* bfd-in2.h (bfd_set_section_vma): Likewise.
* bfd.c (bfd_record_phdr): Cast enums in assignments.
* binary.c (bfd_alloc): Cast enum to long.
* coffgen.c (_bfd_coff_is_local_label_name): Cast return to boolean.
* dwarf2.c (read_abbrevs): Add casts to enum types.
(read_attribute_value): Likewise.
(arange_add): Cast result of bfd_zalloc call.
(comp_unit_contains_address): Return true and false.
(comp_unit_find_nearest_line): Cast return to boolean.
* format.c (bfd_check_format_matches, bfd_set_format): Likewise.
* gen-aout.c: define macro '_' if not defined.
* libbfd.c (bfd_realloc): Cast malloc and realloc to PTR.
(bfd_bwrite): Cast bfd_realloc to bfd_byte *.
(bfd_write_bigendian_4byte_int): Cast return to boolean.
(bfd_seek): Cast bfd_realloc to bfd_byte *.
(bfd_generic_is_local_label_name): Cast return to boolean.
* libcoff.h (_bfd_coff_adjust_symndx): Remove extraneous '\'.
* linker.c (_bfd_link_hash_newfunc): Cast bfd_hash_allocate result to
struct bfd_hash_entry *.
(_bfd_generic_link_hash_newfunc): likewise.
(_bfd_generic_final_link): Cast enum to unsigned int.
* merge.c (sec_merge_emit): Cast return to boolean.
(merge_strings): Add casts to const unsigned char *.
* reloc.c (bfd_get_reloc_code_name): Cast enums in comparison to int.
(bfd_generic_get_relocated_section_content): Cast enum to unsigned int.
* section.c (bfd_section_hash_newfunc): Cast bfd_hash_allocate result to
struct bfd_hash_entry *.
(bfd_set_section_content): Add cast to PTR in comparison.
* simple.c (simple_dummy_warning, simple_dummy_undefined_symbol,
simple_dummy_reloc_overflow, simple_dummy_reloc_dangerous,
simple_dummy_unattached_reloc,
bfd_simple_get_relocated_section_contents): Add K&R declarations and
function definitions.
* srec.c (S3Forced): Initialize to false.
(srec_get_symtab): Cast return value from bfd_alloc to asymbol *.
* stabs.c (_bfd_link_section_stabs): Cast enum to int in comparisons.
(_bfd_discard_section_stabs): Likewise. Also cast return to boolean.
* syms.c (bfd_is_undefined_symclass): Cast return to boolean.
(_bfd_stab_section_find_nearest_line): Cast enum to bfd_byte in
comparisons.
sorted even when given an out-of-order line sequence.
(lookup_address_in_line_info_table): When an exact VMA match is
not found, return line information with the closest VMA.
reloading local sym addend mistakenly removed in 2002-05-01 change.
* dwarf2.c (struct line_head): Make prologue_length a bfd_vma.
(read_abbrevs): Change "offset" param to bfd_vma.
(parse_comp_unit): Change "version" and addr_size to unsigned ints.
Change "abbrev_offset" to bfd_vma.
(read_indirect_string): Use correct conversion chars in error
message format string, cast bfd_vma's to unsigned long.
(read_abbrevs): Likewise.
(read_attribute_value): Likewise.
(decode_line_info): Likewise.
(scan_unit_for_functions): Likewise.
(parse_comp_unit): Likewise.
* dwarf2.c (struct funcinfo): Move up.
(lookup_address_in_function_table): New argument function_ptr.
Set it.
(lookup_address_in_line_table): New argument function. If function
is non-NULL, use it to handle ``addr'' before the first line note of
the function.
(comp_unit_find_nearest_line): Update and swap calls to
lookup_address_in_function_table and lookup_address_in_line_table.
* syms.c (_bfd_stab_section_find_nearest_line): Use the first
N_SLINE encountered if we see an N_FUN before any N_SLINE.
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
(find_rela_addend): New function.
(parse_comp_unit): Call it to find the abbrev offset addend.
(_bfd_dwarf2_find_nearest_line): Initialize and maintain the new
members of dwarf2_debug as debugging information is read.
* dwarf2.c (struct dwarf2_debug): New field dwarf_line_size.
(decode_line_info): Set it. Report error if unit->line_offset is
equal to or larger than it.
as appropriate. Fill in structure initializations. Add variable
initializations. Add casts.
* dwarf1.c (parse_line_table): Change eachLine to unsigned long.
(dwarf1_unit_find_nearest_line): Change i to unsigned long.
* dwarf2.c (struct arange): New type.
(struct comp_unit): Replace LOW and HIGH by member ARANGE.
(arange_add): New function.
(decode_line_info): Keep track of address ranges that a compilation
unit covers.
(comp_unit_contains_address): Return true if address is contained
in _any_ of the address ranges associated with a compilation unit.
(_bfd_dwarf2_find_nearest_line): Call comp_unit_find_nearest_line
on the first comp_unit that contains the address.
* dwarf2.c (struct dwarf2_debug): Add member dwarf_line_buffer.
(decode_line_info): Add variable STASH and initialize it to point
to the per-bfd dwarf2_debug info. Remove static variable
dwarf_line_buffer and use stash->dwarf_line_buffer in its place.
* dwarf2.c (struct line_info): Add member END_SEQUENCE to keep
track of end_sequence markers.
(add_line_info): Add END_SEQUENCE arg.
(decode_line_info): Don't try to infer lo_pc and hi_pc from the
debug-line info---it doesn't work right if a compilation unit
consists of multiple discontiguous code-sequences. It would be
worthwhile to optimize for the common case where a compilation
unit results in a contiguous set of code sequences, but this is
quite tricky to get right for arbitrary DWARF2 files.
(lookup_address_in_line_info_table): Don't use the last line entry
for a compilation unit for anything with an address higher than
this line entry. Also, check for end_sequence markers to
correctly handle discontinuities.
(_bfd_dwarf2_find_nearest_line): When checking previously loaded
compilation units, check all compilation units with each->high==0
just like when reading compilation units.
* dwarf2.c (decode_line_info): Initialize table->files and
table->last_line to NULL to avoid segfaults due to random
values in these members.
(concat_filename): Check for out-of-range file number before
indexing filename table. Segfaults suck.
* dwarf2.c (decode_line_info): Don't truncate address to least
significant 32 bits (breaks 64 bit targets).
(lookup_address_in_function_table): Ditto.
(comp_unit_contains_address): Ditto.
* dwarf2.c (read_abbrevs): Change cast of dwarf_abbrev_buffer
assignment from "unsigned char *" to "char *".
(decode_line_info): Likewise for dwarf_line_buffer assignment.