From c6e653525f8ea3235ab15b974cb9cf9ee686bf8e Mon Sep 17 00:00:00 2001 From: Daniel Jacobowitz Date: Thu, 25 Oct 2007 15:20:24 +0000 Subject: [PATCH] * elf32-ppc.c (ppc_elf_merge_obj_attributes): Add support for Tag_GNU_Power_ABI_Vector. * readelf.c (display_power_gnu_attribute): Add support for Tag_GNU_Power_ABI_Vector. * ppc.h (Tag_GNU_Power_ABI_Vector): New. * ld-powerpc/attr-gnu-8-1.s, ld-powerpc/attr-gnu-8-11.d, ld-powerpc/attr-gnu-8-2.s, ld-powerpc/attr-gnu-8-23.d, ld-powerpc/attr-gnu-8-3.s, ld-powerpc/attr-gnu-8-31.d: New. * ld-powerpc/powerpc.exp: Run new tests. --- bfd/ChangeLog | 5 ++ bfd/elf32-ppc.c | 83 ++++++++++++++++++++----- binutils/ChangeLog | 5 ++ binutils/readelf.c | 26 ++++++++ include/elf/ChangeLog | 4 ++ include/elf/ppc.h | 5 ++ ld/testsuite/ChangeLog | 7 +++ ld/testsuite/ld-powerpc/attr-gnu-8-1.s | 1 + ld/testsuite/ld-powerpc/attr-gnu-8-11.d | 10 +++ ld/testsuite/ld-powerpc/attr-gnu-8-2.s | 1 + ld/testsuite/ld-powerpc/attr-gnu-8-23.d | 6 ++ ld/testsuite/ld-powerpc/attr-gnu-8-3.s | 1 + ld/testsuite/ld-powerpc/attr-gnu-8-31.d | 10 +++ ld/testsuite/ld-powerpc/powerpc.exp | 4 ++ 14 files changed, 152 insertions(+), 16 deletions(-) create mode 100644 ld/testsuite/ld-powerpc/attr-gnu-8-1.s create mode 100644 ld/testsuite/ld-powerpc/attr-gnu-8-11.d create mode 100644 ld/testsuite/ld-powerpc/attr-gnu-8-2.s create mode 100644 ld/testsuite/ld-powerpc/attr-gnu-8-23.d create mode 100644 ld/testsuite/ld-powerpc/attr-gnu-8-3.s create mode 100644 ld/testsuite/ld-powerpc/attr-gnu-8-31.d diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 27f12d936cc..7034943990e 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,8 @@ +2007-10-25 Daniel Jacobowitz + + * elf32-ppc.c (ppc_elf_merge_obj_attributes): Add support for + Tag_GNU_Power_ABI_Vector. + 2007-10-25 Joseph Myers * elfxx-mips.c (_bfd_mips_elf_modify_segment_map): Do not add diff --git a/bfd/elf32-ppc.c b/bfd/elf32-ppc.c index 68804ad806c..a85544012d8 100644 --- a/bfd/elf32-ppc.c +++ b/bfd/elf32-ppc.c @@ -3603,8 +3603,8 @@ ppc_elf_check_relocs (bfd *abfd, static bfd_boolean ppc_elf_merge_obj_attributes (bfd *ibfd, bfd *obfd) { - obj_attribute *in_attr; - obj_attribute *out_attr; + obj_attribute *in_attr, *in_attrs; + obj_attribute *out_attr, *out_attrs; if (!elf_known_obj_attributes_proc (obfd)[0].i) { @@ -3618,33 +3618,84 @@ ppc_elf_merge_obj_attributes (bfd *ibfd, bfd *obfd) return TRUE; } + in_attrs = elf_known_obj_attributes (ibfd)[OBJ_ATTR_GNU]; + out_attrs = elf_known_obj_attributes (obfd)[OBJ_ATTR_GNU]; + /* Check for conflicting Tag_GNU_Power_ABI_FP attributes and merge non-conflicting ones. */ - in_attr = elf_known_obj_attributes (ibfd)[OBJ_ATTR_GNU]; - out_attr = elf_known_obj_attributes (obfd)[OBJ_ATTR_GNU]; - if (in_attr[Tag_GNU_Power_ABI_FP].i != out_attr[Tag_GNU_Power_ABI_FP].i) + in_attr = &in_attrs[Tag_GNU_Power_ABI_FP]; + out_attr = &out_attrs[Tag_GNU_Power_ABI_FP]; + if (in_attr->i != out_attr->i) { - out_attr[Tag_GNU_Power_ABI_FP].type = 1; - if (out_attr[Tag_GNU_Power_ABI_FP].i == 0) - out_attr[Tag_GNU_Power_ABI_FP].i = in_attr[Tag_GNU_Power_ABI_FP].i; - else if (in_attr[Tag_GNU_Power_ABI_FP].i == 0) + out_attr->type = 1; + if (out_attr->i == 0) + out_attr->i = in_attr->i; + else if (in_attr->i == 0) ; - else if (out_attr[Tag_GNU_Power_ABI_FP].i == 1 - && in_attr[Tag_GNU_Power_ABI_FP].i == 2) + else if (out_attr->i == 1 && in_attr->i == 2) _bfd_error_handler (_("Warning: %B uses hard float, %B uses soft float"), obfd, ibfd); - else if (out_attr[Tag_GNU_Power_ABI_FP].i == 2 - && in_attr[Tag_GNU_Power_ABI_FP].i == 1) + else if (out_attr->i == 2 && in_attr->i == 1) _bfd_error_handler (_("Warning: %B uses hard float, %B uses soft float"), ibfd, obfd); - else if (in_attr[Tag_GNU_Power_ABI_FP].i > 2) + else if (in_attr->i > 2) _bfd_error_handler (_("Warning: %B uses unknown floating point ABI %d"), ibfd, - in_attr[Tag_GNU_Power_ABI_FP].i); + in_attr->i); else _bfd_error_handler (_("Warning: %B uses unknown floating point ABI %d"), obfd, - out_attr[Tag_GNU_Power_ABI_FP].i); + out_attr->i); + } + + /* Check for conflicting Tag_GNU_Power_ABI_Vector attributes and + merge non-conflicting ones. */ + in_attr = &in_attrs[Tag_GNU_Power_ABI_Vector]; + out_attr = &out_attrs[Tag_GNU_Power_ABI_Vector]; + if (in_attr->i != out_attr->i) + { + const char *in_abi = NULL, *out_abi = NULL; + + switch (in_attr->i) + { + case 1: in_abi = "generic"; break; + case 2: in_abi = "AltiVec"; break; + case 3: in_abi = "SPE"; break; + } + + switch (out_attr->i) + { + case 1: out_abi = "generic"; break; + case 2: out_abi = "AltiVec"; break; + case 3: out_abi = "SPE"; break; + } + + out_attr->type = 1; + if (out_attr->i == 0) + out_attr->i = in_attr->i; + else if (in_attr->i == 0) + ; + /* For now, allow generic to transition to AltiVec or SPE + without a warning. If GCC marked files with their stack + alignment and used don't-care markings for files which are + not affected by the vector ABI, we could warn about this + case too. */ + else if (out_attr->i == 1) + out_attr->i = in_attr->i; + else if (in_attr->i == 1) + ; + else if (in_abi == NULL) + _bfd_error_handler + (_("Warning: %B uses unknown vector ABI %d"), ibfd, + in_attr->i); + else if (out_abi == NULL) + _bfd_error_handler + (_("Warning: %B uses unknown vector ABI %d"), obfd, + in_attr->i); + else + _bfd_error_handler + (_("Warning: %B uses vector ABI \"%s\", %B uses \"%s\""), + ibfd, obfd, in_abi, out_abi); } /* Merge Tag_compatibility attributes and any common GNU ones. */ diff --git a/binutils/ChangeLog b/binutils/ChangeLog index e9adcc49176..b4e8f6c619e 100644 --- a/binutils/ChangeLog +++ b/binutils/ChangeLog @@ -1,3 +1,8 @@ +2007-10-25 Daniel Jacobowitz + + * readelf.c (display_power_gnu_attribute): Add support for + Tag_GNU_Power_ABI_Vector. + 2007-10-25 Carlos Eduardo Seo * readelf.c (get_note_type): Handle NT_PPC_VMX. diff --git a/binutils/readelf.c b/binutils/readelf.c index abef69c1958..0ffc22b0513 100644 --- a/binutils/readelf.c +++ b/binutils/readelf.c @@ -8553,6 +8553,32 @@ display_power_gnu_attribute (unsigned char *p, int tag) return p; } + if (tag == Tag_GNU_Power_ABI_Vector) + { + val = read_uleb128 (p, &len); + p += len; + printf (" Tag_GNU_Power_ABI_Vector: "); + switch (val) + { + case 0: + printf ("Any\n"); + break; + case 1: + printf ("Generic\n"); + break; + case 2: + printf ("AltiVec\n"); + break; + case 3: + printf ("SPE\n"); + break; + default: + printf ("??? (%d)\n", val); + break; + } + return p; + } + if (tag & 1) type = 1; /* String. */ else diff --git a/include/elf/ChangeLog b/include/elf/ChangeLog index e8e12ac5092..a9a1e12fba8 100644 --- a/include/elf/ChangeLog +++ b/include/elf/ChangeLog @@ -1,3 +1,7 @@ +2007-10-25 Daniel Jacobowitz + + * ppc.h (Tag_GNU_Power_ABI_Vector): New. + 2007-10-19 Nick Clifton * mn10300.h: Add R_MN10300_SYM_DIFF reloc. diff --git a/include/elf/ppc.h b/include/elf/ppc.h index fe48814d86f..5d4462b0694 100644 --- a/include/elf/ppc.h +++ b/include/elf/ppc.h @@ -180,6 +180,11 @@ enum soft-float; 0 for not tagged or not using any ABIs affected by the differences. */ + + /* Value 1 for general purpose registers only, 2 for AltiVec + registers, 3 for SPE registers; 0 for not tagged or not using any + ABIs affected by the differences. */ + Tag_GNU_Power_ABI_Vector = 8, }; #endif /* _ELF_PPC_H */ diff --git a/ld/testsuite/ChangeLog b/ld/testsuite/ChangeLog index db664305f4e..ef2004b7c08 100644 --- a/ld/testsuite/ChangeLog +++ b/ld/testsuite/ChangeLog @@ -1,3 +1,10 @@ +2007-10-25 Daniel Jacobowitz + + * ld-powerpc/attr-gnu-8-1.s, ld-powerpc/attr-gnu-8-11.d, + ld-powerpc/attr-gnu-8-2.s, ld-powerpc/attr-gnu-8-23.d, + ld-powerpc/attr-gnu-8-3.s, ld-powerpc/attr-gnu-8-31.d: New. + * ld-powerpc/powerpc.exp: Run new tests. + 2007-10-19 Nick Clifton * ld-mn10300: New test directory. diff --git a/ld/testsuite/ld-powerpc/attr-gnu-8-1.s b/ld/testsuite/ld-powerpc/attr-gnu-8-1.s new file mode 100644 index 00000000000..81c7b7fb4e1 --- /dev/null +++ b/ld/testsuite/ld-powerpc/attr-gnu-8-1.s @@ -0,0 +1 @@ +.gnu_attribute 8,1 diff --git a/ld/testsuite/ld-powerpc/attr-gnu-8-11.d b/ld/testsuite/ld-powerpc/attr-gnu-8-11.d new file mode 100644 index 00000000000..7e49d4a7ef7 --- /dev/null +++ b/ld/testsuite/ld-powerpc/attr-gnu-8-11.d @@ -0,0 +1,10 @@ +#source: attr-gnu-8-1.s +#source: attr-gnu-8-1.s +#as: -a32 +#ld: -r -melf32ppc +#readelf: -A +#target: powerpc*-*-* + +Attribute Section: gnu +File Attributes + Tag_GNU_Power_ABI_Vector: Generic diff --git a/ld/testsuite/ld-powerpc/attr-gnu-8-2.s b/ld/testsuite/ld-powerpc/attr-gnu-8-2.s new file mode 100644 index 00000000000..0f18f5f7775 --- /dev/null +++ b/ld/testsuite/ld-powerpc/attr-gnu-8-2.s @@ -0,0 +1 @@ +.gnu_attribute 8,2 diff --git a/ld/testsuite/ld-powerpc/attr-gnu-8-23.d b/ld/testsuite/ld-powerpc/attr-gnu-8-23.d new file mode 100644 index 00000000000..b22e4bda3de --- /dev/null +++ b/ld/testsuite/ld-powerpc/attr-gnu-8-23.d @@ -0,0 +1,6 @@ +#source: attr-gnu-8-2.s +#source: attr-gnu-8-3.s +#as: -a32 +#ld: -r -melf32ppc +#warning: Warning: .* uses vector ABI "SPE", .* uses "AltiVec" +#target: powerpc*-*-* diff --git a/ld/testsuite/ld-powerpc/attr-gnu-8-3.s b/ld/testsuite/ld-powerpc/attr-gnu-8-3.s new file mode 100644 index 00000000000..6a1cf4e029b --- /dev/null +++ b/ld/testsuite/ld-powerpc/attr-gnu-8-3.s @@ -0,0 +1 @@ +.gnu_attribute 8,3 diff --git a/ld/testsuite/ld-powerpc/attr-gnu-8-31.d b/ld/testsuite/ld-powerpc/attr-gnu-8-31.d new file mode 100644 index 00000000000..53e8f997e4f --- /dev/null +++ b/ld/testsuite/ld-powerpc/attr-gnu-8-31.d @@ -0,0 +1,10 @@ +#source: attr-gnu-8-3.s +#source: attr-gnu-8-1.s +#as: -a32 +#ld: -r -melf32ppc +#readelf: -A +#target: powerpc*-*-* + +Attribute Section: gnu +File Attributes + Tag_GNU_Power_ABI_Vector: SPE diff --git a/ld/testsuite/ld-powerpc/powerpc.exp b/ld/testsuite/ld-powerpc/powerpc.exp index d65aa1adf8a..b1ad367a88c 100644 --- a/ld/testsuite/ld-powerpc/powerpc.exp +++ b/ld/testsuite/ld-powerpc/powerpc.exp @@ -165,3 +165,7 @@ run_dump_test "attr-gnu-4-20" run_dump_test "attr-gnu-4-21" run_dump_test "attr-gnu-4-22" run_dump_test "attr-gnu-4-31" + +run_dump_test "attr-gnu-8-11" +run_dump_test "attr-gnu-8-23" +run_dump_test "attr-gnu-8-31" -- 2.30.2