This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[RFC PATCH] Synthetize some symbols to improve objdump -d output


Hi!

objdump -d output like:
0000000000400504 <main>:
  400504:       55                      push   %rbp
  400505:       48 89 e5                mov    %rsp,%rbp
  400508:       48 81 ec 00 10 00 00    sub    $0x1000,%rsp
  40050f:       48 8d bd 00 f0 ff ff    lea    0xfffffffffffff000(%rbp),%rdi
  400516:       ba 00 10 00 00          mov    $0x1000,%edx
  40051b:       be 00 e0 ff ff          mov    $0xffffe000,%esi
  400520:       e8 0b ff ff ff          callq  400430 <_init+0x48>
  400525:       48 8d b5 00 f0 ff ff    lea    0xfffffffffffff000(%rbp),%rsi
  40052c:       ba 00 10 00 00          mov    $0x1000,%edx
  400531:       bf 01 00 00 00          mov    $0x1,%edi
  400536:       b8 00 00 00 00          mov    $0x0,%eax
  40053b:       e8 e0 fe ff ff          callq  400420 <_init+0x38>
  400540:       c9                      leaveq
  400541:       c3                      retq
always annoyed me a lot, as one has to look up what the .plt function
at 400430 or 400420 really is.
The following patch synthetizes some symbols in bfd which objdump
can use, so the output then looks like:
0000000000400504 <main>:
  400504:       55                      push   %rbp
  400505:       48 89 e5                mov    %rsp,%rbp
  400508:       48 81 ec 00 10 00 00    sub    $0x1000,%rsp
  40050f:       48 8d bd 00 f0 ff ff    lea    0xfffffffffffff000(%rbp),%rdi
  400516:       ba 00 10 00 00          mov    $0x1000,%edx
  40051b:       be 00 e0 ff ff          mov    $0xffffe000,%esi
  400520:       e8 0b ff ff ff          callq  400430 <memcpy@plt>
  400525:       48 8d b5 00 f0 ff ff    lea    0xfffffffffffff000(%rbp),%rsi
  40052c:       ba 00 10 00 00          mov    $0x1000,%edx
  400531:       bf 01 00 00 00          mov    $0x1,%edi
  400536:       b8 00 00 00 00          mov    $0x0,%eax
  40053b:       e8 e0 fe ff ff          callq  400420 <write@plt>
  400540:       c9                      leaveq
  400541:       c3                      retq
(and the @plt symbols are also shown in .plt disassembly).
Most of the arches should be able to use the generic code,
if they use .got.plt they just need to define elf_backend_plt_entry_size
and elf_backend_reserved_plt_size macros, otherwise they don't need
anything in most cases.  IA-64 will need to define elf_backend_relplt_name,
sparc64 provide its own implementation (as part of PLT is normal PLT like,
the second is .got.plt like).

What do you think?

2004-04-20  Jakub Jelinek  <jakub@redhat.com>

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 create_synthetic_symtab,
	plt_entry_size, reserved_plt_size, relplt_name fields.
	(_bfd_elf_get_synthetic_symtab, _bfd_elf_create_synthetic_symtab):
	New prototypes.
	* elfcode.h (elf_get_synthetic_symtab): Define.
	* elf.c (_bfd_elf_get_synthetic_symtab): New function.
	(_bfd_elf_create_synthetic_symtab): Likewise.
	* elfxx-target.h (bfd_elfNN_get_synthetic_symtab): Define.
	(elf_backend_create_synthetic_symtab): Define.
	(elf_backend_plt_entry_size, elf_backend_reserved_plt_size): Define.
	(elf_backend_relplt_name): Define.
	(elfNN_bed): Add elf_backend_create_synthetic_symtab,
	elf_backend_plt_entry_size, elf_backend_reserved_plt_size
	and elf_backend_relplt_name.
	* bfd-in2.h: Rebuilt.
	* libbfd.h: Rebuilt.
	* elf32-i386.c (elf_backend_plt_entry_size,
	elf_backend_reserved_plt_size): Define.
	* elf64-x86-64.c (elf_backend_plt_entry_size,
	elf_backend_reserved_plt_size): Define.
	* elf32-s390.c (elf_backend_plt_entry_size,
	elf_backend_reserved_plt_size): Define.
	* elf64-s390.c (elf_backend_plt_entry_size,
	elf_backend_reserved_plt_size): 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.

