bfd/
authorBernd Schmidt <bernds@codesourcery.com>
Thu, 5 May 2011 16:05:19 +0000 (16:05 +0000)
committerBernd Schmidt <bernds@codesourcery.com>
Thu, 5 May 2011 16:05:19 +0000 (16:05 +0000)
* elf32-tic6x.c (elf32_tic6x_final_link): New function.
(elf32_tic6x_merge_attributes): Do not warn for PID or PIC
mismatch.  Choose the lower of the two values.
(bfd_elf32_bfd_final_link): New macro.

ld/testsuite/
* ld-tic6x/shared-nopic.d: New test.
* ld-tic6x/shared-nopid.d: New test.
* ld-tic6x/attr-pid-21.d: Don't expect a warning; check readelf
output instead.
* ld-tic6x/attr-pid-12.d: Likewise.
* ld-tic6x/attr-pic-01.d: Likewise.
* ld-tic6x/attr-pic-10.d: Likewise.
* ld-tic6x/attr-pid-01.d: Likewise.
* ld-tic6x/attr-pid-10.d: Likewise.
* ld-tic6x/attr-pid-02.d: Likewise.
* ld-tic6x/attr-pid-20.d: Likewise.
* ld-tic6x/got-reloc-inrange.d: Pass -mpic and -mpid options to gas.

14 files changed:
bfd/ChangeLog
bfd/elf32-tic6x.c
ld/testsuite/ChangeLog
ld/testsuite/ld-tic6x/attr-pic-01.d
ld/testsuite/ld-tic6x/attr-pic-10.d
ld/testsuite/ld-tic6x/attr-pid-01.d
ld/testsuite/ld-tic6x/attr-pid-02.d
ld/testsuite/ld-tic6x/attr-pid-10.d
ld/testsuite/ld-tic6x/attr-pid-12.d
ld/testsuite/ld-tic6x/attr-pid-20.d
ld/testsuite/ld-tic6x/attr-pid-21.d
ld/testsuite/ld-tic6x/got-reloc-inrange.d
ld/testsuite/ld-tic6x/shared-nopic.d [new file with mode: 0644]
ld/testsuite/ld-tic6x/shared-nopid.d [new file with mode: 0644]

index 7af29f07a9fe475c8ec3aa64942eddaa6f789bfd..89547c0c590a6d5ae42f7b4d4e05a6b399a8f1da 100644 (file)
@@ -1,3 +1,10 @@
+2011-05-05  Bernd Schmidt  <bernds@codesourcery.com>
+
+       * elf32-tic6x.c (elf32_tic6x_final_link): New function.
+       (elf32_tic6x_merge_attributes): Do not warn for PID or PIC
+       mismatch.  Choose the lower of the two values.
+       (bfd_elf32_bfd_final_link): New macro.
+
 2011-04-28  Tristan Gingold  <gingold@adacore.com>
 
        * coff-rs6000.c (_bfd_xcoff_swap_aux_in): Adjust for x_file.
index 8b5f5cb4188b4305b81454b08e8cb3444f1a1f51..909225a5c3b705630255596aa234fbab13ae381a 100644 (file)
@@ -1519,6 +1519,31 @@ elf32_tic6x_link_hash_table_create (bfd *abfd)
   return &ret->elf.root;
 }
 
+static bfd_boolean
+elf32_tic6x_final_link (bfd *abfd, struct bfd_link_info *info)
+{
+  if (info->shared)
+    {
+      obj_attribute *out_attr;
+      out_attr = elf_known_obj_attributes_proc (abfd);
+      if (out_attr[Tag_ABI_PIC].i == 0)
+       {
+         _bfd_error_handler (_("warning: generating a shared library "
+                               "containing non-PIC code"));
+       }
+      if (out_attr[Tag_ABI_PID].i == 0)
+       {
+         _bfd_error_handler (_("warning: generating a shared library "
+                               "containing non-PID code"));
+       }
+    }
+  /* Invoke the regular ELF backend linker to do all the work.  */
+  if (!bfd_elf_final_link (abfd, info))
+    return FALSE;
+
+  return TRUE;
+}
+
 /* Destroy a C6X ELF linker hash table.  */
 
 static void
