* elfxx-mips.c (mips_elf_merge_obj_attributes): New.
	(_bfd_mips_elf_merge_private_bfd_data): Call it.

binutils:
	* readelf.c (display_mips_gnu_attribute): New.
	(process_mips_specific): Call process_attributes.

include/elf:
	* mips.h (Tag_GNU_MIPS_ABI_FP): Define.

ld/testsuite:
	* 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.
This commit is contained in:
Joseph Myers 2007-06-29 16:41:32 +00:00
parent 104d59d19c
commit 2cf19d5cb9
31 changed files with 376 additions and 0 deletions

View File

@ -1,3 +1,8 @@
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.

View File

@ -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;

View File

@ -1,3 +1,8 @@
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.

View File

@ -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. */

View File

@ -1,3 +1,7 @@
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,

View File

@ -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 */

View File

@ -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.

View File

@ -0,0 +1 @@
.gnu_attribute 4,0

View File

@ -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*-*-*

View File

@ -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\)

View File

@ -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\)

View File

@ -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

View File

@ -0,0 +1 @@
.gnu_attribute 4,1

View File

@ -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\)

View File

@ -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\)

View File

@ -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*-*-*

View File

@ -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*-*-*

View File

@ -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*-*-*

View File

@ -0,0 +1 @@
.gnu_attribute 4,2

View File

@ -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\)

View File

@ -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*-*-*

View File

@ -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\)

View File

@ -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*-*-*

View File

@ -0,0 +1 @@
.gnu_attribute 4,3

View File

@ -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

View File

@ -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*-*-*

View File

@ -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*-*-*

View File

@ -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

View File

@ -0,0 +1 @@
.gnu_attribute 4,4

View File

@ -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*-*-*

View File

@ -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"