diff options
author | Joseph Myers <joseph@codesourcery.com> | 2007-06-29 16:29:17 +0000 |
---|---|---|
committer | Joseph Myers <joseph@codesourcery.com> | 2007-06-29 16:29:17 +0000 |
commit | 104d59d19c416dcbf54fb387970b27178feb17d5 (patch) | |
tree | 90921bc1aa5b7bca865fdf8645f7b47502946c2f /bfd/elf32-arm.c | |
parent | 5ab79981933708d465b91676baf6994996979da8 (diff) | |
download | gdb-104d59d19c416dcbf54fb387970b27178feb17d5.zip gdb-104d59d19c416dcbf54fb387970b27178feb17d5.tar.gz gdb-104d59d19c416dcbf54fb387970b27178feb17d5.tar.bz2 |
bfd:
* elf-attrs.c: New.
* Makefile.am (BFD32_BACKENDS): Add elf-attrs.lo.
(BFD32_BACKENDS_CFILES): Add elf-attrs.c.
(elf-attrs.lo): Generate dependencies.
* Makefile.in: Regenerate.
* configure.in (elf): Add elf-attrs.lo.
* configure: Regenerate.
* elf-bfd.h (struct elf_backend_data): Add entries for object
attributes.
(NUM_KNOWN_OBJ_ATTRIBUTES, obj_attribute, obj_attribute_list,
OBJ_ATTR_PROC, OBJ_ATTR_GNU, OBJ_ATTR_FIRST, OBJ_ATTR_LAST,
Tag_NULL, Tag_File, Tag_Section, Tag_Symbol, Tag_compatibility):
New.
(struct elf_obj_tdata): Add entries for object attributes.
(elf_known_obj_attributes, elf_other_obj_attributes,
elf_known_obj_attributes_proc, elf_other_obj_attributes_proc):
New.
(bfd_elf_obj_attr_size, bfd_elf_set_obj_attr_contents,
bfd_elf_get_obj_attr_int, bfd_elf_add_obj_attr_int,
bfd_elf_add_proc_attr_int, bfd_elf_add_obj_attr_string,
bfd_elf_add_proc_attr_string, bfd_elf_add_obj_attr_compat,
bfd_elf_add_proc_attr_compat, _bfd_elf_attr_strdup,
_bfd_elf_copy_obj_attributes, _bfd_elf_obj_attrs_arg_type,
_bfd_elf_parse_attributes, _bfd_elf_merge_object_attributes): New.
* elf.c (_bfd_elf_copy_private_bfd_data): Copy object attributes.
(bfd_section_from_shdr): Handle attributes sections.
* elflink.c (bfd_elf_final_link): Handle attributes sections.
* elfxx-target.h (elf_backend_obj_attrs_vendor,
elf_backend_obj_attrs_section, elf_backend_obj_attrs_arg_type,
elf_backend_obj_attrs_section_type): New.
(elfNN_bed): Update.
* elf32-arm.c (NUM_KNOWN_ATTRIBUTES, aeabi_attribute,
aeabi_attribute_list): Remove.
(struct elf32_arm_obj_tdata): Remove object attributes fields.
(check_use_blx, bfd_elf32_arm_set_vfp11_fix, using_thumb2,
elf32_arm_copy_private_bfd_data, elf32_arm_merge_eabi_attributes):
Update for new object attributes interfaces.
(uleb128_size, is_default_attr, eabi_attr_size,
elf32_arm_eabi_attr_size, write_uleb128, write_eabi_attribute,
elf32_arm_set_eabi_attr_contents, elf32_arm_bfd_final_link,
elf32_arm_new_eabi_attr, elf32_arm_get_eabi_attr_int,
elf32_arm_add_eabi_attr_int, attr_strdup,
elf32_arm_add_eabi_attr_string, elf32_arm_add_eabi_attr_compat,
copy_eabi_attributes, elf32_arm_parse_attributes): Remove. Moved
to generic code in elf-attrs.c.
(elf32_arm_obj_attrs_arg_type): New.
(elf32_arm_fake_sections): Do not handle .ARM.attributes.
(elf32_arm_section_from_shdr): Do not handle SHT_ARM_ATTRIBUTES.
(bfd_elf32_bfd_final_link): Remove.
(elf_backend_obj_attrs_vendor, elf_backend_obj_attrs_section,
elf_backend_obj_attrs_arg_type,
elf_backend_obj_attrs_section_type): New.
* elf32-bfin.c (bfin_elf_copy_private_bfd_data): Copy object
attributes.
* elf32-frv.c (frv_elf_copy_private_bfd_data): Likewise.
* elf32-iq2000.c (iq2000_elf_copy_private_bfd_data): Likewise.
* elf32-mep.c (mep_elf_copy_private_bfd_data): Likewise.
* elf32-mt.c (mt_elf_copy_private_bfd_data): Likewise.
* elf32-sh.c (sh_elf_copy_private_data): Likewise.
* elf64-sh64.c (sh_elf64_copy_private_data_internal): Likewise.
binutils:
* readelf.c (display_gnu_attribute): New.
(process_arm_specific): Rearrange as process_attributes.
(process_arm_specific): Replace by wrapper of process_attributes.
gas:
* as.c (create_obj_attrs_section): New.
(main): Call create_obj_attrs_section for ELF.
* read.c (s_gnu_attribute, skip_whitespace, skip_past_char,
skip_past_comma, s_vendor_attribute): New.
(potable): Add gnu_attribute for ELF.
* read.h (s_vendor_attribute): Declare.
* config/tc-arm.c (s_arm_eabi_attribute): Replace by wrapper
round s_vendor_attribute.
(aeabi_set_public_attributes): Update for new attributes
interfaces.
(arm_md_end): Remove attributes contents setting now done
generically.
include/elf:
* 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,
elf32_arm_eabi_attr_size, Tag_NULL, Tag_File, Tag_Section,
Tag_Symbol, Tag_compatibility): Remove.
* common.h (SHT_GNU_ATTRIBUTES): Define.
ld:
* emulparams/armelf.sh (OTHER_SECTIONS): Remove .ARM.attributes.
(ATTRS_SECTIONS): Define.
* scripttempl/elf.sc, scripttempl/elf32sh-symbian.sc,
scripttempl/elf_chaos.sc, scripttempl/elfi370.sc,
scripttempl/elfxtensa.sc: Handle ATTRS_SECTIONS.
Diffstat (limited to 'bfd/elf32-arm.c')
-rw-r--r-- | bfd/elf32-arm.c | 610 |
1 files changed, 47 insertions, 563 deletions
diff --git a/bfd/elf32-arm.c b/bfd/elf32-arm.c index a213bab..85ed8d7 100644 --- a/bfd/elf32-arm.c +++ b/bfd/elf32-arm.c @@ -2064,22 +2064,6 @@ _arm_elf_section_data; /* The size of the thread control block. */ #define TCB_SIZE 8 -#define NUM_KNOWN_ATTRIBUTES 32 - -typedef struct aeabi_attribute -{ - int type; - unsigned int i; - char *s; -} aeabi_attribute; - -typedef struct aeabi_attribute_list -{ - struct aeabi_attribute_list *next; - int tag; - aeabi_attribute attr; -} aeabi_attribute_list; - struct elf32_arm_obj_tdata { struct elf_obj_tdata root; @@ -2087,9 +2071,6 @@ struct elf32_arm_obj_tdata /* tls_type for each local got entry. */ char *local_got_tls_type; - aeabi_attribute known_eabi_attributes[NUM_KNOWN_ATTRIBUTES]; - aeabi_attribute_list *other_eabi_attributes; - /* Zero to warn when linking objects with incompatible enum sizes. */ int no_enum_size_warning; }; @@ -3103,7 +3084,8 @@ bfd_elf32_arm_get_bfd_for_interworking (bfd *abfd, struct bfd_link_info *info) static void check_use_blx(struct elf32_arm_link_hash_table *globals) { - if (elf32_arm_get_eabi_attr_int (globals->obfd, Tag_CPU_arch) > 2) + if (bfd_elf_get_obj_attr_int (globals->obfd, OBJ_ATTR_PROC, + Tag_CPU_arch) > 2) globals->use_blx = 1; } @@ -3321,7 +3303,7 @@ void bfd_elf32_arm_set_vfp11_fix (bfd *obfd, struct bfd_link_info *link_info) { struct elf32_arm_link_hash_table *globals = elf32_arm_hash_table (link_info); - aeabi_attribute *out_attr = elf32_arm_tdata (obfd)->known_eabi_attributes; + obj_attribute *out_attr = elf_known_obj_attributes_proc (obfd); /* We assume that ARMv7+ does not need the VFP11 denorm erratum fix. */ if (out_attr[Tag_CPU_arch].i >= TAG_CPU_ARCH_V7) @@ -4488,7 +4470,8 @@ identify_add_or_sub(bfd_vma insn) static int using_thumb2 (struct elf32_arm_link_hash_table *globals) { - int arch = elf32_arm_get_eabi_attr_int (globals->obfd, Tag_CPU_arch); + int arch = bfd_elf_get_obj_attr_int (globals->obfd, OBJ_ATTR_PROC, + Tag_CPU_arch); return arch == TAG_CPU_ARCH_V6T2 || arch >= TAG_CPU_ARCH_V7; } @@ -6273,194 +6256,6 @@ elf32_arm_final_link_relocate (reloc_howto_type * howto, } } - -static int -uleb128_size (unsigned int i) -{ - int size; - size = 1; - while (i >= 0x80) - { - i >>= 7; - size++; - } - return size; -} - -/* Return TRUE if the attribute has the default value (0/""). */ -static bfd_boolean -is_default_attr (aeabi_attribute *attr) -{ - if ((attr->type & 1) && attr->i != 0) - return FALSE; - if ((attr->type & 2) && attr->s && *attr->s) - return FALSE; - - return TRUE; -} - -/* Return the size of a single attribute. */ -static bfd_vma -eabi_attr_size(int tag, aeabi_attribute *attr) -{ - bfd_vma size; - - if (is_default_attr (attr)) - return 0; - - size = uleb128_size (tag); - if (attr->type & 1) - size += uleb128_size (attr->i); - if (attr->type & 2) - size += strlen ((char *)attr->s) + 1; - return size; -} - -/* Returns the size of the eabi object attributess section. */ -bfd_vma -elf32_arm_eabi_attr_size (bfd *abfd) -{ - bfd_vma size; - aeabi_attribute *attr; - aeabi_attribute_list *list; - int i; - - attr = elf32_arm_tdata (abfd)->known_eabi_attributes; - size = 16; /* 'A' <size> "aeabi" 0x1 <size>. */ - for (i = 4; i < NUM_KNOWN_ATTRIBUTES; i++) - size += eabi_attr_size (i, &attr[i]); - - for (list = elf32_arm_tdata (abfd)->other_eabi_attributes; - list; - list = list->next) - size += eabi_attr_size (list->tag, &list->attr); - - return size; -} - -static bfd_byte * -write_uleb128 (bfd_byte *p, unsigned int val) -{ - bfd_byte c; - do - { - c = val & 0x7f; - val >>= 7; - if (val) - c |= 0x80; - *(p++) = c; - } - while (val); - return p; -} - -/* Write attribute ATTR to butter P, and return a pointer to the following - byte. */ -static bfd_byte * -write_eabi_attribute (bfd_byte *p, int tag, aeabi_attribute *attr) -{ - /* Suppress default entries. */ - if (is_default_attr(attr)) - return p; - - p = write_uleb128 (p, tag); - if (attr->type & 1) - p = write_uleb128 (p, attr->i); - if (attr->type & 2) - { - int len; - - len = strlen (attr->s) + 1; - memcpy (p, attr->s, len); - p += len; - } - - return p; -} - -/* Write the contents of the eabi attributes section to p. */ -void -elf32_arm_set_eabi_attr_contents (bfd *abfd, bfd_byte *contents, bfd_vma size) -{ - bfd_byte *p; - aeabi_attribute *attr; - aeabi_attribute_list *list; - int i; - - p = contents; - *(p++) = 'A'; - bfd_put_32 (abfd, size - 1, p); - p += 4; - memcpy (p, "aeabi", 6); - p += 6; - *(p++) = Tag_File; - bfd_put_32 (abfd, size - 11, p); - p += 4; - - attr = elf32_arm_tdata (abfd)->known_eabi_attributes; - for (i = 4; i < NUM_KNOWN_ATTRIBUTES; i++) - p = write_eabi_attribute (p, i, &attr[i]); - - for (list = elf32_arm_tdata (abfd)->other_eabi_attributes; - list; - list = list->next) - p = write_eabi_attribute (p, list->tag, &list->attr); -} - -/* Override final_link to handle EABI object attribute sections. */ - -static bfd_boolean -elf32_arm_bfd_final_link (bfd *abfd, struct bfd_link_info *info) -{ - asection *o; - struct bfd_link_order *p; - asection *attr_section = NULL; - bfd_byte *contents; - bfd_vma size = 0; - - /* elf32_arm_merge_private_bfd_data will already have merged the - object attributes. Remove the input sections from the link, and set - the contents of the output secton. */ - for (o = abfd->sections; o != NULL; o = o->next) - { - if (strcmp (o->name, ".ARM.attributes") == 0) - { - for (p = o->map_head.link_order; p != NULL; p = p->next) - { - asection *input_section; - - if (p->type != bfd_indirect_link_order) - continue; - input_section = p->u.indirect.section; - /* Hack: reset the SEC_HAS_CONTENTS flag so that - elf_link_input_bfd ignores this section. */ - input_section->flags &= ~SEC_HAS_CONTENTS; - } - - size = elf32_arm_eabi_attr_size (abfd); - bfd_set_section_size (abfd, o, size); - attr_section = o; - /* Skip this section later on. */ - o->map_head.link_order = NULL; - } - } - /* Invoke the ELF linker to do all the work. */ - if (!bfd_elf_final_link (abfd, info)) - return FALSE; - - if (attr_section) - { - contents = bfd_malloc(size); - if (contents == NULL) - return FALSE; - elf32_arm_set_eabi_attr_contents (abfd, contents, size); - bfd_set_section_contents (abfd, attr_section, contents, 0, size); - free (contents); - } - return TRUE; -} - - /* Add INCREMENT to the reloc (of type HOWTO) at ADDRESS. */ static void arm_add_to_rel (bfd * abfd, @@ -6795,130 +6590,6 @@ elf32_arm_relocate_section (bfd * output_bfd, return TRUE; } -/* Allocate/find an object attribute. */ -static aeabi_attribute * -elf32_arm_new_eabi_attr (bfd *abfd, int tag) -{ - aeabi_attribute *attr; - aeabi_attribute_list *list; - aeabi_attribute_list *p; - aeabi_attribute_list **lastp; - - - if (tag < NUM_KNOWN_ATTRIBUTES) - { - /* Knwon tags are preallocated. */ - attr = &elf32_arm_tdata (abfd)->known_eabi_attributes[tag]; - } - else - { - /* Create a new tag. */ - list = (aeabi_attribute_list *) - bfd_alloc (abfd, sizeof (aeabi_attribute_list)); - memset (list, 0, sizeof (aeabi_attribute_list)); - list->tag = tag; - /* Keep the tag list in order. */ - lastp = &elf32_arm_tdata (abfd)->other_eabi_attributes; - for (p = *lastp; p; p = p->next) - { - if (tag < p->tag) - break; - lastp = &p->next; - } - list->next = *lastp; - *lastp = list; - attr = &list->attr; - } - - return attr; -} - -int -elf32_arm_get_eabi_attr_int (bfd *abfd, int tag) -{ - aeabi_attribute_list *p; - - if (tag < NUM_KNOWN_ATTRIBUTES) - { - /* Knwon tags are preallocated. */ - return elf32_arm_tdata (abfd)->known_eabi_attributes[tag].i; - } - else - { - for (p = elf32_arm_tdata (abfd)->other_eabi_attributes; - p; - p = p->next) - { - if (tag == p->tag) - return p->attr.i; - if (tag < p->tag) - break; - } - return 0; - } -} - -void -elf32_arm_add_eabi_attr_int (bfd *abfd, int tag, unsigned int i) -{ - aeabi_attribute *attr; - - attr = elf32_arm_new_eabi_attr (abfd, tag); - attr->type = 1; - attr->i = i; -} - -static char * -attr_strdup (bfd *abfd, const char * s) -{ - char * p; - int len; - - len = strlen (s) + 1; - p = (char *)bfd_alloc(abfd, len); - return memcpy (p, s, len); -} - -void -elf32_arm_add_eabi_attr_string (bfd *abfd, int tag, const char *s) -{ - aeabi_attribute *attr; - - attr = elf32_arm_new_eabi_attr (abfd, tag); - attr->type = 2; - attr->s = attr_strdup (abfd, s); -} - -void -elf32_arm_add_eabi_attr_compat (bfd *abfd, unsigned int i, const char *s) -{ - aeabi_attribute_list *list; - aeabi_attribute_list *p; - aeabi_attribute_list **lastp; - - list = (aeabi_attribute_list *) - bfd_alloc (abfd, sizeof (aeabi_attribute_list)); - memset (list, 0, sizeof (aeabi_attribute_list)); - list->tag = Tag_compatibility; - list->attr.type = 3; - list->attr.i = i; - list->attr.s = attr_strdup (abfd, s); - - lastp = &elf32_arm_tdata (abfd)->other_eabi_attributes; - for (p = *lastp; p; p = p->next) - { - int cmp; - if (p->tag != Tag_compatibility) - break; - cmp = strcmp(s, p->attr.s); - if (cmp < 0 || (cmp == 0 && i < p->attr.i)) - break; - lastp = &p->next; - } - list->next = *lastp; - *lastp = list; -} - /* Set the right machine number. */ static bfd_boolean @@ -6969,50 +6640,6 @@ elf32_arm_set_private_flags (bfd *abfd, flagword flags) return TRUE; } -/* Copy the eabi object attribute from IBFD to OBFD. */ -static void -copy_eabi_attributes (bfd *ibfd, bfd *obfd) -{ - aeabi_attribute *in_attr; - aeabi_attribute *out_attr; - aeabi_attribute_list *list; - int i; - - in_attr = &elf32_arm_tdata (ibfd)->known_eabi_attributes[4]; - out_attr = &elf32_arm_tdata (obfd)->known_eabi_attributes[4]; - for (i = 4; i < NUM_KNOWN_ATTRIBUTES; i++) - { - out_attr->type = in_attr->type; - out_attr->i = in_attr->i; - if (in_attr->s && *in_attr->s) - out_attr->s = attr_strdup (obfd, in_attr->s); - in_attr++; - out_attr++; - } - - for (list = elf32_arm_tdata (ibfd)->other_eabi_attributes; - list; - list = list->next) - { - in_attr = &list->attr; - switch (in_attr->type) - { - case 1: - elf32_arm_add_eabi_attr_int (obfd, list->tag, in_attr->i); - break; - case 2: - elf32_arm_add_eabi_attr_string (obfd, list->tag, in_attr->s); - break; - case 3: - elf32_arm_add_eabi_attr_compat (obfd, in_attr->i, in_attr->s); - break; - default: - abort(); - } - } -} - - /* Copy backend specific data from one object module to another. */ static bfd_boolean @@ -7064,8 +6691,8 @@ elf32_arm_copy_private_bfd_data (bfd *ibfd, bfd *obfd) elf_elfheader (obfd)->e_ident[EI_OSABI] = elf_elfheader (ibfd)->e_ident[EI_OSABI]; - /* Copy EABI object attributes. */ - copy_eabi_attributes (ibfd, obfd); + /* Copy object attributes. */ + _bfd_elf_copy_obj_attributes (ibfd, obfd); return TRUE; } @@ -7097,34 +6724,48 @@ enum AEABI_enum_forced_wide }; +/* Determine whether an object attribute tag takes an integer, a + string or both. */ +static int +elf32_arm_obj_attrs_arg_type (int tag) +{ + if (tag == Tag_compatibility) + return 3; + else if (tag == 4 || tag == 5) + return 2; + else if (tag < 32) + return 1; + else + return (tag & 1) != 0 ? 2 : 1; +} + /* Merge EABI object attributes from IBFD into OBFD. Raise an error if there are conflicting attributes. */ static bfd_boolean elf32_arm_merge_eabi_attributes (bfd *ibfd, bfd *obfd) { - aeabi_attribute *in_attr; - aeabi_attribute *out_attr; - aeabi_attribute_list *in_list; - aeabi_attribute_list *out_list; + obj_attribute *in_attr; + obj_attribute *out_attr; + obj_attribute_list *in_list; /* Some tags have 0 = don't care, 1 = strong requirement, 2 = weak requirement. */ static const int order_312[3] = {3, 1, 2}; int i; - if (!elf32_arm_tdata (obfd)->known_eabi_attributes[0].i) + if (!elf_known_obj_attributes_proc (obfd)[0].i) { /* This is the first object. Copy the attributes. */ - copy_eabi_attributes (ibfd, obfd); + _bfd_elf_copy_obj_attributes (ibfd, obfd); /* Use the Tag_null value to indicate the attributes have been initialized. */ - elf32_arm_tdata (obfd)->known_eabi_attributes[0].i = 1; + elf_known_obj_attributes_proc (obfd)[0].i = 1; return TRUE; } - in_attr = elf32_arm_tdata (ibfd)->known_eabi_attributes; - out_attr = elf32_arm_tdata (obfd)->known_eabi_attributes; + in_attr = elf_known_obj_attributes_proc (ibfd); + out_attr = elf_known_obj_attributes_proc (obfd); /* This needs to happen before Tag_ABI_FP_number_model is merged. */ if (in_attr[Tag_ABI_VFP_args].i != out_attr[Tag_ABI_VFP_args].i) { @@ -7140,7 +6781,7 @@ elf32_arm_merge_eabi_attributes (bfd *ibfd, bfd *obfd) } } - for (i = 4; i < NUM_KNOWN_ATTRIBUTES; i++) + for (i = 4; i < NUM_KNOWN_OBJ_ATTRIBUTES; i++) { /* Merge this attribute with existing attributes. */ switch (i) @@ -7152,7 +6793,7 @@ elf32_arm_merge_eabi_attributes (bfd *ibfd, bfd *obfd) name is non-NULL. */ if (in_attr[Tag_CPU_arch].i > out_attr[Tag_CPU_arch].i && in_attr[i].s) - out_attr[i].s = attr_strdup(obfd, in_attr[i].s); + out_attr[i].s = _bfd_elf_attr_strdup (obfd, in_attr[i].s); break; case Tag_ABI_optimization_goals: @@ -7294,60 +6935,13 @@ elf32_arm_merge_eabi_attributes (bfd *ibfd, bfd *obfd) } } - in_list = elf32_arm_tdata (ibfd)->other_eabi_attributes; - out_list = elf32_arm_tdata (ibfd)->other_eabi_attributes; - while (in_list && in_list->tag == Tag_compatibility) - { - in_attr = &in_list->attr; - if (in_attr->i == 0) - continue; - if (in_attr->i == 1) - { - _bfd_error_handler - (_("ERROR: %B: Must be processed by '%s' toolchain"), - ibfd, in_attr->s); - return FALSE; - } - if (!out_list || out_list->tag != Tag_compatibility - || strcmp (in_attr->s, out_list->attr.s) != 0) - { - /* Add this compatibility tag to the output. */ - elf32_arm_add_eabi_attr_compat (obfd, in_attr->i, in_attr->s); - continue; - } - out_attr = &out_list->attr; - /* Check all the input tags with the same identifier. */ - for (;;) - { - if (out_list->tag != Tag_compatibility - || in_attr->i != out_attr->i - || strcmp (in_attr->s, out_attr->s) != 0) - { - _bfd_error_handler - (_("ERROR: %B: Incompatible object tag '%s':%d"), - ibfd, in_attr->s, in_attr->i); - return FALSE; - } - in_list = in_list->next; - if (in_list->tag != Tag_compatibility - || strcmp (in_attr->s, in_list->attr.s) != 0) - break; - in_attr = &in_list->attr; - out_list = out_list->next; - if (out_list) - out_attr = &out_list->attr; - } + /* Merge Tag_compatibility attributes and any common GNU ones. */ + _bfd_elf_merge_object_attributes (ibfd, obfd); - /* Check the output doesn't have extra tags with this identifier. */ - if (out_list && out_list->tag == Tag_compatibility - && strcmp (in_attr->s, out_list->attr.s) == 0) - { - _bfd_error_handler - (_("ERROR: %B: Incompatible object tag '%s':%d"), - ibfd, in_attr->s, out_list->attr.i); - return FALSE; - } - } + /* Check for any attributes not known on ARM. */ + in_list = elf_other_obj_attributes_proc (ibfd); + while (in_list && in_list->tag == Tag_compatibility) + in_list = in_list->next; for (; in_list; in_list = in_list->next) { @@ -9800,125 +9394,9 @@ elf32_arm_fake_sections (bfd * abfd, Elf_Internal_Shdr * hdr, asection * sec) hdr->sh_type = SHT_ARM_EXIDX; hdr->sh_flags |= SHF_LINK_ORDER; } - else if (strcmp(name, ".ARM.attributes") == 0) - { - hdr->sh_type = SHT_ARM_ATTRIBUTES; - } return TRUE; } -/* Parse an Arm EABI attributes section. */ -static void -elf32_arm_parse_attributes (bfd *abfd, Elf_Internal_Shdr * hdr) -{ - bfd_byte *contents; - bfd_byte *p; - bfd_vma len; - - contents = bfd_malloc (hdr->sh_size); - if (!contents) - return; - if (!bfd_get_section_contents (abfd, hdr->bfd_section, contents, 0, - hdr->sh_size)) - { - free (contents); - return; - } - p = contents; - if (*(p++) == 'A') - { - len = hdr->sh_size - 1; - while (len > 0) - { - int namelen; - bfd_vma section_len; - - section_len = bfd_get_32 (abfd, p); - p += 4; - if (section_len > len) - section_len = len; - len -= section_len; - namelen = strlen ((char *)p) + 1; - section_len -= namelen + 4; - if (strcmp((char *)p, "aeabi") != 0) - { - /* Vendor section. Ignore it. */ - p += namelen + section_len; - } - else - { - p += namelen; - while (section_len > 0) - { - int tag; - unsigned int n; - unsigned int val; - bfd_vma subsection_len; - bfd_byte *end; - - tag = read_unsigned_leb128 (abfd, p, &n); - p += n; - subsection_len = bfd_get_32 (abfd, p); - p += 4; - if (subsection_len > section_len) - subsection_len = section_len; - section_len -= subsection_len; - subsection_len -= n + 4; - end = p + subsection_len; - switch (tag) - { - case Tag_File: - while (p < end) - { - bfd_boolean is_string; - - tag = read_unsigned_leb128 (abfd, p, &n); - p += n; - if (tag == 4 || tag == 5) - is_string = 1; - else if (tag < 32) - is_string = 0; - else - is_string = (tag & 1) != 0; - if (tag == Tag_compatibility) - { - val = read_unsigned_leb128 (abfd, p, &n); - p += n; - elf32_arm_add_eabi_attr_compat (abfd, val, - (char *)p); - p += strlen ((char *)p) + 1; - } - else if (is_string) - { - elf32_arm_add_eabi_attr_string (abfd, tag, - (char *)p); - p += strlen ((char *)p) + 1; - } - else - { - val = read_unsigned_leb128 (abfd, p, &n); - p += n; - elf32_arm_add_eabi_attr_int (abfd, tag, val); - } - } - break; - case Tag_Section: - case Tag_Symbol: - /* Don't have anywhere convenient to attach these. - Fall through for now. */ - default: - /* Ignore things we don't kow about. */ - p += subsection_len; - subsection_len = 0; - break; - } - } - } - } - } - free (contents); -} - /* Handle an ARM specific section when reading an object file. This is called when bfd_section_from_shdr finds a section with an unknown type. */ @@ -9948,8 +9426,6 @@ elf32_arm_section_from_shdr (bfd *abfd, if (! _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex)) return FALSE; - if (hdr->sh_type == SHT_ARM_ATTRIBUTES) - elf32_arm_parse_attributes(abfd, hdr); return TRUE; } @@ -10677,7 +10153,6 @@ const struct elf_size_info elf32_arm_size_info = { #define bfd_elf32_bfd_is_target_special_symbol elf32_arm_is_target_special_symbol #define bfd_elf32_close_and_cleanup elf32_arm_close_and_cleanup #define bfd_elf32_bfd_free_cached_info elf32_arm_bfd_free_cached_info -#define bfd_elf32_bfd_final_link elf32_arm_bfd_final_link #define elf_backend_get_symbol_type elf32_arm_get_symbol_type #define elf_backend_gc_mark_hook elf32_arm_gc_mark_hook @@ -10722,6 +10197,15 @@ const struct elf_size_info elf32_arm_size_info = { #define elf_backend_got_header_size 12 +#undef elf_backend_obj_attrs_vendor +#define elf_backend_obj_attrs_vendor "aeabi" +#undef elf_backend_obj_attrs_section +#define elf_backend_obj_attrs_section ".ARM.attributes" +#undef elf_backend_obj_attrs_arg_type +#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 + #include "elf32-target.h" /* VxWorks Targets */ |