Enable to link ARM object file that hasn't attribute section.
authorTerry Guo <terry.guo@arm.com>
Thu, 20 Nov 2014 05:54:27 +0000 (13:54 +0800)
committerTerry Guo <terry.guo@arm.com>
Thu, 20 Nov 2014 05:54:27 +0000 (13:54 +0800)
bfd/ChangeLog

2014-11-20  Terry Guo  <terry.guo@arm.com>

* elf32-arm.c (elf32_arm_merge_eabi_attributes): Skip if input bfd
hasn't attribute section.

ld/testsuite/ChangeLog:

2014-11-20  Terry Guo  <terry.guo@arm.com>

* ld-arm/attr-merge-nosection-1.d: New file.
* ld-arm/attr-merge-nosection-1a.s: Likewise.
* ld-arm/attr-merge-nosection-1b.s: Likewise.
* ld-arm/arm-elf.exp: Include the new test.

bfd/ChangeLog
bfd/elf32-arm.c
ld/testsuite/ChangeLog
ld/testsuite/ld-arm/arm-elf.exp
ld/testsuite/ld-arm/attr-merge-nosection-1.d [new file with mode: 0644]
ld/testsuite/ld-arm/attr-merge-nosection-1a.s [new file with mode: 0644]
ld/testsuite/ld-arm/attr-merge-nosection-1b.s [new file with mode: 0644]

index 265730615030e83876aa4a8584a88882abe4e1c5..eaf7a99b4fa97e4938f86b60a511ab244079754a 100644 (file)
@@ -1,3 +1,8 @@
+2014-11-20  Terry Guo  <terry.guo@arm.com>
+
+       * elf32-arm.c (elf32_arm_merge_eabi_attributes): Skip if input bfd
+       hasn't attribute section.
+
 2014-11-20  Alan Modra  <amodra@gmail.com>
 
        * elf64-ppc.c (ppc64_elf_size_stubs): Add __go_go to thread_starters.
index 49d0f65611311fbe62886e02d79e5a8aa1d3f194..95f59d5487896d35a3b27cf837a72ea4e1d005ac 100644 (file)
@@ -11700,6 +11700,7 @@ elf32_arm_merge_eabi_attributes (bfd *ibfd, bfd *obfd)
   static const int order_021[3] = {0, 2, 1};
   int i;
   bfd_boolean result = TRUE;
+  const char *sec_name = get_elf_backend_data (ibfd)->obj_attrs_section;
 
   /* Skip the linker stubs file.  This preserves previous behavior
      of accepting unknown attributes in the first input file - but
@@ -11707,6 +11708,12 @@ elf32_arm_merge_eabi_attributes (bfd *ibfd, bfd *obfd)
   if (ibfd->flags & BFD_LINKER_CREATED)
     return TRUE;
 
+  /* Skip any input that hasn't attribute section.
+     This enables to link object files without attribute section with
+     any others.  */
+  if (bfd_get_section_by_name (ibfd, sec_name) == NULL)
+    return TRUE;
+
   if (!elf_known_obj_attributes_proc (obfd)[0].i)
     {
       /* This is the first object.  Copy the attributes.  */
index 72b4bb97038773e6c2d2979e5f6b0f45b4f6919f..1a96da98fc808c22705aaf2cc3bbc7f4344c054d 100644 (file)
@@ -1,3 +1,10 @@
+2014-11-20  Terry Guo  <terry.guo@arm.com>
+
+       * ld-arm/attr-merge-nosection-1.d: New file.
+       * ld-arm/attr-merge-nosection-1a.s: Likewise.
+       * ld-arm/attr-merge-nosection-1b.s: Likewise.
+       * ld-arm/arm-elf.exp: Include the new test.
+
 2014-11-18  H.J. Lu  <hongjiu.lu@intel.com>
 
        PR ld/17618
index 3c8cc689fea4d7521065e003052c39531be81776..d00b74da89a48391f87d8f78f07f7cc514e82c79 100644 (file)
@@ -879,6 +879,7 @@ run_dump_test "attr-merge-vfp-7"
 run_dump_test "attr-merge-vfp-7r"
 run_dump_test "attr-merge-incompatible"
 run_dump_test "attr-merge-arch-2"
+run_dump_test "attr-merge-nosection-1"
 run_dump_test "unresolved-1"
 if { ![istarget "arm*-*-nacl*"] } {
     run_dump_test "unresolved-1-dyn"
diff --git a/ld/testsuite/ld-arm/attr-merge-nosection-1.d b/ld/testsuite/ld-arm/attr-merge-nosection-1.d
new file mode 100644 (file)
index 0000000..a2b8d73
--- /dev/null
@@ -0,0 +1,18 @@
+#source: attr-merge-nosection-1a.s RUN_OBJCOPY
+#source: attr-merge-nosection-1b.s
+#as:
+#objcopy_objects: -R '.ARM.attributes'
+#ld:
+#readelf: -A
+# This test is only valid on ELF based ports.
+# not-target: *-*-*coff *-*-pe *-*-wince *-*-*aout* *-*-netbsd *-*-riscix*
+
+Attribute Section: aeabi
+File Attributes
+  Tag_CPU_name: "Cortex-M4"
+  Tag_CPU_arch: v7E-M
+  Tag_CPU_arch_profile: Microcontroller
+  Tag_THUMB_ISA_use: Thumb-2
+  Tag_FP_arch: VFPv4-D16
+  Tag_ABI_HardFP_use: SP only
+
diff --git a/ld/testsuite/ld-arm/attr-merge-nosection-1a.s b/ld/testsuite/ld-arm/attr-merge-nosection-1a.s
new file mode 100644 (file)
index 0000000..ab358e3
--- /dev/null
@@ -0,0 +1,10 @@
+       .cpu cortex-m0
+       .fpu softvfp
+       .syntax unified
+       .thumb
+       .text
+       .global foo
+       .thumb_func
+       .type foo, %function
+foo:
+       bx lr
diff --git a/ld/testsuite/ld-arm/attr-merge-nosection-1b.s b/ld/testsuite/ld-arm/attr-merge-nosection-1b.s
new file mode 100644 (file)
index 0000000..cd656bd
--- /dev/null
@@ -0,0 +1,10 @@
+        .syntax unified
+        .cpu cortex-m4
+        .fpu fpv4-sp-d16
+        .thumb
+        .text
+        .global _start
+        .thumb_func
+        .type   _start, %function
+_start:
+       bl foo
This page took 0.034533 seconds and 4 git commands to generate.