2009-03-18 Andrew Stubbs <ams@codesourcery.com>
authorAndrew Stubbs <andrew.stubbs@st.com>
Wed, 18 Mar 2009 15:28:24 +0000 (15:28 +0000)
committerAndrew Stubbs <andrew.stubbs@st.com>
Wed, 18 Mar 2009 15:28:24 +0000 (15:28 +0000)
gas/
* config/tc-arm.c (md_apply_fix): Check BFD_RELOC_ARM_IMMEDIATE and
BFD_RELOC_ARM_ADRL_IMMEDIATE value is in the correct section.
Check BFD_RELOC_ARM_ADRL_IMMEDIATE has a defined symbol.

gas/testsuites/
* gas/arm/adr-invalid.d: New file.
* gas/arm/adr-invalid.l: New file.
* gas/arm/adr-invalid.s: New file.

gas/ChangeLog
gas/config/tc-arm.c
gas/testsuite/ChangeLog
gas/testsuite/gas/arm/adr-invalid.d [new file with mode: 0644]
gas/testsuite/gas/arm/adr-invalid.l [new file with mode: 0644]
gas/testsuite/gas/arm/adr-invalid.s [new file with mode: 0644]

index 35d60da7d74ac295e27bf0eb6d52ce62264c4c03..78e868780249537c93ad9d0d0952a52b285b80fc 100644 (file)
@@ -1,3 +1,9 @@
+2009-03-18  Andrew Stubbs  <ams@codesourcery.com>
+
+       * config/tc-arm.c (md_apply_fix): Check BFD_RELOC_ARM_IMMEDIATE and
+       BFD_RELOC_ARM_ADRL_IMMEDIATE value is in the correct section.
+       Check BFD_RELOC_ARM_ADRL_IMMEDIATE has a defined symbol.
+
 2009-03-18  Alan Modra  <amodra@bigpond.net.au>
 
        * as.h: Include alloca-conf.h instead of config.h and remove
index bb783bdd40effd336bf7730b34cb606339beb017..98d8b7ffa3ecd29b080d34f4bc2c7ef93532c911 100644 (file)
@@ -18537,6 +18537,15 @@ md_apply_fix (fixS *   fixP,
          break;
        }
 
+      if (fixP->fx_addsy
+         && S_GET_SEGMENT (fixP->fx_addsy) != seg)
+       {
+         as_bad_where (fixP->fx_file, fixP->fx_line,
+                       _("symbol %s is in a different section"),
+                       S_GET_NAME (fixP->fx_addsy));
+         break;
+       }
+
       newimm = encode_arm_immediate (value);
       temp = md_chars_to_number (buf, INSN_SIZE);
 
@@ -18560,6 +18569,24 @@ md_apply_fix (fixS *   fixP,
        unsigned int highpart = 0;
        unsigned int newinsn  = 0xe1a00000; /* nop.  */
 
+       if (fixP->fx_addsy
+           && ! S_IS_DEFINED (fixP->fx_addsy))
+         {
+           as_bad_where (fixP->fx_file, fixP->fx_line,
+                         _("undefined symbol %s used as an immediate value"),
+                         S_GET_NAME (fixP->fx_addsy));
+           break;
+         }
+
+       if (fixP->fx_addsy
+           && S_GET_SEGMENT (fixP->fx_addsy) != seg)
+         {
+           as_bad_where (fixP->fx_file, fixP->fx_line,
+                         _("symbol %s is in a different section"),
+                         S_GET_NAME (fixP->fx_addsy));
+           break;
+         }
+
        newimm = encode_arm_immediate (value);
        temp = md_chars_to_number (buf, INSN_SIZE);
 
index 1ef1ed3168775dc998e9f1aea7772c8f606d27f4..d5e95883ba4aaf76fea6abe24331855ea49729e8 100644 (file)
@@ -1,3 +1,9 @@
+2009-03-18  Andrew Stubbs  <ams@codesourcery.com>
+
+       * gas/arm/adr-invalid.d: New file.
+       * gas/arm/adr-invalid.l: New file.
+       * gas/arm/adr-invalid.s: New file.
+
 2009-03-14  Richard Sandiford  <r.sandiford@uk.ibm.com>
 
        * gas/ppc/textalign-xcoff-001.d: Expect the section VMAs to be
diff --git a/gas/testsuite/gas/arm/adr-invalid.d b/gas/testsuite/gas/arm/adr-invalid.d
new file mode 100644 (file)
index 0000000..d8043dc
--- /dev/null
@@ -0,0 +1,2 @@
+# name: Invalid use of ADR and ADRL
+# error-output: adr-invalid.l
diff --git a/gas/testsuite/gas/arm/adr-invalid.l b/gas/testsuite/gas/arm/adr-invalid.l
new file mode 100644 (file)
index 0000000..817646e
--- /dev/null
@@ -0,0 +1,5 @@
+[^:]*: Assembler messages:
+[^:]*:3: Error: symbol var is in a different section
+[^:]*:4: Error: undefined symbol undefinedvar used as an immediate value
+[^:]*:5: Error: symbol var is in a different section
+[^:]*:6: Error: undefined symbol undefinedvar used as an immediate value
diff --git a/gas/testsuite/gas/arm/adr-invalid.s b/gas/testsuite/gas/arm/adr-invalid.s
new file mode 100644 (file)
index 0000000..8ff3860
--- /dev/null
@@ -0,0 +1,12 @@
+       .text
+start:
+       adr     r0, var
+       adr     r0, undefinedvar
+       adrl    r1, var
+       adrl    r1, undefinedvar
+
+       .data
+       .globl  var
+var:
+       .word   0x00000000
+