[ARC] Update merging attributes.
authorclaziss <claziss@synopsys.com>
Mon, 6 Aug 2018 13:41:32 +0000 (16:41 +0300)
committerClaudiu Zissulescu <claziss@gmail.com>
Mon, 6 Aug 2018 13:41:32 +0000 (16:41 +0300)
Some attributes were ignored during merging. Fix that, and add some
errors.

bfd/
2017-09-19  Claudiu Zissulescu <claziss@synopsys.com>

* elf32-arc.c (arc_elf_merge_attributes): Fix merge attributes.

ld/
2017-09-19  Claudiu Zissulescu <claziss@synopsys.com>

* testsuite/ld-arc/attr-merge-6.d: New file.
* testsuite/ld-arc/attr-merge-6a.s: Likewise.
* testsuite/ld-arc/attr-merge-6b.s: Likewise.
* testsuite/ld-arc/attr-merge-6bis.d: Likewise.

bfd/ChangeLog
bfd/elf32-arc.c
ld/ChangeLog
ld/testsuite/ld-arc/attr-merge-6.d [new file with mode: 0644]
ld/testsuite/ld-arc/attr-merge-6a.s [new file with mode: 0644]
ld/testsuite/ld-arc/attr-merge-6b.s [new file with mode: 0644]
ld/testsuite/ld-arc/attr-merge-6bis.d [new file with mode: 0644]

index 6b5481c2d459401771995c3b8362a5bd25b819b8..98f0f170161bea32eaf9dd2d034404a32d72def5 100644 (file)
@@ -1,3 +1,7 @@
+2018-08-06  Claudiu Zissulescu  <claziss@synopsys.com>
+
+       * elf32-arc.c (arc_elf_merge_attributes): Fix merge attributes.
+
 2018-08-06  Claudiu Zissulescu  <claziss@synopsys.com>
 
        * elf32-arc.c (arc_elf_merge_attributes): Handle
index aaa2c3b9907f30c2be5d4e5884ea4c2a9ef3a5d8..25c96663633dc379c9c24527cb92a026ed3f3401 100644 (file)
@@ -578,7 +578,6 @@ arc_elf_merge_attributes (bfd *ibfd, struct bfd_link_info *info)
   bfd_boolean result = TRUE;
   const char *sec_name = get_elf_backend_data (ibfd)->obj_attrs_section;
   char *tagname = NULL;
-  int offset = 0;
 
   /* Skip the linker stubs file.  This preserves previous behavior
      of accepting unknown attributes in the first input file - but
@@ -732,7 +731,12 @@ arc_elf_merge_attributes (bfd *ibfd, struct bfd_link_info *info)
            out_attr[i].i = in_attr[i].i;
          break;
 
+         /* The CPU name is given by the vendor, just choose an
+            existing one if missing or different.  There are no fail
+            criteria if they different or both missing.  */
        case Tag_ARC_CPU_name:
+         if (!out_attr[i].s && in_attr[i].s)
+           out_attr[i].s = _bfd_elf_attr_strdup (obfd, in_attr[i].s);
          break;
 
        case Tag_ARC_ABI_rf16:
@@ -764,7 +768,9 @@ arc_elf_merge_attributes (bfd *ibfd, struct bfd_link_info *info)
 
            BFD_ASSERT (in_attr[i].i < 3);
            BFD_ASSERT (out_attr[i].i < 3);
