]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Add support for merging ARMv8-M object files
authorThomas Preud'homme <thomas.preudhomme@arm.com>
Fri, 4 Dec 2015 03:02:24 +0000 (11:02 +0800)
committerThomas Preud'homme <thomas.preudhomme@arm.com>
Thu, 17 Dec 2015 12:38:54 +0000 (20:38 +0800)
bfd/elf32-arm.c
ld/testsuite/ld-arm/arm-elf.exp
ld/testsuite/ld-arm/attr-merge-10.attr [new file with mode: 0644]
ld/testsuite/ld-arm/attr-merge-10a.s [new file with mode: 0644]
ld/testsuite/ld-arm/attr-merge-10b.s [new file with mode: 0644]
ld/testsuite/ld-arm/attr-merge-8.attr [new file with mode: 0644]
ld/testsuite/ld-arm/attr-merge-8a.s [new file with mode: 0644]
ld/testsuite/ld-arm/attr-merge-8b.s [new file with mode: 0644]
ld/testsuite/ld-arm/attr-merge-9.out [new file with mode: 0644]
ld/testsuite/ld-arm/attr-merge-9a.s [new file with mode: 0644]
ld/testsuite/ld-arm/attr-merge-9b.s [new file with mode: 0644]

index fd4f743faca4681037a966b4955378dfa5cb231a..97f2ee0874de52c22d6785049be3bbf911423a7b 100644 (file)
@@ -3445,18 +3445,8 @@ create_ifunc_sections (struct bfd_link_info *info)
 static bfd_boolean
 using_thumb_only (struct elf32_arm_link_hash_table *globals)
 {
-  int arch = bfd_elf_get_obj_attr_int (globals->obfd, OBJ_ATTR_PROC,
-                                      Tag_CPU_arch);
-  int profile;
-
-  if (arch == TAG_CPU_ARCH_V6_M || arch == TAG_CPU_ARCH_V6S_M)
-    return TRUE;
-
-  if (arch != TAG_CPU_ARCH_V7 && arch != TAG_CPU_ARCH_V7E_M)
-    return FALSE;
-
-  profile = bfd_elf_get_obj_attr_int (globals->obfd, OBJ_ATTR_PROC,
-                                     Tag_CPU_arch_profile);
+  int profile = bfd_elf_get_obj_attr_int (globals->obfd, OBJ_ATTR_PROC,
+                                         Tag_CPU_arch_profile);
 
   return profile == 'M';
 }
@@ -12186,6 +12176,47 @@ tag_cpu_arch_combine (bfd *ibfd, int oldtag, int *secondary_compat_out,
       T(V8),           /* V7E_M.  */
       T(V8)            /* V8.  */
     };