@@ -3764,24 +3789,10 @@ elf32_tic6x_merge_attributes (bfd *ibfd, bfd *obfd)
            }
          break;
 
-       case Tag_ABI_PID:
-         if (out_attr[i].i != in_attr[i].i)
-           {
-             _bfd_error_handler
-               (_("warning: %B and %B differ in position-dependence of "
-                  "data addressing"),
-                obfd, ibfd);
-           }
-         break;
-
        case Tag_ABI_PIC:
-         if (out_attr[i].i != in_attr[i].i)
-           {
-             _bfd_error_handler
-               (_("warning: %B and %B differ in position-dependence of "
-                  "code addressing"),
-                obfd, ibfd);
-           }
+       case Tag_ABI_PID:
+         if (out_attr[i].i > in_attr[i].i)
+           out_attr[i].i = in_attr[i].i;
          break;
 
        case Tag_ABI_array_object_alignment:
@@ -3944,6 +3955,8 @@ elf32_tic6x_copy_private_data (bfd * ibfd, bfd * obfd)
   elf32_tic6x_size_dynamic_sections
 #define elf_backend_finish_dynamic_sections \
   elf32_tic6x_finish_dynamic_sections
+#define bfd_elf32_bfd_final_link \
+       elf32_tic6x_final_link
 #define elf_info_to_howto              elf32_tic6x_info_to_howto
 #define elf_info_to_howto_rel          elf32_tic6x_info_to_howto_rel
 
index 6433199d199dd84663c1ed405080a2491153870c..22783602c2eb4861dcfef53d15928bcacb1156b9 100644 (file)
@@ -1,3 +1,18 @@
+2011-05-05  Bernd Schmidt  <bernds@codesourcery.com>
+
+       * ld-tic6x/shared-nopic.d: New test.
+       * ld-tic6x/shared-nopid.d: New test.
+       * ld-tic6x/attr-pid-21.d: Don't expect a warning; check readelf
+       output instead.
+       * ld-tic6x/attr-pid-12.d: Likewise.
+       * ld-tic6x/attr-pic-01.d: Likewise.
+       * ld-tic6x/attr-pic-10.d: Likewise.
+       * ld-tic6x/attr-pid-01.d: Likewise.
+       * ld-tic6x/attr-pid-10.d: Likewise.
+       * ld-tic6x/attr-pid-02.d: Likewise.
+       * ld-tic6x/attr-pid-20.d: Likewise.
+       * ld-tic6x/got-reloc-inrange.d: Pass -mpic and -mpid options to gas.
+
 2011-05-03  Paul Brook  <paul@codesourcery.com>
 
 
index a04713f8b7fe578fef05c40aac5d2035d77f87da..91fb59917214c0081b9ff8e9e7e890807f95243b 100644 (file)
@@ -3,4 +3,8 @@
 #ld: -r -melf32_tic6x_le
 #source: attr-pic-0.s
 #source: attr-pic-1.s
-#warning: .*differ in position-dependence of code addressing
+#readelf: -A
+
+Attribute Section: c6xabi
+File Attributes
+  Tag_ISA: C674x
index bc781c4b78da95f75071df1af31cde4794f27851..ff52a7ac1732c34e79d55ce401a203ad8a7e2920 100644 (file)
@@ -3,4 +3,8 @@
 #ld: -r -melf32_tic6x_le
 #source: attr-pic-1.s
 #source: attr-pic-0.s
-#warning: .*differ in position-dependence of code addressing
+#readelf: -A
+
+Attribute Section: c6xabi
+File Attributes
+  Tag_ISA: C674x
index 5c32e15b9cd998b5ceb7b780d51945aff404816f..a5449dcd63d83740705640a4e0534abc09c48cbc 100644 (file)
@@ -3,4 +3,9 @@
 #ld: -r -melf32_tic6x_le
 #source: attr-pid-0.s
 #source: attr-pid-1.s
