diff options
author | H.J. Lu <hjl.tools@gmail.com> | 2003-07-25 14:35:56 +0000 |
---|---|---|
committer | H.J. Lu <hjl.tools@gmail.com> | 2003-07-25 14:35:56 +0000 |
commit | 2f89ff8d8ead0e6eb034d7c26470be4eac7c3185 (patch) | |
tree | deecbf5e1012acc2b9492ad093cde8236a3404e6 /bfd | |
parent | 20650579793e339d3438ee509c464a253d7ef079 (diff) | |
download | gdb-2f89ff8d8ead0e6eb034d7c26470be4eac7c3185.zip gdb-2f89ff8d8ead0e6eb034d7c26470be4eac7c3185.tar.gz gdb-2f89ff8d8ead0e6eb034d7c26470be4eac7c3185.tar.bz2 |
bfd/
2003-07-25 H.J. Lu <hongjiu.lu@intel.com>
* elf-bfd.h (bfd_elf_special_section): New.
(elf_backend_data): Add special_sections, a pointer to
bfd_elf_special_section.
(elf_section_type). New.
(elf_section_flags): New.
(_bfd_elf_get_sec_type_attr): New.
* elf.c (_bfd_elf_make_section_from_shdr): Always use the
real section type/flags.
(special_sections): New.
(get_special_section): New.
(_bfd_elf_get_sec_type_attr): New.
(_bfd_elf_new_section_hook): Check special_section to set
elf_section_type and elf_section_flags.
(elf_fake_sections): Don't use section name to set ELF section
data.
* elf32-m32r.c (m32r_elf_special_sections): New.
(elf_backend_special_sections): Defined.
* elf32-m68hc11.c (elf32_m68hc11_special_sections): New.
(elf_backend_special_sections): Defined.
* elf32-mcore.c (mcore_elf_special_sections): New.
(elf_backend_special_sections): Defined.
* elf32-ppc.c (ppc_elf_special_sections): New.
(elf_backend_special_sections): Defined.
* elf32-sh64.c (sh64_elf_special_sections): New.
(elf_backend_special_sections): Defined.
* elf32-v850.c (v850_elf_special_sections): New.
(elf_backend_special_sections): Defined.
* elf32-xtensa.c (elf_xtensa_special_sections): New.
(elf_backend_special_sections): Defined.
* elf64-alpha.c (elf64_alpha_special_sections): New.
(elf_backend_special_sections): Defined.
* elf64-hppa.c (elf64_hppa_special_sections): New.
(elf_backend_special_sections): Defined.
* elf64-ppc.c (ppc64_elf_special_sections): New.
(elf_backend_special_sections): Defined.
* elf64-sh64.c (sh64_elf64_special_sections): New.
(elf_backend_special_sections): Defined.
* elfxx-ia64.c (elfNN_ia64_special_sections): New.
(elf_backend_special_sections): Defined.
* elfxx-mips.c (_bfd_mips_elf_special_sections): New.
* elfxx-mips.h (_bfd_mips_elf_special_sections): New.
(elf_backend_special_sections): Defined.
* elfxx-target.h (elf_backend_special_sections): New. Default
to NULL.
(elfNN_bed): Initialize special_sections.
* section.c (bfd_abs_section): Remove const.
(bfd_und_section): Likewise.
(bfd_com_section): Likewise.
(bfd_ind_section): Likewise.
gas/
2003-07-25 H.J. Lu <hongjiu.lu@intel.com>
* config/obj-elf.c (special_sections): Removed.
(obj_elf_change_section): Call _bfd_elf_get_sec_type_attr. Set
elf_section_type and elf_section_flags.
(elf_frob_file): Set SHT_GROUP.
* config/obj-elf.h (obj_sec_set_private_data): New.
* config/tc-alpha.h (ELF_TC_SPECIAL_SECTIONS): Removed.
* config/tc-ia64.h: Likewise.
* config/tc-m32r.h: Likewise.
* config/tc-m68hc11.h: Likewise.
* config/tc-mcore.h: Likewise.
* config/tc-mips.h: Likewise.
* config/tc-ppc.h: Likewise.
* config/tc-sh64.h: Likewise.
* config/tc-v850.h: Likewise.
* config/tc-xtensa.h: Likewise.
* config/tc-v850.h (SHF_V850_GPREL): Removed.
(SHF_V850_EPREL): Likewise.
(SHF_V850_R0REL): Likewise.
* subsegs.c (subseg_get): Call obj_sec_set_private_data if it
is defined.
include/elf/
2003-07-25 H.J. Lu <hongjiu.lu@intel.com>
* v850.h (SHF_V850_GPREL): New.
(SHF_V850_EPREL): Likewise.
(SHF_V850_R0REL): Likewise.
Diffstat (limited to 'bfd')
-rw-r--r-- | bfd/ChangeLog | 69 | ||||
-rw-r--r-- | bfd/elf-bfd.h | 18 | ||||
-rw-r--r-- | bfd/elf.c | 256 | ||||
-rw-r--r-- | bfd/elf32-m32r.c | 11 | ||||
-rw-r--r-- | bfd/elf32-m68hc11.c | 20 | ||||
-rw-r--r-- | bfd/elf32-mcore.c | 11 | ||||
-rw-r--r-- | bfd/elf32-ppc.c | 30 | ||||
-rw-r--r-- | bfd/elf32-sh64.c | 9 | ||||
-rw-r--r-- | bfd/elf32-v850.c | 33 | ||||
-rw-r--r-- | bfd/elf32-xtensa.c | 16 | ||||
-rw-r--r-- | bfd/elf64-alpha.c | 13 | ||||
-rw-r--r-- | bfd/elf64-hppa.c | 13 | ||||
-rw-r--r-- | bfd/elf64-ppc.c | 35 | ||||
-rw-r--r-- | bfd/elf64-sh64.c | 9 | ||||
-rw-r--r-- | bfd/elfxx-ia64.c | 11 | ||||
-rw-r--r-- | bfd/elfxx-mips.c | 18 | ||||
-rw-r--r-- | bfd/elfxx-mips.h | 3 | ||||
-rw-r--r-- | bfd/elfxx-target.h | 5 | ||||
-rw-r--r-- | bfd/section.c | 10 |
19 files changed, 527 insertions, 63 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog index f95dea1..643f13e 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,72 @@ +2003-07-25 H.J. Lu <hongjiu.lu@intel.com> + + * elf-bfd.h (bfd_elf_special_section): New. + (elf_backend_data): Add special_sections, a pointer to + bfd_elf_special_section. + (elf_section_type). New. + (elf_section_flags): New. + (_bfd_elf_get_sec_type_attr): New. + + * elf.c (_bfd_elf_make_section_from_shdr): Always use the + real section type/flags. + (special_sections): New. + (get_special_section): New. + (_bfd_elf_get_sec_type_attr): New. + (_bfd_elf_new_section_hook): Check special_section to set + elf_section_type and elf_section_flags. + (elf_fake_sections): Don't use section name to set ELF section + data. + + * elf32-m32r.c (m32r_elf_special_sections): New. + (elf_backend_special_sections): Defined. + + * elf32-m68hc11.c (elf32_m68hc11_special_sections): New. + (elf_backend_special_sections): Defined. + + * elf32-mcore.c (mcore_elf_special_sections): New. + (elf_backend_special_sections): Defined. + + * elf32-ppc.c (ppc_elf_special_sections): New. + (elf_backend_special_sections): Defined. + + * elf32-sh64.c (sh64_elf_special_sections): New. + (elf_backend_special_sections): Defined. + + * elf32-v850.c (v850_elf_special_sections): New. + (elf_backend_special_sections): Defined. + + * elf32-xtensa.c (elf_xtensa_special_sections): New. + (elf_backend_special_sections): Defined. + + * elf64-alpha.c (elf64_alpha_special_sections): New. + (elf_backend_special_sections): Defined. + + * elf64-hppa.c (elf64_hppa_special_sections): New. + (elf_backend_special_sections): Defined. + + * elf64-ppc.c (ppc64_elf_special_sections): New. + (elf_backend_special_sections): Defined. + + * elf64-sh64.c (sh64_elf64_special_sections): New. + (elf_backend_special_sections): Defined. + + * elfxx-ia64.c (elfNN_ia64_special_sections): New. + (elf_backend_special_sections): Defined. + + * elfxx-mips.c (_bfd_mips_elf_special_sections): New. + + * elfxx-mips.h (_bfd_mips_elf_special_sections): New. + (elf_backend_special_sections): Defined. + + * elfxx-target.h (elf_backend_special_sections): New. Default + to NULL. + (elfNN_bed): Initialize special_sections. + + * section.c (bfd_abs_section): Remove const. + (bfd_und_section): Likewise. + (bfd_com_section): Likewise. + (bfd_ind_section): Likewise. + 2003-07-24 Nick Clifton <nickc@redhat.com> * coff-arm.c (EXTRA_S_FLAGS): Include SEC_CODE so that code diff --git a/bfd/elf-bfd.h b/bfd/elf-bfd.h index 2aa0c59..d297a77 100644 --- a/bfd/elf-bfd.h +++ b/bfd/elf-bfd.h @@ -510,6 +510,17 @@ typedef enum { ict_irix6 } irix_compat_t; +/* Mapping of ELF section names and types. */ +struct bfd_elf_special_section +{ + const char *prefix; + size_t prefix_length; + const char *suffix; + size_t suffix_length; + int type; + int attributes; +}; + struct elf_backend_data { /* The architecture for this backend. */ @@ -871,6 +882,9 @@ struct elf_backend_data const struct elf_size_info *s; + /* An array of target specific special section map. */ + const struct bfd_elf_special_section *special_sections; + /* offset of the _GLOBAL_OFFSET_TABLE_ symbol from the start of the .got section */ bfd_vma got_symbol_offset; @@ -1006,6 +1020,8 @@ struct bfd_elf_section_data }; #define elf_section_data(sec) ((struct bfd_elf_section_data*)sec->used_by_bfd) +#define elf_section_type(sec) (elf_section_data(sec)->this_hdr.sh_type) +#define elf_section_flags(sec) (elf_section_data(sec)->this_hdr.sh_flags) #define elf_group_name(sec) (elf_section_data(sec)->group.name) #define elf_group_id(sec) (elf_section_data(sec)->group.id) #define elf_next_in_group(sec) (elf_section_data(sec)->next_in_group) @@ -1374,6 +1390,8 @@ extern bfd_boolean _bfd_elf_new_section_hook PARAMS ((bfd *, asection *)); extern bfd_boolean _bfd_elf_init_reloc_shdr PARAMS ((bfd *, Elf_Internal_Shdr *, asection *, bfd_boolean)); +extern bfd_boolean _bfd_elf_get_sec_type_attr (bfd *, const char *, + int *, int *); /* If the target doesn't have reloc handling written yet: */ extern void _bfd_elf_no_info_to_howto @@ -741,6 +741,10 @@ _bfd_elf_make_section_from_shdr (abfd, hdr, name) if (newsect == NULL) return FALSE; + /* Always use the real type/flags. */ + elf_section_type (newsect) = hdr->sh_type; + elf_section_flags (newsect) = hdr->sh_flags; + newsect->filepos = hdr->sh_offset; if (! bfd_set_section_vma (abfd, newsect, hdr->sh_addr) @@ -2139,12 +2143,145 @@ bfd_section_from_elf_index (abfd, index) return elf_elfsections (abfd)[index]->bfd_section; } +static struct bfd_elf_special_section const special_sections[] = +{ + { ".bss", 0, NULL, 0, + SHT_NOBITS, SHF_ALLOC + SHF_WRITE }, + { ".comment", 0, NULL, 0, + SHT_PROGBITS, 0 }, + { ".data", 0, NULL, 0, + SHT_PROGBITS, SHF_ALLOC + SHF_WRITE }, + { ".data1", 0, NULL, 0, + SHT_PROGBITS, SHF_ALLOC + SHF_WRITE }, + { ".debug", 0, NULL, 0, + SHT_PROGBITS, 0 }, + { ".fini", 0, NULL, 0, + SHT_PROGBITS, SHF_ALLOC + SHF_EXECINSTR }, + { ".init", 0, NULL, 0, + SHT_PROGBITS, SHF_ALLOC + SHF_EXECINSTR }, + { ".line", 0, NULL, 0, + SHT_PROGBITS, 0 }, + { ".rodata", 0, NULL, 0, + SHT_PROGBITS, SHF_ALLOC }, + { ".rodata1", 0, NULL, 0, + SHT_PROGBITS, SHF_ALLOC }, + { ".tbss", 0, NULL, 0, + SHT_NOBITS, SHF_ALLOC + SHF_WRITE + SHF_TLS }, + { ".tdata", 0, NULL, 0, + SHT_PROGBITS, SHF_ALLOC + SHF_WRITE + SHF_TLS }, + { ".text", 0, NULL, 0, + SHT_PROGBITS, SHF_ALLOC + SHF_EXECINSTR }, + { ".init_array", 0, NULL, 0, + SHT_INIT_ARRAY, SHF_ALLOC + SHF_WRITE }, + { ".fini_array", 0, NULL, 0, + SHT_FINI_ARRAY, SHF_ALLOC + SHF_WRITE }, + { ".preinit_array", 0, NULL, 0, + SHT_PREINIT_ARRAY, SHF_ALLOC + SHF_WRITE }, + { ".debug_line", 0, NULL, 0, + SHT_PROGBITS, 0 }, + { ".debug_info", 0, NULL, 0, + SHT_PROGBITS, 0 }, + { ".debug_abbrev", 0, NULL, 0, + SHT_PROGBITS, 0 }, + { ".debug_aranges", 0, NULL, 0, + SHT_PROGBITS, 0 }, + { ".dynamic", 0, NULL, 0, + SHT_DYNAMIC, SHF_ALLOC }, + { ".dynstr", 0, NULL, 0, + SHT_STRTAB, SHF_ALLOC }, + { ".dynsym", 0, NULL, 0, + SHT_DYNSYM, SHF_ALLOC }, + { ".got", 0, NULL, 0, + SHT_PROGBITS, 0 }, + { ".hash", 0, NULL, 0, + SHT_HASH, SHF_ALLOC }, + { ".interp", 0, NULL, 0, + SHT_PROGBITS, 0 }, + { ".plt", 0, NULL, 0, + SHT_PROGBITS, 0 }, + { ".shstrtab", 0, NULL, 0, + SHT_STRTAB, 0 }, + { ".strtab", 0, NULL, 0, + SHT_STRTAB, 0 }, + { ".symtab", 0, NULL, 0, + SHT_SYMTAB, 0 }, + { ".gnu.version", 0, NULL, 0, + SHT_GNU_versym, 0 }, + { ".gnu.version_d", 0, NULL, 0, + SHT_GNU_verdef, 0 }, + { ".gnu.version_r", 0, NULL, 0, + SHT_GNU_verneed, 0 }, + { ".note", 5, NULL, 0, + SHT_NOTE, 0 }, + { ".rela", 5, NULL, 0, + SHT_RELA, 0 }, + { ".rel", 4, NULL, 0, + SHT_REL, 0 }, + { ".stab", 5, "str", 3, + SHT_STRTAB, 0 }, + { NULL, 0, NULL, 0, + 0, 0 } +}; + +static const struct bfd_elf_special_section * +get_special_section (const char *name, + const struct bfd_elf_special_section *special_sections, + unsigned int rela) +{ + int i; + + for (i = 0; special_sections[i].prefix != NULL; i++) + if (((special_sections[i].prefix_length + && strncmp (name, special_sections[i].prefix, + special_sections[i].prefix_length) == 0 + && (! special_sections[i].suffix_length + || strcmp ((name + strlen (name) + - special_sections[i].suffix_length), + special_sections[i].suffix) == 0)) + || strcmp (name, special_sections[i].prefix) == 0) + && (rela || special_sections[i].type != SHT_RELA)) + return &special_sections[i]; + + return NULL; +} + +bfd_boolean +_bfd_elf_get_sec_type_attr (bfd *abfd, const char *name, + int *type, int *attr) +{ + bfd_boolean found = FALSE; + struct elf_backend_data *bed = get_elf_backend_data (abfd); + + /* See if this is one of the special sections. */ + if (name) + { + const struct bfd_elf_special_section *ssect = NULL; + unsigned int rela = get_elf_backend_data (abfd)->default_use_rela_p; + + if (bed->special_sections) + ssect = get_special_section (name, bed->special_sections, rela); + + if (! ssect) + ssect = get_special_section (name, special_sections, rela); + + if (ssect) + { + *type = ssect->type; + *attr = ssect->attributes; + found = TRUE; + } + } + + return found; +} + bfd_boolean _bfd_elf_new_section_hook (abfd, sec) bfd *abfd; asection *sec; { struct bfd_elf_section_data *sdata; + int type, attr; sdata = (struct bfd_elf_section_data *) sec->used_by_bfd; if (sdata == NULL) @@ -2156,6 +2293,19 @@ _bfd_elf_new_section_hook (abfd, sec) sec->used_by_bfd = (PTR) sdata; } + if ((sec->flags & SEC_ALLOC) != 0 + && (((sec->flags & (SEC_LOAD | SEC_HAS_CONTENTS)) == 0) + || (sec->flags & SEC_NEVER_LOAD) != 0)) + elf_section_type (sec) = SHT_NOBITS; + else + elf_section_type (sec) = SHT_PROGBITS; + if (sec->name && _bfd_elf_get_sec_type_attr (abfd, sec->name, + &type, &attr)) + { + elf_section_type (sec) = type; + elf_section_flags (sec) = attr; + } + /* Indicate whether or not this section should use RELA relocations. */ sec->use_rela_p = get_elf_backend_data (abfd)->default_use_rela_p; @@ -2394,55 +2544,52 @@ elf_fake_sections (abfd, asect, failedptrarg) this_hdr->bfd_section = asect; this_hdr->contents = NULL; - /* FIXME: This should not be based on section names. */ - if (strcmp (asect->name, ".dynstr") == 0) - this_hdr->sh_type = SHT_STRTAB; - else if (strcmp (asect->name, ".hash") == 0) + switch (this_hdr->sh_type) { - this_hdr->sh_type = SHT_HASH; + default: + (*_bfd_error_handler) + (_("%s: Section `%s' has unknown type 0x%0x"), + bfd_get_filename (asect->owner), asect->name, + this_hdr->sh_type); + abort (); + break; + + case SHT_STRTAB: + case SHT_INIT_ARRAY: + case SHT_FINI_ARRAY: + case SHT_PREINIT_ARRAY: + case SHT_NOTE: + case SHT_NOBITS: + case SHT_PROGBITS: + break; + + case SHT_HASH: this_hdr->sh_entsize = bed->s->sizeof_hash_entry; - } - else if (strcmp (asect->name, ".dynsym") == 0) - { - this_hdr->sh_type = SHT_DYNSYM; + break; + + case SHT_DYNSYM: this_hdr->sh_entsize = bed->s->sizeof_sym; - } - else if (strcmp (asect->name, ".dynamic") == 0) - { - this_hdr->sh_type = SHT_DYNAMIC; + break; + + case SHT_DYNAMIC: this_hdr->sh_entsize = bed->s->sizeof_dyn; - } - else if (strncmp (asect->name, ".rela", 5) == 0 - && get_elf_backend_data (abfd)->may_use_rela_p) - { - this_hdr->sh_type = SHT_RELA; - this_hdr->sh_entsize = bed->s->sizeof_rela; - } - else if (strncmp (asect->name, ".rel", 4) == 0 - && get_elf_backend_data (abfd)->may_use_rel_p) - { - this_hdr->sh_type = SHT_REL; - this_hdr->sh_entsize = bed->s->sizeof_rel; - } - else if (strcmp (asect->name, ".init_array") == 0) - this_hdr->sh_type = SHT_INIT_ARRAY; - else if (strcmp (asect->name, ".fini_array") == 0) - this_hdr->sh_type = SHT_FINI_ARRAY; - else if (strcmp (asect->name, ".preinit_array") == 0) - this_hdr->sh_type = SHT_PREINIT_ARRAY; - else if (strncmp (asect->name, ".note", 5) == 0) - this_hdr->sh_type = SHT_NOTE; - else if (strncmp (asect->name, ".stab", 5) == 0 - && strcmp (asect->name + strlen (asect->name) - 3, "str") == 0) - this_hdr->sh_type = SHT_STRTAB; - else if (strcmp (asect->name, ".gnu.version") == 0) - { - this_hdr->sh_type = SHT_GNU_versym; + break; + + case SHT_RELA: + if (get_elf_backend_data (abfd)->may_use_rela_p) + this_hdr->sh_entsize = bed->s->sizeof_rela; + break; + + case SHT_REL: + if (get_elf_backend_data (abfd)->may_use_rel_p) + this_hdr->sh_entsize = bed->s->sizeof_rel; + break; + + case SHT_GNU_versym: this_hdr->sh_entsize = sizeof (Elf_External_Versym); - } - else if (strcmp (asect->name, ".gnu.version_d") == 0) - { - this_hdr->sh_type = SHT_GNU_verdef; + break; + + case SHT_GNU_verdef: this_hdr->sh_entsize = 0; /* objcopy or strip will copy over sh_info, but may not set cverdefs. The linker will set cverdefs, but sh_info will be @@ -2452,10 +2599,9 @@ elf_fake_sections (abfd, asect, failedptrarg) else BFD_ASSERT (elf_tdata (abfd)->cverdefs == 0 || this_hdr->sh_info == elf_tdata (abfd)->cverdefs); - } - else if (strcmp (asect->name, ".gnu.version_r") == 0) - { - this_hdr->sh_type = SHT_GNU_verneed; + break; + + case SHT_GNU_verneed: this_hdr->sh_entsize = 0; /* objcopy or strip will copy over sh_info, but may not set cverrefs. The linker will set cverrefs, but sh_info will be @@ -2465,18 +2611,12 @@ elf_fake_sections (abfd, asect, failedptrarg) else BFD_ASSERT (elf_tdata (abfd)->cverrefs == 0 || this_hdr->sh_info == elf_tdata (abfd)->cverrefs); - } - else if ((asect->flags & SEC_GROUP) != 0) - { - this_hdr->sh_type = SHT_GROUP; + break; + + case SHT_GROUP: this_hdr->sh_entsize = 4; + break; } - else if ((asect->flags & SEC_ALLOC) != 0 - && (((asect->flags & (SEC_LOAD | SEC_HAS_CONTENTS)) == 0) - || (asect->flags & SEC_NEVER_LOAD) != 0)) - this_hdr->sh_type = SHT_NOBITS; - else - this_hdr->sh_type = SHT_PROGBITS; if ((asect->flags & SEC_ALLOC) != 0) this_hdr->sh_flags |= SHF_ALLOC; diff --git a/bfd/elf32-m32r.c b/bfd/elf32-m32r.c index 34773ce..7e955e9 100644 --- a/bfd/elf32-m32r.c +++ b/bfd/elf32-m32r.c @@ -2091,6 +2091,16 @@ m32r_elf_check_relocs (abfd, info, sec, relocs) return TRUE; } + +static struct bfd_elf_special_section const m32r_elf_special_sections[]= +{ + { ".sdata", 0, NULL, 0, + SHT_PROGBITS, SHF_ALLOC + SHF_WRITE }, + { ".sbss", 0, NULL, 0, + SHT_NOBITS, SHF_ALLOC + SHF_WRITE }, + { NULL, 0, NULL, 0, + 0, 0 } +}; #define ELF_ARCH bfd_arch_m32r #define ELF_MACHINE_CODE EM_M32R @@ -2126,5 +2136,6 @@ m32r_elf_check_relocs (abfd, info, sec, relocs) #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 #include "elf32-target.h" diff --git a/bfd/elf32-m68hc11.c b/bfd/elf32-m68hc11.c index 0383907..b9d9bfc 100644 --- a/bfd/elf32-m68hc11.c +++ b/bfd/elf32-m68hc11.c @@ -1281,6 +1281,25 @@ m68hc11_elf_relax_delete_bytes (abfd, sec, addr, count) } } +/* Specific sections: + - The .page0 is a data section that is mapped in [0x0000..0x00FF]. + Page0 accesses are faster on the M68HC11. Soft registers used by GCC-m6811 + are located in .page0. + - The .vectors is the data section that represents the interrupt + vectors. */ +static struct bfd_elf_special_section const elf32_m68hc11_special_sections[]= +{ + { ".eeprom", 0, NULL, 0, + SHT_PROGBITS, SHF_ALLOC + SHF_WRITE }, + { ".softregs", 0, NULL, 0, + SHT_NOBITS, SHF_ALLOC + SHF_WRITE }, + { ".page0", 0, NULL, 0, + SHT_PROGBITS, SHF_ALLOC + SHF_WRITE }, + { ".vectors", 0, NULL, 0, + SHT_PROGBITS, SHF_ALLOC + SHF_WRITE }, + { NULL, 0, NULL, 0, + 0, 0 } +}; #define ELF_ARCH bfd_arch_m68hc11 #define ELF_MACHINE_CODE EM_68HC11 @@ -1300,6 +1319,7 @@ m68hc11_elf_relax_delete_bytes (abfd, sec, addr, count) #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 bfd_elf32_bfd_link_hash_table_create \ m68hc11_elf_bfd_link_hash_table_create diff --git a/bfd/elf32-mcore.c b/bfd/elf32-mcore.c index e88f01d..3f878cf 100644 --- a/bfd/elf32-mcore.c +++ b/bfd/elf32-mcore.c @@ -681,6 +681,16 @@ mcore_elf_check_relocs (abfd, info, sec, relocs) return TRUE; } +static struct bfd_elf_special_section const mcore_elf_special_sections[]= +{ + { ".ctors", 0, NULL, 0, + SHT_PROGBITS, SHF_ALLOC + SHF_WRITE }, + { ".dtors", 0, NULL, 0, + SHT_PROGBITS, SHF_ALLOC + SHF_WRITE }, + { NULL, 0, NULL, 0, + 0, 0 } +}; + #define TARGET_BIG_SYM bfd_elf32_mcore_big_vec #define TARGET_BIG_NAME "elf32-mcore-big" #define TARGET_LITTLE_SYM bfd_elf32_mcore_little_vec @@ -699,6 +709,7 @@ mcore_elf_check_relocs (abfd, info, sec, relocs) #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_can_gc_sections 1 #define elf_backend_rela_normal 1 diff --git a/bfd/elf32-ppc.c b/bfd/elf32-ppc.c index ebf9dc0..31765b1 100644 --- a/bfd/elf32-ppc.c +++ b/bfd/elf32-ppc.c @@ -6016,6 +6016,35 @@ ppc_elf_final_write_processing (bfd *abfd, bfd_boolean linker ATTRIBUTE_UNUSED) apuinfo_list_finish (); } + +/* Add extra PPC sections -- Note, for now, make .sbss2 and + .PPC.EMB.sbss0 a normal section, and not a bss section so + that the linker doesn't crater when trying to make more than + 2 sections. */ + +static struct bfd_elf_special_section const ppc_elf_special_sections[]= +{ + { ".tags", 0, NULL, 0, + SHT_ORDERED, SHF_ALLOC }, + { ".sdata", 0, NULL, 0, + SHT_PROGBITS, SHF_ALLOC + SHF_WRITE }, + { ".sbss", 0, NULL, 0, + SHT_NOBITS, SHF_ALLOC + SHF_WRITE }, + { ".sdata2", 0, NULL, 0, + SHT_PROGBITS, SHF_ALLOC }, + { ".sbss2", 0, NULL, 0, + SHT_PROGBITS, SHF_ALLOC }, + { ".PPC.EMB.apuinfo", 0, NULL, 0, + SHT_NOTE, 0 }, + { ".PPC.EMB.sdata0", 0, NULL, 0, + SHT_PROGBITS, SHF_ALLOC }, + { ".PPC.EMB.sbss0", 0, NULL, 0, + SHT_PROGBITS, SHF_ALLOC }, + { ".plt", 0, NULL, 0, + SHT_NOBITS, 0 }, + { NULL, 0, NULL, 0, + 0, 0 } +}; #define TARGET_LITTLE_SYM bfd_elf32_powerpcle_vec #define TARGET_LITTLE_NAME "elf32-powerpcle" @@ -6075,5 +6104,6 @@ ppc_elf_final_write_processing (bfd *abfd, bfd_boolean linker ATTRIBUTE_UNUSED) #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 #include "elf32-target.h" diff --git a/bfd/elf32-sh64.c b/bfd/elf32-sh64.c index eabc8ee..2678548 100644 --- a/bfd/elf32-sh64.c +++ b/bfd/elf32-sh64.c @@ -87,6 +87,7 @@ static void sh64_find_section_for_address sh64_elf_link_output_symbol_hook #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 bfd_elf32_new_section_hook sh64_elf_new_section_hook @@ -734,6 +735,14 @@ sh64_elf_final_write_processing (bfd *abfd, } } +static struct bfd_elf_special_section const sh64_elf_special_sections[]= +{ + { ".cranges", 0, NULL, 0, + SHT_PROGBITS, 0 }, + { NULL, 0, NULL, 0, + 0, 0 } +}; + #undef TARGET_BIG_SYM #define TARGET_BIG_SYM bfd_elf32_sh64_vec #undef TARGET_BIG_NAME diff --git a/bfd/elf32-v850.c b/bfd/elf32-v850.c index e41d0c0..8437c3d 100644 --- a/bfd/elf32-v850.c +++ b/bfd/elf32-v850.c @@ -3139,6 +3139,38 @@ v850_elf_relax_section (abfd, sec, link_info, again) result = FALSE; goto finish; } + +static struct bfd_elf_special_section const v850_elf_special_sections[]= +{ + { ".sdata", 0, NULL, 0, + SHT_PROGBITS, SHF_ALLOC + SHF_WRITE + SHF_V850_GPREL }, + { ".rosdata", 0, NULL, 0, + SHT_PROGBITS, SHF_ALLOC + SHF_V850_GPREL }, + { ".sbss", 0, NULL, 0, + SHT_NOBITS, SHF_ALLOC + SHF_WRITE + SHF_V850_GPREL }, + { ".scommon", 0, NULL, 0, + SHT_V850_SCOMMON, SHF_ALLOC + SHF_WRITE + SHF_V850_GPREL }, + { ".tdata", 0, NULL, 0, + SHT_PROGBITS, SHF_ALLOC + SHF_WRITE + SHF_V850_EPREL }, + { ".tbss", 0, NULL, 0, + SHT_NOBITS, SHF_ALLOC + SHF_WRITE + SHF_V850_EPREL }, + { ".tcommon", 0, NULL, 0, + SHT_V850_TCOMMON, SHF_ALLOC + SHF_WRITE + SHF_V850_R0REL }, + { ".zdata", 0, NULL, 0, + SHT_PROGBITS, SHF_ALLOC + SHF_WRITE + SHF_V850_R0REL }, + { ".rozdata", 0, NULL, 0, + SHT_PROGBITS, SHF_ALLOC + SHF_V850_R0REL }, + { ".zbss", 0, NULL, 0, + SHT_NOBITS, SHF_ALLOC + SHF_WRITE + SHF_V850_R0REL }, + { ".zcommon", 0, NULL, 0, + SHT_V850_ZCOMMON, SHF_ALLOC + SHF_WRITE + SHF_V850_R0REL }, + { ".call_table_data", 0, NULL, 0, + SHT_PROGBITS, SHF_ALLOC + SHF_WRITE }, + { ".call_table_text", 0, NULL, 0, + SHT_PROGBITS, SHF_ALLOC + SHF_WRITE + SHF_EXECINSTR }, + { NULL, 0, NULL, 0, + 0, 0 } +}; #define TARGET_LITTLE_SYM bfd_elf32_v850_vec #define TARGET_LITTLE_NAME "elf32-v850" @@ -3162,6 +3194,7 @@ v850_elf_relax_section (abfd, sec, link_info, again) #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_can_gc_sections 1 #define elf_backend_rela_normal 1 diff --git a/bfd/elf32-xtensa.c b/bfd/elf32-xtensa.c index 1f4b594..3322c9e 100644 --- a/bfd/elf32-xtensa.c +++ b/bfd/elf32-xtensa.c @@ -5865,6 +5865,21 @@ xtensa_callback_required_dependence (abfd, sec, link_info, callback, closure) return ok; } +/* 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 elf_xtensa_special_sections[]= +{ + { ".literal", 0, NULL, 0, + SHT_PROGBITS, SHF_ALLOC + SHF_EXECINSTR }, + { ".init.literal", 0, NULL, 0, + SHT_PROGBITS, SHF_ALLOC + SHF_EXECINSTR }, + { ".fini.literal", 0, NULL, 0, + SHT_PROGBITS, SHF_ALLOC + SHF_EXECINSTR }, + { NULL, 0, NULL, 0, + 0, 0 } +}; + #ifndef ELF_ARCH #define TARGET_LITTLE_SYM bfd_elf32_xtensa_le_vec @@ -5925,5 +5940,6 @@ xtensa_callback_required_dependence (abfd, sec, link_info, callback, closure) #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 #include "elf32-target.h" diff --git a/bfd/elf64-alpha.c b/bfd/elf64-alpha.c index 625b243..1d35a6d 100644 --- a/bfd/elf64-alpha.c +++ b/bfd/elf64-alpha.c @@ -5465,6 +5465,16 @@ elf64_alpha_reloc_type_class (rela) } } +static struct bfd_elf_special_section const elf64_alpha_special_sections[]= +{ + { ".sdata", 0, NULL, 0, + SHT_PROGBITS, SHF_ALLOC + SHF_WRITE + SHF_ALPHA_GPREL }, + { ".sbss", 0, NULL, 0, + SHT_NOBITS, SHF_ALLOC + SHF_WRITE + SHF_ALPHA_GPREL }, + { NULL, 0, NULL, 0, + 0, 0 } +}; + /* ECOFF swapping routines. These are used when dealing with the .mdebug section, which is in the ECOFF debugging format. Copied from elf32-mips.c. */ @@ -5603,6 +5613,9 @@ 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 + /* A few constants that determine how the .plt section is set up. */ #define elf_backend_want_got_plt 0 #define elf_backend_plt_readonly 0 diff --git a/bfd/elf64-hppa.c b/bfd/elf64-hppa.c index 2cee551..5d329e9 100644 --- a/bfd/elf64-hppa.c +++ b/bfd/elf64-hppa.c @@ -2667,6 +2667,16 @@ elf64_hppa_elf_get_symbol_type (elf_sym, type) return type; } +static struct bfd_elf_special_section const elf64_hppa_special_sections[]= +{ + { ".fini", 0, NULL, 0, + SHT_PROGBITS, SHF_ALLOC + SHF_WRITE }, + { ".init", 0, NULL, 0, + SHT_PROGBITS, SHF_ALLOC + SHF_WRITE }, + { NULL, 0, NULL, 0, + 0, 0 } +}; + /* The hash bucket size is the standard one, namely 4. */ const struct elf_size_info hppa64_elf_size_info = @@ -2764,6 +2774,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 #include "elf64-target.h" @@ -2772,5 +2783,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 + #define INCLUDED_TARGET_FILE 1 #include "elf64-target.h" diff --git a/bfd/elf64-ppc.c b/bfd/elf64-ppc.c index a052cd0..1e6d22d 100644 --- a/bfd/elf64-ppc.c +++ b/bfd/elf64-ppc.c @@ -28,6 +28,7 @@ #include "bfdlink.h" #include "libbfd.h" #include "elf-bfd.h" +#include "elf/ppc.h" #include "elf/ppc64.h" #include "elf64-ppc.h" @@ -90,6 +91,7 @@ static bfd_reloc_status_type ppc64_elf_unhandled_reloc #define elf_backend_finish_dynamic_symbol ppc64_elf_finish_dynamic_symbol #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_special_sections ppc64_elf_special_sections /* The name of the dynamic interpreter. This is put in the .interp section. */ @@ -8760,4 +8762,37 @@ ppc64_elf_finish_dynamic_sections (bfd *output_bfd, return TRUE; } +/* Add extra PPC sections -- Note, for now, make .sbss2 and + .PPC.EMB.sbss0 a normal section, and not a bss section so + that the linker doesn't crater when trying to make more than + 2 sections. */ + +static struct bfd_elf_special_section const ppc64_elf_special_sections[]= +{ + { ".tags", 0, NULL, 0, + SHT_ORDERED, SHF_ALLOC }, + { ".sdata", 0, NULL, 0, + SHT_PROGBITS, SHF_ALLOC + SHF_WRITE }, + { ".sbss", 0, NULL, 0, + SHT_NOBITS, SHF_ALLOC + SHF_WRITE }, + { ".sdata2", 0, NULL, 0, + SHT_PROGBITS, SHF_ALLOC }, + { ".sbss2", 0, NULL, 0, + SHT_PROGBITS, SHF_ALLOC }, + { ".PPC.EMB.apuinfo", 0, NULL, 0, + SHT_NOTE, 0 }, + { ".PPC.EMB.sdata0", 0, NULL, 0, + SHT_PROGBITS, SHF_ALLOC }, + { ".PPC.EMB.sbss0", 0, NULL, 0, + SHT_PROGBITS, SHF_ALLOC }, + { ".plt", 0, NULL, 0, + SHT_NOBITS, 0 }, + { ".toc", 0, NULL, 0, + SHT_PROGBITS, SHF_ALLOC + SHF_WRITE }, + { ".tocbss", 0, NULL, 0, + SHT_NOBITS, SHF_ALLOC + SHF_WRITE }, + { NULL, 0, NULL, 0, + 0, 0 } +}; + #include "elf64-target.h" diff --git a/bfd/elf64-sh64.c b/bfd/elf64-sh64.c index 234b237..905cadd 100644 --- a/bfd/elf64-sh64.c +++ b/bfd/elf64-sh64.c @@ -4112,6 +4112,14 @@ sh64_elf64_finish_dynamic_sections (bfd *output_bfd, return TRUE; } +static struct bfd_elf_special_section const sh64_elf64_special_sections[]= +{ + { ".cranges", 0, NULL, 0, + SHT_PROGBITS, 0 }, + { NULL, 0, NULL, 0, + 0, 0 } +}; + #define TARGET_BIG_SYM bfd_elf64_sh64_vec #define TARGET_BIG_NAME "elf64-sh64" #define TARGET_LITTLE_SYM bfd_elf64_sh64l_vec @@ -4167,6 +4175,7 @@ sh64_elf64_finish_dynamic_sections (bfd *output_bfd, 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_want_got_plt 1 #define elf_backend_plt_readonly 1 diff --git a/bfd/elfxx-ia64.c b/bfd/elfxx-ia64.c index 8d786d2..73ab4e8 100644 --- a/bfd/elfxx-ia64.c +++ b/bfd/elfxx-ia64.c @@ -4773,6 +4773,16 @@ elfNN_ia64_reloc_type_class (rela) } } +static struct bfd_elf_special_section const elfNN_ia64_special_sections[]= +{ + { ".sbss", 0, NULL, 0, + SHT_NOBITS, SHF_ALLOC + SHF_WRITE + SHF_IA_64_SHORT }, + { ".sdata", 0, NULL, 0, + SHT_PROGBITS, SHF_ALLOC + SHF_WRITE + SHF_IA_64_SHORT }, + { NULL, 0, NULL, 0, + 0, 0 } +}; + static bfd_boolean elfNN_ia64_hpux_vec (const bfd_target *vec) { @@ -4880,6 +4890,7 @@ elfNN_hpux_backend_section_from_bfd_section (abfd, sec, retval) #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 #include "elfNN-target.h" diff --git a/bfd/elfxx-mips.c b/bfd/elfxx-mips.c index b817223..4c54965 100644 --- a/bfd/elfxx-mips.c +++ b/bfd/elfxx-mips.c @@ -9290,3 +9290,21 @@ _bfd_mips_elf_print_private_bfd_data (abfd, ptr) return TRUE; } + +struct bfd_elf_special_section const _bfd_mips_elf_special_sections[]= +{ + { ".sdata", 0, NULL, 0, + SHT_PROGBITS, SHF_ALLOC + SHF_WRITE + SHF_MIPS_GPREL }, + { ".sbss", 0, NULL, 0, + SHT_NOBITS, SHF_ALLOC + SHF_WRITE + SHF_MIPS_GPREL }, + { ".lit4", 0, NULL, 0, + SHT_PROGBITS, SHF_ALLOC + SHF_WRITE + SHF_MIPS_GPREL }, + { ".lit8", 0, NULL, 0, + SHT_PROGBITS, SHF_ALLOC + SHF_WRITE + SHF_MIPS_GPREL }, + { ".ucode", 0, NULL, 0, + SHT_MIPS_UCODE, 0 }, + { ".mdebug", 0, NULL, 0, + SHT_MIPS_DEBUG, 0 }, + { NULL, 0, NULL, 0, + 0, 0 } +}; diff --git a/bfd/elfxx-mips.h b/bfd/elfxx-mips.h index 088dd6a..f6459a5 100644 --- a/bfd/elfxx-mips.h +++ b/bfd/elfxx-mips.h @@ -112,3 +112,6 @@ extern bfd_boolean _bfd_mips_relax_section PARAMS ((bfd *, asection *, struct bfd_link_info *, bfd_boolean *)); extern bfd_vma _bfd_mips_elf_sign_extend PARAMS ((bfd_vma, int)); + +extern struct bfd_elf_special_section const _bfd_mips_elf_special_sections[]; +#define elf_backend_special_sections _bfd_mips_elf_special_sections diff --git a/bfd/elfxx-target.h b/bfd/elfxx-target.h index 58a96b1..c2bca91 100644 --- a/bfd/elfxx-target.h +++ b/bfd/elfxx-target.h @@ -434,6 +434,10 @@ #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 @@ -497,6 +501,7 @@ 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_symbol_offset, elf_backend_got_header_size, elf_backend_plt_header_size, diff --git a/bfd/section.c b/bfd/section.c index aaeb0ef..5347c2b 100644 --- a/bfd/section.c +++ b/bfd/section.c @@ -532,18 +532,18 @@ CODE_FRAGMENT .#define BFD_IND_SECTION_NAME "*IND*" . .{* The absolute section. *} -.extern const asection bfd_abs_section; +.extern asection bfd_abs_section; .#define bfd_abs_section_ptr ((asection *) &bfd_abs_section) .#define bfd_is_abs_section(sec) ((sec) == bfd_abs_section_ptr) .{* Pointer to the undefined section. *} -.extern const asection bfd_und_section; +.extern asection bfd_und_section; .#define bfd_und_section_ptr ((asection *) &bfd_und_section) .#define bfd_is_und_section(sec) ((sec) == bfd_und_section_ptr) .{* Pointer to the common section. *} -.extern const asection bfd_com_section; +.extern asection bfd_com_section; .#define bfd_com_section_ptr ((asection *) &bfd_com_section) .{* Pointer to the indirect section. *} -.extern const asection bfd_ind_section; +.extern asection bfd_ind_section; .#define bfd_ind_section_ptr ((asection *) &bfd_ind_section) .#define bfd_is_ind_section(sec) ((sec) == bfd_ind_section_ptr) . @@ -616,7 +616,7 @@ static const asymbol global_syms[] = #define STD_SECTION(SEC, FLAGS, SYM, NAME, IDX) \ const asymbol * const SYM = (asymbol *) &global_syms[IDX]; \ - const asection SEC = \ + asection SEC = \ /* name, id, index, next, flags, user_set_vma, reloc_done, */ \ { NAME, IDX, 0, NULL, FLAGS, 0, 0, \ \ |