diff options
-rw-r--r-- | bfd/ChangeLog | 43 | ||||
-rw-r--r-- | bfd/elf-bfd.h | 15 | ||||
-rw-r--r-- | bfd/elf.c | 87 | ||||
-rw-r--r-- | bfd/elf32-arm.c | 96 | ||||
-rw-r--r-- | bfd/elf32-m32r.c | 55 | ||||
-rw-r--r-- | bfd/elf32-m68hc11.c | 69 | ||||
-rw-r--r-- | bfd/elf32-m68hc12.c | 69 | ||||
-rw-r--r-- | bfd/elf32-mcore.c | 57 | ||||
-rw-r--r-- | bfd/elf32-ppc.c | 84 | ||||
-rw-r--r-- | bfd/elf32-sh64.c | 53 | ||||
-rw-r--r-- | bfd/elf32-v850.c | 87 | ||||
-rw-r--r-- | bfd/elf32-xtensa.c | 64 | ||||
-rw-r--r-- | bfd/elf64-alpha.c | 55 | ||||
-rw-r--r-- | bfd/elf64-hppa.c | 59 | ||||
-rw-r--r-- | bfd/elf64-ppc.c | 65 | ||||
-rw-r--r-- | bfd/elf64-sh64.c | 53 | ||||
-rw-r--r-- | bfd/elfxx-ia64.c | 51 | ||||
-rw-r--r-- | bfd/elfxx-mips.c | 68 | ||||
-rw-r--r-- | bfd/elfxx-mips.h | 5 | ||||
-rw-r--r-- | bfd/elfxx-target.h | 9 | ||||
-rw-r--r-- | binutils/ChangeLog | 7 | ||||
-rw-r--r-- | binutils/objcopy.c | 69 | ||||
-rw-r--r-- | gas/ChangeLog | 6 | ||||
-rw-r--r-- | gas/config/obj-elf.c | 4 |
24 files changed, 433 insertions, 797 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 72e3bdf..388c568 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,46 @@ +2005-07-04 Alan Modra <amodra@bigpond.net.au> + + PR 1004 + * 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. + 2005-07-01 Nick Clifton <nickc@redhat.com> * cpu-d10v.c: Update to ISO C90 style function declarations and diff --git a/bfd/elf-bfd.h b/bfd/elf-bfd.h index 7c75891..103b613 100644 --- a/bfd/elf-bfd.h +++ b/bfd/elf-bfd.h @@ -633,11 +633,16 @@ struct elf_backend_data bfd_boolean (*elf_backend_section_from_shdr) (bfd *, Elf_Internal_Shdr *, const char *, int); - /* A function to convert machine dependent section header flags to + /* A function to convert machine dependent ELF section header flags to BFD internal section header flags. */ bfd_boolean (*elf_backend_section_flags) (flagword *, const Elf_Internal_Shdr *); + /* A function that returns a struct containing ELF section flags and + type for the given BFD section. */ + const struct bfd_elf_special_section * (*get_sec_type_attr) + (bfd *, asection *); + /* A function to handle unusual program segment types when creating BFD sections from ELF program segments. */ bfd_boolean (*elf_backend_section_from_phdr) @@ -976,10 +981,6 @@ struct elf_backend_data const struct elf_size_info *s; - /* An array of 27 target specific special section map arrays, - covering 'a' to 'z', plus other. */ - const struct bfd_elf_special_section **special_sections; - /* The size in bytes of the header for the GOT. This includes the so-called reserved entries on some systems. */ bfd_vma got_header_size; @@ -1501,8 +1502,10 @@ extern bfd_boolean _bfd_elf_new_section_hook (bfd *, asection *); extern bfd_boolean _bfd_elf_init_reloc_shdr (bfd *, Elf_Internal_Shdr *, asection *, bfd_boolean); +extern const struct bfd_elf_special_section *_bfd_elf_get_special_section + (const char *, const struct bfd_elf_special_section *, unsigned int); extern const struct bfd_elf_special_section *_bfd_elf_get_sec_type_attr - (bfd *, const char *); + (bfd *, asection *); /* If the target doesn't have reloc handling written yet: */ extern void _bfd_elf_no_info_to_howto @@ -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; } diff --git a/bfd/elf32-arm.c b/bfd/elf32-arm.c index af26109..d140e67 100644 --- a/bfd/elf32-arm.c +++ b/bfd/elf32-arm.c @@ -6943,7 +6943,7 @@ elf32_arm_symbian_link_hash_table_create (bfd *abfd) } static struct bfd_elf_special_section const - symbian_special_sections_d[]= +elf32_arm_symbian_special_sections[] = { /* In a BPABI executable, the dynamic linking sections do not go in the loadable read-only segment. The post-linker may wish to @@ -6952,92 +6952,34 @@ static struct bfd_elf_special_section const { ".dynamic", 8, 0, SHT_DYNAMIC, 0 }, { ".dynstr", 7, 0, SHT_STRTAB, 0 }, { ".dynsym", 7, 0, SHT_DYNSYM, 0 }, - { NULL, 0, 0, 0, 0 } -}; - -static struct bfd_elf_special_section const - symbian_special_sections_g[]= -{ - /* In a BPABI executable, the dynamic linking sections do not go in - the loadable read-only segment. The post-linker may wish to - refer to these sections, but they are not part of the final - program image. */ { ".got", 4, 0, SHT_PROGBITS, 0 }, - { NULL, 0, 0, 0, 0 } -}; - -static struct bfd_elf_special_section const - symbian_special_sections_h[]= -{ - /* In a BPABI executable, the dynamic linking sections do not go in - the loadable read-only segment. The post-linker may wish to - refer to these sections, but they are not part of the final - program image. */ { ".hash", 5, 0, SHT_HASH, 0 }, - { NULL, 0, 0, 0, 0 } -}; - -static struct bfd_elf_special_section const - symbian_special_sections_i[]= -{ /* These sections do not need to be writable as the SymbianOS postlinker will arrange things so that no dynamic relocation is required. */ { ".init_array", 11, 0, SHT_INIT_ARRAY, SHF_ALLOC }, - { NULL, 0, 0, 0, 0 } -}; - -static struct bfd_elf_special_section const - symbian_special_sections_f[]= -{ - /* These sections do not need to be writable as the SymbianOS - postlinker will arrange things so that no dynamic relocation is - required. */ { ".fini_array", 11, 0, SHT_FINI_ARRAY, SHF_ALLOC }, - { NULL, 0, 0, 0, 0 } -}; - -static struct bfd_elf_special_section const - symbian_special_sections_p[]= -{ - /* These sections do not need to be writable as the SymbianOS - postlinker will arrange things so that no dynamic relocation is - required. */ { ".preinit_array", 14, 0, SHT_PREINIT_ARRAY, SHF_ALLOC }, { NULL, 0, 0, 0, 0 } }; -static struct bfd_elf_special_section const * - elf32_arm_symbian_special_sections[27]= +static const struct bfd_elf_special_section * +elf32_arm_symbian_get_sec_type_attr (bfd *abfd, asection *sec) { - NULL, /* 'a' */ - NULL, /* 'b' */ - NULL, /* 'c' */ - symbian_special_sections_d, /* 'd' */ - NULL, /* 'e' */ - symbian_special_sections_f, /* 'f' */ - symbian_special_sections_g, /* 'g' */ - symbian_special_sections_h, /* 'h' */ - symbian_special_sections_i, /* 'i' */ - NULL, /* 'j' */ - NULL, /* 'k' */ - NULL, /* 'l' */ - NULL, /* 'm' */ - NULL, /* 'n' */ - NULL, /* 'o' */ - symbian_special_sections_p, /* 'p' */ - NULL, /* 'q' */ - NULL, /* 'r' */ - NULL, /* 's' */ - NULL, /* 't' */ - NULL, /* 'u' */ - NULL, /* 'v' */ - NULL, /* 'w' */ - NULL, /* 'x' */ - NULL, /* 'y' */ - NULL, /* 'z' */ - NULL /* other */ -}; + const struct bfd_elf_special_section const *ssect; + + /* See if this is one of the special sections. */ + if (sec->name == NULL) + return NULL; + + ssect = _bfd_elf_get_special_section (sec->name, + elf32_arm_symbian_special_sections, + sec->use_rela_p); + if (ssect != NULL) + return ssect; + + return _bfd_elf_get_sec_type_attr (abfd, sec); +} static void elf32_arm_symbian_begin_write_processing (bfd *abfd, @@ -7091,8 +7033,8 @@ elf32_arm_symbian_modify_segment_map (bfd *abfd, #define bfd_elf32_bfd_link_hash_table_create \ elf32_arm_symbian_link_hash_table_create -#undef elf_backend_special_sections -#define elf_backend_special_sections elf32_arm_symbian_special_sections +#undef elf_backend_get_sec_type_attr +#define elf_backend_get_sec_type_attr elf32_arm_symbian_get_sec_type_attr #undef elf_backend_begin_write_processing #define elf_backend_begin_write_processing \ diff --git a/bfd/elf32-m32r.c b/bfd/elf32-m32r.c index ea6a40d..f798088 100644 --- a/bfd/elf32-m32r.c +++ b/bfd/elf32-m32r.c @@ -4013,45 +4013,30 @@ m32r_elf_check_relocs (bfd *abfd, return TRUE; } -static struct bfd_elf_special_section const - m32r_elf_special_sections_s[] = +static struct bfd_elf_special_section const m32r_elf_special_sections[] = { - { ".sdata", 6, -2, SHT_PROGBITS, SHF_ALLOC + SHF_WRITE }, { ".sbss", 5, -2, SHT_NOBITS, SHF_ALLOC + SHF_WRITE }, - { NULL, 0, 0, 0, 0 } + { ".sdata", 6, -2, SHT_PROGBITS, SHF_ALLOC + SHF_WRITE }, + { NULL, 0, 0, 0, 0 } }; -static struct bfd_elf_special_section const * - m32r_elf_special_sections[27] = +static const struct bfd_elf_special_section * +m32r_elf_get_sec_type_attr (bfd *abfd, asection *sec) { - NULL, /* 'a' */ - NULL, /* 'b' */ - NULL, /* 'c' */ - NULL, /* 'd' */ - NULL, /* 'e' */ - NULL, /* 'f' */ - NULL, /* 'g' */ - NULL, /* 'h' */ - NULL, /* 'i' */ - NULL, /* 'j' */ - NULL, /* 'k' */ - NULL, /* 'l' */ - NULL, /* 'm' */ - NULL, /* 'n' */ - NULL, /* 'o' */ - NULL, /* 'p' */ - NULL, /* 'q' */ - NULL, /* 'r' */ - m32r_elf_special_sections_s, /* 's' */ - NULL, /* 't' */ - NULL, /* 'u' */ - NULL, /* 'v' */ - NULL, /* 'w' */ - NULL, /* 'x' */ - NULL, /* 'y' */ - NULL, /* 'z' */ - NULL /* other */ -}; + const struct bfd_elf_special_section const *ssect; + + /* See if this is one of the special sections. */ + if (sec->name == NULL) + return NULL; + + ssect = _bfd_elf_get_special_section (sec->name, + m32r_elf_special_sections, + sec->use_rela_p); + if (ssect != NULL) + return ssect; + + return _bfd_elf_get_sec_type_attr (abfd, sec); +} static bfd_boolean m32r_elf_fake_sections (bfd *abfd, @@ -4156,7 +4141,7 @@ m32r_elf_reloc_type_class (const Elf_Internal_Rela *rela) #define bfd_elf32_bfd_merge_private_bfd_data m32r_elf_merge_private_bfd_data #define bfd_elf32_bfd_set_private_flags m32r_elf_set_private_flags #define bfd_elf32_bfd_print_private_bfd_data m32r_elf_print_private_bfd_data -#define elf_backend_special_sections m32r_elf_special_sections +#define elf_backend_get_sec_type_attr m32r_elf_get_sec_type_attr #include "elf32-target.h" diff --git a/bfd/elf32-m68hc11.c b/bfd/elf32-m68hc11.c index aff4be6..0cdeef7 100644 --- a/bfd/elf32-m68hc11.c +++ b/bfd/elf32-m68hc11.c @@ -1257,65 +1257,32 @@ m68hc11_elf_relax_delete_bytes (bfd *abfd, asection *sec, are located in .page0. - The .vectors is the section that represents the interrupt vectors. */ -static struct bfd_elf_special_section const - m68hc11_special_sections_e[] = +static struct bfd_elf_special_section const elf32_m68hc11_special_sections[] = { { ".eeprom", 7, 0, SHT_PROGBITS, SHF_ALLOC + SHF_WRITE }, - { NULL, 0, 0, 0, 0 } -}; - -static struct bfd_elf_special_section const - m68hc11_special_sections_s[]= -{ + { ".page0", 6, 0, SHT_PROGBITS, SHF_ALLOC + SHF_WRITE }, { ".softregs", 9, 0, SHT_NOBITS, SHF_ALLOC + SHF_WRITE }, + { ".vectors", 8, 0, SHT_PROGBITS, SHF_ALLOC }, { NULL, 0, 0, 0, 0 } }; -static struct bfd_elf_special_section const - m68hc11_special_sections_p[]= +static const struct bfd_elf_special_section * +elf32_m68hc11_get_sec_type_attr (bfd *abfd, asection *sec) { - { ".page0", 6, 0, SHT_PROGBITS, SHF_ALLOC + SHF_WRITE }, - { NULL, 0, 0, 0, 0 } -}; + const struct bfd_elf_special_section const *ssect; -static struct bfd_elf_special_section const - m68hc11_special_sections_v[]= -{ - { ".vectors", 8, 0, SHT_PROGBITS, SHF_ALLOC }, - { NULL, 0, 0, 0, 0 } -}; + /* See if this is one of the special sections. */ + if (sec->name == NULL) + return NULL; -static struct bfd_elf_special_section const * - elf32_m68hc11_special_sections[27] = -{ - NULL, /* 'a' */ - NULL, /* 'b' */ - NULL, /* 'c' */ - NULL, /* 'd' */ - m68hc11_special_sections_e, /* 'e' */ - NULL, /* 'f' */ - NULL, /* 'g' */ - NULL, /* 'h' */ - NULL, /* 'i' */ - NULL, /* 'j' */ - NULL, /* 'k' */ - NULL, /* 'l' */ - NULL, /* 'm' */ - NULL, /* 'n' */ - NULL, /* 'o' */ - m68hc11_special_sections_p, /* 'p' */ - NULL, /* 'q' */ - NULL, /* 'r' */ - m68hc11_special_sections_s, /* 's' */ - NULL, /* 't' */ - NULL, /* 'u' */ - m68hc11_special_sections_v, /* 'v' */ - NULL, /* 'w' */ - NULL, /* 'x' */ - NULL, /* 'y' */ - NULL, /* 'z' */ - NULL /* other */ -}; + ssect = _bfd_elf_get_special_section (sec->name, + elf32_m68hc11_special_sections, + sec->use_rela_p); + if (ssect != NULL) + return ssect; + + return _bfd_elf_get_sec_type_attr (abfd, sec); +} #define ELF_ARCH bfd_arch_m68hc11 #define ELF_MACHINE_CODE EM_68HC11 @@ -1335,7 +1302,7 @@ static struct bfd_elf_special_section const * #define elf_backend_object_p 0 #define elf_backend_final_write_processing 0 #define elf_backend_can_gc_sections 1 -#define elf_backend_special_sections elf32_m68hc11_special_sections +#define elf_backend_get_sec_type_attr elf32_m68hc11_get_sec_type_attr #define bfd_elf32_bfd_link_hash_table_create \ m68hc11_elf_bfd_link_hash_table_create diff --git a/bfd/elf32-m68hc12.c b/bfd/elf32-m68hc12.c index 213ead2..6a3a86e 100644 --- a/bfd/elf32-m68hc12.c +++ b/bfd/elf32-m68hc12.c @@ -535,65 +535,32 @@ m68hc12_elf_set_mach_from_flags (bfd *abfd) Page0 accesses are faster on the M68HC12. - The .vectors is the section that represents the interrupt vectors. */ -static struct bfd_elf_special_section const - m68hc12_special_sections_e[] = +static struct bfd_elf_special_section const elf32_m68hc12_special_sections[] = { { ".eeprom", 7, 0, SHT_PROGBITS, SHF_ALLOC + SHF_WRITE }, - { NULL, 0, 0, 0, 0 } -}; - -static struct bfd_elf_special_section const - m68hc12_special_sections_s[]= -{ + { ".page0", 6, 0, SHT_PROGBITS, SHF_ALLOC + SHF_WRITE }, { ".softregs", 9, 0, SHT_NOBITS, SHF_ALLOC + SHF_WRITE }, + { ".vectors", 8, 0, SHT_PROGBITS, SHF_ALLOC }, { NULL, 0, 0, 0, 0 } }; -static struct bfd_elf_special_section const - m68hc12_special_sections_p[]= +static const struct bfd_elf_special_section * +elf32_m68hc12_get_sec_type_attr (bfd *abfd, asection *sec) { - { ".page0", 6, 0, SHT_PROGBITS, SHF_ALLOC + SHF_WRITE }, - { NULL, 0, 0, 0, 0 } -}; + const struct bfd_elf_special_section const *ssect; -static struct bfd_elf_special_section const - m68hc12_special_sections_v[]= -{ - { ".vectors", 8, 0, SHT_PROGBITS, SHF_ALLOC }, - { NULL, 0, 0, 0, 0 } -}; + /* See if this is one of the special sections. */ + if (sec->name == NULL) + return NULL; -static struct bfd_elf_special_section const * - elf32_m68hc12_special_sections[27] = -{ - NULL, /* 'a' */ - NULL, /* 'b' */ - NULL, /* 'c' */ - NULL, /* 'd' */ - m68hc12_special_sections_e, /* 'e' */ - NULL, /* 'f' */ - NULL, /* 'g' */ - NULL, /* 'h' */ - NULL, /* 'i' */ - NULL, /* 'j' */ - NULL, /* 'k' */ - NULL, /* 'l' */ - NULL, /* 'm' */ - NULL, /* 'n' */ - NULL, /* 'o' */ - m68hc12_special_sections_p, /* 'p' */ - NULL, /* 'q' */ - NULL, /* 'r' */ - m68hc12_special_sections_s, /* 's' */ - NULL, /* 't' */ - NULL, /* 'u' */ - m68hc12_special_sections_v, /* 'v' */ - NULL, /* 'w' */ - NULL, /* 'x' */ - NULL, /* 'y' */ - NULL, /* 'z' */ - NULL /* other */ -}; + ssect = _bfd_elf_get_special_section (sec->name, + elf32_m68hc12_special_sections, + sec->use_rela_p); + if (ssect != NULL) + return ssect; + + return _bfd_elf_get_sec_type_attr (abfd, sec); +} #define ELF_ARCH bfd_arch_m68hc12 #define ELF_MACHINE_CODE EM_68HC12 @@ -611,7 +578,7 @@ static struct bfd_elf_special_section const * #define elf_backend_object_p m68hc12_elf_set_mach_from_flags #define elf_backend_final_write_processing 0 #define elf_backend_can_gc_sections 1 -#define elf_backend_special_sections elf32_m68hc12_special_sections +#define elf_backend_get_sec_type_attr elf32_m68hc12_get_sec_type_attr #define elf_backend_post_process_headers elf32_m68hc11_post_process_headers #define elf_backend_add_symbol_hook elf32_m68hc11_add_symbol_hook diff --git a/bfd/elf32-mcore.c b/bfd/elf32-mcore.c index b554ec0..cd2590d 100644 --- a/bfd/elf32-mcore.c +++ b/bfd/elf32-mcore.c @@ -635,51 +635,30 @@ mcore_elf_check_relocs (bfd * abfd, return TRUE; } -static struct bfd_elf_special_section const - mcore_special_sections_c [] = +static struct bfd_elf_special_section const mcore_elf_special_sections[]= { { ".ctors", 6, -2, SHT_PROGBITS, SHF_ALLOC + SHF_WRITE }, - { NULL, 0, 0, 0, 0 } -}; - -static struct bfd_elf_special_section const - mcore_special_sections_d[]= -{ { ".dtors", 6, -2, SHT_PROGBITS, SHF_ALLOC + SHF_WRITE }, { NULL, 0, 0, 0, 0 } }; -static struct bfd_elf_special_section const * - mcore_elf_special_sections[27]= +static const struct bfd_elf_special_section * +mcore_elf_get_sec_type_attr (bfd *abfd, asection *sec) { - NULL, /* 'a' */ - NULL, /* 'b' */ - mcore_special_sections_c, /* 'c' */ - mcore_special_sections_d, /* 'd' */ - NULL, /* 'e' */ - NULL, /* 'f' */ - NULL, /* 'g' */ - NULL, /* 'h' */ - NULL, /* 'i' */ - NULL, /* 'j' */ - NULL, /* 'k' */ - NULL, /* 'l' */ - NULL, /* 'm' */ - NULL, /* 'n' */ - NULL, /* 'o' */ - NULL, /* 'p' */ - NULL, /* 'q' */ - NULL, /* 'r' */ - NULL, /* 's' */ - NULL, /* 't' */ - NULL, /* 'u' */ - NULL, /* 'v' */ - NULL, /* 'w' */ - NULL, /* 'x' */ - NULL, /* 'y' */ - NULL, /* 'z' */ - NULL /* other */ -}; + const struct bfd_elf_special_section const *ssect; + + /* See if this is one of the special sections. */ + if (sec->name == NULL) + return NULL; + + ssect = _bfd_elf_get_special_section (sec->name, + mcore_elf_special_sections, + sec->use_rela_p); + if (ssect != NULL) + return ssect; + + return _bfd_elf_get_sec_type_attr (abfd, sec); +} #define TARGET_BIG_SYM bfd_elf32_mcore_big_vec #define TARGET_BIG_NAME "elf32-mcore-big" @@ -699,7 +678,7 @@ static struct bfd_elf_special_section const * #define elf_backend_gc_mark_hook mcore_elf_gc_mark_hook #define elf_backend_gc_sweep_hook mcore_elf_gc_sweep_hook #define elf_backend_check_relocs mcore_elf_check_relocs -#define elf_backend_special_sections mcore_elf_special_sections +#define elf_backend_get_sec_type_attr mcore_elf_get_sec_type_attr #define elf_backend_can_gc_sections 1 #define elf_backend_rela_normal 1 diff --git a/bfd/elf32-ppc.c b/bfd/elf32-ppc.c index 1d41f57..1569fb0 100644 --- a/bfd/elf32-ppc.c +++ b/bfd/elf32-ppc.c @@ -1828,70 +1828,44 @@ ppc_elf_additional_program_headers (bfd *abfd) that the linker doesn't crater when trying to make more than 2 sections. */ -static struct bfd_elf_special_section const - ppc_special_sections_p[] = +static struct bfd_elf_special_section const ppc_elf_special_sections[] = { { ".plt", 4, 0, SHT_NOBITS, SHF_ALLOC + SHF_EXECINSTR }, - { NULL, 0, 0, 0, 0 } -}; - -static struct bfd_elf_special_section const - ppc_special_sections_s[] = -{ - { ".sdata", 6, -2, SHT_PROGBITS, SHF_ALLOC + SHF_WRITE }, { ".sbss", 5, -2, SHT_NOBITS, SHF_ALLOC + SHF_WRITE }, - { ".sdata2", 7, -2, SHT_PROGBITS, SHF_ALLOC }, { ".sbss2", 6, -2, SHT_PROGBITS, SHF_ALLOC }, - { NULL, 0, 0, 0, 0 } -}; - -static struct bfd_elf_special_section const - ppc_special_sections_t[] = -{ + { ".sdata", 6, -2, SHT_PROGBITS, SHF_ALLOC + SHF_WRITE }, + { ".sdata2", 7, -2, SHT_PROGBITS, SHF_ALLOC }, { ".tags", 5, 0, SHT_ORDERED, SHF_ALLOC }, - { NULL, 0, 0, 0, 0 } -}; - -static struct bfd_elf_special_section const - ppc_special_sections_other[]= -{ { ".PPC.EMB.apuinfo", 16, 0, SHT_NOTE, 0 }, - { ".PPC.EMB.sdata0", 15, 0, SHT_PROGBITS, SHF_ALLOC }, { ".PPC.EMB.sbss0", 14, 0, SHT_PROGBITS, SHF_ALLOC }, - { NULL, 0, 0, 0, 0 } + { ".PPC.EMB.sdata0", 15, 0, SHT_PROGBITS, SHF_ALLOC }, + { NULL, 0, 0, 0, 0 } }; -static struct bfd_elf_special_section const * - ppc_elf_special_sections[27]= +/* This is what we want for new plt/got. */ +static struct bfd_elf_special_section ppc_alt_plt = + { ".plt", 4, 0, SHT_PROGBITS, SHF_ALLOC }; + +static const struct bfd_elf_special_section * +ppc_elf_get_sec_type_attr (bfd *abfd ATTRIBUTE_UNUSED, asection *sec) { - NULL, /* 'a' */ - NULL, /* 'b' */ - NULL, /* 'c' */ - NULL, /* 'd' */ - NULL, /* 'e' */ - NULL, /* 'f' */ - NULL, /* 'g' */ - NULL, /* 'h' */ - NULL, /* 'i' */ - NULL, /* 'j' */ - NULL, /* 'k' */ - NULL, /* 'l' */ - NULL, /* 'm' */ - NULL, /* 'n' */ - NULL, /* 'o' */ - ppc_special_sections_p, /* 'p' */ - NULL, /* 'q' */ - NULL, /* 'r' */ - ppc_special_sections_s, /* 's' */ - ppc_special_sections_t, /* 's' */ - NULL, /* 'u' */ - NULL, /* 'v' */ - NULL, /* 'w' */ - NULL, /* 'x' */ - NULL, /* 'y' */ - NULL, /* 'z' */ - ppc_special_sections_other, /* other */ -}; + const struct bfd_elf_special_section const *ssect; + + /* See if this is one of the special sections. */ + if (sec->name == NULL) + return NULL; + + ssect = _bfd_elf_get_special_section (sec->name, ppc_elf_special_sections, + sec->use_rela_p); + if (ssect != NULL) + { + if (ssect == ppc_elf_special_sections && (sec->flags & SEC_LOAD) != 0) + ssect = &ppc_alt_plt; + return ssect; + } + + return _bfd_elf_get_sec_type_attr (abfd, sec); +} /* Very simple linked list structure for recording apuinfo values. */ typedef struct apuinfo_list @@ -6978,7 +6952,7 @@ ppc_elf_finish_dynamic_sections (bfd *output_bfd, #define elf_backend_begin_write_processing ppc_elf_begin_write_processing #define elf_backend_final_write_processing ppc_elf_final_write_processing #define elf_backend_write_section ppc_elf_write_section -#define elf_backend_special_sections ppc_elf_special_sections +#define elf_backend_get_sec_type_attr ppc_elf_get_sec_type_attr #define elf_backend_plt_sym_val ppc_elf_plt_sym_val #include "elf32-target.h" diff --git a/bfd/elf32-sh64.c b/bfd/elf32-sh64.c index dac8bb4..d9b3f38 100644 --- a/bfd/elf32-sh64.c +++ b/bfd/elf32-sh64.c @@ -89,7 +89,7 @@ static void sh64_find_section_for_address #define elf_backend_merge_symbol_attribute sh64_elf_merge_symbol_attribute #define elf_backend_final_write_processing sh64_elf_final_write_processing #define elf_backend_section_from_shdr sh64_backend_section_from_shdr -#define elf_backend_special_sections sh64_elf_special_sections +#define elf_backend_get_sec_type_attr sh64_elf_get_sec_type_attr #define elf_backend_section_flags sh64_elf_section_flags #define bfd_elf32_new_section_hook sh64_elf_new_section_hook @@ -754,44 +754,29 @@ sh64_elf_merge_symbol_attribute (struct elf_link_hash_entry *h, return; } -static struct bfd_elf_special_section const - sh64_special_sections_c[] = +static struct bfd_elf_special_section const sh64_elf_special_sections[] = { { ".cranges", 8, 0, SHT_PROGBITS, 0 }, - { NULL, 0, 0, 0, 0 } + { NULL, 0, 0, 0, 0 } }; -static struct bfd_elf_special_section const * - sh64_elf_special_sections[27]= +static const struct bfd_elf_special_section * +sh64_elf_get_sec_type_attr (bfd *abfd, asection *sec) { - NULL, /* 'a' */ - NULL, /* 'b' */ - sh64_special_sections_c, /* 'c' */ - NULL, /* 'd' */ - NULL, /* 'e' */ - NULL, /* 'f' */ - NULL, /* 'g' */ - NULL, /* 'h' */ - NULL, /* 'i' */ - NULL, /* 'j' */ - NULL, /* 'k' */ - NULL, /* 'l' */ - NULL, /* 'm' */ - NULL, /* 'n' */ - NULL, /* 'o' */ - NULL, /* 'p' */ - NULL, /* 'q' */ - NULL, /* 'r' */ - NULL, /* 's' */ - NULL, /* 't' */ - NULL, /* 'u' */ - NULL, /* 'v' */ - NULL, /* 'w' */ - NULL, /* 'x' */ - NULL, /* 'y' */ - NULL, /* 'z' */ - NULL /* other */ -}; + const struct bfd_elf_special_section const *ssect; + + /* See if this is one of the special sections. */ + if (sec->name == NULL) + return NULL; + + ssect = _bfd_elf_get_special_section (sec->name, + sh64_elf_special_sections, + sec->use_rela_p); + if (ssect != NULL) + return ssect; + + return _bfd_elf_get_sec_type_attr (abfd, sec); +} #undef TARGET_BIG_SYM #define TARGET_BIG_SYM bfd_elf32_sh64_vec diff --git a/bfd/elf32-v850.c b/bfd/elf32-v850.c index ba98a18..26f479c 100644 --- a/bfd/elf32-v850.c +++ b/bfd/elf32-v850.c @@ -3024,93 +3024,54 @@ v850_elf_relax_section (bfd *abfd, goto finish; } -static struct bfd_elf_special_section const - v850_special_sections_c[]= +static struct bfd_elf_special_section const v850_elf_special_sections[] = { { ".call_table_data", 16, 0, SHT_PROGBITS, (SHF_ALLOC + SHF_WRITE) }, { ".call_table_text", 16, 0, SHT_PROGBITS, (SHF_ALLOC + SHF_WRITE + SHF_EXECINSTR) }, - { NULL, 0, 0, 0, 0 } -}; - -static struct bfd_elf_special_section const - v850_special_sections_r[]= -{ { ".rosdata", 8, -2, SHT_PROGBITS, (SHF_ALLOC + SHF_V850_GPREL) }, { ".rozdata", 8, -2, SHT_PROGBITS, (SHF_ALLOC + SHF_V850_R0REL) }, - { NULL, 0, 0, 0, 0 } -}; - -static struct bfd_elf_special_section const - v850_special_sections_s[]= -{ - { ".sdata", 6, -2, SHT_PROGBITS, (SHF_ALLOC + SHF_WRITE - + SHF_V850_GPREL) }, { ".sbss", 5, -2, SHT_NOBITS, (SHF_ALLOC + SHF_WRITE + SHF_V850_GPREL) }, { ".scommon", 8, -2, SHT_V850_SCOMMON, (SHF_ALLOC + SHF_WRITE + SHF_V850_GPREL) }, - { NULL, 0, 0, 0, 0 } -}; - -static struct bfd_elf_special_section const - v850_special_sections_t[]= -{ - { ".tdata", 6, -2, SHT_PROGBITS, (SHF_ALLOC + SHF_WRITE - + SHF_V850_EPREL) }, + { ".sdata", 6, -2, SHT_PROGBITS, (SHF_ALLOC + SHF_WRITE + + SHF_V850_GPREL) }, { ".tbss", 5, -2, SHT_NOBITS, (SHF_ALLOC + SHF_WRITE + SHF_V850_EPREL) }, { ".tcommon", 8, -2, SHT_V850_TCOMMON, (SHF_ALLOC + SHF_WRITE + SHF_V850_R0REL) }, - { NULL, 0, 0, 0, 0 } -}; - -static struct bfd_elf_special_section const - v850_special_sections_z[]= -{ - { ".zdata", 6, -2, SHT_PROGBITS, (SHF_ALLOC + SHF_WRITE - + SHF_V850_R0REL) }, + { ".tdata", 6, -2, SHT_PROGBITS, (SHF_ALLOC + SHF_WRITE + + SHF_V850_EPREL) }, { ".zbss", 5, -2, SHT_NOBITS, (SHF_ALLOC + SHF_WRITE + SHF_V850_R0REL) }, { ".zcommon", 8, -2, SHT_V850_ZCOMMON, (SHF_ALLOC + SHF_WRITE + SHF_V850_R0REL) }, + { ".zdata", 6, -2, SHT_PROGBITS, (SHF_ALLOC + SHF_WRITE + + SHF_V850_R0REL) }, { NULL, 0, 0, 0, 0 } }; -static struct bfd_elf_special_section const * - v850_elf_special_sections[27] = +static const struct bfd_elf_special_section * +v850_elf_get_sec_type_attr (bfd *abfd, asection *sec) { - NULL, /* 'a' */ - NULL, /* 'b' */ - v850_special_sections_c, /* 'c' */ - NULL, /* 'd' */ - NULL, /* 'e' */ - NULL, /* 'f' */ - NULL, /* 'g' */ - NULL, /* 'h' */ - NULL, /* 'i' */ - NULL, /* 'j' */ - NULL, /* 'k' */ - NULL, /* 'l' */ - NULL, /* 'm' */ - NULL, /* 'n' */ - NULL, /* 'o' */ - NULL, /* 'p' */ - NULL, /* 'q' */ - v850_special_sections_r, /* 'r' */ - v850_special_sections_s, /* 's' */ - v850_special_sections_t, /* 't' */ - NULL, /* 'u' */ - NULL, /* 'v' */ - NULL, /* 'w' */ - NULL, /* 'x' */ - NULL, /* 'y' */ - v850_special_sections_z, /* 'z' */ - NULL /* other */ -}; + const struct bfd_elf_special_section const *ssect; + + /* See if this is one of the special sections. */ + if (sec->name == NULL) + return NULL; + + ssect = _bfd_elf_get_special_section (sec->name, + v850_elf_special_sections, + sec->use_rela_p); + if (ssect != NULL) + return ssect; + + return _bfd_elf_get_sec_type_attr (abfd, sec); +} #define TARGET_LITTLE_SYM bfd_elf32_v850_vec #define TARGET_LITTLE_NAME "elf32-v850" @@ -3135,7 +3096,7 @@ static struct bfd_elf_special_section const * #define elf_backend_fake_sections v850_elf_fake_sections #define elf_backend_gc_mark_hook v850_elf_gc_mark_hook #define elf_backend_gc_sweep_hook v850_elf_gc_sweep_hook -#define elf_backend_special_sections v850_elf_special_sections +#define elf_backend_get_sec_type_attr v850_elf_get_sec_type_attr #define elf_backend_can_gc_sections 1 #define elf_backend_rela_normal 1 diff --git a/bfd/elf32-xtensa.c b/bfd/elf32-xtensa.c index fea89dd..69cc6ba 100644 --- a/bfd/elf32-xtensa.c +++ b/bfd/elf32-xtensa.c @@ -9482,57 +9482,31 @@ xtensa_callback_required_dependence (bfd *abfd, /* The default literal sections should always be marked as "code" (i.e., SHF_EXECINSTR). This is particularly important for the Linux kernel module loader so that the literals are not placed after the text. */ -static struct bfd_elf_special_section const - xtensa_special_sections_f[]= +static struct bfd_elf_special_section const elf_xtensa_special_sections[] = { { ".fini.literal", 13, 0, SHT_PROGBITS, SHF_ALLOC + SHF_EXECINSTR }, - { NULL, 0, 0, 0, 0 } -}; - -static struct bfd_elf_special_section const - xtensa_special_sections_i[]= -{ { ".init.literal", 13, 0, SHT_PROGBITS, SHF_ALLOC + SHF_EXECINSTR }, - { NULL, 0, 0, 0, 0 } -}; -static struct bfd_elf_special_section const - xtensa_special_sections_l[]= -{ { ".literal", 8, 0, SHT_PROGBITS, SHF_ALLOC + SHF_EXECINSTR }, { NULL, 0, 0, 0, 0 } }; -static struct bfd_elf_special_section const * - elf_xtensa_special_sections[27] = -{ - NULL, /* 'a' */ - NULL, /* 'b' */ - NULL, /* 'c' */ - NULL, /* 'd' */ - NULL, /* 'e' */ - xtensa_special_sections_f, /* 'f' */ - NULL, /* 'g' */ - NULL, /* 'h' */ - xtensa_special_sections_i, /* 'i' */ - NULL, /* 'j' */ - NULL, /* 'k' */ - xtensa_special_sections_l, /* 'l' */ - NULL, /* 'm' */ - NULL, /* 'n' */ - NULL, /* 'o' */ - NULL, /* 'p' */ - NULL, /* 'q' */ - NULL, /* 'r' */ - NULL, /* 's' */ - NULL, /* 't' */ - NULL, /* 'u' */ - NULL, /* 'v' */ - NULL, /* 'w' */ - NULL, /* 'x' */ - NULL, /* 'y' */ - NULL, /* 'z' */ - NULL /* other */ -}; +static const struct bfd_elf_special_section * +elf_xtensa_get_sec_type_attr (bfd *abfd, asection *sec) +{ + const struct bfd_elf_special_section const *ssect; + + /* See if this is one of the special sections. */ + if (sec->name == NULL) + return NULL; + + ssect = _bfd_elf_get_special_section (sec->name, + elf_xtensa_special_sections, + sec->use_rela_p); + if (ssect != NULL) + return ssect; + + return _bfd_elf_get_sec_type_attr (abfd, sec); +} #ifndef ELF_ARCH @@ -9592,6 +9566,6 @@ static struct bfd_elf_special_section const * #define elf_backend_reloc_type_class elf_xtensa_reloc_type_class #define elf_backend_relocate_section elf_xtensa_relocate_section #define elf_backend_size_dynamic_sections elf_xtensa_size_dynamic_sections -#define elf_backend_special_sections elf_xtensa_special_sections +#define elf_backend_get_sec_type_attr elf_xtensa_get_sec_type_attr #include "elf32-target.h" diff --git a/bfd/elf64-alpha.c b/bfd/elf64-alpha.c index ac7ada2..52f82d2 100644 --- a/bfd/elf64-alpha.c +++ b/bfd/elf64-alpha.c @@ -5162,45 +5162,30 @@ elf64_alpha_reloc_type_class (const Elf_Internal_Rela *rela) } } -static struct bfd_elf_special_section const - alpha_special_sections_s[]= +static struct bfd_elf_special_section const elf64_alpha_special_sections[] = { - { ".sdata", 6, -2, SHT_PROGBITS, SHF_ALLOC + SHF_WRITE + SHF_ALPHA_GPREL }, { ".sbss", 5, -2, SHT_NOBITS, SHF_ALLOC + SHF_WRITE + SHF_ALPHA_GPREL }, + { ".sdata", 6, -2, SHT_PROGBITS, SHF_ALLOC + SHF_WRITE + SHF_ALPHA_GPREL }, { NULL, 0, 0, 0, 0 } }; -static struct bfd_elf_special_section const * - elf64_alpha_special_sections[27] = +static const struct bfd_elf_special_section * +elf64_alpha_get_sec_type_attr (bfd *abfd, asection *sec) { - NULL, /* 'a' */ - NULL, /* 'b' */ - NULL, /* 'c' */ - NULL, /* 'd' */ - NULL, /* 'e' */ - NULL, /* 'f' */ - NULL, /* 'g' */ - NULL, /* 'h' */ - NULL, /* 'i' */ - NULL, /* 'j' */ - NULL, /* 'k' */ - NULL, /* 'l' */ - NULL, /* 'm' */ - NULL, /* 'n' */ - NULL, /* 'o' */ - NULL, /* 'p' */ - NULL, /* 'q' */ - NULL, /* 'r' */ - alpha_special_sections_s, /* 's' */ - NULL, /* 't' */ - NULL, /* 'u' */ - NULL, /* 'v' */ - NULL, /* 'w' */ - NULL, /* 'x' */ - NULL, /* 'y' */ - NULL, /* 'z' */ - NULL /* other */ -}; + const struct bfd_elf_special_section const *ssect; + + /* See if this is one of the special sections. */ + if (sec->name == NULL) + return NULL; + + ssect = _bfd_elf_get_special_section (sec->name, + elf64_alpha_special_sections, + sec->use_rela_p); + if (ssect != NULL) + return ssect; + + return _bfd_elf_get_sec_type_attr (abfd, sec); +} /* ECOFF swapping routines. These are used when dealing with the .mdebug section, which is in the ECOFF debugging format. Copied @@ -5340,8 +5325,8 @@ static const struct elf_size_info alpha_elf_size_info = #define elf_backend_size_info \ alpha_elf_size_info -#define elf_backend_special_sections \ - elf64_alpha_special_sections +#define elf_backend_get_sec_type_attr \ + elf64_alpha_get_sec_type_attr /* A few constants that determine how the .plt section is set up. */ #define elf_backend_want_got_plt 0 diff --git a/bfd/elf64-hppa.c b/bfd/elf64-hppa.c index 9084f1f..267c623 100644 --- a/bfd/elf64-hppa.c +++ b/bfd/elf64-hppa.c @@ -2671,51 +2671,30 @@ elf64_hppa_elf_get_symbol_type (elf_sym, type) return type; } -static struct bfd_elf_special_section const - hppa_special_sections_f[]= +static struct bfd_elf_special_section const elf64_hppa_special_sections[] = { { ".fini", 5, 0, SHT_PROGBITS, SHF_ALLOC + SHF_WRITE }, - { NULL, 0, 0, 0, 0 } -}; - -static struct bfd_elf_special_section const - hppa_special_sections_i[]= -{ { ".init", 5, 0, SHT_PROGBITS, SHF_ALLOC + SHF_WRITE }, { NULL, 0, 0, 0, 0 } }; -static struct bfd_elf_special_section const * - elf64_hppa_special_sections[27] = +static const struct bfd_elf_special_section * +elf64_hppa_get_sec_type_attr (bfd *abfd, asection *sec) { - NULL, /* 'a' */ - NULL, /* 'b' */ - NULL, /* 'c' */ - NULL, /* 'd' */ - NULL, /* 'e' */ - hppa_special_sections_f, /* 'f' */ - NULL, /* 'g' */ - NULL, /* 'h' */ - hppa_special_sections_i, /* 'i' */ - NULL, /* 'j' */ - NULL, /* 'k' */ - NULL, /* 'l' */ - NULL, /* 'm' */ - NULL, /* 'n' */ - NULL, /* 'o' */ - NULL, /* 'f' */ - NULL, /* 'q' */ - NULL, /* 'r' */ - NULL, /* 's' */ - NULL, /* 't' */ - NULL, /* 'u' */ - NULL, /* 'v' */ - NULL, /* 'w' */ - NULL, /* 'x' */ - NULL, /* 'y' */ - NULL, /* 'z' */ - NULL /* other */ -}; + const struct bfd_elf_special_section const *ssect; + + /* See if this is one of the special sections. */ + if (sec->name == NULL) + return NULL; + + ssect = _bfd_elf_get_special_section (sec->name, + elf64_hppa_special_sections, + sec->use_rela_p); + if (ssect != NULL) + return ssect; + + return _bfd_elf_get_sec_type_attr (abfd, sec); +} /* The hash bucket size is the standard one, namely 4. */ @@ -2813,7 +2792,7 @@ const struct elf_size_info hppa64_elf_size_info = #define elf_backend_get_symbol_type elf64_hppa_elf_get_symbol_type #define elf_backend_reloc_type_class elf64_hppa_reloc_type_class #define elf_backend_rela_normal 1 -#define elf_backend_special_sections elf64_hppa_special_sections +#define elf_backend_get_sec_type_attr elf64_hppa_get_sec_type_attr #include "elf64-target.h" @@ -2822,7 +2801,7 @@ const struct elf_size_info hppa64_elf_size_info = #undef TARGET_BIG_NAME #define TARGET_BIG_NAME "elf64-hppa-linux" -#undef elf_backend_special_sections +#undef elf_backend_get_sec_type_attr #define INCLUDED_TARGET_FILE 1 #include "elf64-target.h" diff --git a/bfd/elf64-ppc.c b/bfd/elf64-ppc.c index 51b6cc9..570754a 100644 --- a/bfd/elf64-ppc.c +++ b/bfd/elf64-ppc.c @@ -100,7 +100,7 @@ static bfd_vma opd_entry_value #define elf_backend_reloc_type_class ppc64_elf_reloc_type_class #define elf_backend_finish_dynamic_sections ppc64_elf_finish_dynamic_sections #define elf_backend_link_output_symbol_hook ppc64_elf_output_symbol_hook -#define elf_backend_special_sections ppc64_elf_special_sections +#define elf_backend_get_sec_type_attr ppc64_elf_get_sec_type_attr /* The name of the dynamic interpreter. This is put in the .interp section. */ @@ -2508,61 +2508,34 @@ ppc64_elf_merge_private_bfd_data (bfd *ibfd, bfd *obfd) /* Add extra PPC sections. */ -static struct bfd_elf_special_section const - ppc64_special_sections_p[]= +static struct bfd_elf_special_section const ppc64_elf_special_sections[]= { { ".plt", 4, 0, SHT_NOBITS, 0 }, - { NULL, 0, 0, 0, 0 } -}; - -static struct bfd_elf_special_section const - ppc64_special_sections_s[]= -{ - { ".sdata", 6, -2, SHT_PROGBITS, SHF_ALLOC + SHF_WRITE }, { ".sbss", 5, -2, SHT_NOBITS, SHF_ALLOC + SHF_WRITE }, - { NULL, 0, 0, 0, 0 } -}; - -static struct bfd_elf_special_section const - ppc64_special_sections_t[]= -{ + { ".sdata", 6, -2, SHT_PROGBITS, SHF_ALLOC + SHF_WRITE }, { ".toc", 4, 0, SHT_PROGBITS, SHF_ALLOC + SHF_WRITE }, { ".toc1", 5, 0, SHT_PROGBITS, SHF_ALLOC + SHF_WRITE }, { ".tocbss", 7, 0, SHT_NOBITS, SHF_ALLOC + SHF_WRITE }, { NULL, 0, 0, 0, 0 } }; -static struct bfd_elf_special_section const * - ppc64_elf_special_sections[27]= +static const struct bfd_elf_special_section * +ppc64_elf_get_sec_type_attr (bfd *abfd, asection *sec) { - NULL, /* 'a' */ - NULL, /* 'b' */ - NULL, /* 'c' */ - NULL, /* 'd' */ - NULL, /* 'e' */ - NULL, /* 'f' */ - NULL, /* 'g' */ - NULL, /* 'h' */ - NULL, /* 'i' */ - NULL, /* 'j' */ - NULL, /* 'k' */ - NULL, /* 'l' */ - NULL, /* 'm' */ - NULL, /* 'n' */ - NULL, /* 'o' */ - ppc64_special_sections_p, /* 'p' */ - NULL, /* 'q' */ - NULL, /* 'r' */ - ppc64_special_sections_s, /* 's' */ - ppc64_special_sections_t, /* 't' */ - NULL, /* 'u' */ - NULL, /* 'v' */ - NULL, /* 'w' */ - NULL, /* 'x' */ - NULL, /* 'y' */ - NULL, /* 'z' */ - NULL /* other */ -}; + const struct bfd_elf_special_section const *ssect; + + /* See if this is one of the special sections. */ + if (sec->name == NULL) + return NULL; + + ssect = _bfd_elf_get_special_section (sec->name, + ppc64_elf_special_sections, + sec->use_rela_p); + if (ssect != NULL) + return ssect; + + return _bfd_elf_get_sec_type_attr (abfd, sec); +} struct _ppc64_elf_section_data { diff --git a/bfd/elf64-sh64.c b/bfd/elf64-sh64.c index 2b4630d..16fbe5e 100644 --- a/bfd/elf64-sh64.c +++ b/bfd/elf64-sh64.c @@ -4068,44 +4068,29 @@ sh64_elf64_merge_symbol_attribute (struct elf_link_hash_entry *h, return; } -static struct bfd_elf_special_section const - sh64_special_sections_c[] = +static struct bfd_elf_special_section const sh64_elf64_special_sections[]= { { ".cranges", 8, 0, SHT_PROGBITS, 0 }, - { NULL, 0, 0, 0, 0 } + { NULL, 0, 0, 0, 0 } }; -static struct bfd_elf_special_section const * - sh64_elf64_special_sections[27]= +static const struct bfd_elf_special_section * +sh64_elf64_get_sec_type_attr (bfd *abfd, asection *sec) { - NULL, /* 'a' */ - NULL, /* 'b' */ - sh64_special_sections_c, /* 'c' */ - NULL, /* 'd' */ - NULL, /* 'e' */ - NULL, /* 'f' */ - NULL, /* 'g' */ - NULL, /* 'h' */ - NULL, /* 'i' */ - NULL, /* 'j' */ - NULL, /* 'k' */ - NULL, /* 'l' */ - NULL, /* 'm' */ - NULL, /* 'n' */ - NULL, /* 'o' */ - NULL, /* 'p' */ - NULL, /* 'q' */ - NULL, /* 'r' */ - NULL, /* 's' */ - NULL, /* 't' */ - NULL, /* 'u' */ - NULL, /* 'v' */ - NULL, /* 'w' */ - NULL, /* 'x' */ - NULL, /* 'y' */ - NULL, /* 'z' */ - NULL /* other */ -}; + const struct bfd_elf_special_section const *ssect; + + /* See if this is one of the special sections. */ + if (sec->name == NULL) + return NULL; + + ssect = _bfd_elf_get_special_section (sec->name, + sh64_elf64_special_sections, + sec->use_rela_p); + if (ssect != NULL) + return ssect; + + return _bfd_elf_get_sec_type_attr (abfd, sec); +} #define TARGET_BIG_SYM bfd_elf64_sh64_vec #define TARGET_BIG_NAME "elf64-sh64" @@ -4165,7 +4150,7 @@ static struct bfd_elf_special_section const * sh64_elf64_finish_dynamic_symbol #define elf_backend_finish_dynamic_sections \ sh64_elf64_finish_dynamic_sections -#define elf_backend_special_sections sh64_elf64_special_sections +#define elf_backend_get_sec_type_attr sh64_elf64_get_sec_type_attr #define elf_backend_want_got_plt 1 #define elf_backend_plt_readonly 1 diff --git a/bfd/elfxx-ia64.c b/bfd/elfxx-ia64.c index 9963734..d9f8762 100644 --- a/bfd/elfxx-ia64.c +++ b/bfd/elfxx-ia64.c @@ -5050,45 +5050,30 @@ elfNN_ia64_reloc_type_class (rela) } } -static struct bfd_elf_special_section const - ia64_special_sections_s[]= +static struct bfd_elf_special_section const elfNN_ia64_special_sections[] = { { ".sbss", 5, -1, SHT_NOBITS, SHF_ALLOC + SHF_WRITE + SHF_IA_64_SHORT }, { ".sdata", 6, -1, SHT_PROGBITS, SHF_ALLOC + SHF_WRITE + SHF_IA_64_SHORT }, { NULL, 0, 0, 0, 0 } }; -static struct bfd_elf_special_section const * - elfNN_ia64_special_sections[27] = +static const struct bfd_elf_special_section * +elfNN_ia64_get_sec_type_attr (bfd *abfd, asection *sec) { - NULL, /* 'a' */ - NULL, /* 'b' */ - NULL, /* 'c' */ - NULL, /* 'd' */ - NULL, /* 'e' */ - NULL, /* 'f' */ - NULL, /* 'g' */ - NULL, /* 'h' */ - NULL, /* 'i' */ - NULL, /* 'j' */ - NULL, /* 'k' */ - NULL, /* 'l' */ - NULL, /* 'm' */ - NULL, /* 'n' */ - NULL, /* 'o' */ - NULL, /* 'p' */ - NULL, /* 'q' */ - NULL, /* 'r' */ - ia64_special_sections_s, /* 's' */ - NULL, /* 't' */ - NULL, /* 'u' */ - NULL, /* 'v' */ - NULL, /* 'w' */ - NULL, /* 'x' */ - NULL, /* 'y' */ - NULL, /* 'z' */ - NULL /* other */ -}; + const struct bfd_elf_special_section const *ssect; + + /* See if this is one of the special sections. */ + if (sec->name == NULL) + return NULL; + + ssect = _bfd_elf_get_special_section (sec->name, + elfNN_ia64_special_sections, + sec->use_rela_p); + if (ssect != NULL) + return ssect; + + return _bfd_elf_get_sec_type_attr (abfd, sec); +} static bfd_boolean elfNN_ia64_object_p (bfd *abfd) @@ -5311,7 +5296,7 @@ elfNN_hpux_backend_symbol_processing (bfd *abfd ATTRIBUTE_UNUSED, #define elf_backend_hide_symbol elfNN_ia64_hash_hide_symbol #define elf_backend_reloc_type_class elfNN_ia64_reloc_type_class #define elf_backend_rela_normal 1 -#define elf_backend_special_sections elfNN_ia64_special_sections +#define elf_backend_get_sec_type_attr elfNN_ia64_get_sec_type_attr /* FIXME: PR 290: The Intel C compiler generates SHT_IA_64_UNWIND with SHF_LINK_ORDER. But it doesn't set theh sh_link or sh_info fields. diff --git a/bfd/elfxx-mips.c b/bfd/elfxx-mips.c index 10ce7d1..dc75331 100644 --- a/bfd/elfxx-mips.c +++ b/bfd/elfxx-mips.c @@ -9969,63 +9969,31 @@ _bfd_mips_elf_print_private_bfd_data (bfd *abfd, void *ptr) return TRUE; } -static struct bfd_elf_special_section const - mips_special_sections_l[]= +struct bfd_elf_special_section const _bfd_mips_elf_special_sections[] = { { ".lit4", 5, 0, SHT_PROGBITS, SHF_ALLOC + SHF_WRITE + SHF_MIPS_GPREL }, { ".lit8", 5, 0, SHT_PROGBITS, SHF_ALLOC + SHF_WRITE + SHF_MIPS_GPREL }, - { NULL, 0, 0, 0, 0 } -}; - -static struct bfd_elf_special_section const - mips_special_sections_m[]= -{ { ".mdebug", 7, 0, SHT_MIPS_DEBUG, 0 }, + { ".sbss", 5, -2, SHT_NOBITS, SHF_ALLOC + SHF_WRITE + SHF_MIPS_GPREL }, + { ".sdata", 6, -2, SHT_PROGBITS, SHF_ALLOC + SHF_WRITE + SHF_MIPS_GPREL }, + { ".ucode", 6, 0, SHT_MIPS_UCODE, 0 }, { NULL, 0, 0, 0, 0 } }; -static struct bfd_elf_special_section const - mips_special_sections_s[]= +const struct bfd_elf_special_section * +_bfd_mips_elf_get_sec_type_attr (bfd *abfd, asection *sec) { - { ".sdata", 6, -2, SHT_PROGBITS, SHF_ALLOC + SHF_WRITE + SHF_MIPS_GPREL }, - { ".sbss", 5, -2, SHT_NOBITS, SHF_ALLOC + SHF_WRITE + SHF_MIPS_GPREL }, -}; + const struct bfd_elf_special_section const *ssect; -static struct bfd_elf_special_section const - mips_special_sections_u[]= -{ - { ".ucode", 6, 0, SHT_MIPS_UCODE, 0 }, - { NULL, 0, 0, 0, 0 } -}; + /* See if this is one of the special sections. */ + if (sec->name == NULL) + return NULL; -struct bfd_elf_special_section const * - _bfd_mips_elf_special_sections[27] = -{ - NULL, /* 'a' */ - NULL, /* 'b' */ - NULL, /* 'c' */ - NULL, /* 'd' */ - NULL, /* 'e' */ - NULL, /* 'f' */ - NULL, /* 'g' */ - NULL, /* 'h' */ - NULL, /* 'i' */ - NULL, /* 'j' */ - NULL, /* 'k' */ - mips_special_sections_l, /* 'l' */ - mips_special_sections_m, /* 'm' */ - NULL, /* 'n' */ - NULL, /* 'o' */ - NULL, /* 'p' */ - NULL, /* 'q' */ - NULL, /* 'r' */ - mips_special_sections_s, /* 'm' */ - NULL, /* 't' */ - mips_special_sections_u, /* 'u' */ - NULL, /* 'v' */ - NULL, /* 'w' */ - NULL, /* 'x' */ - NULL, /* 'y' */ - NULL, /* 'z' */ - NULL /* other */ -}; + ssect = _bfd_elf_get_special_section (sec->name, + _bfd_mips_elf_special_sections, + sec->use_rela_p); + if (ssect != NULL) + return ssect; + + return _bfd_elf_get_sec_type_attr (abfd, sec); +} diff --git a/bfd/elfxx-mips.h b/bfd/elfxx-mips.h index 624d4ab..2c63123 100644 --- a/bfd/elfxx-mips.h +++ b/bfd/elfxx-mips.h @@ -127,9 +127,10 @@ extern bfd_boolean _bfd_mips_relax_section (bfd *, asection *, struct bfd_link_info *, bfd_boolean *); extern bfd_vma _bfd_mips_elf_sign_extend (bfd_vma, int); +extern const struct bfd_elf_special_section *_bfd_mips_elf_get_sec_type_attr + (bfd *, asection *); -extern struct bfd_elf_special_section const *_bfd_mips_elf_special_sections[]; #define elf_backend_name_local_section_symbols \ _bfd_mips_elf_name_local_section_symbols -#define elf_backend_special_sections _bfd_mips_elf_special_sections +#define elf_backend_get_sec_type_attr _bfd_mips_elf_get_sec_type_attr #define elf_backend_eh_frame_address_size _bfd_mips_elf_eh_frame_address_size diff --git a/bfd/elfxx-target.h b/bfd/elfxx-target.h index fcfd040..7a7f3e8 100644 --- a/bfd/elfxx-target.h +++ b/bfd/elfxx-target.h @@ -331,6 +331,9 @@ #ifndef elf_backend_section_flags #define elf_backend_section_flags 0 #endif +#ifndef elf_backend_get_sec_type_attr +#define elf_backend_get_sec_type_attr _bfd_elf_get_sec_type_attr +#endif #ifndef elf_backend_section_from_phdr #define elf_backend_section_from_phdr _bfd_elf_make_section_from_phdr #endif @@ -506,10 +509,6 @@ #define elf_backend_size_info _bfd_elfNN_size_info #endif -#ifndef elf_backend_special_sections -#define elf_backend_special_sections NULL -#endif - #ifndef elf_backend_sign_extend_vma #define elf_backend_sign_extend_vma 0 #endif @@ -540,6 +539,7 @@ static const struct elf_backend_data elfNN_bed = elf_backend_section_processing, elf_backend_section_from_shdr, elf_backend_section_flags, + elf_backend_get_sec_type_attr, elf_backend_section_from_phdr, elf_backend_fake_sections, elf_backend_section_from_bfd_section, @@ -591,7 +591,6 @@ static const struct elf_backend_data elfNN_bed = ELF_MACHINE_ALT1, ELF_MACHINE_ALT2, &elf_backend_size_info, - elf_backend_special_sections, elf_backend_got_header_size, elf_backend_collect, elf_backend_type_change_ok, diff --git a/binutils/ChangeLog b/binutils/ChangeLog index 3e25586..2498494 100644 --- a/binutils/ChangeLog +++ b/binutils/ChangeLog @@ -1,3 +1,10 @@ +2005-07-04 Alan Modra <amodra@bigpond.net.au> + + PR 1004 + * objcopy.c (copy_object): Use bfd_make_section_with_flags. + (write_debugging_info): Likewise. + (setup_section): Use bfd_make_section_anyway_with_flags. + 2005-07-01 Steve Ellcey <sje@cup.hp.com> * configure.in (AM_BINUTILS_WARNINGS): Add. diff --git a/binutils/objcopy.c b/binutils/objcopy.c index 4dfba3c..abc0eb1 100644 --- a/binutils/objcopy.c +++ b/binutils/objcopy.c @@ -1290,7 +1290,15 @@ copy_object (bfd *ibfd, bfd *obfd) { flagword flags; - padd->section = bfd_make_section (obfd, padd->name); + pset = find_section_list (padd->name, FALSE); + if (pset != NULL) + pset->used = TRUE; + + flags = SEC_HAS_CONTENTS | SEC_READONLY | SEC_DATA; + if (pset != NULL && pset->set_flags) + flags = pset->flags | SEC_HAS_CONTENTS; + + padd->section = bfd_make_section_with_flags (obfd, padd->name, flags); if (padd->section == NULL) { non_fatal (_("can't create section `%s': %s"), @@ -1304,21 +1312,6 @@ copy_object (bfd *ibfd, bfd *obfd) return FALSE; } - pset = find_section_list (padd->name, FALSE); - if (pset != NULL) - pset->used = TRUE; - - if (pset != NULL && pset->set_flags) - flags = pset->flags | SEC_HAS_CONTENTS; - else - flags = SEC_HAS_CONTENTS | SEC_READONLY | SEC_DATA; - - if (! bfd_set_section_flags (obfd, padd->section, flags)) - { - bfd_nonfatal (bfd_get_filename (obfd)); - return FALSE; - } - if (pset != NULL) { if (pset->change_vma != CHANGE_IGNORE) @@ -2001,7 +1994,12 @@ setup_section (bfd *ibfd, sec_ptr isection, void *obfdarg) name = n; } - osection = bfd_make_section_anyway (obfd, name); + if (p != NULL && p->set_flags) + flags = p->flags | (flags & (SEC_HAS_CONTENTS | SEC_RELOC)); + else if (strip_symbols == STRIP_NONDEBUG && (flags & SEC_ALLOC) != 0) + flags &= ~(SEC_HAS_CONTENTS | SEC_LOAD); + + osection = bfd_make_section_anyway_with_flags (obfd, name, flags); if (osection == NULL) { @@ -2009,6 +2007,12 @@ setup_section (bfd *ibfd, sec_ptr isection, void *obfdarg) goto loser; } + if (strip_symbols == STRIP_NONDEBUG + && obfd->xvec->flavour == bfd_target_elf_flavour + && (flags & SEC_ALLOC) != 0 + && (p == NULL || !p->set_flags)) + elf_section_type (osection) = SHT_NOBITS; + size = bfd_section_size (ibfd, isection); if (copy_byte >= 0) size = (size + interleave - 1) / interleave; @@ -2057,21 +2061,6 @@ setup_section (bfd *ibfd, sec_ptr isection, void *obfdarg) goto loser; } - if (p != NULL && p->set_flags) - flags = p->flags | (flags & (SEC_HAS_CONTENTS | SEC_RELOC)); - else if (strip_symbols == STRIP_NONDEBUG && (flags & SEC_ALLOC) != 0) - { - flags &= ~(SEC_HAS_CONTENTS | SEC_LOAD); - if (obfd->xvec->flavour == bfd_target_elf_flavour) - elf_section_type (osection) = SHT_NOBITS; - } - - if (!bfd_set_section_flags (obfd, osection, flags)) - { - err = _("flags"); - goto loser; - } - /* Copy merge entity size. */ osection->entsize = isection->entsize; @@ -2353,28 +2342,22 @@ write_debugging_info (bfd *obfd, void *dhandle, bfd_byte *syms, *strings; bfd_size_type symsize, stringsize; asection *stabsec, *stabstrsec; + flagword flags; if (! write_stabs_in_sections_debugging_info (obfd, dhandle, &syms, &symsize, &strings, &stringsize)) return FALSE; - stabsec = bfd_make_section (obfd, ".stab"); - stabstrsec = bfd_make_section (obfd, ".stabstr"); + flags = SEC_HAS_CONTENTS | SEC_READONLY | SEC_DEBUGGING; + stabsec = bfd_make_section_with_flags (obfd, ".stab", flags); + stabstrsec = bfd_make_section_with_flags (obfd, ".stabstr", flags); if (stabsec == NULL || stabstrsec == NULL || ! bfd_set_section_size (obfd, stabsec, symsize) || ! bfd_set_section_size (obfd, stabstrsec, stringsize) || ! bfd_set_section_alignment (obfd, stabsec, 2) - || ! bfd_set_section_alignment (obfd, stabstrsec, 0) - || ! bfd_set_section_flags (obfd, stabsec, - (SEC_HAS_CONTENTS - | SEC_READONLY - | SEC_DEBUGGING)) - || ! bfd_set_section_flags (obfd, stabstrsec, - (SEC_HAS_CONTENTS - | SEC_READONLY - | SEC_DEBUGGING))) + || ! bfd_set_section_alignment (obfd, stabstrsec, 0)) { non_fatal (_("%s: can't create debugging section: %s"), bfd_get_filename (obfd), diff --git a/gas/ChangeLog b/gas/ChangeLog index 2fd0e63..b883fbc 100644 --- a/gas/ChangeLog +++ b/gas/ChangeLog @@ -1,3 +1,9 @@ +2005-07-04 Alan Modra <amodra@bigpond.net.au> + + PR 1004 + * config/obj-elf.c (obj_elf_change_section): Use backend + get_sec_type_attr. + 2005-07-01 Jan Beulich <jbeulich@novell.com> * config/tc-ia64.c (line_separator_chars): Add '{' and '}'. diff --git a/gas/config/obj-elf.c b/gas/config/obj-elf.c index 1db7b48..d015dab 100644 --- a/gas/config/obj-elf.c +++ b/gas/config/obj-elf.c @@ -520,6 +520,7 @@ obj_elf_change_section (const char *name, asection *old_sec; segT sec; flagword flags; + const struct elf_backend_data *bed; const struct bfd_elf_special_section *ssect; #ifdef md_flush_pending_output @@ -551,7 +552,8 @@ obj_elf_change_section (const char *name, else sec = subseg_force_new (name, 0); - ssect = _bfd_elf_get_sec_type_attr (stdoutput, name); + bed = get_elf_backend_data (stdoutput); + ssect = (*bed->get_sec_type_attr) (stdoutput, sec); if (ssect != NULL) { |