--enable-targets=arm breaks disassembler

Andreas Schwab schwab@suse.de
Tue Jan 17 16:39:00 GMT 2006


When configuring binutils with --enable-targets=arm-* objdump is compiled
in a special way (-DDISASSEMBLER_NEEDS_RELOCS) which effects the output on
all targets.  This patch makes that a runtime option.  Tested on
ia64-suse-linux with --enable-targets=arm-linux and with
--target=arm-linux.

2006-01-17  Andreas Schwab  <schwab@suse.de>

binutils/:
	* configure.in: Don't define DISASSEMBLER_NEEDS_RELOCS.
	* configure: Regenerate.
	* objdump.c (struct objdump_disasm_info): Don't check for
	DISASSEMBLER_NEEDS_RELOCS.
	(objdump_print_addr): Likewise.
	(disassemble_bytes): Check disassembler_needs_relocs from
	disassemble_info at run-time instead of DISASSEMBLER_NEEDS_RELOCS
	at compile-time.
	(disassemble_section): Likewise.
	(disassemble_data): Initialize it.

include/:
	* dis-asm.h (struct disassemble_info): Add
	disassembler_needs_relocs.

objdump/:
	* disassemble.c (disassemble_init_for_target): Set
	disassembler_needs_relocs for bfd_arch_arm.

Index: binutils/configure
===================================================================
RCS file: /cvs/src/src/binutils/configure,v
retrieving revision 1.76
diff -u -a -p -r1.76 configure
--- binutils/configure	30 Nov 2005 21:02:04 -0000	1.76
+++ binutils/configure	17 Jan 2006 15:15:34 -0000
@@ -10474,9 +10474,6 @@ do
 	  DLLTOOL_DEFS="$DLLTOOL_DEFS -DDLLTOOL_ARM"
 	  BUILD_WINDRES='$(WINDRES_PROG)$(EXEEXT)'
 	  ;;
-  	arm*-* | xscale-* | strongarm-* | d10v-*)
-	  OBJDUMP_DEFS="-DDISASSEMBLER_NEEDS_RELOCS"
-	  ;;
 	i[3-7]86-*-pe* | i[3-7]86-*-cygwin* | i[3-7]86-*-mingw32** | i[3-7]86-*-netbsdpe*)
   	  BUILD_DLLTOOL='$(DLLTOOL_PROG)$(EXEEXT)'
 	  DLLTOOL_DEFS="$DLLTOOL_DEFS -DDLLTOOL_I386"
Index: binutils/configure.in
===================================================================
RCS file: /cvs/src/src/binutils/configure.in,v
retrieving revision 1.57
diff -u -a -p -r1.57 configure.in
--- binutils/configure.in	30 Nov 2005 21:02:04 -0000	1.57
+++ binutils/configure.in	17 Jan 2006 15:15:34 -0000
@@ -250,9 +250,6 @@ changequote([,])dnl
 	  DLLTOOL_DEFS="$DLLTOOL_DEFS -DDLLTOOL_ARM"
 	  BUILD_WINDRES='$(WINDRES_PROG)$(EXEEXT)'
 	  ;;
-  	arm*-* | xscale-* | strongarm-* | d10v-*)
-	  OBJDUMP_DEFS="-DDISASSEMBLER_NEEDS_RELOCS"
-	  ;;
 changequote(,)dnl
 	i[3-7]86-*-pe* | i[3-7]86-*-cygwin* | i[3-7]86-*-mingw32** | i[3-7]86-*-netbsdpe*)
 changequote([,])dnl
Index: binutils/objdump.c
===================================================================
RCS file: /cvs/src/src/binutils/objdump.c,v
retrieving revision 1.115
diff -u -a -p -r1.115 objdump.c
--- binutils/objdump.c	3 Oct 2005 19:37:44 -0000	1.115
+++ binutils/objdump.c	17 Jan 2006 15:15:35 -0000
@@ -130,9 +130,7 @@ struct objdump_disasm_info
   arelent **         dynrelbuf;
   long               dynrelcount;
   disassembler_ftype disassemble_fn;
-#ifdef DISASSEMBLER_NEEDS_RELOCS
   arelent *          reloc;
-#endif
 };
 
 /* Architecture to disassemble for, or default if NULL.  */
