2009-01-19 Andrew Stubbs <ams@codesourcery.com>

bfd/
	* elf-attrs.c (vendor_set_obj_attr_contents): Support tag ordering.
	* elf-bfd.h (elf_backend_data): Add obj_attrs_order.
	* elf32-arm.c (elf32_arm_obj_attrs_order): New function.
	(elf_backend_obj_attrs_order): New define.
	* elfxx-target.h (elf_backend_obj_attrs_order): New define.
	(elfNN_bed): Add elf_backend_obj_attrs_order.

	gas/testsuite/
	* gas/arm/attr-order.d: New file.
	* gas/arm/attr-order.s: New file.
This commit is contained in:
Andrew Stubbs 2009-01-19 12:14:05 +00:00
parent 3483fe2e0b
commit 5aa6ff7ca4
8 changed files with 73 additions and 1 deletions

View File

@ -1,3 +1,12 @@
2009-01-19 Andrew Stubbs <ams@codesourcery.com>
* elf-attrs.c (vendor_set_obj_attr_contents): Support tag ordering.
* elf-bfd.h (elf_backend_data): Add obj_attrs_order.
* elf32-arm.c (elf32_arm_obj_attrs_order): New function.
(elf_backend_obj_attrs_order): New define.
* elfxx-target.h (elf_backend_obj_attrs_order): New define.
(elfNN_bed): Add elf_backend_obj_attrs_order.
2009-01-19 Andrew Stubbs <ams@codesourcery.com>
* elf-attrs.c (is_default_attr): Substitute magic numbers with macros.

View File

@ -189,7 +189,12 @@ vendor_set_obj_attr_contents (bfd *abfd, bfd_byte *contents, bfd_vma size,
attr = elf_known_obj_attributes (abfd)[vendor];
for (i = 4; i < NUM_KNOWN_OBJ_ATTRIBUTES; i++)
p = write_obj_attribute (p, i, &attr[i]);
{
int tag = i;
if (get_elf_backend_data (abfd)->obj_attrs_order)
tag = get_elf_backend_data (abfd)->obj_attrs_order (i);
p = write_obj_attribute (p, tag, &attr[tag]);
}
for (list = elf_other_obj_attributes (abfd)[vendor];
list;

View File

@ -1167,6 +1167,12 @@ struct elf_backend_data
/* The section type to use for an attributes section. */
unsigned int obj_attrs_section_type;
/* This function determines the order in which any attributes are written.
It must be defined for input in the range 4..NUM_KNOWN_OBJ_ATTRIBUTES-1
(this range is used in order to make unity easy). The returned value is
the actual tag number to place in the input position. */
int (*obj_attrs_order) (int);
/* This is TRUE if the linker should act like collect and gather
global constructors and destructors by name. This is TRUE for
MIPS ELF because the Irix 5 tools can not handle the .init

View File

@ -8149,6 +8149,24 @@ elf32_arm_obj_attrs_arg_type (int tag)
return (tag & 1) != 0 ? ATTR_TYPE_FLAG_STR_VAL : ATTR_TYPE_FLAG_INT_VAL;
}
/* The ABI defines that Tag_conformance should be emitted first, and that
Tag_nodefaults should be second (if either is defined). This sets those
two positions, and bumps up the position of all the remaining tags to
compensate. */
static int
elf32_arm_obj_attrs_order (int num)
{
if (num == 4)
return Tag_conformance;
if (num == 5)
return Tag_nodefaults;
if ((num - 2) < Tag_nodefaults)
return num - 2;
if ((num - 1) < Tag_conformance)
return num - 1;
return num;
}
/* Read the architecture from the Tag_also_compatible_with attribute, if any.
Returns -1 if no architecture could be read. */
@ -12292,6 +12310,7 @@ const struct elf_size_info elf32_arm_size_info =
#define elf_backend_obj_attrs_arg_type elf32_arm_obj_attrs_arg_type
#undef elf_backend_obj_attrs_section_type
#define elf_backend_obj_attrs_section_type SHT_ARM_ATTRIBUTES
#define elf_backend_obj_attrs_order elf32_arm_obj_attrs_order
#include "elf32-target.h"

View File

@ -461,6 +461,9 @@
#ifndef elf_backend_obj_attrs_section_type
#define elf_backend_obj_attrs_section_type SHT_GNU_ATTRIBUTES
#endif
#ifndef elf_backend_obj_attrs_order
#define elf_backend_obj_attrs_order NULL
#endif
#ifndef elf_backend_post_process_headers
#define elf_backend_post_process_headers NULL
#endif
@ -720,6 +723,7 @@ static struct elf_backend_data elfNN_bed =
elf_backend_obj_attrs_section,
elf_backend_obj_attrs_arg_type,
elf_backend_obj_attrs_section_type,
elf_backend_obj_attrs_order,
elf_backend_collect,
elf_backend_type_change_ok,
elf_backend_may_use_rel_p,

View File

@ -1,3 +1,8 @@
2009-01-19 Andrew Stubbs <ams@codesourcery.com>
* gas/arm/attr-order.d: New file.
* gas/arm/attr-order.s: New file.
2009-01-16 Andrew Stubbs <ams@codesourcery.com>
Daniel Jacobowitz <dan@codesourcery.com>

View File

@ -0,0 +1,15 @@
# name: EABI attribute ordering
# source: attr-order.s
# as:
# readelf: -A
Attribute Section: aeabi
File Attributes
Tag_conformance: "2.07"
Tag_nodefaults: True
Tag_CPU_name: "ARM7TDMI"
Tag_CPU_arch: v4T
Tag_unknown_63: "val"
Tag_also_compatible_with: v6-M
Tag_T2EE_use: Allowed
Tag_Virtualization_use: Allowed

View File

@ -0,0 +1,9 @@
@ This test ensures that the following attributes
@ are emitted in the proper order.
.cpu arm7tdmi
.eabi_attribute 63, "val"
.eabi_attribute Tag_nodefaults, 0
.eabi_attribute Tag_also_compatible_with, "\006\013"
.eabi_attribute Tag_T2EE_use, 1
.eabi_attribute Tag_conformance, "2.07"
.eabi_attribute Tag_Virtualization_use, 1