+  const int v8m_baseline[] =
+    {
+      -1,              /* PRE_V4.  */
+      -1,              /* V4.  */
+      -1,              /* V4T.  */
+      -1,              /* V5T.  */
+      -1,              /* V5TE.  */
+      -1,              /* V5TEJ.  */
+      -1,              /* V6.  */
+      -1,              /* V6KZ.  */
+      -1,              /* V6T2.  */
+      -1,              /* V6K.  */
+      -1,              /* V7.  */
+      T(V8M_BASE),     /* V6_M.  */
+      T(V8M_BASE),     /* V6S_M.  */
+      -1,              /* V7E_M.  */
+      -1,              /* V8.  */
+      -1,
+      T(V8M_BASE),     /* V8-M BASELINE.  */
+    };
+  const int v8m_mainline[] =
+    {
+      -1,              /* PRE_V4.  */
+      -1,              /* V4.  */
+      -1,              /* V4T.  */
+      -1,              /* V5T.  */
+      -1,              /* V5TE.  */
+      -1,              /* V5TEJ.  */
+      -1,              /* V6.  */
+      -1,              /* V6KZ.  */
+      -1,              /* V6T2.  */
+      -1,              /* V6K.  */
+      T(V8M_MAIN),     /* V7.  */
+      T(V8M_MAIN),     /* V6_M.  */
+      T(V8M_MAIN),     /* V6S_M.  */
+      T(V8M_MAIN),     /* V7E_M.  */
+      -1,              /* V8.  */
+      -1,
+      T(V8M_MAIN),     /* V8-M BASELINE.  */
+      T(V8M_MAIN),     /* V8-M MAINLINE.  */
+    };
   const int v4t_plus_v6_m[] =
     {
       -1,              /* PRE_V4.  */
@@ -12203,7 +12234,9 @@ tag_cpu_arch_combine (bfd *ibfd, int oldtag, int *secondary_compat_out,
       T(V6S_M),                /* V6S_M.  */
       T(V7E_M),                /* V7E_M.  */
       T(V8),           /* V8.  */
-      T(V4T_PLUS_V6_M) /* V4T plus V6_M.  */
+      T(V4T_PLUS_V6_M),        /* V4T plus V6_M.  */
+      -1,              /* V8-M BASELINE.  */
+      -1               /* V8-M MAINLINE.  */
     };
   const int *comb[] =
     {
@@ -12214,8 +12247,9 @@ tag_cpu_arch_combine (bfd *ibfd, int oldtag, int *secondary_compat_out,
       v6s_m,
       v7e_m,
       v8,
-      /* Pseudo-architecture.  */
-      v4t_plus_v6_m
+      v4t_plus_v6_m, /* Pseudo-architecture.  */
+      v8m_baseline,
+      v8m_mainline,
     };
 
   /* Check we've not got a higher architecture than we know about.  */
@@ -12429,7 +12463,10 @@ elf32_arm_merge_eabi_attributes (bfd *ibfd, bfd *obfd)
                "ARM v7",
                "ARM v6-M",
                "ARM v6S-M",
-               "ARM v8"
+               "ARM v8",
+               "",
+               "ARM v8-M.baseline",
+               "ARM v8-M.mainline",
            };
 
            /* Merge Tag_CPU_arch and Tag_also_compatible_with.  */
index 1d9b1c83f4b8f961d0397672ccca705d016e3e52..14b74030fbf2994785e305ab01531f538276f41e 100644 (file)
@@ -370,6 +370,15 @@ set armeabitests_common {
      {"EABI attribute merging 7" "-r" "" "" {attr-merge-7a.s attr-merge-7b.s}
       {{readelf -A attr-merge-7.attr}}
       "attr-merge-7"}
+     {"EABI attribute merging 8" "-r" "" "" {attr-merge-8a.s attr-merge-8b.s}
+      {{readelf -A attr-merge-8.attr}}
+      "attr-merge-8"}
+     {"EABI attribute merging 9" "-r" "" "" {attr-merge-9a.s attr-merge-9b.s}
+      {{ld attr-merge-9.out}}
+      "attr-merge-9"}
+     {"EABI attribute merging 10" "-r" "" "" {attr-merge-10a.s attr-merge-10b.s}
+      {{readelf -A attr-merge-10.attr}}
+      "attr-merge-10"}
      {"EABI attribute arch merging 1" "-r" "" "" {arch-v6k.s arch-v6t2.s}
       {{readelf -A attr-merge-arch-1.attr}}
       "attr-merge-arch-1"}
@@ -433,6 +442,12 @@ set armeabitests_nonacl {
     {"Thumb-Thumb farcall M profile" "-Ttext 0x1000 --section-start .foo=0x2001014" "" "-march=armv7-m" {farcall-thumb-thumb.s}
      {{objdump -d farcall-thumb-thumb-m.d}}
      "farcall-thumb-thumb-m"}
+    {"Thumb-Thumb farcall v8-M Baseline" "-Ttext 0x1000 --section-start .foo=0x2001014" "" "-march=armv8-m.base" {farcall-thumb-thumb.s}
+     {{objdump -d farcall-thumb-thumb-m.d}}
+     "farcall-thumb-thumb-v8-m-base"}
+    {"Thumb-Thumb farcall v8-M Mainline" "-Ttext 0x1000 --section-start .foo=0x2001014" "" "-march=armv8-m.main" {farcall-thumb-thumb.s}
+     {{objdump -d farcall-thumb-thumb-m.d}}
+     "farcall-thumb-thumb-v8-m-main"}
     {"Thumb-Thumb farcall v6-M" "-Ttext 0x1000 --section-start .foo=0x2001014" "" "-march=armv6-m" {farcall-thumb-thumb.s}
      {{objdump -d farcall-thumb-thumb-m.d}}
      "farcall-thumb-thumb-v6-m"}
diff --git a/ld/testsuite/ld-arm/attr-merge-10.attr b/ld/testsuite/ld-arm/attr-merge-10.attr
new file mode 100644 (file)
index 0000000..3d4e82c
--- /dev/null
@@ -0,0 +1,6 @@
+Attribute Section: aeabi
+File Attributes
+  Tag_CPU_name: "8-M.MAIN"
+  Tag_CPU_arch: v8-M.mainline
+  Tag_CPU_arch_profile: Microcontroller
+  Tag_THUMB_ISA_use: Yes
diff --git a/ld/testsuite/ld-arm/attr-merge-10a.s b/ld/testsuite/ld-arm/attr-merge-10a.s
new file mode 100644 (file)
index 0000000..faff6bd
--- /dev/null
@@ -0,0 +1,5 @@
+       .arch armv8-m.base
+
+       @ Tag_CPU_arch & Tag_CPU_arch_profile = v8-M.BASE
+       .eabi_attribute Tag_CPU_arch, 16
+       .eabi_attribute Tag_CPU_arch_profile, 'M'
diff --git a/ld/testsuite/ld-arm/attr-merge-10b.s b/ld/testsuite/ld-arm/attr-merge-10b.s
new file mode 100644 (file)
index 0000000..68625d3
--- /dev/null
@@ -0,0 +1,5 @@
+       .arch armv8-m.main
+
+       @ Tag_CPU_arch & Tag_CPU_arch_profile = v8-M.MAIN
+       .eabi_attribute Tag_CPU_arch, 17
+       .eabi_attribute Tag_CPU_arch_profile, 'M'
diff --git a/ld/testsuite/ld-arm/attr-merge-8.attr b/ld/testsuite/ld-arm/attr-merge-8.attr
new file mode 100644 (file)
index 0000000..7f922ac
--- /dev/null
@@ -0,0 +1,6 @@
+Attribute Section: aeabi
+File Attributes
+  Tag_CPU_name: "8-M.BASE"
+  Tag_CPU_arch: v8-M.baseline
+  Tag_CPU_arch_profile: Microcontroller
+  Tag_THUMB_ISA_use: Yes
diff --git a/ld/testsuite/ld-arm/attr-merge-8a.s b/ld/testsuite/ld-arm/attr-merge-8a.s
new file mode 100644 (file)
index 0000000..fc5ea8b
--- /dev/null
@@ -0,0 +1,5 @@
+       .arch armv6-m
+
+       @ Tag_CPU_arch & Tag_CPU_arch_profile = v6-M
+       .eabi_attribute Tag_CPU_arch, 11
+       .eabi_attribute Tag_CPU_arch_profile, 'M'
diff --git a/ld/testsuite/ld-arm/attr-merge-8b.s b/ld/testsuite/ld-arm/attr-merge-8b.s
new file mode 100644 (file)
index 0000000..8ee553a
--- /dev/null
@@ -0,0 +1,5 @@
+       .arch armv8-m.base
+
+       @ Tag_CPU_arch & Tag_CPU_arch_profile = v8-M Baseline
+       .eabi_attribute Tag_CPU_arch, 16
+       .eabi_attribute Tag_CPU_arch_profile, 'M'
diff --git a/ld/testsuite/ld-arm/attr-merge-9.out b/ld/testsuite/ld-arm/attr-merge-9.out
new file mode 100644 (file)
index 0000000..bb09181
--- /dev/null
@@ -0,0 +1,2 @@
+.*: error: .*: Conflicting CPU architectures 10/16
+.*: failed to merge target specific data of file tmpdir/attr-merge-9b.o
diff --git a/ld/testsuite/ld-arm/attr-merge-9a.s b/ld/testsuite/ld-arm/attr-merge-9a.s
new file mode 100644 (file)
index 0000000..0e24017
--- /dev/null
@@ -0,0 +1,5 @@
+       .arch armv7-m
+
+       @ Tag_CPU_arch & Tag_CPU_arch_profile = v7-M
+       .eabi_attribute Tag_CPU_arch, 10
+       .eabi_attribute Tag_CPU_arch_profile, 'M'
diff --git a/ld/testsuite/ld-arm/attr-merge-9b.s b/ld/testsuite/ld-arm/attr-merge-9b.s
new file mode 100644 (file)
index 0000000..8ee553a
--- /dev/null
@@ -0,0 +1,5 @@
+       .arch armv8-m.base
+
+       @ Tag_CPU_arch & Tag_CPU_arch_profile = v8-M Baseline
+       .eabi_attribute Tag_CPU_arch, 16
+       .eabi_attribute Tag_CPU_arch_profile, 'M'