diff options
author | Ian Lance Taylor <ian@airs.com> | 1996-12-15 19:59:18 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@airs.com> | 1996-12-15 19:59:18 +0000 |
commit | e35765a9a2eaff0df62757f3e6480c8ba5ab8ee8 (patch) | |
tree | 53ee31421fdd884963cf43049adaa55a2b828ba0 /bfd/elf.c | |
parent | d31b72a3144f839485f928bc2ef9dc6b51e6c87e (diff) | |
download | gdb-e35765a9a2eaff0df62757f3e6480c8ba5ab8ee8.zip gdb-e35765a9a2eaff0df62757f3e6480c8ba5ab8ee8.tar.gz gdb-e35765a9a2eaff0df62757f3e6480c8ba5ab8ee8.tar.bz2 |
* elfcode.h (elf_slurp_reloc_table): Add dynamic parameter.
* elf.c (_bfd_elf_canonicalize_reloc): Pass new argument to
slurp_reloc_table.
(_bfd_elf_get_dynamic_reloc_upper_bound): New function.
(_bfd_elf_canonicalize_dynamic_reloc): New function.
* elf-bfd.h (struct elf_size_info): Update declaration of
slurp_reloc_table.
(_bfd_elf_get_dynamic_reloc_upper_bound): Declare.
(_bfd_elf_canonicalize_dynamic_reloc): Declare.
* elfxx-target.h: Use new dynamic reloc routines by default.
* elf64-mips.c (mips_elf64_slurp_reloc_table): Add dynamic
parameter.
Diffstat (limited to 'bfd/elf.c')
-rw-r--r-- | bfd/elf.c | 86 |
1 files changed, 85 insertions, 1 deletions
@@ -868,6 +868,7 @@ bfd_section_from_shdr (abfd, shindex) if (! _bfd_elf_make_section_from_shdr (abfd, hdr, name)) return false; if (hdr->bfd_section != NULL + && hdr->sh_info > 0 && bfd_section_from_shdr (abfd, hdr->sh_info)) { target_sect = bfd_section_from_elf_index (abfd, hdr->sh_info); @@ -3249,7 +3250,10 @@ _bfd_elf_canonicalize_reloc (abfd, section, relptr, symbols) arelent *tblptr; unsigned int i; - if (! get_elf_backend_data (abfd)->s->slurp_reloc_table (abfd, section, symbols)) + if (! get_elf_backend_data (abfd)->s->slurp_reloc_table (abfd, + section, + symbols, + false)) return -1; tblptr = section->relocation; @@ -3281,6 +3285,86 @@ _bfd_elf_canonicalize_dynamic_symtab (abfd, alocation) return get_elf_backend_data (abfd)->s->slurp_symbol_table (abfd, alocation, true); } +/* Return the size required for the dynamic reloc entries. Any + section that was actually installed in the BFD, and has type + SHT_REL or SHT_RELA, and uses the dynamic symbol table, is + considered to be a dynamic reloc section. */ + +long +_bfd_elf_get_dynamic_reloc_upper_bound (abfd) + bfd *abfd; +{ + long ret; + asection *s; + + if (elf_dynsymtab (abfd) == 0) + { + bfd_set_error (bfd_error_invalid_operation); + return -1; + } + + ret = sizeof (arelent *); + for (s = abfd->sections; s != NULL; s = s->next) + if (elf_section_data (s)->this_hdr.sh_link == elf_dynsymtab (abfd) + && (elf_section_data (s)->this_hdr.sh_type == SHT_REL + || elf_section_data (s)->this_hdr.sh_type == SHT_RELA)) + ret += ((s->_raw_size / elf_section_data (s)->this_hdr.sh_entsize) + * sizeof (arelent *)); + + return ret; +} + +/* Canonicalize the dynamic relocation entries. Note that we return + the dynamic relocations as a single block, although they are + actually associated with particular sections; the interface, which + was designed for SunOS style shared libraries, expects that there + is only one set of dynamic relocs. Any section that was actually + installed in the BFD, and has type SHT_REL or SHT_RELA, and uses + the dynamic symbol table, is considered to be a dynamic reloc + section. */ + +long +_bfd_elf_canonicalize_dynamic_reloc (abfd, storage, syms) + bfd *abfd; + arelent **storage; + asymbol **syms; +{ + boolean (*slurp_relocs) PARAMS ((bfd *, asection *, asymbol **, boolean)); + asection *s; + long ret; + + if (elf_dynsymtab (abfd) == 0) + { + bfd_set_error (bfd_error_invalid_operation); + return -1; + } + + slurp_relocs = get_elf_backend_data (abfd)->s->slurp_reloc_table; + ret = 0; + for (s = abfd->sections; s != NULL; s = s->next) + { + if (elf_section_data (s)->this_hdr.sh_link == elf_dynsymtab (abfd) + && (elf_section_data (s)->this_hdr.sh_type == SHT_REL + || elf_section_data (s)->this_hdr.sh_type == SHT_RELA)) + { + arelent *p; + long count, i; + + if (! (*slurp_relocs) (abfd, s, syms, true)) + return -1; + count = s->_raw_size / elf_section_data (s)->this_hdr.sh_entsize; + p = s->relocation; + for (i = 0; i < count; i++) + *storage++ = p++; + ret += count; + } + } + + *storage = NULL; + + return ret; +} + asymbol * _bfd_elf_make_empty_symbol (abfd) bfd *abfd; |