-#warning: .*differ in position-dependence of data addressing
+#readelf: -A
+
+Attribute Section: c6xabi
+File Attributes
+  Tag_ISA: C674x
+
index d155b56157091a9286b503d243e9c14821f98952..2a7bfd1ef615fead5ed2c77f486339c24d75b5cc 100644 (file)
@@ -3,4 +3,9 @@
 #ld: -r -melf32_tic6x_le
 #source: attr-pid-0.s
 #source: attr-pid-2.s
-#warning: .*differ in position-dependence of data addressing
+#readelf: -A
+
+Attribute Section: c6xabi
+File Attributes
+  Tag_ISA: C674x
+
index edb8a659cfdad912103057840f7a61c5fa1b0329..a421d4032120e335426d883b73f451c0cde4b3d1 100644 (file)
@@ -3,4 +3,9 @@
 #ld: -r -melf32_tic6x_le
 #source: attr-pid-1.s
 #source: attr-pid-0.s
-#warning: .*differ in position-dependence of data addressing
+#readelf: -A
+
+Attribute Section: c6xabi
+File Attributes
+  Tag_ISA: C674x
+
index 138ae8889a975039b691408e1c2dcef1b70cf121..af7a76599e66f47c9de8b01f7fe3793c16d0ed63 100644 (file)
@@ -3,4 +3,10 @@
 #ld: -r -melf32_tic6x_le
 #source: attr-pid-1.s
 #source: attr-pid-2.s
-#warning: .*differ in position-dependence of data addressing
+#readelf: -A
+
+Attribute Section: c6xabi
+File Attributes
+  Tag_ISA: C674x
+  Tag_ABI_PID: Data addressing position-independent, GOT near DP
+
index ce319bd6175da8b0f1a383e0ef94111c453e6cab..e2cd0bc2999f1fd0abf9dd6a7217a29c9ac1922d 100644 (file)
@@ -3,4 +3,8 @@
 #ld: -r -melf32_tic6x_le
 #source: attr-pid-2.s
 #source: attr-pid-0.s
-#warning: .*differ in position-dependence of data addressing
+#readelf: -A
+
+Attribute Section: c6xabi
+File Attributes
+  Tag_ISA: C674x
index 7097db675772c574a4ce253146a5c69a8946eb94..c0f71df9ccc9cf3797223bd855b5981a9e56524e 100644 (file)
@@ -3,4 +3,9 @@
 #ld: -r -melf32_tic6x_le
 #source: attr-pid-2.s
 #source: attr-pid-1.s
-#warning: .*differ in position-dependence of data addressing
+#readelf: -A
+
+Attribute Section: c6xabi
+File Attributes
+  Tag_ISA: C674x
+  Tag_ABI_PID: Data addressing position-independent, GOT near DP
index e4fed04aac8368a493c6cda0178571463cc89013..4260444fd49fd33f20444214d5e500fd827a4e31 100644 (file)
@@ -1,5 +1,5 @@
 #name: C6X GOT relocations, no overflow
-#as: -mlittle-endian -mdsbt
+#as: -mlittle-endian -mdsbt -mpic -mpid=near
 #ld: -melf32_tic6x_le -Tdsbt-inrange.ld --dsbt-index 4 -shared
 #source: got-reloc-global.s
 #objdump: -dr
diff --git a/ld/testsuite/ld-tic6x/shared-nopic.d b/ld/testsuite/ld-tic6x/shared-nopic.d
new file mode 100644 (file)
index 0000000..8748f10
--- /dev/null
@@ -0,0 +1,5 @@
+#name: C6X shared library without PIC code
+#as: -mlittle-endian -mdsbt -mpid=near
+#ld: -melf32_tic6x_le -Tdsbt-inrange.ld --dsbt-index 4 -shared
+#source: got-reloc-global.s
+#warning: non-PIC code
diff --git a/ld/testsuite/ld-tic6x/shared-nopid.d b/ld/testsuite/ld-tic6x/shared-nopid.d
new file mode 100644 (file)
index 0000000..7f366f3
--- /dev/null
@@ -0,0 +1,5 @@
+#name: C6X shared library without PIC code
+#as: -mlittle-endian -mdsbt -mpic
+#ld: -melf32_tic6x_le -Tdsbt-inrange.ld --dsbt-index 4 -shared
+#source: got-reloc-global.s
+#warning: non-PID code