--- bfd/elf-bfd.h.jj	2004-03-30 11:52:36.000000000 +0200
+++ bfd/elf-bfd.h	2004-04-20 13:51:49.968261324 +0200
@@ -902,6 +902,14 @@ struct elf_backend_data
      (bfd *templ, bfd_vma ehdr_vma, bfd_vma *loadbasep,
       int (*target_read_memory) (bfd_vma vma, char *myaddr, int len));
 
+  /* This function implements `bfd_elf_get_synthetic_symtab';
+     see elf.c.  */
+  long (*create_synthetic_symtab) (bfd *, asymbol **dynsyms, asymbol **ret);
+
+  /* Data for the common implementation of the above two functions.  */
+  int plt_entry_size, reserved_plt_size;
+  const char *relplt_name;
+
   /* Alternate EM_xxxx machine codes for this backend.  */
   int elf_machine_alt1;
   int elf_machine_alt2;
@@ -1385,6 +1393,8 @@ extern long _bfd_elf_get_dynamic_symtab_
   (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
@@ -1662,6 +1672,9 @@ extern bfd_boolean bfd_elf_gc_common_fin
 extern bfd_boolean bfd_elf_reloc_symbol_deleted_p
   (bfd_vma, void *);
 
+extern long _bfd_elf_create_synthetic_symtab
+  (bfd *, asymbol **, asymbol **);
+
 /* Exported interface for writing elf corefile notes. */
 extern char *elfcore_write_note
   (bfd *, char *, int *, const char *, int, const void *, int);
--- bfd/bfd-in2.h.jj	2004-04-18 20:23:30.000000000 +0200
+++ bfd/bfd-in2.h	2004-04-20 13:58:40.666658824 +0200
@@ -4004,6 +4004,9 @@ bfd_boolean bfd_set_private_flags (bfd *
 #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))
 
@@ -4385,6 +4388,7 @@ typedef struct bfd_target
 #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
 
@@ -4393,6 +4397,9 @@ typedef struct bfd_target
   /* 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.  */
--- bfd/elf64-x86-64.c.jj	2004-03-30 11:52:40.000000000 +0200
+++ bfd/elf64-x86-64.c	2004-04-20 13:51:49.989257561 +0200
@@ -2764,6 +2764,8 @@ elf64_x86_64_finish_dynamic_sections (bf
 #define elf_backend_want_plt_sym	    0
 #define elf_backend_got_header_size	    (GOT_ENTRY_SIZE*3)
 #define elf_backend_rela_normal		    1
+#define elf_backend_plt_entry_size	    PLT_ENTRY_SIZE
+#define elf_backend_reserved_plt_size	    PLT_ENTRY_SIZE
 
 #define elf_info_to_howto		    elf64_x86_64_info_to_howto
 
--- bfd/elfcode.h.jj	2004-03-30 11:52:40.000000000 +0200
+++ bfd/elfcode.h	2004-04-20 13:51:49.990257382 +0200
@@ -105,6 +105,8 @@ Foundation, Inc., 59 Temple Place - Suit
 #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)
--- bfd/aout-tic30.c.jj	2003-10-22 08:48:47.000000000 +0200
+++ bfd/aout-tic30.c	2004-04-20 13:51:49.992257023 +0200
@@ -1040,6 +1040,10 @@ tic30_aout_set_arch_mach (abfd, arch, ma
 #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
--- bfd/coff-rs6000.c.jj	2003-12-02 15:37:52.000000000 +0100
+++ bfd/coff-rs6000.c	2004-04-20 13:51:49.995256486 +0200
@@ -4201,6 +4201,7 @@ const bfd_target rs6000coff_vec =
     /* 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,
 
@@ -4443,6 +4444,7 @@ const bfd_target pmac_xcoff_vec =
     /* 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/vms.c.jj	2003-11-17 09:21:10.000000000 +0100
+++ bfd/vms.c	2004-04-20 13:51:49.996256307 +0200
@@ -154,6 +154,7 @@ static long vms_get_dynamic_symtab_upper
   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
--- bfd/bfd.c.jj	2004-04-18 20:23:30.000000000 +0200
+++ bfd/bfd.c	2004-04-20 13:51:49.998255948 +0200
@@ -1115,6 +1115,9 @@ DESCRIPTION
 .#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))
 .
--- bfd/targets.c.jj	2004-04-18 20:23:31.000000000 +0200
+++ bfd/targets.c	2004-04-20 13:51:49.999255769 +0200
@@ -450,6 +450,7 @@ BFD_JUMP_TABLE macros.
 .#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
 .
@@ -458,6 +459,9 @@ BFD_JUMP_TABLE macros.
 .  {* 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.  *}
--- bfd/libbfd-in.h.jj	2004-02-18 20:02:12.000000000 +0100
+++ bfd/libbfd-in.h	2004-04-20 13:51:50.000255590 +0200
@@ -378,6 +378,8 @@ extern bfd_boolean _bfd_generic_set_sect
 #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)
--- bfd/libbfd.h.jj	2004-04-18 20:23:31.000000000 +0200
+++ bfd/libbfd.h	2004-04-20 13:51:50.001255411 +0200
@@ -383,6 +383,8 @@ extern bfd_boolean _bfd_generic_set_sect
 #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)
--- bfd/coff64-rs6000.c.jj	2003-12-02 15:37:52.000000000 +0100
+++ bfd/coff64-rs6000.c	2004-04-20 13:51:50.004254873 +0200
@@ -2742,6 +2742,7 @@ const bfd_target rs6000coff64_vec =
     /* 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,
 
@@ -2985,6 +2986,7 @@ const bfd_target aix5coff64_vec =
     /* 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/elf.c.jj	2004-03-30 11:57:41.000000000 +0200
+++ bfd/elf.c	2004-04-20 14:30:11.457804433 +0200
@@ -5673,6 +5673,17 @@ _bfd_elf_canonicalize_dynamic_symtab (bf
   return symcount;
 }
 
+long
+_bfd_elf_get_synthetic_symtab (bfd *abfd, asymbol **dynsyms, asymbol **ret)
+{
+  const struct elf_backend_data *bed = get_elf_backend_data (abfd);
+
+  if (bed->create_synthetic_symtab == NULL)
+    return 0;
+
+  return bed->create_synthetic_symtab (abfd, dynsyms, ret);
+}
+
 /* 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
@@ -7513,3 +7524,84 @@ 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_create_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;
+  bfd_vma addr = 0;
+  size_t size;
+  bfd_boolean want_got_plt = bed->want_got_plt;
+  Elf_Internal_Shdr *hdr;
+  char *names;
+  asection *plt;
+
+  *ret = NULL;                                 
+  if (bed->want_got_plt && bed->plt_entry_size == 0)
+    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;
+  addr = bed->reserved_plt_size;
+
+  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;
+  for (i = 0; i < count; i++, s++, p++)
+    {
+      size_t len;
+      *s = **p->sym_ptr_ptr;
+
+      s->name = names;
+      len = strlen ((*p->sym_ptr_ptr)->name);
+      memcpy (names, (*p->sym_ptr_ptr)->name, len);
+      strcpy (names + len, "@plt");
+      names += len + sizeof ("@plt");
+
+      s->section = plt;
+
+      if (want_got_plt)
+	{
+	  s->value = addr;
+	  addr += bed->plt_entry_size;
+	}
+      else
+	{
+	  s->value = p->address - plt->vma;
+	}
+    }
+
+  return count;
+}
--- bfd/elf32-i386.c.jj	2004-03-30 11:52:37.000000000 +0200
+++ bfd/elf32-i386.c	2004-04-20 14:36:06.864110995 +0200
@@ -3260,6 +3260,8 @@ elf_i386_finish_dynamic_sections (bfd *o
 #define elf_backend_plt_readonly	1
 #define elf_backend_want_plt_sym	0
 #define elf_backend_got_header_size	12
+#define elf_backend_plt_entry_size	PLT_ENTRY_SIZE
+#define elf_backend_reserved_plt_size	PLT_ENTRY_SIZE
 
 /* Support RELA for objdump of prelink objects.  */
 #define elf_info_to_howto		      elf_i386_info_to_howto_rel
--- bfd/aout-target.h.jj	2003-11-17 09:20:50.000000000 +0100
+++ bfd/aout-target.h	2004-04-20 13:51:50.009253977 +0200
@@ -584,6 +584,10 @@ MY_bfd_final_link (abfd, info)
 #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
--- bfd/sunos.c.jj	2003-12-02 15:37:54.000000000 +0100
+++ bfd/sunos.c	2004-04-20 13:51:50.011253619 +0200
@@ -73,6 +73,7 @@ static bfd_boolean sunos_finish_dynamic_
 
 #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
--- bfd/elf32-s390.c.jj	2004-03-30 11:52:38.000000000 +0200
+++ bfd/elf32-s390.c	2004-04-20 14:39:31.574424242 +0200
@@ -3471,6 +3471,8 @@ elf_s390_grok_prstatus (abfd, note)
 #define elf_backend_want_plt_sym	0
 #define elf_backend_got_header_size	12
 #define elf_backend_rela_normal		1
+#define elf_backend_plt_entry_size	PLT_ENTRY_SIZE
+#define elf_backend_reserved_plt_size	PLT_FIRST_ENTRY_SIZE
 
 #define elf_info_to_howto		      elf_s390_info_to_howto
 
--- bfd/elfxx-target.h.jj	2004-03-30 11:52:41.000000000 +0200
+++ bfd/elfxx-target.h	2004-04-20 13:51:50.013253261 +0200
@@ -34,6 +34,8 @@
 
 #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
@@ -443,6 +445,20 @@
 #define elf_backend_rela_normal 0
 #endif
 
+#ifndef elf_backend_create_synthetic_symtab
+#define elf_backend_create_synthetic_symtab \
+  _bfd_elf_create_synthetic_symtab
+#endif
+#ifndef elf_backend_plt_entry_size
+#define elf_backend_plt_entry_size 0
+#endif
+#ifndef elf_backend_reserved_plt_size
+#define elf_backend_reserved_plt_size 0
+#endif
+#ifndef elf_backend_relplt_name
+#define elf_backend_relplt_name NULL
+#endif
+
 #ifndef ELF_MACHINE_ALT1
 #define ELF_MACHINE_ALT1 0
 #endif
@@ -524,6 +540,10 @@ static const struct elf_backend_data elf
   elf_backend_mips_rtype_to_howto,
   elf_backend_ecoff_debug_swap,
   elf_backend_bfd_from_remote_memory,
+  elf_backend_create_synthetic_symtab,
+  elf_backend_plt_entry_size,
+  elf_backend_reserved_plt_size,
+  elf_backend_relplt_name,
   ELF_MACHINE_ALT1,
   ELF_MACHINE_ALT2,
   &elf_backend_size_info,
--- bfd/elf64-s390.c.jj	2004-03-30 11:52:40.000000000 +0200
+++ bfd/elf64-s390.c	2004-04-20 14:40:04.916448917 +0200
@@ -3419,6 +3419,8 @@ const struct elf_size_info s390_elf64_si
 #define elf_backend_want_plt_sym	0
 #define elf_backend_got_header_size	24
 #define elf_backend_rela_normal		1
+#define elf_backend_plt_entry_size	PLT_ENTRY_SIZE
+#define elf_backend_reserved_plt_size	PLT_FIRST_ENTRY_SIZE
 
 #define elf_info_to_howto		elf_s390_info_to_howto
 
--- binutils/objdump.c.jj	2004-03-25 12:38:34.000000000 +0100
+++ binutils/objdump.c	2004-04-20 13:55:56.442090005 +0200
@@ -1,6 +1,6 @@
 /* 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.
@@ -153,6 +153,10 @@ static long sorted_symcount = 0;
 /* 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;
 
@@ -1775,6 +1779,7 @@ disassemble_data (bfd *abfd)
 {
   struct disassemble_info disasm_info;
   struct objdump_disasm_info aux;
+  long i;
 
   print_files = NULL;
   prev_functionname = NULL;
@@ -1782,10 +1787,18 @@ disassemble_data (bfd *abfd)
 
   /* 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);
@@ -2545,8 +2558,14 @@ dump_bfd (bfd *abfd)
 
   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);
@@ -2591,6 +2610,16 @@ dump_bfd (bfd *abfd)
       free (dynsyms);
       dynsyms = NULL;
     }
+
+  if (synthsyms)
+    {
+      free (synthsyms);
+      synthsyms = NULL;
+    }
+
+  symcount = 0;
+  dynsymcount = 0;
+  synthcount = 0;
 }
 
 static void

	Jakub


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]