@@ -866,9 +864,7 @@ objdump_print_addr (bfd_vma vma,
 {
   struct objdump_disasm_info *aux;
   asymbol *sym = NULL; /* Initialize to avoid compiler warning.  */
-#ifdef DISASSEMBLER_NEEDS_RELOCS
   bfd_boolean skip_find = FALSE;
-#endif
 
   if (sorted_symcount < 1)
     {
@@ -879,7 +875,6 @@ objdump_print_addr (bfd_vma vma,
 
   aux = (struct objdump_disasm_info *) info->application_data;
 
-#ifdef DISASSEMBLER_NEEDS_RELOCS
   if (aux->reloc != NULL
       && aux->reloc->sym_ptr_ptr != NULL
       && * aux->reloc->sym_ptr_ptr != NULL)
@@ -894,7 +889,6 @@ objdump_print_addr (bfd_vma vma,
     }
 
   if (!skip_find)
-#endif
     sym = find_symbol_for_address (vma, info, NULL);
 
   objdump_print_addr_with_sym (aux->abfd, aux->sec, sym, vma, info,
@@ -1319,12 +1313,10 @@ disassemble_bytes (struct disassemble_in
     {
       bfd_vma z;
       bfd_boolean need_nl = FALSE;
-#ifdef DISASSEMBLER_NEEDS_RELOCS
       int previous_octets;
 
       /* Remember the length of the previous instruction.  */
       previous_octets = octets;
-#endif
       octets = 0;
 
       /* If we see more than SKIP_ZEROES octets of zeroes, we just
@@ -1389,8 +1381,8 @@ disassemble_bytes (struct disassemble_in
 	      info->bytes_per_chunk = 0;
 	      info->flags = 0;
 
-#ifdef DISASSEMBLER_NEEDS_RELOCS
-	      if (*relppp < relppend)
+	      if (info->disassembler_needs_relocs
+		  && *relppp < relppend)
 		{
 		  bfd_signed_vma distance_to_rel;
 
@@ -1420,7 +1412,7 @@ disassemble_bytes (struct disassemble_in
 		  else
 		    aux->reloc = NULL;
 		}
-#endif
+
 	      octets = (*disassemble_fn) (section->vma + addr_offset, info);
 	      info->fprintf_func = (fprintf_ftype) fprintf;
 	      info->stream = stdout;
@@ -1672,10 +1664,7 @@ disassemble_section (bfd *abfd, asection
       rel_offset = 0;
 
       if ((section->flags & SEC_RELOC) != 0
-#ifndef DISASSEMBLER_NEEDS_RELOCS
-	  && dump_reloc_info
-#endif
-	  )
+	  && (dump_reloc_info || pinfo->disassembler_needs_relocs))
 	{
 	  long relsize;
 
@@ -1882,9 +1871,7 @@ disassemble_data (bfd *abfd)
   aux.require_sec = FALSE;
   aux.dynrelbuf = NULL;
   aux.dynrelcount = 0;
-#ifdef DISASSEMBLER_NEEDS_RELOCS
   aux.reloc = NULL;
-#endif
 
   disasm_info.print_address_func = objdump_print_address;
   disasm_info.symbol_at_address_func = objdump_symbol_at_address;
@@ -1926,6 +1913,7 @@ disassemble_data (bfd *abfd)
   disasm_info.octets_per_byte = bfd_octets_per_byte (abfd);
   disasm_info.skip_zeroes = DEFAULT_SKIP_ZEROES;
   disasm_info.skip_zeroes_at_end = DEFAULT_SKIP_ZEROES_AT_END;
+  disasm_info.disassembler_needs_relocs = FALSE;
 
   if (bfd_big_endian (abfd))
     disasm_info.display_endian = disasm_info.endian = BFD_ENDIAN_BIG;
Index: include/dis-asm.h
===================================================================
RCS file: /cvs/src/src/include/dis-asm.h,v
retrieving revision 1.60
diff -u -a -p -r1.60 dis-asm.h
--- include/dis-asm.h	16 Dec 2005 10:23:10 -0000	1.60
+++ include/dis-asm.h	17 Jan 2006 15:15:35 -0000
@@ -172,6 +172,9 @@ typedef struct disassemble_info {
      alignment.  */
   unsigned int skip_zeroes_at_end;
 
+  /* Whether the disassembler always needs the relocations.  */
+  bfd_boolean disassembler_needs_relocs;
+
   /* Results from instruction decoders.  Not all decoders yet support
      this information.  This info is set each time an instruction is
      decoded, and is only valid for the last such instruction.
Index: opcodes/disassemble.c
===================================================================
RCS file: /cvs/src/src/opcodes/disassemble.c,v
retrieving revision 1.60
diff -u -a -p -r1.60 disassemble.c
--- opcodes/disassemble.c	16 Dec 2005 10:23:12 -0000	1.60
+++ opcodes/disassemble.c	17 Jan 2006 15:15:35 -0000
@@ -442,6 +442,7 @@ disassemble_init_for_target (struct disa
 #ifdef ARCH_arm
     case bfd_arch_arm:
       info->symbol_is_valid = arm_symbol_is_valid;
+      info->disassembler_needs_relocs = TRUE;
       break;
 #endif
 #ifdef ARCH_ia64

Andreas.

-- 
Andreas Schwab, SuSE Labs, schwab@suse.de
SuSE Linux Products GmbH, Maxfeldstraße 5, 90409 Nürnberg, Germany
PGP key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."



More information about the Binutils mailing list