diff options
author | Jakub Jelinek <jakub@redhat.com> | 2004-04-22 14:45:32 +0000 |
---|---|---|
committer | Jakub Jelinek <jakub@redhat.com> | 2004-04-22 14:45:32 +0000 |
commit | 4c45e5c9ceb986f7d84ad09586d3bdf521140083 (patch) | |
tree | a31256112b6e7734a2f48e82d423d5c4133ee5ea /bfd/elf.c | |
parent | d2f7ecac2c3c1058a1d07d19dc095eac7170ff7f (diff) | |
download | gdb-4c45e5c9ceb986f7d84ad09586d3bdf521140083.zip gdb-4c45e5c9ceb986f7d84ad09586d3bdf521140083.tar.gz gdb-4c45e5c9ceb986f7d84ad09586d3bdf521140083.tar.bz2 |
bfd/
* bfd.c (bfd_get_synthetic_symtab): Define.
* targets.c (BFD_JUMP_TABLE_DYNAMIC): Add
NAME##_get_synthetic_symtab.
(struct bfd_target): Add _bfd_get_synthetic_symtab.
* libbfd-in.h (_bfd_nodynamic_get_synthetic_symtab): Define.
* elf-bfd.h (struct elf_backend_data): Add plt_sym_val and
relplt_name fields.
(_bfd_elf_get_synthetic_symtab): New prototype.
* elfcode.h (elf_get_synthetic_symtab): Define.
* elf.c (_bfd_elf_get_synthetic_symtab): New function.
* elfxx-target.h (bfd_elfNN_get_synthetic_symtab): Define.
(elf_backend_plt_sym_val, elf_backend_relplt_name): Define.
(elfNN_bed): Add elf_backend_plt_sym_val and elf_backend_relplt_name.
* bfd-in2.h: Rebuilt.
* libbfd.h: Rebuilt.
* elf32-i386.c (elf_i386_plt_sym_val): New function.
(elf_backend_plt_sym_val): Define.
* elf64-x86-64.c (elf64_x86_64_plt_sym_val): New function.
(elf_backend_plt_sym_val): Define.
* elf32-s390.c (elf_s390_plt_sym_val): New function.
(elf_backend_plt_sym_val): Define.
* elf64-s390.c (elf_s390_plt_sym_val): New function.
(elf_backend_plt_sym_val): Define.
* elf32-sparc (elf32_sparc_plt_sym_val): New function.
(elf_backend_plt_sym_val): Define.
* elf64-sparc.c (sparc64_elf_plt_sym_val): New function.
(elf_backend_plt_sym_val): Define.
* elf32-ppc.c (ppc_elf_plt_sym_val): New function.
(elf_backend_plt_sym_val): Define.
* aout-target.h (MY_get_synthetic_symtab): Define.
* aout-tic30.c (MY_get_synthetic_symtab): Define.
* coff-rs6000.c (rs6000coff_vec): Add
_bfd_nodynamic_get_synthetic_symtab.
(pmac_xcoff_vec): Likewise.
* coff64-rs6000.c (rs6000coff64_vec): Add
_bfd_nodynamic_get_synthetic_symtab.
(aix5coff64_vec): Likewise.
* sunos.c (MY_get_synthetic_symtab): Define.
* vms.c (vms_get_synthetic_symtab): Define.
binutils/
* objdump.c (synthsyms, synthcount): New variables.
(disassemble_data): Use dynsyms for stripped binaries or libraries.
Add synthetized symbols.
(dump_bfd): For disassemble, initialize dynsyms always and
also synthsyms. Free synthsyms and clear {sym,dynsym,synth}count
before returning.
Diffstat (limited to 'bfd/elf.c')
-rw-r--r-- | bfd/elf.c | 76 |
1 files changed, 76 insertions, 0 deletions
@@ -7513,3 +7513,79 @@ bfd_elf_bfd_from_remote_memory return (*get_elf_backend_data (templ)->elf_backend_bfd_from_remote_memory) (templ, ehdr_vma, loadbasep, target_read_memory); } + +long +_bfd_elf_get_synthetic_symtab (bfd *abfd, asymbol **dynsyms, asymbol **ret) +{ + const struct elf_backend_data *bed = get_elf_backend_data (abfd); + asection *relplt; + asymbol *s; + const char *relplt_name; + bfd_boolean (*slurp_relocs) (bfd *, asection *, asymbol **, bfd_boolean); + arelent *p; + long count, i, n; + size_t size; + Elf_Internal_Shdr *hdr; + char *names; + asection *plt; + + *ret = NULL; + if (!bed->plt_sym_val) + return 0; + + relplt_name = bed->relplt_name; + if (relplt_name == NULL) + relplt_name = bed->default_use_rela_p ? ".rela.plt" : ".rel.plt"; + relplt = bfd_get_section_by_name (abfd, relplt_name); + if (relplt == NULL) + return 0; + + hdr = &elf_section_data (relplt)->this_hdr; + if (hdr->sh_link != elf_dynsymtab (abfd) + || (hdr->sh_type != SHT_REL && hdr->sh_type != SHT_RELA)) + return 0; + + plt = bfd_get_section_by_name (abfd, ".plt"); + if (plt == NULL) + return 0; + + slurp_relocs = get_elf_backend_data (abfd)->s->slurp_reloc_table; + if (! (*slurp_relocs) (abfd, relplt, dynsyms, TRUE)) + return -1; + + count = relplt->_raw_size / hdr->sh_entsize; + size = count * sizeof (asymbol); + p = relplt->relocation; + for (i = 0; i < count; i++, s++, p++) + size += strlen ((*p->sym_ptr_ptr)->name) + sizeof ("@plt"); + + s = *ret = bfd_malloc (size); + if (s == NULL) + return -1; + + names = (char *) (s + count); + p = relplt->relocation; + n = 0; + for (i = 0; i < count; i++, s++, p++) + { + size_t len; + bfd_vma addr; + + addr = bed->plt_sym_val (i, plt, p); + if (addr == (bfd_vma) -1) + continue; + + *s = **p->sym_ptr_ptr; + s->section = plt; + s->value = addr - plt->vma; + s->name = names; + len = strlen ((*p->sym_ptr_ptr)->name); + memcpy (names, (*p->sym_ptr_ptr)->name, len); + names += len; + memcpy (names, "@plt", sizeof ("@plt")); + names += sizeof ("@plt"); + ++n; + } + + return n; +} |