This is the mail archive of the binutils@sourceware.org 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]

Re: [PATCH] ARM Disassembler fix


Hi Pedro,

Pedro Alves wrote:
On Monday 04 January 2010 20:43:29, Daniel Gutson wrote:
Hi Nick,

Nick Clifton wrote:
Hi Daniel,

The attached patch fixes a bug that causes the disassembler to dump code when it should dump data.
This looks wrong to me. Why should the disassembler assume that, in the absence of mapping symbols to guide it, the .text section contains data rather than instructions ? Surely it is more likely to contain instructions and it is merely that the mapping symbols are absent ?

Please refer to the AAELF, i.e. IHI0044D pp 23, @4.6.5.1, e.g.
"A section must have a mapping symbol defined at the beginning of the section; however, if the section contains only data then the mapping symbol may be omitted."

The patch breaks text disassembly on arm non-elf targets. Could this be restrict to elf, please?


I now restricted the value initialization of is_data depending on the obj flavour.


ChangeLog is the same.

Please let me know how does this look now.

Thanks!
	Daniel.


-- Daniel Gutson CodeSourcery www.codesourcery.com
Index: gas/testsuite/gas/arm/dis-data.d
===================================================================
RCS file: gas/testsuite/gas/arm/dis-data.d
diff -N gas/testsuite/gas/arm/dis-data.d
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gas/testsuite/gas/arm/dis-data.d	5 Jan 2010 22:12:56 -0000
@@ -0,0 +1,9 @@
+# name: Data disassembler test 
+# objdump: -dr --prefix-addresses --show-raw-insn
+
+.*: +file format .*arm.*
+
+Disassembly of section \.text:
+0x00000000 20010000 	.word	0x20010000
+0x00000004 000000f9 	.word	0x000000f9
+0x00000008 00004cd5 	.word	0x00004cd5
Index: gas/testsuite/gas/arm/dis-data.s
===================================================================
RCS file: gas/testsuite/gas/arm/dis-data.s
diff -N gas/testsuite/gas/arm/dis-data.s
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gas/testsuite/gas/arm/dis-data.s	5 Jan 2010 22:12:56 -0000
@@ -0,0 +1,5 @@
+.syntax unified
+.word	0x20010000
+.word	0x000000f9
+.word	0x00004cd5
+
Index: opcodes/arm-dis.c
===================================================================
RCS file: /cvs/src/src/opcodes/arm-dis.c,v
retrieving revision 1.120
diff -u -p -r1.120 arm-dis.c
--- opcodes/arm-dis.c	4 Jan 2010 10:18:32 -0000	1.120
+++ opcodes/arm-dis.c	5 Jan 2010 22:12:57 -0000
@@ -4355,7 +4355,8 @@ print_insn (bfd_vma pc, struct disassemb
   long		given;
   int           status;
   int           is_thumb = FALSE;
-  int           is_data = FALSE;
+  int           is_data = (bfd_asymbol_flavour (*info->symtab)
+			   == bfd_target_elf_flavour) ? TRUE : FALSE;
   int           little_code;
   unsigned int	size = 4;
   void	 	(*printer) (bfd_vma, struct disassemble_info *, long);
@@ -4415,7 +4416,7 @@ print_insn (bfd_vma pc, struct disassemb
       bfd_vma addr;
       int n;
       int last_sym = -1;
-      enum map_type type = MAP_ARM;
+      enum map_type type = MAP_DATA;
 
       if (pc <= last_mapping_addr)
 	last_mapping_sym = -1;
@@ -4478,7 +4479,9 @@ print_insn (bfd_vma pc, struct disassemb
 	  for (n = last_sym + 1; n < info->symtab_size; n++)
 	    {
 	      addr = bfd_asymbol_value (info->symtab[n]);
-	      if (addr > pc)
+	      if (addr > pc
+		  && (info->section == NULL
+		      || info->section == info->symtab[n]->section))
 		{
 		  if (addr - pc < size)
 		    size = addr - pc;

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