diff options
author | Alan Modra <amodra@gmail.com> | 2005-07-04 01:53:44 +0000 |
---|---|---|
committer | Alan Modra <amodra@gmail.com> | 2005-07-04 01:53:44 +0000 |
commit | 551b43fde1ab573285b643ee28f757f4d4aeb500 (patch) | |
tree | a8a767cc88f27a8dca9ee044fa6534ecd8d7a659 /bfd/elf.c | |
parent | 90f7da277eddfb6a92eba0895644fe09de5409d2 (diff) | |
download | gdb-551b43fde1ab573285b643ee28f757f4d4aeb500.zip gdb-551b43fde1ab573285b643ee28f757f4d4aeb500.tar.gz gdb-551b43fde1ab573285b643ee28f757f4d4aeb500.tar.bz2 |
PR 1004
bfd/
* elf-bfd.h (struct elf_backend_data): Add get_sec_type_attr. Delete
special_sections.
(_bfd_elf_get_special_section): Declare.
(bfd_elf_special_section): Update prototype.
* elf.c (special_sections): Remove unused outer entries.
(get_special_section): Delete.
(_bfd_elf_get_special_section): New function.
(_bfd_elf_get_sec_type_attr): Replace "name" arg with "sec". Update
special_sections indexing.
(_bfd_elf_new_section_hook): Call backend get_sec_type_attr.
* elf32-arm.c (symbian_special_sections_d): Delete.
(symbian_special_sections_g, symbian_special_sections_h): Delete.
(symbian_special_sections_i, symbian_special_sections_f): Delete.
(symbian_special_sections_p): Delete.
(elf32_arm_symbian_special_sections): Merge above to here.
(elf32_arm_symbian_get_sec_type_attr): New function.
(elf_backend_special_sections): Don't define.
(elf_backend_get_sec_type_attr): Define.
* elf32-m32r.c: Similarly to elf32-arm.c.
* elf32-m68hc11.c: Likewise.
* elf32-m68hc12.c: Likewise.
* elf32-mcore.c: Likewise.
* elf32-sh64.c: Likewise.
* elf32-v850.c: Likewise.
* elf32-xtensa.c: Likewise.
* elf64-alpha.c: Likewise.
* elf64-hppa.c: Likewise.
* elf64-ppc.c: Likewise.
* elf64-sh64.c: Likewise.
* elfxx-ia64.c: Likewise.
* elfxx-mips.c: Likewise.
* elf32-ppc.c: Likewise.
(bfd_elf_special_section ppc_alt_plt): New. Use it if .plt loadable.
* elfxx-mips.h (_bfd_mips_elf_get_sec_type_attr): Declare.
(_bfd_mips_elf_special_sections, elf_backend_special_sections): Delete.
(elf_backend_get_sec_type_attr): Define.
* elfxx-target.h (elf_backend_get_sec_type_attr): Define.
(elf_backend_special_sections): Don't define.
(elfNN_bed): Update.
binutils/
* objcopy.c (copy_object): Use bfd_make_section_with_flags.
(write_debugging_info): Likewise.
(setup_section): Use bfd_make_section_anyway_with_flags.
gas/
* config/obj-elf.c (obj_elf_change_section): Use backend
get_sec_type_attr.
Diffstat (limited to 'bfd/elf.c')
-rw-r--r-- | bfd/elf.c | 87 |
1 files changed, 35 insertions, 52 deletions
@@ -2270,9 +2270,8 @@ static struct bfd_elf_special_section const special_sections_t[] = { NULL, 0, 0, 0, 0 } }; -static struct bfd_elf_special_section const *special_sections [27] = +static struct bfd_elf_special_section const *special_sections[] = { - NULL, /* 'a' */ special_sections_b, /* 'b' */ special_sections_c, /* 'b' */ special_sections_d, /* 'd' */ @@ -2292,51 +2291,29 @@ static struct bfd_elf_special_section const *special_sections [27] = special_sections_r, /* 'r' */ special_sections_s, /* 's' */ special_sections_t, /* 't' */ - NULL, /* 'u' */ - NULL, /* 'v' */ - NULL, /* 'w' */ - NULL, /* 'x' */ - NULL, /* 'y' */ - NULL, /* 'z' */ - NULL /* other */ }; -static const struct bfd_elf_special_section * -get_special_section (const char *name, - const struct bfd_elf_special_section **special_sections_p, - unsigned int rela) +const struct bfd_elf_special_section * +_bfd_elf_get_special_section (const char *name, + const struct bfd_elf_special_section *spec, + unsigned int rela) { int i; int len; - const struct bfd_elf_special_section *special_sections; - - if (name [0] == '.') - { - i = name [1] - 'a'; - if (i < 0 || i > 25) - i = 26; - } - else - i = 26; - - special_sections = special_sections_p [i]; - if (!special_sections) - return special_sections; + len = strlen (name); - len= strlen (name); - - for (i = 0; special_sections[i].prefix != NULL; i++) + for (i = 0; spec[i].prefix != NULL; i++) { int suffix_len; - int prefix_len = special_sections[i].prefix_length; + int prefix_len = spec[i].prefix_length; if (len < prefix_len) continue; - if (memcmp (name, special_sections[i].prefix, prefix_len) != 0) + if (memcmp (name, spec[i].prefix, prefix_len) != 0) continue; - suffix_len = special_sections[i].suffix_length; + suffix_len = spec[i].suffix_length; if (suffix_len <= 0) { if (name[prefix_len] != 0) @@ -2345,7 +2322,7 @@ get_special_section (const char *name, continue; if (name[prefix_len] != '.' && (suffix_len == -2 - || (rela && special_sections[i].type == SHT_REL))) + || (rela && spec[i].type == SHT_REL))) continue; } } @@ -2354,41 +2331,46 @@ get_special_section (const char *name, if (len < prefix_len + suffix_len) continue; if (memcmp (name + len - suffix_len, - special_sections[i].prefix + prefix_len, + spec[i].prefix + prefix_len, suffix_len) != 0) continue; } - return &special_sections[i]; + return &spec[i]; } return NULL; } const struct bfd_elf_special_section * -_bfd_elf_get_sec_type_attr (bfd *abfd, const char *name) +_bfd_elf_get_sec_type_attr (bfd *abfd ATTRIBUTE_UNUSED, asection *sec) { - const struct elf_backend_data *bed = get_elf_backend_data (abfd); - const struct bfd_elf_special_section *ssect = NULL; + int i; + const struct bfd_elf_special_section *spec; /* See if this is one of the special sections. */ - if (name) - { - unsigned int rela = bed->default_use_rela_p; + if (sec->name == NULL) + return NULL; - if (bed->special_sections) - ssect = get_special_section (name, bed->special_sections, rela); + if (sec->name[0] != '.') + return NULL; - if (! ssect) - ssect = get_special_section (name, special_sections, rela); - } + i = sec->name[1] - 'b'; + if (i < 0 || i > 't' - 'b') + return NULL; + + spec = special_sections[i]; - return ssect; + if (spec == NULL) + return NULL; + + return _bfd_elf_get_special_section (sec->name, spec, sec->use_rela_p); } bfd_boolean _bfd_elf_new_section_hook (bfd *abfd, asection *sec) { struct bfd_elf_section_data *sdata; + const struct elf_backend_data *bed; const struct bfd_elf_special_section *ssect; sdata = (struct bfd_elf_section_data *) sec->used_by_bfd; @@ -2400,13 +2382,17 @@ _bfd_elf_new_section_hook (bfd *abfd, asection *sec) sec->used_by_bfd = sdata; } + /* Indicate whether or not this section should use RELA relocations. */ + bed = get_elf_backend_data (abfd); + sec->use_rela_p = bed->default_use_rela_p; + /* When we read a file, we don't need section type and flags unless it is a linker created section. They will be overridden in _bfd_elf_make_section_from_shdr anyway. */ if (abfd->direction != read_direction || (sec->flags & SEC_LINKER_CREATED) != 0) { - ssect = _bfd_elf_get_sec_type_attr (abfd, sec->name); + ssect = (*bed->get_sec_type_attr) (abfd, sec); if (ssect != NULL) { elf_section_type (sec) = ssect->type; @@ -2414,9 +2400,6 @@ _bfd_elf_new_section_hook (bfd *abfd, asection *sec) } } - /* Indicate whether or not this section should use RELA relocations. */ - sec->use_rela_p = get_elf_backend_data (abfd)->default_use_rela_p; - return TRUE; } |