-           if (out_attr[i].i != 0 && in_attr[i].i != 0
+           if (out_attr[i].i == 0)
+             out_attr[i].i = in_attr[i].i;
+           else if (out_attr[i].i != 0 && in_attr[i].i != 0
                && out_attr[i].i != in_attr[i].i)
              {
                _bfd_error_handler
@@ -789,7 +795,9 @@ arc_elf_merge_attributes (bfd *ibfd, struct bfd_link_info *info)
          if (!tagname)
            tagname = "ABI exceptions";
 
-         if (out_attr[i].i != 0 && in_attr[i].i != 0
+         if (out_attr[i].i == 0)
+           out_attr[i].i = in_attr[i].i;
+         else if (out_attr[i].i != 0 && in_attr[i].i != 0
              && out_attr[i].i != in_attr[i].i)
            {
              _bfd_error_handler
index 04f19ce082aa33dcd563a7f654ae4598ff45ec8e..90efdd7f7c7d3c3053836e46403afb299ae4c31c 100644 (file)
@@ -1,3 +1,10 @@
+2018-08-06  Claudiu Zissulescu  <claziss@synopsys.com>
+
+       * testsuite/ld-arc/attr-merge-6.d: New file.
+       * testsuite/ld-arc/attr-merge-6a.s: Likewise.
+       * testsuite/ld-arc/attr-merge-6b.s: Likewise.
+       * testsuite/ld-arc/attr-merge-6bis.d: Likewise.
+
 2018-08-06  Claudiu Zissulescu  <claziss@synopsys.com>
 
        * testsuite/ld-arc/attr-merge-0.d: Update test.
diff --git a/ld/testsuite/ld-arc/attr-merge-6.d b/ld/testsuite/ld-arc/attr-merge-6.d
new file mode 100644 (file)
index 0000000..c90a503
--- /dev/null
@@ -0,0 +1,16 @@
+# source: attr-merge-6a.s
+# source: attr-merge-6b.s
+# as:
+# ld: -r
+# readelf: -A
+
+Attribute Section: ARC
+File Attributes
+  Tag_ARC_PCS_config: Bare metal/newlib
+  Tag_ARC_CPU_base: ARCEM
+  Tag_ARC_CPU_variation: Core2
+  Tag_ARC_CPU_name: "arcem"
+  Tag_ARC_ABI_osver: v4
+  Tag_ARC_ABI_sda: MWDT
+  Tag_ARC_ISA_config: "CD"
+  Tag_ARC_ATR_version: 1
diff --git a/ld/testsuite/ld-arc/attr-merge-6a.s b/ld/testsuite/ld-arc/attr-merge-6a.s
new file mode 100644 (file)
index 0000000..cbd4fb4
--- /dev/null
@@ -0,0 +1,9 @@
+# MWDT like attribute structure
+       .cpu EM
+       .arc_attribute  Tag_ARC_ATR_version, 1
+       .arc_attribute  Tag_ARC_ABI_sda, 1
+       .arc_attribute  Tag_ARC_ABI_enumsize, 0
+       .arc_attribute  Tag_ARC_CPU_variation, 1
+       .arc_attribute  Tag_ARC_ISA_mpy_option, 0
+       .arc_attribute  Tag_ARC_ABI_osver, 0
+       .arc_attribute  Tag_ARC_CPU_name, ""
diff --git a/ld/testsuite/ld-arc/attr-merge-6b.s b/ld/testsuite/ld-arc/attr-merge-6b.s
new file mode 100644 (file)
index 0000000..1e1392c
--- /dev/null
@@ -0,0 +1,8 @@
+#GCC like attribute structure
+       .cpu EM
+       .arc_attribute  Tag_ARC_PCS_config, 2
+       .arc_attribute  Tag_ARC_CPU_variation, 2
+       .arc_attribute  Tag_ARC_CPU_name, "arcem"
+       .arc_attribute  Tag_ARC_ABI_osver, 4
+       .arc_attribute  Tag_ARC_ISA_config, "CD"
+       .arc_attribute  Tag_ARC_ATR_version, 1
diff --git a/ld/testsuite/ld-arc/attr-merge-6bis.d b/ld/testsuite/ld-arc/attr-merge-6bis.d
new file mode 100644 (file)
index 0000000..795ac0d
--- /dev/null
@@ -0,0 +1,16 @@
+# source: attr-merge-6b.s
+# source: attr-merge-6a.s
+# as:
+# ld: -r
+# readelf: -A
+
+Attribute Section: ARC
+File Attributes
+  Tag_ARC_PCS_config: Bare metal/newlib
+  Tag_ARC_CPU_base: ARCEM
+  Tag_ARC_CPU_variation: Core2
+  Tag_ARC_CPU_name: "arcem"
+  Tag_ARC_ABI_osver: v4
+  Tag_ARC_ABI_sda: MWDT
+  Tag_ARC_ISA_config: "CD"
+  Tag_ARC_ATR_version: 1
This page took 0.054461 seconds and 4 git commands to generate.