* elf-eh-frame.c (struct cie): Add "local_personality". Make
"personality" a union.
(cie_eq): Compare local_personality too. Adjust personality
comparison.
(_bfd_elf_discard_section_eh_frame): Check binding on personality
reloc sym to allow for bad symtab. Use stashed local syms rather
than reading personality local sym. Handle discarded sections.
(cie_compare): Removed.
(cie_eq, cie_hash, cie_compute_hash): New functions.
(_bfd_elf_discard_section_eh_frame): Rewrite not to rely on FDEs
pointing only to last CIE and allow merging of any duplicate CIEs,
not just duplicate consecutive CIEs.
(_bfd_elf_discard_section_eh_frame_hdr): Delete cies hash table.
* elf-bfd.h (struct cie_header, struct cie): Removed.
(struct eh_frame_sec_info): Remove alloced field.
(struct eh_frame_hdr_info): Remove last_cie, last_cie_sec
and last_cie_inf fields. Add cies field.
* ld-elf/eh5.d: New test.
* ld-elf/eh5.s: New file.
* ld-elf/eh5a.s: New file.
* ld-elf/eh5b.s: New file.
* elf-eh-frame.c (skip_cfa_op): Fix handling of DW_CFA_advance_loc.
Handle DW_CFA_{remember,restore}_state, DW_CFA_GNU_window_save,
DW_CFA_val_{offset{,_sf},expression}.
(skip_non_nops): Record number of DW_CFA_set_loc ops.
(_bfd_elf_discard_section_eh_frame): Require skip_non_nops recognizes
all ops. If there are any DW_CFA_set_loc ops and they are pcrel
or going to be pcrel, compute set_loc array.
(_bfd_elf_eh_frame_section_offset): If make_relative, kill relocations
against DW_CFA_set_loc operands.
(_bfd_elf_write_section_eh_frame): Handle DW_CFA_set_loc adjusting.
* ld-elf/eh4.d: New test.
* ld-elf/eh4.s: New file.
* ld-elf/eh4a.s: New file.
(_bfd_elf_eh_frame_address_size): Declare.
* elfxx-target.h (elf_backend_eh_frame_address_size): Define a default.
(elfNN_bed): Initialize elf_backend_eh_frame_address_size.
* elfxx-mips.h (_bfd_mips_elf_eh_frame_address_size): Declare.
(elf_backend_eh_frame_address_size): Define.
* elfxx-mips.c (_bfd_mips_elf_eh_frame_address_size): New function.
* elf-eh-frame.c (_bfd_elf_discard_section_eh_frame): Get the address
size from the new backend hook.
(_bfd_elf_write_section_eh_frame): Likewise.
(_bfd_elf_eh_frame_address_size): New function.
(_bfd_elf_discard_section_eh_frame): Use them to interpret the CFA
instructions. If the amount of padding is known, reduce the size
of the CIE or FDE by that amount.
augmentation_size. Use bfd_signed_vmas for data_align.
* elf-eh-frame.c (read_uleb128, read_sleb128): Delete in favor of...
(read_byte, skip_leb128, read_uleb128, read_sleb128): ...these new
functions. Don't read past the end of the enclosing CIE or FDE.
(skip_bytes): New utility function.
(_bfd_elf_discard_section_eh_frame): Use new functions, adding more
sanity checking.
(_bfd_elf_write_section_eh_frame): Use new functions.
* 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.
add_fde_encoding. Remove need_relative.
* elf-eh-frame.c (extra_augmentation_string_bytes)
(extra_augmentation_data_bytes, size_of_output_cie_fde): New functions.
(_bfd_elf_discard_section_eh_frame): Consider changing the FDE encoding
in cases where the CIE has no existing 'R' augmentation. Use
size_of_output_cie_fde when assigning offsets. Use the final offset
as the new section size.
(_bfd_elf_eh_frame_section_offset): Remove need_relative handling.
Account for any extra augmentation bytes in the returned offset.
(_bfd_elf_write_section_eh_frame): Rework so that the entries are
moved before being modified. Pad growing entries with DW_CFA_nops.
Add 'z' and 'R' augmentations as directed by add_augmentation_size
and add_fde_encoding.
parameter. If called after _bfd_elf_write_section_eh_frame,
don't allow a -2 return unless need_* bit is already set, and
handle offsets adjusted for output_offset.
* elf-bfd.h (_bfd_elf_eh_frame_section_offset): Update prototype.
* elf.c (_bfd_elf_section_offset): Update call.
(struct eh_frame_hdr_info): Add last_cie_inf, remove last_cie_offset.
* elf-eh-frame.c (_bfd_elf_discard_section_eh_frame): Delete code
setting offsets for removed CIEs. Don't set "sec", instead set
cie_inf for FDEs. Keep a pointer to last struct eh_cie_fde for a
CIE in hdr_info. Only set make_relative and make_lsda_relative
for CIEs. Use pointers rather than array indices.
(_bfd_elf_eh_frame_section_offset): Test/set make_relative,
make_lsda_relative, need_* on cie_inf for FDEs.
(_bfd_elf_write_section_eh_frame): Adjust offset and new_offset for
section output_offset. Delete cie_offset, instead use cie_inf
pointer to CIE entry. Use need_relative and need_lsda_relative on
CIE entry for FDEs. Use pointers rather than array indices.
need_lsda_relative.
* elf-eh-frame.c (_bfd_elf_eh_frame_section_offset): Set
need_relative or need_lsda_relative if we are processing an
offset for a reloc on a FDE initial loc or LSDA field
respectively.
(_bfd_elf_write_section_eh_frame): Test need_relative and
need_lsda_relative in place of corresponding make_* field
when deciding to use pc-relative encodings.
* elf-eh-frame.c (_bfd_elf_discard_section_eh_frame): Don't
use the last CIE from a different section.
(_bfd_elf_write_section_eh_frame): Don't pad beyond the raw
size of the output section.
(read_value): Add parameter is_signed, use signed extraction if
the value is signed.
(_bfd_elf_write_section_eh_frame): Pass signed flag of the
encoding to read_value.
(_bfd_elf_discard_section_eh_frame): Don't discard duplicate CIEs
on a relocatable link. Comment typos.
* elf.c (_bfd_elf_link_hash_newfunc): Assign elements of structure
in the order they are declared. Clear elf_hash_value too.
(_bfd_elf_link_hash_table_init): Likewise assign in order. Clear
eh_info and tls_segment.
* elflink.h (elf_link_input_bfd <emit_relocs>): Keep reloc offsets
sorted when discarding relocs by turning them into R_*_NONE.
* libbfd.c (warn_deprecated): Comment spelling.
* po/SRC-POTFILES.in: Regenerate.
* elf-eh-frame.c (_bfd_elf_discard_section_eh_frame): Don't mix
signed and unsigned in comparison.
Approved by: Alan Modra <amodra@bigpond.net.au>
Message-ID: <20021012185224.Y979@bubble.sa.bigpond.net.au>