This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Fix ARM mapping symbols for .ascii and other directives
- From: "Joseph S. Myers" <joseph at codesourcery dot com>
- To: binutils at sourceware dot org
- Date: Tue, 3 Mar 2009 17:45:14 +0000 (UTC)
- Subject: Fix ARM mapping symbols for .ascii and other directives
On ARM EABI, special mapping symbols must be generated by the
assembler to mark ARM code, Thumb code and data. These are used by
the linker to swap the endianness of code for BE8 while leaving the
endianness of data unchanged.
It turns out that various generic assembler directives generating data
did not cause the $d mapping symbols to be generated. In particular,
.ascii and other string directives failed to do so, meaning that if an
assembly file included such a directive when the current state was
text, the linker would wrongly swap bytes in the string when linking
for BE8.
Directives that ended up using cons_worker did not suffer from this
problem because it calls md_cons_align, and for ARM this ensures that
data state is entered. It seems natural to use md_cons_align more
generally for directives generating data; this patch does so. Tested
with no regressions with cross to arm-none-eabi. OK to commit?
gas:
2009-03-03 Joseph Myers <joseph@codesourcery.com>
* read.c (s_fill, s_space, s_float_space, float_cons, stringer,
s_incbin): Call md_cons_align (1).
gas/testsuite:
2009-03-03 Joseph Myers <joseph@codesourcery.com>
* gas/arm/mapmisc.d, gas/arm/mapmisc.dat, gas/arm/mapmisc.s: New.
Index: read.c
===================================================================
RCS file: /cvs/src/src/gas/read.c,v
retrieving revision 1.148
diff -u -p -r1.148 read.c
--- read.c 26 Jan 2009 14:36:42 -0000 1.148
+++ read.c 3 Mar 2009 17:36:47 -0000
@@ -1920,6 +1920,10 @@ s_fill (int ignore ATTRIBUTE_UNUSED)
md_flush_pending_output ();
#endif
+#ifdef md_cons_align
+ md_cons_align (1);
+#endif
+
get_known_segmented_expression (&rep_exp);
if (*input_line_pointer == ',')
{
@@ -3119,6 +3123,10 @@ s_space (int mult)
md_flush_pending_output ();
#endif
+#ifdef md_cons_align
+ md_cons_align (1);
+#endif
+
if (flag_mri)
stop = mri_comment_field (&stopc);
@@ -3290,6 +3298,10 @@ s_float_space (int float_type)
char *stop = NULL;
char stopc = 0;
+#ifdef md_cons_align
+ md_cons_align (1);
+#endif
+
if (flag_mri)
stop = mri_comment_field (&stopc);
@@ -4631,6 +4643,10 @@ float_cons (/* Clobbers input_line-point
md_flush_pending_output ();
#endif
+#ifdef md_cons_align
+ md_cons_align (1);
+#endif
+
do
{
/* input_line_pointer->1st char of a flonum (we hope!). */
@@ -5075,6 +5091,10 @@ stringer (int bits_appendzero)
md_flush_pending_output ();
#endif
+#ifdef md_cons_align
+ md_cons_align (1);
+#endif
+
/* The following awkward logic is to parse ZERO or more strings,
comma separated. Recall a string expression includes spaces
before the opening '\"' and spaces after the closing '\"'.
@@ -5453,6 +5473,10 @@ s_incbin (int x ATTRIBUTE_UNUSED)
md_flush_pending_output ();
#endif
+#ifdef md_cons_align
+ md_cons_align (1);
+#endif
+
SKIP_WHITESPACE ();
filename = demand_copy_string (& len);
if (filename == NULL)
Index: testsuite/gas/arm/mapmisc.d
===================================================================
RCS file: testsuite/gas/arm/mapmisc.d
diff -N testsuite/gas/arm/mapmisc.d
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ testsuite/gas/arm/mapmisc.d 3 Mar 2009 17:36:47 -0000
@@ -0,0 +1,95 @@
+#as: -EL -I$srcdir/$subdir
+#objdump: --syms --special-syms -d
+#name: ARM Mapping Symbols for miscellaneous directives
+# This test is only valid on EABI based ports.
+#target: *-*-*eabi *-*-symbianelf *-*-linux-* *-*-elf
+#source: mapmisc.s
+
+
+.*: +file format .*arm.*
+
+SYMBOL TABLE:
+0+00 l d .text 00000000 .text
+0+00 l d .data 00000000 .data
+0+00 l d .bss 00000000 .bss
+0+00 l F .text 00000000 foo
+0+00 l .text 00000000 \$a
+0+04 l .text 00000000 \$d
+0+08 l .text 00000000 \$a
+0+0c l .text 00000000 \$d
+0+10 l .text 00000000 \$a
+0+14 l .text 00000000 \$d
+0+18 l .text 00000000 \$a
+0+1c l .text 00000000 \$d
+0+20 l .text 00000000 \$a
+0+24 l .text 00000000 \$d
+0+28 l .text 00000000 \$a
+0+2c l .text 00000000 \$d
+0+34 l .text 00000000 \$a
+0+38 l .text 00000000 \$d
+0+48 l .text 00000000 \$a
+0+4c l .text 00000000 \$d
+0+50 l .text 00000000 \$a
+0+54 l .text 00000000 \$d
+0+58 l .text 00000000 \$a
+0+5c l .text 00000000 \$d
+0+64 l .text 00000000 \$a
+0+68 l .text 00000000 \$d
+0+70 l .text 00000000 \$a
+0+74 l .text 00000000 \$d
+0+84 l .text 00000000 \$a
+0+88 l .text 00000000 \$d
+0+8c l .text 00000000 \$a
+0+90 l .text 00000000 \$d
+0+94 l .text 00000000 \$a
+0+98 l .text 00000000 \$d
+0+9c l .text 00000000 \$a
+0+a0 l .text 00000000 \$d
+0+a4 l .text 00000000 \$a
+0+00 l d .ARM.attributes 00000000 .ARM.attributes
+
+
+
+Disassembly of section .text:
+
+00000000 <foo>:
+ 0: e1a00000 nop \(mov r0,r0\)
+ 4: 64636261 .word 0x64636261
+ 8: e1a00000 nop \(mov r0,r0\)
+ c: 00636261 .word 0x00636261
+ 10: e1a00000 nop \(mov r0,r0\)
+ 14: 00676665 .word 0x00676665
+ 18: e1a00000 nop \(mov r0,r0\)
+ 1c: 006a6968 .word 0x006a6968
+ 20: e1a00000 nop \(mov r0,r0\)
+ 24: 0000006b .word 0x0000006b
+ 28: e1a00000 nop \(mov r0,r0\)
+ 2c: 0000006c .word 0x0000006c
+ 30: 00000000 .word 0x00000000
+ 34: e1a00000 nop \(mov r0,r0\)
+ 38: 0000006d .word 0x0000006d
+ ...
+ 48: e1a00000 nop \(mov r0,r0\)
+ 4c: 3fc00000 .word 0x3fc00000
+ 50: e1a00000 nop \(mov r0,r0\)
+ 54: 40200000 .word 0x40200000
+ 58: e1a00000 nop \(mov r0,r0\)
+ 5c: 400c0000 .word 0x400c0000
+ 60: 00000000 .word 0x00000000
+ 64: e1a00000 nop \(mov r0,r0\)
+ 68: 40120000 .word 0x40120000
+ 6c: 00000000 .word 0x00000000
+ 70: e1a00000 nop \(mov r0,r0\)
+ 74: 00000004 .word 0x00000004
+ 78: 00000004 .word 0x00000004
+ 7c: 00000004 .word 0x00000004
+ 80: 00000004 .word 0x00000004
+ 84: e1a00000 nop \(mov r0,r0\)
+ 88: 00000000 .word 0x00000000
+ 8c: e1a00000 nop \(mov r0,r0\)
+ 90: 00000000 .word 0x00000000
+ 94: e1a00000 nop \(mov r0,r0\)
+ 98: 00000000 .word 0x00000000
+ 9c: e1a00000 nop \(mov r0,r0\)
+ a0: 7778797a .word 0x7778797a
+ a4: e1a00000 nop \(mov r0,r0\)
Index: testsuite/gas/arm/mapmisc.dat
===================================================================
RCS file: testsuite/gas/arm/mapmisc.dat
diff -N testsuite/gas/arm/mapmisc.dat
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ testsuite/gas/arm/mapmisc.dat 3 Mar 2009 17:36:47 -0000
@@ -0,0 +1 @@
+zyxw
\ No newline at end of file
Index: testsuite/gas/arm/mapmisc.s
===================================================================
RCS file: testsuite/gas/arm/mapmisc.s
diff -N testsuite/gas/arm/mapmisc.s
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ testsuite/gas/arm/mapmisc.s 3 Mar 2009 17:36:47 -0000
@@ -0,0 +1,36 @@
+ .text
+ .type foo, %function
+foo:
+ nop
+ .ascii "abcd"
+ nop
+ .asciz "abc"
+ nop
+ .string "efg"
+ nop
+ .string8 "hij"
+ nop
+ .string16 "k"
+ nop
+ .string32 "l"
+ nop
+ .string64 "m"
+ nop
+ .float 0e1.5
+ nop
+ .single 0e2.5
+ nop
+ .double 0e3.5
+ nop
+ .dcb.d 1, 4.5
+ nop
+ .fill 4, 4, 4
+ nop
+ .space 4
+ nop
+ .skip 4
+ nop
+ .zero 4
+ nop
+ .incbin "mapmisc.dat"
+ nop
--
Joseph S. Myers
joseph@codesourcery.com