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.
(obj_attr_size): Likewise.
(write_obj_attribute): Likewise.
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;
/* 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
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. */
#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"
#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
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,
+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>
--- /dev/null
+# 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
--- /dev/null
+@ 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