public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* [patch] Arm BE8 mode and mapping sybols
@ 2006-05-06  9:43 Paul Brook
  2006-05-07 21:32 ` Nick Clifton
  0 siblings, 1 reply; 6+ messages in thread
From: Paul Brook @ 2006-05-06  9:43 UTC (permalink / raw)
  To: binutils

[-- Attachment #1: Type: text/plain, Size: 531 bytes --]

When building a section code map we are only interested in $a, $t and $d 
mapping symbols. bfd_is_arm_mapping_symbol_name can return true for other 
(obsolete) mapping symbols.  The attached patch makes sure these are ignored.

Tested with cross to arm-none-eabi.
Ok?

Paul

2006-05-05  Paul Brook  <paul@codesourcery.com>

bfd/
	* elf32-arm.c (elf32_arm_output_symbol_hook): Ignore everything but
	a, t and d symbols.
ld/testsuite/
	* ld-arm/arm-be8.d: New test.
	* ld-arm/arm-be8.s: New test.
	* ld-arm/arm-elf.exp: Add arm-be8.

[-- Attachment #2: patch.map_obsolete --]
[-- Type: text/x-diff, Size: 2343 bytes --]

Index: bfd/elf32-arm.c
===================================================================
RCS file: /var/cvsroot/src-cvs/src/bfd/elf32-arm.c,v
retrieving revision 1.73
diff -u -p -r1.73 elf32-arm.c
--- bfd/elf32-arm.c	3 May 2006 14:26:40 -0000	1.73
+++ bfd/elf32-arm.c	5 May 2006 17:10:09 -0000
@@ -7789,8 +7789,9 @@ elf32_arm_output_symbol_hook (struct bfd
   if (!globals->byteswap_code)
     return TRUE;
 
-  /* We only want mapping symbols.  */
-  if (! bfd_is_arm_mapping_symbol_name (name))
+  /* We only want 'a', 't' and 'd' mapping symbols.  */
+  if (! bfd_is_arm_mapping_symbol_name (name)
+      || (name[1] != 'a' && name[1] != 't' && name[1] != 'd'))
     return TRUE;
 
   /* If this section has not been allocated an _arm_elf_section_data
Index: ld/testsuite/ld-arm/arm-be8.d
===================================================================
RCS file: ld/testsuite/ld-arm/arm-be8.d
diff -N ld/testsuite/ld-arm/arm-be8.d
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ ld/testsuite/ld-arm/arm-be8.d	5 May 2006 21:38:32 -0000
@@ -0,0 +1,8 @@
+
+.*:     file format.*
+
+Contents of section .text:
+ 8000 0000a0e3 1eff2fe1 c0467047 fcfffff7 .*
+ 8010 12345678                            .*
+# Ignore .ARM.attributes section
+#...
Index: ld/testsuite/ld-arm/arm-be8.s
===================================================================
RCS file: ld/testsuite/ld-arm/arm-be8.s
diff -N ld/testsuite/ld-arm/arm-be8.s
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ ld/testsuite/ld-arm/arm-be8.s	5 May 2006 18:06:32 -0000
@@ -0,0 +1,14 @@
+.arch armv6
+.text
+arm:
+mov r0, #0
+$m:
+bx lr
+.thumb
+.thumb_func
+thumb:
+nop
+bx lr
+bl thumb
+data:
+.word 0x12345678
Index: ld/testsuite/ld-arm/arm-elf.exp
===================================================================
RCS file: /var/cvsroot/src-cvs/src/ld/testsuite/ld-arm/arm-elf.exp,v
retrieving revision 1.12
diff -u -p -r1.12 arm-elf.exp
--- ld/testsuite/ld-arm/arm-elf.exp	2 May 2006 13:09:18 -0000	1.12
+++ ld/testsuite/ld-arm/arm-elf.exp	5 May 2006 18:03:00 -0000
@@ -122,6 +122,9 @@ set armelftests {
     {"thumb-rel32" "-static -T arm.ld" "" {thumb-rel32.s}
      {{objdump -s thumb-rel32.d}}
      "thumb-rel32"}
+    {"BE8 Mapping Symbols" "-static -T arm.ld -EB --be8" "-EB" {arm-be8.s}
+     {{objdump -s arm-be8.d}}
+     "arm-be8"}
 }
 
 run_ld_link_tests $armelftests

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [patch] Arm BE8 mode and mapping sybols
  2006-05-06  9:43 [patch] Arm BE8 mode and mapping sybols Paul Brook
@ 2006-05-07 21:32 ` Nick Clifton
  2006-05-08 18:20   ` Richard Earnshaw
  0 siblings, 1 reply; 6+ messages in thread
From: Nick Clifton @ 2006-05-07 21:32 UTC (permalink / raw)
  To: Paul Brook; +Cc: binutils

Hi Paul,

> +  /* We only want 'a', 't' and 'd' mapping symbols.  */
> +  if (! bfd_is_arm_mapping_symbol_name (name)
> +      || (name[1] != 'a' && name[1] != 't' && name[1] != 'd'))
>      return TRUE;

Actually I think that it would be cleaner if 
bfd_is_arm_mapping_symbol_name() took a second argument which 
distinguishes between a request for any mapping symbol versus a request 
for only-valid-for-modern-ABIs mapping symbol.  That way the knowledge 
about which symbols are valid can be kept in one place, with the code 
that actually detects them.

Cheers
   Nick

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [patch] Arm BE8 mode and mapping sybols
  2006-05-07 21:32 ` Nick Clifton
