* 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.
+2004-04-22 Jakub Jelinek <jakub@redhat.com>
+
+ * 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.
+
2004-04-22 Nick Clifton <nickc@redhat.com>
* bfd.c (bfd_archive_filename): Return NULL on NULL input.
#define MY_canonicalize_dynamic_symtab \
_bfd_nodynamic_canonicalize_dynamic_symtab
#endif
+#ifndef MY_get_synthetic_symtab
+#define MY_get_synthetic_symtab \
+ _bfd_nodynamic_get_synthetic_symtab
+#endif
#ifndef MY_get_dynamic_reloc_upper_bound
#define MY_get_dynamic_reloc_upper_bound \
_bfd_nodynamic_get_dynamic_reloc_upper_bound
#define MY_canonicalize_dynamic_symtab \
_bfd_nodynamic_canonicalize_dynamic_symtab
#endif
+#ifndef MY_get_synthetic_symtab
+#define MY_get_synthetic_symtab \
+ _bfd_nodynamic_get_synthetic_symtab
+#endif
#ifndef MY_get_dynamic_reloc_upper_bound
#define MY_get_dynamic_reloc_upper_bound \
_bfd_nodynamic_get_dynamic_reloc_upper_bound
#define bfd_canonicalize_dynamic_symtab(abfd, asymbols) \
BFD_SEND (abfd, _bfd_canonicalize_dynamic_symtab, (abfd, asymbols))
+#define bfd_get_synthetic_symtab(abfd, dynsyms, ret) \
+ BFD_SEND (abfd, _bfd_get_synthetic_symtab, (abfd, dynsyms, ret))
+
#define bfd_get_dynamic_reloc_upper_bound(abfd) \
BFD_SEND (abfd, _bfd_get_dynamic_reloc_upper_bound, (abfd))
#define BFD_JUMP_TABLE_DYNAMIC(NAME) \
NAME##_get_dynamic_symtab_upper_bound, \
NAME##_canonicalize_dynamic_symtab, \
+ NAME##_get_synthetic_symtab, \
NAME##_get_dynamic_reloc_upper_bound, \
NAME##_canonicalize_dynamic_reloc
/* Read in the dynamic symbols. */
long (*_bfd_canonicalize_dynamic_symtab)
(bfd *, struct bfd_symbol **);
+ /* Create synthetized symbols. */
+ long (*_bfd_get_synthetic_symtab)
+ (bfd *, struct bfd_symbol **, struct bfd_symbol **);
/* Get the amount of memory required to hold the dynamic relocs. */
long (*_bfd_get_dynamic_reloc_upper_bound) (bfd *);
/* Read in the dynamic relocs. */
.#define bfd_canonicalize_dynamic_symtab(abfd, asymbols) \
. BFD_SEND (abfd, _bfd_canonicalize_dynamic_symtab, (abfd, asymbols))
.
+.#define bfd_get_synthetic_symtab(abfd, dynsyms, ret) \
+. BFD_SEND (abfd, _bfd_get_synthetic_symtab, (abfd, dynsyms, ret))
+.
.#define bfd_get_dynamic_reloc_upper_bound(abfd) \
. BFD_SEND (abfd, _bfd_get_dynamic_reloc_upper_bound, (abfd))
.
/* Dynamic */
_bfd_xcoff_get_dynamic_symtab_upper_bound,
_bfd_xcoff_canonicalize_dynamic_symtab,
+ _bfd_nodynamic_get_synthetic_symtab,
_bfd_xcoff_get_dynamic_reloc_upper_bound,
_bfd_xcoff_canonicalize_dynamic_reloc,
/* Dynamic */
_bfd_xcoff_get_dynamic_symtab_upper_bound,
_bfd_xcoff_canonicalize_dynamic_symtab,
+ _bfd_nodynamic_get_synthetic_symtab,
_bfd_xcoff_get_dynamic_reloc_upper_bound,
_bfd_xcoff_canonicalize_dynamic_reloc,
/* Dynamic */
_bfd_xcoff_get_dynamic_symtab_upper_bound,
_bfd_xcoff_canonicalize_dynamic_symtab,
+ _bfd_nodynamic_get_synthetic_symtab,
_bfd_xcoff_get_dynamic_reloc_upper_bound,
_bfd_xcoff_canonicalize_dynamic_reloc,
/* Dynamic */
_bfd_xcoff_get_dynamic_symtab_upper_bound,
_bfd_xcoff_canonicalize_dynamic_symtab,
+ _bfd_nodynamic_get_synthetic_symtab,
_bfd_xcoff_get_dynamic_reloc_upper_bound,
_bfd_xcoff_canonicalize_dynamic_reloc,
(bfd *templ, bfd_vma ehdr_vma, bfd_vma *loadbasep,
int (*target_read_memory) (bfd_vma vma, char *myaddr, int len));
+ /* This function is used by `_bfd_elf_get_synthetic_symtab';
+ see elf.c. */
+ bfd_vma (*plt_sym_val) (bfd_vma, const asection *, const arelent *);
+
+ /* Name of the PLT relocation section. */
+ const char *relplt_name;
+
/* Alternate EM_xxxx machine codes for this backend. */
int elf_machine_alt1;
int elf_machine_alt2;
(bfd *);
extern long _bfd_elf_canonicalize_dynamic_symtab
(bfd *, asymbol **);
+extern long _bfd_elf_get_synthetic_symtab
+ (bfd *, asymbol **, asymbol **);
extern long _bfd_elf_get_reloc_upper_bound
(bfd *, sec_ptr);
extern long _bfd_elf_canonicalize_reloc
return (*get_elf_backend_data (templ)->elf_backend_bfd_from_remote_memory)
(templ, ehdr_vma, loadbasep, target_read_memory);
}
+\f
+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;
+}
return TRUE;
}
+/* Return address for Ith PLT stub in section PLT, for relocation REL
+ or (bfd_vma) -1 if it should not be included. */
+
+static bfd_vma
+elf_i386_plt_sym_val (bfd_vma i, const asection *plt,
+ const arelent *rel ATTRIBUTE_UNUSED)
+{
+ return plt->vma + (i + 1) * PLT_ENTRY_SIZE;
+}
+
+
#define TARGET_LITTLE_SYM bfd_elf32_i386_vec
#define TARGET_LITTLE_NAME "elf32-i386"
#define ELF_ARCH bfd_arch_i386
#define elf_backend_reloc_type_class elf_i386_reloc_type_class
#define elf_backend_relocate_section elf_i386_relocate_section
#define elf_backend_size_dynamic_sections elf_i386_size_dynamic_sections
+#define elf_backend_plt_sym_val elf_i386_plt_sym_val
#include "elf32-target.h"
apuinfo_list_finish ();
}
+/* Return address for Ith PLT stub in section PLT, for relocation REL
+ or (bfd_vma) -1 if it should not be included. */
+
+static bfd_vma
+ppc_elf_plt_sym_val (bfd_vma i ATTRIBUTE_UNUSED,
+ const asection *plt ATTRIBUTE_UNUSED,
+ const arelent *rel)
+{
+ return rel->address;
+}
+
/* Add extra PPC sections -- Note, for now, make .sbss2 and
.PPC.EMB.sbss0 a normal section, and not a bss section so
that the linker doesn't crater when trying to make more than
#define elf_backend_final_write_processing ppc_elf_final_write_processing
#define elf_backend_write_section ppc_elf_write_section
#define elf_backend_special_sections ppc_elf_special_sections
+#define elf_backend_plt_sym_val ppc_elf_plt_sym_val
#include "elf32-target.h"
raw_size, note->descpos + offset);
}
+/* Return address for Ith PLT stub in section PLT, for relocation REL
+ or (bfd_vma) -1 if it should not be included. */
+
+static bfd_vma
+elf_s390_plt_sym_val (bfd_vma i, const asection *plt,
+ const arelent *rel ATTRIBUTE_UNUSED)
+{
+ return plt->vma + PLT_FIRST_ENTRY_SIZE + i * PLT_ENTRY_SIZE;
+}
+
+
#define TARGET_BIG_SYM bfd_elf32_s390_vec
#define TARGET_BIG_NAME "elf32-s390"
#define ELF_ARCH bfd_arch_s390
#define elf_backend_size_dynamic_sections elf_s390_size_dynamic_sections
#define elf_backend_reloc_type_class elf_s390_reloc_type_class
#define elf_backend_grok_prstatus elf_s390_grok_prstatus
+#define elf_backend_plt_sym_val elf_s390_plt_sym_val
#define bfd_elf32_mkobject elf_s390_mkobject
#define elf_backend_object_p elf_s390_object_p
return reloc_class_normal;
}
}
+
+/* Return address for Ith PLT stub in section PLT, for relocation REL
+ or (bfd_vma) -1 if it should not be included. */
+
+static bfd_vma
+elf32_sparc_plt_sym_val (bfd_vma i ATTRIBUTE_UNUSED,
+ const asection *plt ATTRIBUTE_UNUSED,
+ const arelent *rel)
+{
+ return rel->address;
+}
\f
#define TARGET_BIG_SYM bfd_elf32_sparc_vec
#define TARGET_BIG_NAME "elf32-sparc"
#define elf_backend_gc_sweep_hook elf32_sparc_gc_sweep_hook
#define elf_backend_grok_psinfo elf32_sparc_grok_psinfo
#define elf_backend_reloc_type_class elf32_sparc_reloc_type_class
+#define elf_backend_plt_sym_val elf32_sparc_plt_sym_val
#define elf_backend_can_gc_sections 1
#define elf_backend_can_refcount 1
return TRUE;
}
+/* Return address for Ith PLT stub in section PLT, for relocation REL
+ or (bfd_vma) -1 if it should not be included. */
+
+static bfd_vma
+elf_s390_plt_sym_val (bfd_vma i, const asection *plt,
+ const arelent *rel ATTRIBUTE_UNUSED)
+{
+ return plt->vma + PLT_FIRST_ENTRY_SIZE + i * PLT_ENTRY_SIZE;
+}
+
+
/* Why was the hash table entry size definition changed from
ARCH_SIZE/8 to 4? This breaks the 64 bit dynamic linker and
this is the only reason for the s390_elf64_size_info structure. */
#define elf_backend_relocate_section elf_s390_relocate_section
#define elf_backend_size_dynamic_sections elf_s390_size_dynamic_sections
#define elf_backend_reloc_type_class elf_s390_reloc_type_class
+#define elf_backend_plt_sym_val elf_s390_plt_sym_val
#define bfd_elf64_mkobject elf_s390_mkobject
#define elf_backend_object_p elf_s390_object_p
return bfd_default_set_arch_mach (abfd, bfd_arch_sparc, mach);
}
+/* Return address for Ith PLT stub in section PLT, for relocation REL
+ or (bfd_vma) -1 if it should not be included. */
+
+static bfd_vma
+sparc64_elf_plt_sym_val (bfd_vma i, const asection *plt,
+ const arelent *rel)
+{
+ bfd_vma j;
+
+ i += PLT_HEADER_SIZE / PLT_ENTRY_SIZE;
+ if (i < LARGE_PLT_THRESHOLD)
+ return plt->vma + i * PLT_ENTRY_SIZE;
+
+ j = (i - LARGE_PLT_THRESHOLD) % 160;
+ i -= j;
+ return plt->vma + i * PLT_ENTRY_SIZE + j * 4 * 6;
+}
+
/* Relocations in the 64 bit SPARC ELF ABI are more complex than in
standard ELF, because R_SPARC_OLO10 has secondary addend in
ELF64_R_TYPE_DATA field. This structure is used to redirect the
sparc64_elf_merge_private_bfd_data
#define elf_backend_fake_sections \
sparc64_elf_fake_sections
+#define elf_backend_plt_sym_val \
+ sparc64_elf_plt_sym_val
#define elf_backend_size_info \
sparc64_elf_size_info
return TRUE;
}
+/* Return address for Ith PLT stub in section PLT, for relocation REL
+ or (bfd_vma) -1 if it should not be included. */
+
+static bfd_vma
+elf64_x86_64_plt_sym_val (bfd_vma i, const asection *plt,
+ const arelent *rel ATTRIBUTE_UNUSED)
+{
+ return plt->vma + (i + 1) * PLT_ENTRY_SIZE;
+}
#define TARGET_LITTLE_SYM bfd_elf64_x86_64_vec
#define TARGET_LITTLE_NAME "elf64-x86-64"
#define elf_backend_reloc_type_class elf64_x86_64_reloc_type_class
#define elf_backend_relocate_section elf64_x86_64_relocate_section
#define elf_backend_size_dynamic_sections elf64_x86_64_size_dynamic_sections
+#define elf_backend_plt_sym_val elf64_x86_64_plt_sym_val
#define elf_backend_object_p elf64_x86_64_elf_object_p
#define bfd_elf64_mkobject elf64_x86_64_mkobject
#define elf_canonicalize_symtab NAME(bfd_elf,canonicalize_symtab)
#define elf_canonicalize_dynamic_symtab \
NAME(bfd_elf,canonicalize_dynamic_symtab)
+#define elf_get_synthetic_symtab \
+ NAME(bfd_elf,get_synthetic_symtab)
#define elf_make_empty_symbol NAME(bfd_elf,make_empty_symbol)
#define elf_get_symbol_info NAME(bfd_elf,get_symbol_info)
#define elf_get_lineno NAME(bfd_elf,get_lineno)
#define bfd_elfNN_canonicalize_dynamic_symtab \
_bfd_elf_canonicalize_dynamic_symtab
+#define bfd_elfNN_get_synthetic_symtab \
+ _bfd_elf_get_synthetic_symtab
#ifndef bfd_elfNN_canonicalize_reloc
#define bfd_elfNN_canonicalize_reloc _bfd_elf_canonicalize_reloc
#endif
#define elf_backend_rela_normal 0
#endif
+#ifndef elf_backend_plt_sym_val
+#define elf_backend_plt_sym_val NULL
+#endif
+#ifndef elf_backend_relplt_name
+#define elf_backend_relplt_name NULL
+#endif
+
#ifndef ELF_MACHINE_ALT1
#define ELF_MACHINE_ALT1 0
#endif
elf_backend_mips_rtype_to_howto,
elf_backend_ecoff_debug_swap,
elf_backend_bfd_from_remote_memory,
+ elf_backend_plt_sym_val,
+ elf_backend_relplt_name,
ELF_MACHINE_ALT1,
ELF_MACHINE_ALT2,
&elf_backend_size_info,
#define _bfd_nodynamic_get_dynamic_symtab_upper_bound _bfd_n1
#define _bfd_nodynamic_canonicalize_dynamic_symtab \
((long (*) (bfd *, asymbol **)) _bfd_n1)
+#define _bfd_nodynamic_get_synthetic_symtab \
+ ((long (*) (bfd *, asymbol **, asymbol **)) _bfd_n1)
#define _bfd_nodynamic_get_dynamic_reloc_upper_bound _bfd_n1
#define _bfd_nodynamic_canonicalize_dynamic_reloc \
((long (*) (bfd *, arelent **, asymbol **)) _bfd_n1)
#define _bfd_nodynamic_get_dynamic_symtab_upper_bound _bfd_n1
#define _bfd_nodynamic_canonicalize_dynamic_symtab \
((long (*) (bfd *, asymbol **)) _bfd_n1)
+#define _bfd_nodynamic_get_synthetic_symtab \
+ ((long (*) (bfd *, asymbol **, asymbol **)) _bfd_n1)
#define _bfd_nodynamic_get_dynamic_reloc_upper_bound _bfd_n1
#define _bfd_nodynamic_canonicalize_dynamic_reloc \
((long (*) (bfd *, arelent **, asymbol **)) _bfd_n1)
#define MY_get_dynamic_symtab_upper_bound sunos_get_dynamic_symtab_upper_bound
#define MY_canonicalize_dynamic_symtab sunos_canonicalize_dynamic_symtab
+#define MY_get_synthetic_symtab _bfd_nodynamic_get_synthetic_symtab
#define MY_get_dynamic_reloc_upper_bound sunos_get_dynamic_reloc_upper_bound
#define MY_canonicalize_dynamic_reloc sunos_canonicalize_dynamic_reloc
#define MY_bfd_link_hash_table_create sunos_link_hash_table_create
.#define BFD_JUMP_TABLE_DYNAMIC(NAME) \
. NAME##_get_dynamic_symtab_upper_bound, \
. NAME##_canonicalize_dynamic_symtab, \
+. NAME##_get_synthetic_symtab, \
. NAME##_get_dynamic_reloc_upper_bound, \
. NAME##_canonicalize_dynamic_reloc
.
. {* Read in the dynamic symbols. *}
. long (*_bfd_canonicalize_dynamic_symtab)
. (bfd *, struct bfd_symbol **);
+. {* Create synthetized symbols. *}
+. long (*_bfd_get_synthetic_symtab)
+. (bfd *, struct bfd_symbol **, struct bfd_symbol **);
. {* Get the amount of memory required to hold the dynamic relocs. *}
. long (*_bfd_get_dynamic_reloc_upper_bound) (bfd *);
. {* Read in the dynamic relocs. *}
PARAMS ((bfd *abfd));
static long vms_canonicalize_dynamic_symtab
PARAMS ((bfd *abfd, asymbol **symbols));
+#define vms_get_synthetic_symtab _bfd_nodynamic_get_synthetic_symtab
static long vms_get_dynamic_reloc_upper_bound
PARAMS ((bfd *abfd));
static long vms_canonicalize_dynamic_reloc
+2004-04-22 Jakub Jelinek <jakub@redhat.com>
+
+ * 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.
+
2004-04-14 Alan Modra <amodra@bigpond.net.au>
* strings.c (print_strings): Cast file_off to unsigned long in
/* objdump.c -- dump information about an object file.
Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
- 2000, 2001, 2002, 2003
+ 2000, 2001, 2002, 2003, 2004
Free Software Foundation, Inc.
This file is part of GNU Binutils.
/* The dynamic symbol table. */
static asymbol **dynsyms;
+/* The synthetic symbol table. */
+static asymbol *synthsyms;
+static long synthcount = 0;
+
/* Number of symbols in `dynsyms'. */
static long dynsymcount = 0;
{
struct disassemble_info disasm_info;
struct objdump_disasm_info aux;
+ long i;
print_files = NULL;
prev_functionname = NULL;
/* We make a copy of syms to sort. We don't want to sort syms
because that will screw up the relocs. */
- sorted_syms = xmalloc (symcount * sizeof (asymbol *));
- memcpy (sorted_syms, syms, symcount * sizeof (asymbol *));
+ sorted_symcount = symcount ? symcount : dynsymcount;
+ sorted_syms = xmalloc ((sorted_symcount + synthcount) * sizeof (asymbol *));
+ memcpy (sorted_syms, symcount ? syms : dynsyms,
+ sorted_symcount * sizeof (asymbol *));
- sorted_symcount = remove_useless_symbols (sorted_syms, symcount);
+ sorted_symcount = remove_useless_symbols (sorted_syms, sorted_symcount);
+
+ for (i = 0; i < synthcount; ++i)
+ {
+ sorted_syms[sorted_symcount] = synthsyms + i;
+ ++sorted_symcount;
+ }
/* Sort the symbols into section and symbol order. */
qsort (sorted_syms, sorted_symcount, sizeof (asymbol *), compare_symbols);
if (dump_symtab || dump_reloc_info || disassemble || dump_debugging)
syms = slurp_symtab (abfd);
- if (dump_dynamic_symtab || dump_dynamic_reloc_info)
+ if (dump_dynamic_symtab || dump_dynamic_reloc_info
+ || (disassemble && bfd_get_dynamic_symtab_upper_bound (abfd) > 0))
dynsyms = slurp_dynamic_symtab (abfd);
+ if (disassemble && dynsymcount > 0)
+ {
+ synthcount = bfd_get_synthetic_symtab (abfd, dynsyms, &synthsyms);
+ if (synthcount < 0) synthcount = 0;
+ }
if (dump_symtab)
dump_symbols (abfd, FALSE);
free (dynsyms);
dynsyms = NULL;
}
+
+ if (synthsyms)
+ {
+ free (synthsyms);
+ synthsyms = NULL;
+ }
+
+ symcount = 0;
+ dynsymcount = 0;
+ synthcount = 0;
}
static void