diff options
31 files changed, 376 insertions, 0 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 051b530..92de3e5 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,5 +1,10 @@ 2007-06-29 Joseph Myers <joseph@codesourcery.com> + * elfxx-mips.c (mips_elf_merge_obj_attributes): New. + (_bfd_mips_elf_merge_private_bfd_data): Call it. + +2007-06-29 Joseph Myers <joseph@codesourcery.com> + * elf-attrs.c: New. * Makefile.am (BFD32_BACKENDS): Add elf-attrs.lo. (BFD32_BACKENDS_CFILES): Add elf-attrs.c. diff --git a/bfd/elfxx-mips.c b/bfd/elfxx-mips.c index dafd607..d368d41 100644 --- a/bfd/elfxx-mips.c +++ b/bfd/elfxx-mips.c @@ -10960,6 +10960,112 @@ mips_32bit_flags_p (flagword flags) } +/* Merge object attributes from IBFD into OBFD. Raise an error if + there are conflicting attributes. */ +static bfd_boolean +mips_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_MIPS_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_MIPS_ABI_FP].i != out_attr[Tag_GNU_MIPS_ABI_FP].i) + { + out_attr[Tag_GNU_MIPS_ABI_FP].type = 1; + if (out_attr[Tag_GNU_MIPS_ABI_FP].i == 0) + out_attr[Tag_GNU_MIPS_ABI_FP].i = in_attr[Tag_GNU_MIPS_ABI_FP].i; + else if (in_attr[Tag_GNU_MIPS_ABI_FP].i == 0) + ; + else if (in_attr[Tag_GNU_MIPS_ABI_FP].i > 3) + _bfd_error_handler + (_("Warning: %B uses unknown floating point ABI %d"), ibfd, + in_attr[Tag_GNU_MIPS_ABI_FP].i); + else if (out_attr[Tag_GNU_MIPS_ABI_FP].i > 3) + _bfd_error_handler + (_("Warning: %B uses unknown floating point ABI %d"), obfd, + out_attr[Tag_GNU_MIPS_ABI_FP].i); + else + switch (out_attr[Tag_GNU_MIPS_ABI_FP].i) + { + case 1: + switch (in_attr[Tag_GNU_MIPS_ABI_FP].i) + { + case 2: + _bfd_error_handler + (_("Warning: %B uses -msingle-float, %B uses -mdouble-float"), + obfd, ibfd); + + case 3: + _bfd_error_handler + (_("Warning: %B uses hard float, %B uses soft float"), + obfd, ibfd); + break; + + default: + abort (); + } + break; + + case 2: + switch (in_attr[Tag_GNU_MIPS_ABI_FP].i) + { + case 1: + _bfd_error_handler + (_("Warning: %B uses -msingle-float, %B uses -mdouble-float"), + ibfd, obfd); + + case 3: + _bfd_error_handler + (_("Warning: %B uses hard float, %B uses soft float"), + obfd, ibfd); + break; + + default: + abort (); + } + break; + + case 3: + switch (in_attr[Tag_GNU_MIPS_ABI_FP].i) + { + case 1: + case 2: + _bfd_error_handler + (_("Warning: %B uses hard float, %B uses soft float"), + ibfd, obfd); + break; + + default: + abort (); + } + break; + + default: + abort (); + } + } + + /* 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. */ @@ -10993,6 +11099,9 @@ _bfd_mips_elf_merge_private_bfd_data (bfd *ibfd, bfd *obfd) return FALSE; } + if (!mips_elf_merge_obj_attributes (ibfd, obfd)) + return FALSE; + new_flags = elf_elfheader (ibfd)->e_flags; elf_elfheader (obfd)->e_flags |= new_flags & EF_MIPS_NOREORDER; old_flags = elf_elfheader (obfd)->e_flags; diff --git a/binutils/ChangeLog b/binutils/ChangeLog index 2dfb51e..76e0b68 100644 --- a/binutils/ChangeLog +++ b/binutils/ChangeLog @@ -1,5 +1,10 @@ 2007-06-29 Joseph Myers <joseph@codesourcery.com> + * readelf.c (display_mips_gnu_attribute): New. + (process_mips_specific): Call process_attributes. + +2007-06-29 Joseph Myers <joseph@codesourcery.com> + * readelf.c (display_gnu_attribute): New. (process_arm_specific): Rearrange as process_attributes. (process_arm_specific): Replace by wrapper of process_attributes. diff --git a/binutils/readelf.c b/binutils/readelf.c index 1c4c715..c20fcd6 100644 --- a/binutils/readelf.c +++ b/binutils/readelf.c @@ -8346,6 +8346,60 @@ display_gnu_attribute (unsigned char *p, return p; } +static unsigned char * +display_mips_gnu_attribute (unsigned char *p, int tag) +{ + int type; + unsigned int len; + int val; + + if (tag == Tag_GNU_MIPS_ABI_FP) + { + val = read_uleb128 (p, &len); + p += len; + printf (" Tag_GNU_MIPS_ABI_FP: "); + switch (val) + { + case 0: + printf ("Hard or soft float\n"); + break; + case 1: + printf ("Hard float (-mdouble-float)\n"); + break; + case 2: + printf ("Hard float (-msingle-float)\n"); + break; + case 3: + 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 int process_attributes (FILE *file, const char *public_name, unsigned int proc_type, @@ -8495,6 +8549,9 @@ process_mips_specific (FILE *file) size_t options_offset = 0; size_t conflicts_offset = 0; + process_attributes (file, NULL, SHT_GNU_ATTRIBUTES, NULL, + display_mips_gnu_attribute); + /* We have a lot of special sections. Thanks SGI! */ if (dynamic_section == NULL) /* No information available. */ diff --git a/include/elf/ChangeLog b/include/elf/ChangeLog index d6fe54a..d690ad4 100644 --- a/include/elf/ChangeLog +++ b/include/elf/ChangeLog @@ -1,5 +1,9 @@ 2007-06-29 Joseph Myers <joseph@codesourcery.com> + * mips.h (Tag_GNU_MIPS_ABI_FP): Define. + +2007-06-29 Joseph Myers <joseph@codesourcery.com> + * arm.h (elf32_arm_add_eabi_attr_int, elf32_arm_add_eabi_attr_string, elf32_arm_add_eabi_attr_compat, elf32_arm_get_eabi_attr_int, elf32_arm_set_eabi_attr_contents, diff --git a/include/elf/mips.h b/include/elf/mips.h index c0d3eb1..4f60675 100644 --- a/include/elf/mips.h +++ b/include/elf/mips.h @@ -1006,4 +1006,15 @@ extern void bfd_mips_elf64_swap_reginfo_out #define OHWA0_R4KEOP_CLEAN 0x00000002 +/* Object attribute tags. */ +enum +{ + /* 0-3 are generic. */ + Tag_GNU_MIPS_ABI_FP = 4, /* Value 1 for hard-float -mdouble-float, 2 + for hard-float -msingle-float, 3 for + soft-float; 0 for not tagged or not + using any ABIs affected by the + differences. */ +}; + #endif /* _ELF_MIPS_H */ diff --git a/ld/testsuite/ChangeLog b/ld/testsuite/ChangeLog index cd4281d..5271fcf 100644 --- a/ld/testsuite/ChangeLog +++ b/ld/testsuite/ChangeLog @@ -1,3 +1,19 @@ +2007-06-29 Joseph Myers <joseph@codesourcery.com> + + * ld-mips-elf/attr-gnu-4-0.s, ld-mips-elf/attr-gnu-4-00.d, + ld-mips-elf/attr-gnu-4-01.d, ld-mips-elf/attr-gnu-4-02.d, + ld-mips-elf/attr-gnu-4-03.d, ld-mips-elf/attr-gnu-4-1.s, + ld-mips-elf/attr-gnu-4-10.d, ld-mips-elf/attr-gnu-4-11.d, + ld-mips-elf/attr-gnu-4-12.d, ld-mips-elf/attr-gnu-4-13.d, + ld-mips-elf/attr-gnu-4-14.d, ld-mips-elf/attr-gnu-4-2.s, + ld-mips-elf/attr-gnu-4-20.d, ld-mips-elf/attr-gnu-4-21.d, + ld-mips-elf/attr-gnu-4-22.d, ld-mips-elf/attr-gnu-4-23.d, + ld-mips-elf/attr-gnu-4-3.s, ld-mips-elf/attr-gnu-4-30.d, + ld-mips-elf/attr-gnu-4-31.d, ld-mips-elf/attr-gnu-4-32.d, + ld-mips-elf/attr-gnu-4-33.d, ld-mips-elf/attr-gnu-4-4.s, + ld-mips-elf/attr-gnu-4-41.d: New. + * ld-mips-elf/mips-elf.exp: Run these new tests. + 2007-06-29 Paul Brook <paul@codesourcery.com> * ld-arm/arm-elf.exp (armelftests): Add callweak. diff --git a/ld/testsuite/ld-mips-elf/attr-gnu-4-0.s b/ld/testsuite/ld-mips-elf/attr-gnu-4-0.s new file mode 100644 index 0000000..a143746 --- /dev/null +++ b/ld/testsuite/ld-mips-elf/attr-gnu-4-0.s @@ -0,0 +1 @@ +.gnu_attribute 4,0 diff --git a/ld/testsuite/ld-mips-elf/attr-gnu-4-00.d b/ld/testsuite/ld-mips-elf/attr-gnu-4-00.d new file mode 100644 index 0000000..cd95356 --- /dev/null +++ b/ld/testsuite/ld-mips-elf/attr-gnu-4-00.d @@ -0,0 +1,7 @@ +#source: attr-gnu-4-0.s +#source: attr-gnu-4-0.s +#as: -EB -32 +#ld: -r -melf32btsmip +#readelf: -A +#target: mips*-*-* + diff --git a/ld/testsuite/ld-mips-elf/attr-gnu-4-01.d b/ld/testsuite/ld-mips-elf/attr-gnu-4-01.d new file mode 100644 index 0000000..3e68405 --- /dev/null +++ b/ld/testsuite/ld-mips-elf/attr-gnu-4-01.d @@ -0,0 +1,10 @@ +#source: attr-gnu-4-0.s +#source: attr-gnu-4-1.s +#as: -EB -32 +#ld: -r -melf32btsmip +#readelf: -A +#target: mips*-*-* + +Attribute Section: gnu +File Attributes + Tag_GNU_MIPS_ABI_FP: Hard float \(-mdouble-float\) diff --git a/ld/testsuite/ld-mips-elf/attr-gnu-4-02.d b/ld/testsuite/ld-mips-elf/attr-gnu-4-02.d new file mode 100644 index 0000000..0641a85 --- /dev/null +++ b/ld/testsuite/ld-mips-elf/attr-gnu-4-02.d @@ -0,0 +1,10 @@ +#source: attr-gnu-4-0.s +#source: attr-gnu-4-2.s +#as: -EB -32 +#ld: -r -melf32btsmip +#readelf: -A +#target: mips*-*-* + +Attribute Section: gnu +File Attributes + Tag_GNU_MIPS_ABI_FP: Hard float \(-msingle-float\) diff --git a/ld/testsuite/ld-mips-elf/attr-gnu-4-03.d b/ld/testsuite/ld-mips-elf/attr-gnu-4-03.d new file mode 100644 index 0000000..64f03f5 --- /dev/null +++ b/ld/testsuite/ld-mips-elf/attr-gnu-4-03.d @@ -0,0 +1,10 @@ +#source: attr-gnu-4-0.s +#source: attr-gnu-4-3.s +#as: -EB -32 +#ld: -r -melf32btsmip +#readelf: -A +#target: mips*-*-* + +Attribute Section: gnu +File Attributes + Tag_GNU_MIPS_ABI_FP: Soft float diff --git a/ld/testsuite/ld-mips-elf/attr-gnu-4-1.s b/ld/testsuite/ld-mips-elf/attr-gnu-4-1.s new file mode 100644 index 0000000..e985a56 --- /dev/null +++ b/ld/testsuite/ld-mips-elf/attr-gnu-4-1.s @@ -0,0 +1 @@ +.gnu_attribute 4,1 diff --git a/ld/testsuite/ld-mips-elf/attr-gnu-4-10.d b/ld/testsuite/ld-mips-elf/attr-gnu-4-10.d new file mode 100644 index 0000000..d57dd96 --- /dev/null +++ b/ld/testsuite/ld-mips-elf/attr-gnu-4-10.d @@ -0,0 +1,10 @@ +#source: attr-gnu-4-1.s +#source: attr-gnu-4-0.s +#as: -EB -32 +#ld: -r -melf32btsmip +#readelf: -A +#target: mips*-*-* + +Attribute Section: gnu +File Attributes + Tag_GNU_MIPS_ABI_FP: Hard float \(-mdouble-float\) diff --git a/ld/testsuite/ld-mips-elf/attr-gnu-4-11.d b/ld/testsuite/ld-mips-elf/attr-gnu-4-11.d new file mode 100644 index 0000000..d694508 --- /dev/null +++ b/ld/testsuite/ld-mips-elf/attr-gnu-4-11.d @@ -0,0 +1,10 @@ +#source: attr-gnu-4-1.s +#source: attr-gnu-4-1.s +#as: -EB -32 +#ld: -r -melf32btsmip +#readelf: -A +#target: mips*-*-* + +Attribute Section: gnu +File Attributes + Tag_GNU_MIPS_ABI_FP: Hard float \(-mdouble-float\) diff --git a/ld/testsuite/ld-mips-elf/attr-gnu-4-12.d b/ld/testsuite/ld-mips-elf/attr-gnu-4-12.d new file mode 100644 index 0000000..3ee6025 --- /dev/null +++ b/ld/testsuite/ld-mips-elf/attr-gnu-4-12.d @@ -0,0 +1,6 @@ +#source: attr-gnu-4-1.s +#source: attr-gnu-4-2.s +#as: -EB -32 +#ld: -r -melf32btsmip +#warning: Warning: .* uses -msingle-float, .* uses -mdouble-float +#target: mips*-*-* diff --git a/ld/testsuite/ld-mips-elf/attr-gnu-4-13.d b/ld/testsuite/ld-mips-elf/attr-gnu-4-13.d new file mode 100644 index 0000000..a48c119 --- /dev/null +++ b/ld/testsuite/ld-mips-elf/attr-gnu-4-13.d @@ -0,0 +1,6 @@ +#source: attr-gnu-4-1.s +#source: attr-gnu-4-3.s +#as: -EB -32 +#ld: -r -melf32btsmip +#warning: Warning: .* uses hard float, .* uses soft float +#target: mips*-*-* diff --git a/ld/testsuite/ld-mips-elf/attr-gnu-4-14.d b/ld/testsuite/ld-mips-elf/attr-gnu-4-14.d new file mode 100644 index 0000000..7b15327 --- /dev/null +++ b/ld/testsuite/ld-mips-elf/attr-gnu-4-14.d @@ -0,0 +1,6 @@ +#source: attr-gnu-4-1.s +#source: attr-gnu-4-4.s +#as: -EB -32 +#ld: -r -melf32btsmip +#warning: Warning: .* uses unknown floating point ABI 4 +#target: mips*-*-* diff --git a/ld/testsuite/ld-mips-elf/attr-gnu-4-2.s b/ld/testsuite/ld-mips-elf/attr-gnu-4-2.s new file mode 100644 index 0000000..54ebf4e --- /dev/null +++ b/ld/testsuite/ld-mips-elf/attr-gnu-4-2.s @@ -0,0 +1 @@ +.gnu_attribute 4,2 diff --git a/ld/testsuite/ld-mips-elf/attr-gnu-4-20.d b/ld/testsuite/ld-mips-elf/attr-gnu-4-20.d new file mode 100644 index 0000000..7ea84ab --- /dev/null +++ b/ld/testsuite/ld-mips-elf/attr-gnu-4-20.d @@ -0,0 +1,10 @@ +#source: attr-gnu-4-2.s +#source: attr-gnu-4-0.s +#as: -EB -32 +#ld: -r -melf32btsmip +#readelf: -A +#target: mips*-*-* + +Attribute Section: gnu +File Attributes + Tag_GNU_MIPS_ABI_FP: Hard float \(-msingle-float\) diff --git a/ld/testsuite/ld-mips-elf/attr-gnu-4-21.d b/ld/testsuite/ld-mips-elf/attr-gnu-4-21.d new file mode 100644 index 0000000..3f84867 --- /dev/null +++ b/ld/testsuite/ld-mips-elf/attr-gnu-4-21.d @@ -0,0 +1,6 @@ +#source: attr-gnu-4-2.s +#source: attr-gnu-4-1.s +#as: -EB -32 +#ld: -r -melf32btsmip +#warning: Warning: .* uses -msingle-float, .* uses -mdouble-float +#target: mips*-*-* diff --git a/ld/testsuite/ld-mips-elf/attr-gnu-4-22.d b/ld/testsuite/ld-mips-elf/attr-gnu-4-22.d new file mode 100644 index 0000000..603e5c1 --- /dev/null +++ b/ld/testsuite/ld-mips-elf/attr-gnu-4-22.d @@ -0,0 +1,10 @@ +#source: attr-gnu-4-2.s +#source: attr-gnu-4-2.s +#as: -EB -32 +#ld: -r -melf32btsmip +#readelf: -A +#target: mips*-*-* + +Attribute Section: gnu +File Attributes + Tag_GNU_MIPS_ABI_FP: Hard float \(-msingle-float\) diff --git a/ld/testsuite/ld-mips-elf/attr-gnu-4-23.d b/ld/testsuite/ld-mips-elf/attr-gnu-4-23.d new file mode 100644 index 0000000..c0c14fd --- /dev/null +++ b/ld/testsuite/ld-mips-elf/attr-gnu-4-23.d @@ -0,0 +1,6 @@ +#source: attr-gnu-4-2.s +#source: attr-gnu-4-3.s +#as: -EB -32 +#ld: -r -melf32btsmip +#warning: Warning: .* uses hard float, .* uses soft float +#target: mips*-*-* diff --git a/ld/testsuite/ld-mips-elf/attr-gnu-4-3.s b/ld/testsuite/ld-mips-elf/attr-gnu-4-3.s new file mode 100644 index 0000000..32e5f5d --- /dev/null +++ b/ld/testsuite/ld-mips-elf/attr-gnu-4-3.s @@ -0,0 +1 @@ +.gnu_attribute 4,3 diff --git a/ld/testsuite/ld-mips-elf/attr-gnu-4-30.d b/ld/testsuite/ld-mips-elf/attr-gnu-4-30.d new file mode 100644 index 0000000..d123328 --- /dev/null +++ b/ld/testsuite/ld-mips-elf/attr-gnu-4-30.d @@ -0,0 +1,10 @@ +#source: attr-gnu-4-3.s +#source: attr-gnu-4-0.s +#as: -EB -32 +#ld: -r -melf32btsmip +#readelf: -A +#target: mips*-*-* + +Attribute Section: gnu +File Attributes + Tag_GNU_MIPS_ABI_FP: Soft float diff --git a/ld/testsuite/ld-mips-elf/attr-gnu-4-31.d b/ld/testsuite/ld-mips-elf/attr-gnu-4-31.d new file mode 100644 index 0000000..6a629e7 --- /dev/null +++ b/ld/testsuite/ld-mips-elf/attr-gnu-4-31.d @@ -0,0 +1,6 @@ +#source: attr-gnu-4-3.s +#source: attr-gnu-4-1.s +#as: -EB -32 +#ld: -r -melf32btsmip +#warning: Warning: .* uses hard float, .* uses soft float +#target: mips*-*-* diff --git a/ld/testsuite/ld-mips-elf/attr-gnu-4-32.d b/ld/testsuite/ld-mips-elf/attr-gnu-4-32.d new file mode 100644 index 0000000..824d467 --- /dev/null +++ b/ld/testsuite/ld-mips-elf/attr-gnu-4-32.d @@ -0,0 +1,6 @@ +#source: attr-gnu-4-3.s +#source: attr-gnu-4-2.s +#as: -EB -32 +#ld: -r -melf32btsmip +#warning: Warning: .* uses hard float, .* uses soft float +#target: mips*-*-* diff --git a/ld/testsuite/ld-mips-elf/attr-gnu-4-33.d b/ld/testsuite/ld-mips-elf/attr-gnu-4-33.d new file mode 100644 index 0000000..28d9d31 --- /dev/null +++ b/ld/testsuite/ld-mips-elf/attr-gnu-4-33.d @@ -0,0 +1,10 @@ +#source: attr-gnu-4-3.s +#source: attr-gnu-4-3.s +#as: -EB -32 +#ld: -r -melf32btsmip +#readelf: -A +#target: mips*-*-* + +Attribute Section: gnu +File Attributes + Tag_GNU_MIPS_ABI_FP: Soft float diff --git a/ld/testsuite/ld-mips-elf/attr-gnu-4-4.s b/ld/testsuite/ld-mips-elf/attr-gnu-4-4.s new file mode 100644 index 0000000..3ff129a --- /dev/null +++ b/ld/testsuite/ld-mips-elf/attr-gnu-4-4.s @@ -0,0 +1 @@ +.gnu_attribute 4,4 diff --git a/ld/testsuite/ld-mips-elf/attr-gnu-4-41.d b/ld/testsuite/ld-mips-elf/attr-gnu-4-41.d new file mode 100644 index 0000000..5fffe75 --- /dev/null +++ b/ld/testsuite/ld-mips-elf/attr-gnu-4-41.d @@ -0,0 +1,6 @@ +#source: attr-gnu-4-4.s +#source: attr-gnu-4-1.s +#as: -EB -32 +#ld: -r -melf32btsmip +#warning: Warning: .* uses unknown floating point ABI 4 +#target: mips*-*-* diff --git a/ld/testsuite/ld-mips-elf/mips-elf.exp b/ld/testsuite/ld-mips-elf/mips-elf.exp index eab8678..6e3e1a3 100644 --- a/ld/testsuite/ld-mips-elf/mips-elf.exp +++ b/ld/testsuite/ld-mips-elf/mips-elf.exp @@ -271,3 +271,22 @@ set mips16_intermix_test { run_ld_link_tests $mips16_intermix_test run_dump_test "mips16-local-stubs-1" + +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-03" +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-14" +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-23" +run_dump_test "attr-gnu-4-30" +run_dump_test "attr-gnu-4-31" +run_dump_test "attr-gnu-4-32" +run_dump_test "attr-gnu-4-33" +run_dump_test "attr-gnu-4-41" |