@ 2006-05-08 18:20   ` Richard Earnshaw
  2006-05-08 20:42     ` Nick Clifton
  2006-05-09 19:06     ` Paul Brook
  0 siblings, 2 replies; 6+ messages in thread
From: Richard Earnshaw @ 2006-05-08 18:20 UTC (permalink / raw)
  To: Nick Clifton; +Cc: Paul Brook, binutils

On Sun, 2006-05-07 at 15:45, Nick Clifton wrote:
> Hi Paul,
> 
> > +  /* We only want 'a', 't' and 'd' mapping symbols.  */
> > +  if (! bfd_is_arm_mapping_symbol_name (name)
> > +      || (name[1] != 'a' && name[1] != 't' && name[1] != 'd'))
> >      return TRUE;
> 
> Actually I think that it would be cleaner if 
> bfd_is_arm_mapping_symbol_name() took a second argument which 
> distinguishes between a request for any mapping symbol versus a request 
> for only-valid-for-modern-ABIs mapping symbol.  That way the knowledge 
> about which symbols are valid can be kept in one place, with the code 
> that actually detects them.
> 
> Cheers
>    Nick

There have only ever been three mapping symbols: $a, $t and $d.  The
remainder have always been 'tagging' symbols.  Maybe the routine should
be renamed to bfd_is_arm_special_symbol name and then given an argument
TYPE_MAP, TYPE_TAG or TYPE_ANY.

R.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [patch] Arm BE8 mode and mapping sybols
  2006-05-08 18:20   ` Richard Earnshaw
@ 2006-05-08 20:42     ` Nick Clifton
  2006-05-09 19:06     ` Paul Brook
  1 sibling, 0 replies; 6+ messages in thread
From: Nick Clifton @ 2006-05-08 20:42 UTC (permalink / raw)
  To: Richard Earnshaw, Paul Brook; +Cc: binutils

Hi Richard,

> There have only ever been three mapping symbols: $a, $t and $d.  The
> remainder have always been 'tagging' symbols.  Maybe the routine should
> be renamed to bfd_is_arm_special_symbol name and then given an argument
> TYPE_MAP, TYPE_TAG or TYPE_ANY.

Yes - that sounds like a very good idea.  Paul - over to you...

Cheers
   Nick


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [patch] Arm BE8 mode and mapping sybols
  2006-05-08 18:20   ` Richard Earnshaw
  2006-05-08 20:42     ` Nick Clifton
@ 2006-05-09 19:06     ` Paul Brook
  2006-05-15 16:59       ` Nick Clifton
  1 sibling, 1 reply; 6+ messages in thread
From: Paul Brook @ 2006-05-09 19:06 UTC (permalink / raw)
  To: binutils; +Cc: Richard Earnshaw, Nick Clifton

