bfd:
authorJoseph Myers <joseph@codesourcery.com>
Thu, 30 Apr 2009 00:01:11 +0000 (00:01 +0000)
committerJoseph Myers <joseph@codesourcery.com>
Thu, 30 Apr 2009 00:01:11 +0000 (00:01 +0000)
* elf32-arm.c (elf32_arm_check_relocs): Give errors for absolute
MOVW and MOVT relocations in a shared library link.

ld/testsuite:
* ld-arm/movw-shared-1.d, ld-arm/movw-shared-1.s,
ld-arm/movw-shared-2.d, ld-arm/movw-shared-2.s,
ld-arm/movw-shared-3.d, ld-arm/movw-shared-3.s,
ld-arm/movw-shared-4.d, ld-arm/movw-shared-4.s: New tests.
* ld-arm/arm-elf.exp: Run these new tests.

12 files changed:
bfd/ChangeLog
bfd/elf32-arm.c
ld/testsuite/ChangeLog
ld/testsuite/ld-arm/arm-elf.exp
ld/testsuite/ld-arm/movw-shared-1.d [new file with mode: 0644]
ld/testsuite/ld-arm/movw-shared-1.s [new file with mode: 0644]
ld/testsuite/ld-arm/movw-shared-2.d [new file with mode: 0644]
ld/testsuite/ld-arm/movw-shared-2.s [new file with mode: 0644]
ld/testsuite/ld-arm/movw-shared-3.d [new file with mode: 0644]
ld/testsuite/ld-arm/movw-shared-3.s [new file with mode: 0644]
ld/testsuite/ld-arm/movw-shared-4.d [new file with mode: 0644]
ld/testsuite/ld-arm/movw-shared-4.s [new file with mode: 0644]

index 51f059bcadc5041030ce6d0176c1bf3007a12696..25c21ef69e6a8e6f8d37526691562afbaecb2081 100644 (file)
@@ -1,3 +1,8 @@
+2009-04-30  Joseph Myers  <joseph@codesourcery.com>
+
+       * elf32-arm.c (elf32_arm_check_relocs): Give errors for absolute
+       MOVW and MOVT relocations in a shared library link.
+
 2009-04-27  Anthony Green  <green@moxielogic.com>
 
        * verilog.c: New file.
