aboutsummaryrefslogtreecommitdiff
path: root/bfd
diff options
context:
space:
mode:
authorAndrew Stubbs <andrew.stubbs@st.com>2009-01-19 12:14:05 +0000
committerAndrew Stubbs <andrew.stubbs@st.com>2009-01-19 12:14:05 +0000
commit5aa6ff7ca4d5209dece43cf89fa5750f5dcaa033 (patch)
treeaf1aaeae14e0dbe24962fe72cd800af96678760b /bfd
parent3483fe2e0bd83ee8dba72f73c6a309cae2d75e7e (diff)
downloadgdb-5aa6ff7ca4d5209dece43cf89fa5750f5dcaa033.zip
gdb-5aa6ff7ca4d5209dece43cf89fa5750f5dcaa033.tar.gz
gdb-5aa6ff7ca4d5209dece43cf89fa5750f5dcaa033.tar.bz2
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.
Diffstat (limited to 'bfd')
-rw-r--r--bfd/ChangeLog9
-rw-r--r--bfd/elf-attrs.c7
-rw-r--r--bfd/elf-bfd.h6
-rw-r--r--bfd/elf32-arm.c19
-rw-r--r--bfd/elfxx-target.h4
5 files changed, 44 insertions, 1 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 65300c1..c2cc5e3 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,5 +1,14 @@
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.
diff --git a/bfd/elf-attrs.c b/bfd/elf-attrs.c
index 1e8076b..e60053b 100644
--- a/bfd/elf-attrs.c
+++ b/bfd/elf-attrs.c
@@ -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;
diff --git a/bfd/elf-bfd.h b/bfd/elf-bfd.h
index c0d8c8a..35dc018 100644
--- a/bfd/elf-bfd.h
+++ b/bfd/elf-bfd.h
@@ -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
diff --git a/bfd/elf32-arm.c b/bfd/elf32-arm.c
index bf1f06f..5fdd138 100644
--- a/bfd/elf32-arm.c
+++ b/bfd/elf32-arm.c
@@ -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"
diff --git a/bfd/elfxx-target.h b/bfd/elfxx-target.h
index 811dbf5..4aa8dd4 100644
--- a/bfd/elfxx-target.h
+++ b/bfd/elfxx-target.h
@@ -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,