[-- Attachment #1: Type: text/plain, Size: 1116 bytes --]

> There have only ever been three mapping symbols: $a, $t and $d.  The
> remainder have always been 'tagging' symbols.  Maybe the routine should
> be renamed to bfd_is_arm_special_symbol name and then given an argument
> TYPE_MAP, TYPE_TAG or TYPE_ANY.

Something like this?

Paul

2006-05-09  Paul Brook  <paul@codesourcery.com>

bfd/
	* cpu-arm.c (bfd_is_arm_mapping_symbol_name): Rename ...
	(bfd_is_arm_special_symbol_name): ... to this.  Add type argument.
	Check symbol name is of specified type.
	* elf32-arm.c (elf32_arm_is_target_special_symbol,
	arm_elf_find_function, elf32_arm_output_symbol_hook): Use
	bfd_is_arm_special_symbol_name.
	* bfd-in.h (BFD_ARM_SPECIAL_SYM_TYPE_MAP,
	BFD_ARM_SPECIAL_SYM_TYPE_TAG, BFD_ARM_SPECIAL_SYM_TYPE_OTHER,
	BFD_ARM_SPECIAL_SYM_TYPE_ANY): Define.
	(bfd_is_arm_mapping_symbol_name): Remove prototype.
	(bfd_is_arm_special_symbol_name): Add prototype.
	* bfd-in2.h: Regenerate.
gas/
	* config/tc-arm.c (arm_adjust_symtab): Use
	bfd_is_arm_special_symbol_name.
ld/testsuite/
	* ld-arm/arm-be8.d: New test.
	* ld-arm/arm-be8.s: New test.
	* ld-arm/arm-elf.exp: Add arm-be8.

[-- Attachment #2: patch.map_obsolete --]
[-- Type: text/x-diff, Size: 5920 bytes --]

Index: bfd/bfd-in.h
===================================================================
RCS file: /var/cvsroot/src-cvs/src/bfd/bfd-in.h,v
retrieving revision 1.114
diff -u -p -r1.114 bfd-in.h
--- bfd/bfd-in.h	1 May 2006 19:36:27 -0000	1.114
+++ bfd/bfd-in.h	9 May 2006 13:26:52 -0000
@@ -850,8 +850,12 @@ extern bfd_boolean bfd_elf32_arm_add_glu
   (bfd *, struct bfd_link_info *);
 
 /* ELF ARM mapping symbol support */
-extern bfd_boolean bfd_is_arm_mapping_symbol_name
-  (const char * name);
+#define BFD_ARM_SPECIAL_SYM_TYPE_MAP	1
+#define BFD_ARM_SPECIAL_SYM_TYPE_TAG	2
+#define BFD_ARM_SPECIAL_SYM_TYPE_OTHER  4
+#define BFD_ARM_SPECIAL_SYM_TYPE_ANY	7
+extern bfd_boolean bfd_is_arm_special_symbol_name
+  (const char * name, int type);
 
 /* ARM Note section processing.  */
 extern bfd_boolean bfd_arm_merge_machines
Index: bfd/cpu-arm.c
===================================================================
RCS file: /var/cvsroot/src-cvs/src/bfd/cpu-arm.c,v
retrieving revision 1.21
diff -u -p -r1.21 cpu-arm.c
--- bfd/cpu-arm.c	4 May 2006 18:15:21 -0000	1.21
+++ bfd/cpu-arm.c	9 May 2006 13:26:52 -0000
@@ -402,14 +402,22 @@ bfd_arm_get_mach_from_notes (bfd *abfd, 
 }
 
 bfd_boolean
-bfd_is_arm_mapping_symbol_name (const char * name)
+bfd_is_arm_special_symbol_name (const char * name, int type)
 {
   /* The ARM compiler outputs several obsolete forms.  Recognize them
      in addition to the standard $a, $t and $d.  We are somewhat loose
      in what we accept here, since the full set is not documented.  */
-  return (name != NULL)
-    && (name[0] == '$')
-    && (name[1] >= 'a' && name[1] <= 'z')
-    && (name[2] == 0 || name[2] == '.');
+  if (!name || name[0] != '$')
+    return FALSE;
+  if (name[1] == 'a' || name[1] == 't' || name[1] == 'd')
+    type &= BFD_ARM_SPECIAL_SYM_TYPE_MAP;
+  else if (name[1] == 'm' || name[1] == 'f' || name[1] == 'p')
+    type &= BFD_ARM_SPECIAL_SYM_TYPE_TAG;
+  else if (name[1] >= 'a' && name[1] <= 'z')
+    type &= BFD_ARM_SPECIAL_SYM_TYPE_OTHER;
+  else
+    return FALSE;
+
+  return (type != 0 && (name[2] == 0 || name[2] == '.'));
 }
 
Index: bfd/elf32-arm.c
===================================================================
RCS file: /var/cvsroot/src-cvs/src/bfd/elf32-arm.c,v
retrieving revision 1.73
diff -u -p -r1.73 elf32-arm.c
--- bfd/elf32-arm.c	3 May 2006 14:26:40 -0000	1.73
+++ bfd/elf32-arm.c	9 May 2006 13:26:52 -0000
@@ -6021,7 +6021,8 @@ elf32_arm_check_relocs (bfd *abfd, struc
 static bfd_boolean
 elf32_arm_is_target_special_symbol (bfd * abfd ATTRIBUTE_UNUSED, asymbol * sym)
 {
-  return bfd_is_arm_mapping_symbol_name (sym->name);
+  return bfd_is_arm_special_symbol_name (sym->name,
+					 BFD_ARM_SPECIAL_SYM_TYPE_ANY);
 }
 
 /* This is a copy of elf_find_function() from elf.c except that
@@ -6057,9 +6058,10 @@ arm_elf_find_function (bfd *         abf
 	case STT_FUNC:
 	case STT_ARM_TFUNC:
 	case STT_NOTYPE:
-	  /* Skip $a and $t symbols.  */
+	  /* Skip mapping symbols.  */
 	  if ((q->symbol.flags & BSF_LOCAL)
-	      && bfd_is_arm_mapping_symbol_name (q->symbol.name))
+	      && bfd_is_arm_special_symbol_name (q->symbol.name,
+		    BFD_ARM_SPECIAL_SYM_TYPE_ANY))
 	    continue;
 	  /* Fall through.  */
 	  if (bfd_get_section (&q->symbol) == section
@@ -7790,7 +7792,7 @@ elf32_arm_output_symbol_hook (struct bfd
     return TRUE;
 
   /* We only want mapping symbols.  */
-  if (! bfd_is_arm_mapping_symbol_name (name))
+  if (!bfd_is_arm_special_symbol_name (name, BFD_ARM_SPECIAL_SYM_TYPE_MAP))
     return TRUE;
 
   /* If this section has not been allocated an _arm_elf_section_data
Index: gas/config/tc-arm.c
===================================================================
RCS file: /var/cvsroot/src-cvs/src/gas/config/tc-arm.c,v
retrieving revision 1.265
diff -u -p -r1.265 tc-arm.c
--- gas/config/tc-arm.c	5 May 2006 18:54:44 -0000	1.265
+++ gas/config/tc-arm.c	9 May 2006 13:26:52 -0000
@@ -17171,7 +17171,8 @@ arm_adjust_symtab (void)
 	  elf_sym = elf_symbol (symbol_get_bfdsym (sym));
 	  bind = ELF_ST_BIND (elf_sym->internal_elf_sym.st_info);
 
-	  if (! bfd_is_arm_mapping_symbol_name (elf_sym->symbol.name))
+	  if (! bfd_is_arm_special_symbol_name (elf_sym->symbol.name,
+		BFD_ARM_SPECIAL_SYM_TYPE_ANY))
 	    {
 	      /* If it's a .thumb_func, declare it as so,
 		 otherwise tag label as .code 16.  */
Index: ld/testsuite/ld-arm/arm-be8.d
===================================================================
RCS file: ld/testsuite/ld-arm/arm-be8.d
diff -N ld/testsuite/ld-arm/arm-be8.d
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ ld/testsuite/ld-arm/arm-be8.d	9 May 2006 15:19:17 -0000
@@ -0,0 +1,8 @@
+
+.*:     file format.*
+
+Contents of section .text:
+ 8000 0000a0e3 1eff2fe1 c0467047 fff7fcff .*
+ 8010 12345678                            .*
+# Ignore .ARM.attributes section
+#...
Index: ld/testsuite/ld-arm/arm-be8.s
===================================================================
RCS file: ld/testsuite/ld-arm/arm-be8.s
diff -N ld/testsuite/ld-arm/arm-be8.s
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ ld/testsuite/ld-arm/arm-be8.s	9 May 2006 15:19:17 -0000
@@ -0,0 +1,14 @@
+.arch armv6
+.text
+arm:
+mov r0, #0
+$m:
+bx lr
+.thumb
+.thumb_func
+thumb:
+nop
+bx lr
+bl thumb
+data:
+.word 0x12345678
Index: ld/testsuite/ld-arm/arm-elf.exp
===================================================================
RCS file: /var/cvsroot/src-cvs/src/ld/testsuite/ld-arm/arm-elf.exp,v
retrieving revision 1.12
diff -u -p -r1.12 arm-elf.exp
--- ld/testsuite/ld-arm/arm-elf.exp	2 May 2006 13:09:18 -0000	1.12
+++ ld/testsuite/ld-arm/arm-elf.exp	9 May 2006 13:26:52 -0000
@@ -122,6 +122,9 @@ set armelftests {
     {"thumb-rel32" "-static -T arm.ld" "" {thumb-rel32.s}
      {{objdump -s thumb-rel32.d}}
      "thumb-rel32"}
+    {"BE8 Mapping Symbols" "-static -T arm.ld -EB --be8" "-EB" {arm-be8.s}
+     {{objdump -s arm-be8.d}}
+     "arm-be8"}
 }
 
 run_ld_link_tests $armelftests

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [patch] Arm BE8 mode and mapping sybols
  2006-05-09 19:06     ` Paul Brook
@ 2006-05-15 16:59       ` Nick Clifton
  0 siblings, 0 replies; 6+ messages in thread
From: Nick Clifton @ 2006-05-15 16:59 UTC (permalink / raw)
  To: Paul Brook; +Cc: binutils, Richard Earnshaw

Hi Paul,

> 2006-05-09  Paul Brook  <paul@codesourcery.com>
> 
> bfd/
> 	* cpu-arm.c (bfd_is_arm_mapping_symbol_name): Rename ...
> 	(bfd_is_arm_special_symbol_name): ... to this.  Add type argument.
> 	Check symbol name is of specified type.
> 	* elf32-arm.c (elf32_arm_is_target_special_symbol,
> 	arm_elf_find_function, elf32_arm_output_symbol_hook): Use
> 	bfd_is_arm_special_symbol_name.
> 	* bfd-in.h (BFD_ARM_SPECIAL_SYM_TYPE_MAP,
> 	BFD_ARM_SPECIAL_SYM_TYPE_TAG, BFD_ARM_SPECIAL_SYM_TYPE_OTHER,
> 	BFD_ARM_SPECIAL_SYM_TYPE_ANY): Define.
> 	(bfd_is_arm_mapping_symbol_name): Remove prototype.
> 	(bfd_is_arm_special_symbol_name): Add prototype.
> 	* bfd-in2.h: Regenerate.
> gas/
> 	* config/tc-arm.c (arm_adjust_symtab): Use
> 	bfd_is_arm_special_symbol_name.
> ld/testsuite/
> 	* ld-arm/arm-be8.d: New test.
> 	* ld-arm/arm-be8.s: New test.
> 	* ld-arm/arm-elf.exp: Add arm-be8.

Approved - please apply.

One small point:

> +#define BFD_ARM_SPECIAL_SYM_TYPE_MAP	1
> +#define BFD_ARM_SPECIAL_SYM_TYPE_TAG	2
> +#define BFD_ARM_SPECIAL_SYM_TYPE_OTHER  4
> +#define BFD_ARM_SPECIAL_SYM_TYPE_ANY	7

Since these constants are flags in a bitfield, I personally think that 
it is clearer to use shifted values, rather than relying upon the 
knowledge of how decimal numbers are encoded in binary.  ie:

   #define BFD_ARM_SPECIAL_SYM_TYPE_MAP	  (1 << 0)
   #define BFD_ARM_SPECIAL_SYM_TYPE_TAG	  (1 << 1)
   #define BFD_ARM_SPECIAL_SYM_TYPE_OTHER  (1 << 2)
   #define BFD_ARM_SPECIAL_SYM_TYPE_ANY	  ~0

This is just a personal thing though, not a requirement.

Cheers
   Nick

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2006-05-15  9:32 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-05-06  9:43 [patch] Arm BE8 mode and mapping sybols Paul Brook
2006-05-07 21:32 ` Nick Clifton
2006-05-08 18:20   ` Richard Earnshaw
2006-05-08 20:42     ` Nick Clifton
2006-05-09 19:06     ` Paul Brook
2006-05-15 16:59       ` Nick Clifton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).