From 34c8bcbae2e6ea0752c1ebe6e1282cc74a821957 Mon Sep 17 00:00:00 2001 From: Joseph Myers Date: Sat, 30 Jun 2007 00:03:40 +0000 Subject: [PATCH] bfd: * elf32-ppc.c (ppc_elf_merge_obj_attributes): New. (ppc_elf_merge_private_bfd_data): Call it. binutils: * readelf.c (display_power_gnu_attribute, process_power_specific): New. (process_arch_specific): Call process_power_specific. include/elf: * ppc.h (Tag_GNU_Power_ABI_FP): Define. ld/testsuite: * ld-powerpc/attr-gnu-4-0.s, ld-powerpc/attr-gnu-4-00.d, ld-powerpc/attr-gnu-4-01.d, ld-powerpc/attr-gnu-4-02.d, ld-powerpc/attr-gnu-4-1.s, ld-powerpc/attr-gnu-4-10.d, ld-powerpc/attr-gnu-4-11.d, ld-powerpc/attr-gnu-4-12.d, ld-powerpc/attr-gnu-4-13.d, ld-powerpc/attr-gnu-4-2.s, ld-powerpc/attr-gnu-4-20.d, ld-powerpc/attr-gnu-4-21.d, ld-powerpc/attr-gnu-4-22.d, ld-powerpc/attr-gnu-4-3.s, ld-powerpc/attr-gnu-4-31.d: New. * ld-powerpc/powerpc.exp: Run these new tests. --- bfd/ChangeLog | 5 ++ bfd/elf32-ppc.c | 59 ++++++++++++++++++++++++ binutils/ChangeLog | 6 +++ binutils/readelf.c | 61 +++++++++++++++++++++++++ include/elf/ChangeLog | 4 ++ include/elf/ppc.h | 11 +++++ ld/testsuite/ChangeLog | 12 +++++ ld/testsuite/ld-powerpc/attr-gnu-4-0.s | 1 + ld/testsuite/ld-powerpc/attr-gnu-4-00.d | 7 +++ ld/testsuite/ld-powerpc/attr-gnu-4-01.d | 10 ++++ ld/testsuite/ld-powerpc/attr-gnu-4-02.d | 10 ++++ ld/testsuite/ld-powerpc/attr-gnu-4-1.s | 1 + ld/testsuite/ld-powerpc/attr-gnu-4-10.d | 10 ++++ ld/testsuite/ld-powerpc/attr-gnu-4-11.d | 10 ++++ ld/testsuite/ld-powerpc/attr-gnu-4-12.d | 6 +++ ld/testsuite/ld-powerpc/attr-gnu-4-13.d | 6 +++ ld/testsuite/ld-powerpc/attr-gnu-4-2.s | 1 + ld/testsuite/ld-powerpc/attr-gnu-4-20.d | 10 ++++ ld/testsuite/ld-powerpc/attr-gnu-4-21.d | 6 +++ ld/testsuite/ld-powerpc/attr-gnu-4-22.d | 10 ++++ ld/testsuite/ld-powerpc/attr-gnu-4-3.s | 1 + ld/testsuite/ld-powerpc/attr-gnu-4-31.d | 6 +++ ld/testsuite/ld-powerpc/powerpc.exp | 12 +++++ 23 files changed, 265 insertions(+) create mode 100644 ld/testsuite/ld-powerpc/attr-gnu-4-0.s create mode 100644 ld/testsuite/ld-powerpc/attr-gnu-4-00.d create mode 100644 ld/testsuite/ld-powerpc/attr-gnu-4-01.d create mode 100644 ld/testsuite/ld-powerpc/attr-gnu-4-02.d create mode 100644 ld/testsuite/ld-powerpc/attr-gnu-4-1.s create mode 100644 ld/testsuite/ld-powerpc/attr-gnu-4-10.d create mode 100644 ld/testsuite/ld-powerpc/attr-gnu-4-11.d create mode 100644 ld/testsuite/ld-powerpc/attr-gnu-4-12.d create mode 100644 ld/testsuite/ld-powerpc/attr-gnu-4-13.d create mode 100644 ld/testsuite/ld-powerpc/attr-gnu-4-2.s create mode 100644 ld/testsuite/ld-powerpc/attr-gnu-4-20.d create mode 100644 ld/testsuite/ld-powerpc/attr-gnu-4-21.d create mode 100644 ld/testsuite/ld-powerpc/attr-gnu-4-22.d create mode 100644 ld/testsuite/ld-powerpc/attr-gnu-4-3.s create mode 100644 ld/testsuite/ld-powerpc/attr-gnu-4-31.d diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 92de3e5f403..bd2a82c2354 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,8 @@ +2007-06-29 Joseph Myers + + * elf32-ppc.c (ppc_elf_merge_obj_attributes): New. + (ppc_elf_merge_private_bfd_data): Call it. + 2007-06-29 Joseph Myers * elfxx-mips.c (mips_elf_merge_obj_attributes): New. diff --git a/bfd/elf32-ppc.c b/bfd/elf32-ppc.c index b84f0af2ad8..d67ad866a6f 100644 --- a/bfd/elf32-ppc.c +++ b/bfd/elf32-ppc.c @@ -3594,6 +3594,62 @@ ppc_elf_check_relocs (bfd *abfd, return TRUE; } + +/* Merge object attributes from IBFD into OBFD. Raise an error if + there are conflicting attributes. */ +static bfd_boolean +ppc_elf_merge_obj_attributes (bfd *ibfd, bfd *obfd) +{ + obj_attribute *in_attr; + obj_attribute *out_attr; + + if (!elf_known_obj_attributes_proc (obfd)[0].i) + { + /* This is the first object. Copy the attributes. */ + _bfd_elf_copy_obj_attributes (ibfd, obfd); + + /* Use the Tag_null value to indicate the attributes have been + initialized. */ + elf_known_obj_attributes_proc (obfd)[0].i = 1; + + return TRUE; + } + + /* 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) + { + 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) + ; + else if (out_attr[Tag_GNU_Power_ABI_FP].i == 1 + && in_attr[Tag_GNU_Power_ABI_FP].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) + _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) + _bfd_error_handler + (_("Warning: %B uses unknown floating point ABI %d"), ibfd, + in_attr[Tag_GNU_Power_ABI_FP].i); + else + _bfd_error_handler + (_("Warning: %B uses unknown floating point ABI %d"), obfd, + out_attr[Tag_GNU_Power_ABI_FP].i); + } + + /* Merge Tag_compatibility attributes and any common GNU ones. */ + _bfd_elf_merge_object_attributes (ibfd, obfd); + + return TRUE; +} + /* Merge backend specific data from an object file to the output object file when linking. */ @@ -3612,6 +3668,9 @@ ppc_elf_merge_private_bfd_data (bfd *ibfd, bfd *obfd) if (! _bfd_generic_verify_endian_match (ibfd, obfd)) return FALSE; + if (!ppc_elf_merge_obj_attributes (ibfd, obfd)) + return FALSE; + new_flags = elf_elfheader (ibfd)->e_flags; old_flags = elf_elfheader (obfd)->e_flags; if (!elf_flags_init (obfd)) diff --git a/binutils/ChangeLog b/binutils/ChangeLog index 76e0b682e62..4096ba29a9a 100644 --- a/binutils/ChangeLog +++ b/binutils/ChangeLog @@ -1,3 +1,9 @@ +2007-06-29 Joseph Myers + + * readelf.c (display_power_gnu_attribute, process_power_specific): + New. + (process_arch_specific): Call process_power_specific. + 2007-06-29 Joseph Myers * readelf.c (display_mips_gnu_attribute): New. diff --git a/binutils/readelf.c b/binutils/readelf.c index c20fcd6e525..ab41e28828b 100644 --- a/binutils/readelf.c +++ b/binutils/readelf.c @@ -8346,6 +8346,57 @@ display_gnu_attribute (unsigned char *p, return p; } +static unsigned char * +display_power_gnu_attribute (unsigned char *p, int tag) +{ + int type; + unsigned int len; + int val; + + if (tag == Tag_GNU_Power_ABI_FP) + { + val = read_uleb128 (p, &len); + p += len; + printf (" Tag_GNU_Power_ABI_FP: "); + switch (val) + { + case 0: + printf ("Hard or soft float\n"); + break; + case 1: + printf ("Hard float\n"); + break; + case 2: + printf ("Soft float\n"); + break; + default: + printf ("??? (%d)\n", val); + break; + } + return p; + } + + if (tag & 1) + type = 1; /* String. */ + else + type = 2; /* uleb128. */ + printf (" Tag_unknown_%d: ", tag); + + if (type == 1) + { + printf ("\"%s\"\n", p); + p += strlen ((char *)p) + 1; + } + else + { + val = read_uleb128 (p, &len); + p += len; + printf ("%d (0x%x)\n", val, val); + } + + return p; +} + static unsigned char * display_mips_gnu_attribute (unsigned char *p, int tag) { @@ -8539,6 +8590,13 @@ process_arm_specific (FILE *file) display_arm_attribute, NULL); } +static int +process_power_specific (FILE *file) +{ + return process_attributes (file, NULL, SHT_GNU_ATTRIBUTES, NULL, + display_power_gnu_attribute); +} + static int process_mips_specific (FILE *file) { @@ -9317,6 +9375,9 @@ process_arch_specific (FILE *file) case EM_MIPS_RS3_LE: return process_mips_specific (file); break; + case EM_PPC: + return process_power_specific (file); + break; default: break; } diff --git a/include/elf/ChangeLog b/include/elf/ChangeLog index d690ad47499..ba08331c4c0 100644 --- a/include/elf/ChangeLog +++ b/include/elf/ChangeLog @@ -1,3 +1,7 @@ +2007-06-29 Joseph Myers + + * ppc.h (Tag_GNU_Power_ABI_FP): Define. + 2007-06-29 Joseph Myers * mips.h (Tag_GNU_MIPS_ABI_FP): Define. diff --git a/include/elf/ppc.h b/include/elf/ppc.h index ca5035274d9..fe48814d86f 100644 --- a/include/elf/ppc.h +++ b/include/elf/ppc.h @@ -171,4 +171,15 @@ END_RELOC_NUMBERS (R_PPC_max) builds when those objects \ are not to be furhter \ relocated. */ + +/* Object attribute tags. */ +enum +{ + /* 0-3 are generic. */ + Tag_GNU_Power_ABI_FP = 4, /* Value 1 for hard-float, 2 for + soft-float; 0 for not tagged or not + using any ABIs affected by the + differences. */ +}; + #endif /* _ELF_PPC_H */ diff --git a/ld/testsuite/ChangeLog b/ld/testsuite/ChangeLog index 5271fcfa556..28099e90191 100644 --- a/ld/testsuite/ChangeLog +++ b/ld/testsuite/ChangeLog @@ -1,3 +1,15 @@ +2007-06-29 Joseph Myers + + * ld-powerpc/attr-gnu-4-0.s, ld-powerpc/attr-gnu-4-00.d, + ld-powerpc/attr-gnu-4-01.d, ld-powerpc/attr-gnu-4-02.d, + ld-powerpc/attr-gnu-4-1.s, ld-powerpc/attr-gnu-4-10.d, + ld-powerpc/attr-gnu-4-11.d, ld-powerpc/attr-gnu-4-12.d, + ld-powerpc/attr-gnu-4-13.d, ld-powerpc/attr-gnu-4-2.s, + ld-powerpc/attr-gnu-4-20.d, ld-powerpc/attr-gnu-4-21.d, + ld-powerpc/attr-gnu-4-22.d, ld-powerpc/attr-gnu-4-3.s, + ld-powerpc/attr-gnu-4-31.d: New. + * ld-powerpc/powerpc.exp: Run these new tests. + 2007-06-29 Joseph Myers * ld-mips-elf/attr-gnu-4-0.s, ld-mips-elf/attr-gnu-4-00.d, diff --git a/ld/testsuite/ld-powerpc/attr-gnu-4-0.s b/ld/testsuite/ld-powerpc/attr-gnu-4-0.s new file mode 100644 index 00000000000..a1437461d04 --- /dev/null +++ b/ld/testsuite/ld-powerpc/attr-gnu-4-0.s @@ -0,0 +1 @@ +.gnu_attribute 4,0 diff --git a/ld/testsuite/ld-powerpc/attr-gnu-4-00.d b/ld/testsuite/ld-powerpc/attr-gnu-4-00.d new file mode 100644 index 00000000000..a4751a13766 --- /dev/null +++ b/ld/testsuite/ld-powerpc/attr-gnu-4-00.d @@ -0,0 +1,7 @@ +#source: attr-gnu-4-0.s +#source: attr-gnu-4-0.s +#as: -a32 +#ld: -r -melf32ppc +#readelf: -A +#target: powerpc*-*-* + diff --git a/ld/testsuite/ld-powerpc/attr-gnu-4-01.d b/ld/testsuite/ld-powerpc/attr-gnu-4-01.d new file mode 100644 index 00000000000..212e0c46f0c --- /dev/null +++ b/ld/testsuite/ld-powerpc/attr-gnu-4-01.d @@ -0,0 +1,10 @@ +#source: attr-gnu-4-0.s +#source: attr-gnu-4-1.s +#as: -a32 +#ld: -r -melf32ppc +#readelf: -A +#target: powerpc*-*-* + +Attribute Section: gnu +File Attributes + Tag_GNU_Power_ABI_FP: Hard float diff --git a/ld/testsuite/ld-powerpc/attr-gnu-4-02.d b/ld/testsuite/ld-powerpc/attr-gnu-4-02.d new file mode 100644 index 00000000000..9bd42b59ba6 --- /dev/null +++ b/ld/testsuite/ld-powerpc/attr-gnu-4-02.d @@ -0,0 +1,10 @@ +#source: attr-gnu-4-0.s +#source: attr-gnu-4-2.s +#as: -a32 +#ld: -r -melf32ppc +#readelf: -A +#target: powerpc*-*-* + +Attribute Section: gnu +File Attributes + Tag_GNU_Power_ABI_FP: Soft float diff --git a/ld/testsuite/ld-powerpc/attr-gnu-4-1.s b/ld/testsuite/ld-powerpc/attr-gnu-4-1.s new file mode 100644 index 00000000000..e985a56f6b1 --- /dev/null +++ b/ld/testsuite/ld-powerpc/attr-gnu-4-1.s @@ -0,0 +1 @@ +.gnu_attribute 4,1 diff --git a/ld/testsuite/ld-powerpc/attr-gnu-4-10.d b/ld/testsuite/ld-powerpc/attr-gnu-4-10.d new file mode 100644 index 00000000000..93297c20f1f --- /dev/null +++ b/ld/testsuite/ld-powerpc/attr-gnu-4-10.d @@ -0,0 +1,10 @@ +#source: attr-gnu-4-1.s +#source: attr-gnu-4-0.s +#as: -a32 +#ld: -r -melf32ppc +#readelf: -A +#target: powerpc*-*-* + +Attribute Section: gnu +File Attributes + Tag_GNU_Power_ABI_FP: Hard float diff --git a/ld/testsuite/ld-powerpc/attr-gnu-4-11.d b/ld/testsuite/ld-powerpc/attr-gnu-4-11.d new file mode 100644 index 00000000000..fb2b76e9571 --- /dev/null +++ b/ld/testsuite/ld-powerpc/attr-gnu-4-11.d @@ -0,0 +1,10 @@ +#source: attr-gnu-4-1.s +#source: attr-gnu-4-1.s +#as: -a32 +#ld: -r -melf32ppc +#readelf: -A +#target: powerpc*-*-* + +Attribute Section: gnu +File Attributes + Tag_GNU_Power_ABI_FP: Hard float diff --git a/ld/testsuite/ld-powerpc/attr-gnu-4-12.d b/ld/testsuite/ld-powerpc/attr-gnu-4-12.d new file mode 100644 index 00000000000..b7ffba0ff15 --- /dev/null +++ b/ld/testsuite/ld-powerpc/attr-gnu-4-12.d @@ -0,0 +1,6 @@ +#source: attr-gnu-4-1.s +#source: attr-gnu-4-2.s +#as: -a32 +#ld: -r -melf32ppc +#warning: Warning: .* uses hard float, .* uses soft float +#target: powerpc*-*-* diff --git a/ld/testsuite/ld-powerpc/attr-gnu-4-13.d b/ld/testsuite/ld-powerpc/attr-gnu-4-13.d new file mode 100644 index 00000000000..be1290e6570 --- /dev/null +++ b/ld/testsuite/ld-powerpc/attr-gnu-4-13.d @@ -0,0 +1,6 @@ +#source: attr-gnu-4-1.s +#source: attr-gnu-4-3.s +#as: -a32 +#ld: -r -melf32ppc +#warning: Warning: .* uses unknown floating point ABI 3 +#target: powerpc*-*-* diff --git a/ld/testsuite/ld-powerpc/attr-gnu-4-2.s b/ld/testsuite/ld-powerpc/attr-gnu-4-2.s new file mode 100644 index 00000000000..54ebf4ed8dd --- /dev/null +++ b/ld/testsuite/ld-powerpc/attr-gnu-4-2.s @@ -0,0 +1 @@ +.gnu_attribute 4,2 diff --git a/ld/testsuite/ld-powerpc/attr-gnu-4-20.d b/ld/testsuite/ld-powerpc/attr-gnu-4-20.d new file mode 100644 index 00000000000..3d838938020 --- /dev/null +++ b/ld/testsuite/ld-powerpc/attr-gnu-4-20.d @@ -0,0 +1,10 @@ +#source: attr-gnu-4-2.s +#source: attr-gnu-4-0.s +#as: -a32 +#ld: -r -melf32ppc +#readelf: -A +#target: powerpc*-*-* + +Attribute Section: gnu +File Attributes + Tag_GNU_Power_ABI_FP: Soft float diff --git a/ld/testsuite/ld-powerpc/attr-gnu-4-21.d b/ld/testsuite/ld-powerpc/attr-gnu-4-21.d new file mode 100644 index 00000000000..b38f24837be --- /dev/null +++ b/ld/testsuite/ld-powerpc/attr-gnu-4-21.d @@ -0,0 +1,6 @@ +#source: attr-gnu-4-2.s +#source: attr-gnu-4-1.s +#as: -a32 +#ld: -r -melf32ppc +#warning: Warning: .* uses hard float, .* uses soft float +#target: powerpc*-*-* diff --git a/ld/testsuite/ld-powerpc/attr-gnu-4-22.d b/ld/testsuite/ld-powerpc/attr-gnu-4-22.d new file mode 100644 index 00000000000..f6bd198efdf --- /dev/null +++ b/ld/testsuite/ld-powerpc/attr-gnu-4-22.d @@ -0,0 +1,10 @@ +#source: attr-gnu-4-2.s +#source: attr-gnu-4-2.s +#as: -a32 +#ld: -r -melf32ppc +#readelf: -A +#target: powerpc*-*-* + +Attribute Section: gnu +File Attributes + Tag_GNU_Power_ABI_FP: Soft float diff --git a/ld/testsuite/ld-powerpc/attr-gnu-4-3.s b/ld/testsuite/ld-powerpc/attr-gnu-4-3.s new file mode 100644 index 00000000000..32e5f5d1af4 --- /dev/null +++ b/ld/testsuite/ld-powerpc/attr-gnu-4-3.s @@ -0,0 +1 @@ +.gnu_attribute 4,3 diff --git a/ld/testsuite/ld-powerpc/attr-gnu-4-31.d b/ld/testsuite/ld-powerpc/attr-gnu-4-31.d new file mode 100644 index 00000000000..9cf8f4f5930 --- /dev/null +++ b/ld/testsuite/ld-powerpc/attr-gnu-4-31.d @@ -0,0 +1,6 @@ +#source: attr-gnu-4-3.s +#source: attr-gnu-4-1.s +#as: -a32 +#ld: -r -melf32ppc +#warning: Warning: .* uses unknown floating point ABI 3 +#target: powerpc*-*-* diff --git a/ld/testsuite/ld-powerpc/powerpc.exp b/ld/testsuite/ld-powerpc/powerpc.exp index 927c4b83452..ad224b09a94 100644 --- a/ld/testsuite/ld-powerpc/powerpc.exp +++ b/ld/testsuite/ld-powerpc/powerpc.exp @@ -147,3 +147,15 @@ if [ supports_ppc64 ] then { } run_dump_test "plt1" + +run_dump_test "attr-gnu-4-00" +run_dump_test "attr-gnu-4-01" +run_dump_test "attr-gnu-4-02" +run_dump_test "attr-gnu-4-10" +run_dump_test "attr-gnu-4-11" +run_dump_test "attr-gnu-4-12" +run_dump_test "attr-gnu-4-13" +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" -- 2.30.2