index d94744a6129becbfa5a7a006f46258f7701d4c8b..831f458f63563353f3f77410396a8b5a6588c624 100644 (file)
@@ -9808,16 +9808,27 @@ elf32_arm_check_relocs (bfd *abfd, struct bfd_link_info *info,
            needs_plt = 1;
            goto normal_reloc;
 
+         case R_ARM_MOVW_ABS_NC:
+         case R_ARM_MOVT_ABS:
+         case R_ARM_THM_MOVW_ABS_NC:
+         case R_ARM_THM_MOVT_ABS:
+           if (info->shared)
+             {
+               (*_bfd_error_handler)
+                 (_("%B: relocation %s against `%s' can not be used when making a shared object; recompile with -fPIC"),
+                  abfd, elf32_arm_howto_table_1[r_type].name,
+                  (h) ? h->root.root.string : "a local symbol");
+               bfd_set_error (bfd_error_bad_value);
+               return FALSE;
+             }
+
+           /* Fall through.  */
          case R_ARM_ABS32:
          case R_ARM_ABS32_NOI:
          case R_ARM_REL32:
          case R_ARM_REL32_NOI:
-         case R_ARM_MOVW_ABS_NC:
-         case R_ARM_MOVT_ABS:
          case R_ARM_MOVW_PREL_NC:
          case R_ARM_MOVT_PREL:
-         case R_ARM_THM_MOVW_ABS_NC:
-         case R_ARM_THM_MOVT_ABS:
          case R_ARM_THM_MOVW_PREL_NC:
          case R_ARM_THM_MOVT_PREL:
            needs_plt = 0;
index dec4cbba102bc724ed83efa84d8c7fa88e12a432..4542a246149f0d2fb7c4e2cb75e46b2ad9f4997a 100644 (file)
@@ -1,3 +1,11 @@
+2009-04-30  Joseph Myers  <joseph@codesourcery.com>
+
+       * ld-arm/movw-shared-1.d, ld-arm/movw-shared-1.s,
+       ld-arm/movw-shared-2.d, ld-arm/movw-shared-2.s,
+       ld-arm/movw-shared-3.d, ld-arm/movw-shared-3.s,
+       ld-arm/movw-shared-4.d, ld-arm/movw-shared-4.s: New tests.
+       * ld-arm/arm-elf.exp: Run these new tests.
+
 2009-04-29  Chris Demetriou  <cgd@google.com>
 
        * ld-elfvers/vers.exp (vers4b): New test to verify that
index b524cceef89274a731bc16e6479610494a7fdae5..04bbcf2a84a48c322e0b3d25798297f847548c77 100644 (file)
@@ -187,6 +187,10 @@ run_dump_test "group-relocs-ldc-bad"
 run_dump_test "thumb2-bl-undefweak"
 run_dump_test "thumb2-bl-undefweak1"
 run_dump_test "emit-relocs1"
+run_dump_test "movw-shared-1"
+run_dump_test "movw-shared-2"
+run_dump_test "movw-shared-3"
+run_dump_test "movw-shared-4"
 
 # Exclude non-ARM-EABI targets.
 
diff --git a/ld/testsuite/ld-arm/movw-shared-1.d b/ld/testsuite/ld-arm/movw-shared-1.d
new file mode 100644 (file)
index 0000000..5a05818
--- /dev/null
@@ -0,0 +1,4 @@
+#name: MOVW/MOVT shared libraries test 1
+#source: movw-shared-1.s
+#ld: -shared
+#error: .*: relocation R_ARM_MOVW_ABS_NC against `a' can not be used when making a shared object; recompile with -fPIC
diff --git a/ld/testsuite/ld-arm/movw-shared-1.s b/ld/testsuite/ld-arm/movw-shared-1.s
new file mode 100644 (file)
index 0000000..512946a
--- /dev/null
@@ -0,0 +1,5 @@
+.arch armv7-a
+.text
+.syntax unified
+f:
+movw r0, #:lower16:a
diff --git a/ld/testsuite/ld-arm/movw-shared-2.d b/ld/testsuite/ld-arm/movw-shared-2.d
new file mode 100644 (file)
index 0000000..08ceaf0
--- /dev/null
@@ -0,0 +1,4 @@
+#name: MOVW/MOVT shared libraries test 2
+#source: movw-shared-2.s
+#ld: -shared
+#error: .*: relocation R_ARM_MOVT_ABS against `b' can not be used when making a shared object; recompile with -fPIC
diff --git a/ld/testsuite/ld-arm/movw-shared-2.s b/ld/testsuite/ld-arm/movw-shared-2.s
new file mode 100644 (file)
index 0000000..bd70b76
--- /dev/null
@@ -0,0 +1,5 @@
+.arch armv7-a
+.text
+.syntax unified
+f:
+movt r0, #:upper16:b
diff --git a/ld/testsuite/ld-arm/movw-shared-3.d b/ld/testsuite/ld-arm/movw-shared-3.d
new file mode 100644 (file)
index 0000000..90b9cf1
--- /dev/null
@@ -0,0 +1,4 @@
+#name: MOVW/MOVT shared libraries test 3
+#source: movw-shared-3.s
+#ld: -shared
+#error: .*: relocation R_ARM_THM_MOVW_ABS_NC against `c' can not be used when making a shared object; recompile with -fPIC
diff --git a/ld/testsuite/ld-arm/movw-shared-3.s b/ld/testsuite/ld-arm/movw-shared-3.s
new file mode 100644 (file)
index 0000000..a4db9a9
--- /dev/null
@@ -0,0 +1,6 @@
+.arch armv7-a
+.text
+.syntax unified
+f:
+.thumb
+movw r0, #:lower16:c
diff --git a/ld/testsuite/ld-arm/movw-shared-4.d b/ld/testsuite/ld-arm/movw-shared-4.d
new file mode 100644 (file)
index 0000000..cc7a418
--- /dev/null
@@ -0,0 +1,4 @@
+#name: MOVW/MOVT shared libraries test 4
+#source: movw-shared-4.s
+#ld: -shared
+#error: .*: relocation R_ARM_THM_MOVT_ABS against `d' can not be used when making a shared object; recompile with -fPIC
diff --git a/ld/testsuite/ld-arm/movw-shared-4.s b/ld/testsuite/ld-arm/movw-shared-4.s
new file mode 100644 (file)
index 0000000..09f2952
--- /dev/null
@@ -0,0 +1,6 @@
+.arch armv7-a
+.text
+.syntax unified
+f:
+.thumb
+movt r0, #:upper16:d