aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2003-07-25 14:35:56 +0000
committerH.J. Lu <hjl.tools@gmail.com>2003-07-25 14:35:56 +0000
commit2f89ff8d8ead0e6eb034d7c26470be4eac7c3185 (patch)
treedeecbf5e1012acc2b9492ad093cde8236a3404e6
parent20650579793e339d3438ee509c464a253d7ef079 (diff)
downloadgdb-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.
-rw-r--r--bfd/ChangeLog69
-rw-r--r--bfd/elf-bfd.h18
-rw-r--r--bfd/elf.c256
-rw-r--r--bfd/elf32-m32r.c11
-rw-r--r--bfd/elf32-m68hc11.c20
-rw-r--r--bfd/elf32-mcore.c11
-rw-r--r--bfd/elf32-ppc.c30
-rw-r--r--bfd/elf32-sh64.c9
-rw-r--r--bfd/elf32-v850.c33
-rw-r--r--bfd/elf32-xtensa.c16
-rw-r--r--bfd/elf64-alpha.c13
-rw-r--r--bfd/elf64-hppa.c13
-rw-r--r--bfd/elf64-ppc.c35
-rw-r--r--bfd/elf64-sh64.c9
-rw-r--r--bfd/elfxx-ia64.c11
-rw-r--r--bfd/elfxx-mips.c18
-rw-r--r--bfd/elfxx-mips.h3
-rw-r--r--bfd/elfxx-target.h5
-rw-r--r--bfd/section.c10
-rw-r--r--gas/ChangeLog27
-rw-r--r--gas/config/obj-elf.c143
-rw-r--r--gas/config/obj-elf.h7
-rw-r--r--gas/config/tc-alpha.h4
-rw-r--r--gas/config/tc-ia64.h4
-rw-r--r--gas/config/tc-m32r.h5
-rw-r--r--gas/config/tc-m68hc11.h12
-rw-r--r--gas/config/tc-mcore.h6
-rw-r--r--gas/config/tc-mips.h10
-rw-r--r--gas/config/tc-ppc.h16
-rw-r--r--gas/config/tc-sh64.h3
-rw-r--r--gas/config/tc-v850.h22
-rw-r--r--gas/config/tc-xtensa.h8
-rw-r--r--gas/subsegs.c4
-rw-r--r--include/elf/ChangeLog6
-rw-r--r--include/elf/v850.h11
35 files changed, 628 insertions, 250 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
diff --git a/bfd/elf.c b/bfd/elf.c
index e342821..95aa192 100644
--- a/bfd/elf.c
+++ b/bfd/elf.c
@@ -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, \
\
diff --git a/gas/ChangeLog b/gas/ChangeLog
index 7560fc0..43cfcc7 100644
--- a/gas/ChangeLog
+++ b/gas/ChangeLog
@@ -1,3 +1,30 @@
+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.
+
2003-07-24 Stephane Carrez <stcarrez@nerim.fr>
* config/tc-m68hc11.h (DWARF2_ADDR_SIZE): Use 32-bit address for
diff --git a/gas/config/obj-elf.c b/gas/config/obj-elf.c
index 18cf50d..7d89175 100644
--- a/gas/config/obj-elf.c
+++ b/gas/config/obj-elf.c
@@ -601,63 +601,6 @@ static struct section_stack *section_stack;
other possibilities, but I don't know what they are. In any case,
BFD doesn't really let us set the section type. */
-/* Certain named sections have particular defined types, listed on p.
- 4-19 of the ABI. */
-struct special_section
-{
- const char *name;
- int type;
- int attributes;
-};
-
-static struct special_section const special_sections[] =
-{
- { ".bss", SHT_NOBITS, SHF_ALLOC + SHF_WRITE },
- { ".comment", SHT_PROGBITS, 0 },
- { ".data", SHT_PROGBITS, SHF_ALLOC + SHF_WRITE },
- { ".data1", SHT_PROGBITS, SHF_ALLOC + SHF_WRITE },
- { ".debug", SHT_PROGBITS, 0 },
-#if defined (TC_HPPA) && !defined (TE_LINUX) && TARGET_ARCH_SIZE == 64
- { ".fini", SHT_PROGBITS, SHF_ALLOC + SHF_WRITE },
- { ".init", SHT_PROGBITS, SHF_ALLOC + SHF_WRITE },
-#else
- { ".fini", SHT_PROGBITS, SHF_ALLOC + SHF_EXECINSTR },
- { ".init", SHT_PROGBITS, SHF_ALLOC + SHF_EXECINSTR },
-#endif
- { ".line", SHT_PROGBITS, 0 },
- { ".note", SHT_NOTE, 0 },
- { ".rodata", SHT_PROGBITS, SHF_ALLOC },
- { ".rodata1", SHT_PROGBITS, SHF_ALLOC },
- { ".tbss", SHT_NOBITS, SHF_ALLOC + SHF_WRITE + SHF_TLS },
- { ".tdata", SHT_PROGBITS, SHF_ALLOC + SHF_WRITE + SHF_TLS },
- { ".text", SHT_PROGBITS, SHF_ALLOC + SHF_EXECINSTR },
- { ".init_array",SHT_INIT_ARRAY, SHF_ALLOC + SHF_WRITE },
- { ".fini_array",SHT_FINI_ARRAY, SHF_ALLOC + SHF_WRITE },
- { ".preinit_array",SHT_PREINIT_ARRAY, SHF_ALLOC + SHF_WRITE },
-
-#ifdef ELF_TC_SPECIAL_SECTIONS
- ELF_TC_SPECIAL_SECTIONS
-#endif
-
-#if 0
- /* The following section names are special, but they can not
- reasonably appear in assembler code. Some of the attributes are
- processor dependent. */
- { ".dynamic", SHT_DYNAMIC, SHF_ALLOC /* + SHF_WRITE */ },
- { ".dynstr", SHT_STRTAB, SHF_ALLOC },
- { ".dynsym", SHT_DYNSYM, SHF_ALLOC },
- { ".got", SHT_PROGBITS, 0 },
- { ".hash", SHT_HASH, SHF_ALLOC },
- { ".interp", SHT_PROGBITS, /* SHF_ALLOC */ },
- { ".plt", SHT_PROGBITS, 0 },
- { ".shstrtab",SHT_STRTAB, 0 },
- { ".strtab", SHT_STRTAB, /* SHF_ALLOC */ },
- { ".symtab", SHT_SYMTAB, /* SHF_ALLOC */ },
-#endif
-
- { NULL, 0, 0 }
-};
-
void
obj_elf_change_section (name, type, attr, entsize, group_name, linkonce, push)
const char *name;
@@ -671,7 +614,8 @@ obj_elf_change_section (name, type, attr, entsize, group_name, linkonce, push)
asection *old_sec;
segT sec;
flagword flags;
- int i;
+ int def_type;
+ int def_attr;
#ifdef md_flush_pending_output
md_flush_pending_output ();
@@ -695,48 +639,52 @@ obj_elf_change_section (name, type, attr, entsize, group_name, linkonce, push)
old_sec = bfd_get_section_by_name (stdoutput, name);
sec = subseg_new (name, 0);
- /* See if this is one of the special sections. */
- for (i = 0; special_sections[i].name != NULL; i++)
- if (strcmp (name, special_sections[i].name) == 0)
- {
- if (type == SHT_NULL)
- type = special_sections[i].type;
- else if (type != special_sections[i].type)
- {
- if (old_sec == NULL
- /* FIXME: gcc, as of 2002-10-22, will emit
+ if (_bfd_elf_get_sec_type_attr (stdoutput, name, &def_type,
+ &def_attr))
+ {
+ if (type == SHT_NULL)
+ type = def_type;
+ else if (type != def_type)
+ {
+ if (old_sec == NULL
+ /* FIXME: gcc, as of 2002-10-22, will emit
- .section .init_array,"aw",@progbits
+ .section .init_array,"aw",@progbits
- for __attribute__ ((section (".init_array"))).
- "@progbits" is incorrect. */
- && special_sections[i].type != SHT_INIT_ARRAY
- && special_sections[i].type != SHT_FINI_ARRAY
- && special_sections[i].type != SHT_PREINIT_ARRAY)
- {
- as_warn (_("setting incorrect section type for %s"), name);
- }
- else
- {
- as_warn (_("ignoring incorrect section type for %s"), name);
- type = special_sections[i].type;
- }
- }
- if ((attr &~ special_sections[i].attributes) != 0
- && old_sec == NULL)
- {
- /* As a GNU extension, we permit a .note section to be
- allocatable. If the linker sees an allocateable .note
- section, it will create a PT_NOTE segment in the output
- file. */
- if (strcmp (name, ".note") != 0
- || attr != SHF_ALLOC)
- as_warn (_("setting incorrect section attributes for %s"),
+ for __attribute__ ((section (".init_array"))).
+ "@progbits" is incorrect. */
+ && def_type != SHT_INIT_ARRAY
+ && def_type != SHT_FINI_ARRAY
+ && def_type != SHT_PREINIT_ARRAY)
+ {
+ /* We allow to specify any type for a .note section. */
+ if (def_type != SHT_NOTE)
+ as_warn (_("setting incorrect section type for %s"),
+ name);
+ }
+ else
+ {
+ as_warn (_("ignoring incorrect section type for %s"),
name);
- }
- attr |= special_sections[i].attributes;
- break;
- }
+ type = def_type;
+ }
+ }
+
+ if (old_sec == NULL && (attr &~ def_attr) != 0)
+ {
+ /* As a GNU extension, we permit a .note section to be
+ allocatable. If the linker sees an allocateable .note
+ section, it will create a PT_NOTE segment in the output
+ file. */
+ if (strcmp (name, ".note") != 0 || attr != SHF_ALLOC)
+ as_warn (_("setting incorrect section attributes for %s"),
+ name);
+ }
+ attr |= def_attr;
+
+ elf_section_type (sec) = type;
+ elf_section_flags (sec) = attr;
+ }
/* Convert ELF type and flags to BFD flags. */
flags = (SEC_RELOC
@@ -2076,6 +2024,7 @@ elf_frob_file ()
as_fatal (_("can't create group: %s"),
bfd_errmsg (bfd_get_error ()));
}
+ elf_section_type (s) = SHT_GROUP;
/* Pass a pointer to the first section in this group. */
elf_next_in_group (s) = list.head[i];
diff --git a/gas/config/obj-elf.h b/gas/config/obj-elf.h
index 0fa2ba6..641a373 100644
--- a/gas/config/obj-elf.h
+++ b/gas/config/obj-elf.h
@@ -134,6 +134,13 @@ int elf_s_get_other PARAMS ((symbolS *));
extern asection *gdb_section;
+#ifndef obj_sec_set_private_data
+#define obj_sec_set_private_data(B, S) \
+ if (! BFD_SEND ((B), _new_section_hook, ((B), (S)))) \
+ as_fatal (_("can't allocate ELF private section data: %s"), \
+ bfd_errmsg (bfd_get_error ()))
+#endif
+
#ifndef obj_frob_file
#define obj_frob_file elf_frob_file
#endif
diff --git a/gas/config/tc-alpha.h b/gas/config/tc-alpha.h
index d9275e2..37e5838 100644
--- a/gas/config/tc-alpha.h
+++ b/gas/config/tc-alpha.h
@@ -104,10 +104,6 @@ extern void alpha_frob_file_before_adjust PARAMS ((void));
#define DIFF_EXPR_OK /* foo-. gets turned into PC relative relocs */
#ifdef OBJ_ELF
-#define ELF_TC_SPECIAL_SECTIONS \
- { ".sdata", SHT_PROGBITS, SHF_ALLOC + SHF_WRITE + SHF_ALPHA_GPREL }, \
- { ".sbss", SHT_NOBITS, SHF_ALLOC + SHF_WRITE + SHF_ALPHA_GPREL },
-
#define md_elf_section_letter alpha_elf_section_letter
extern int alpha_elf_section_letter PARAMS ((int, char **));
#define md_elf_section_flags alpha_elf_section_flags
diff --git a/gas/config/tc-ia64.h b/gas/config/tc-ia64.h
index 884bfb7..8d2f437 100644
--- a/gas/config/tc-ia64.h
+++ b/gas/config/tc-ia64.h
@@ -151,10 +151,6 @@ extern void ia64_check_label PARAMS ((symbolS *));
#define WORKING_DOT_WORD /* don't do broken word processing for now */
-#define ELF_TC_SPECIAL_SECTIONS \
-{ ".sbss", SHT_NOBITS, SHF_ALLOC + SHF_WRITE + SHF_IA_64_SHORT }, \
-{ ".sdata", SHT_PROGBITS, SHF_ALLOC + SHF_WRITE + SHF_IA_64_SHORT },
-
#define DWARF2_LINE_MIN_INSN_LENGTH 1 /* so slot-multipliers can be 1 */
/* This is the information required for unwind records in an ia64
diff --git a/gas/config/tc-m32r.h b/gas/config/tc-m32r.h
index 12512f7..f54c980 100644
--- a/gas/config/tc-m32r.h
+++ b/gas/config/tc-m32r.h
@@ -98,11 +98,6 @@ int m32r_fill_insn PARAMS ((int));
#define md_after_pass_hook() m32r_fill_insn (1)
#define TC_START_LABEL(ch, ptr) (ch == ':' && m32r_fill_insn (0))
-/* Add extra M32R sections. */
-#define ELF_TC_SPECIAL_SECTIONS \
- { ".sdata", SHT_PROGBITS, SHF_ALLOC + SHF_WRITE }, \
- { ".sbss", SHT_NOBITS, SHF_ALLOC + SHF_WRITE },
-
#define md_cleanup m32r_elf_section_change_hook
#define md_elf_section_change_hook m32r_elf_section_change_hook
extern void m32r_elf_section_change_hook PARAMS ((void));
diff --git a/gas/config/tc-m68hc11.h b/gas/config/tc-m68hc11.h
index 7254db4..c894edd 100644
--- a/gas/config/tc-m68hc11.h
+++ b/gas/config/tc-m68hc11.h
@@ -53,18 +53,6 @@ extern int m68hc11_mach PARAMS ((void));
#define TARGET_FORMAT (m68hc11_arch_format ())
extern const char *m68hc11_arch_format PARAMS ((void));
-/* 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. */
-#define ELF_TC_SPECIAL_SECTIONS \
- { ".eeprom", SHT_PROGBITS, SHF_ALLOC + SHF_WRITE }, \
- { ".softregs",SHT_NOBITS, SHF_ALLOC + SHF_WRITE }, \
- { ".page0", SHT_PROGBITS, SHF_ALLOC + SHF_WRITE }, \
- { ".vectors", SHT_PROGBITS, SHF_ALLOC + SHF_WRITE },
-
#define LISTING_WORD_SIZE 1 /* A word is 1 bytes */
#define LISTING_LHS_WIDTH 4 /* One word on the first line */
#define LISTING_LHS_WIDTH_SECOND 4 /* One word on the second line */
diff --git a/gas/config/tc-mcore.h b/gas/config/tc-mcore.h
index 4ab84e4..c727a57 100644
--- a/gas/config/tc-mcore.h
+++ b/gas/config/tc-mcore.h
@@ -83,12 +83,6 @@ struct mcore_tc_sy
#define TARGET_FORMAT (target_big_endian ? "elf32-mcore-big" : "elf32-mcore-little")
-#define ELF_TC_SPECIAL_SECTIONS \
- { ".ctors", SHT_PROGBITS, SHF_ALLOC + SHF_WRITE }, \
- { ".dtors", SHT_PROGBITS, SHF_ALLOC + SHF_WRITE }, \
-/* Other special sections not generated by the assembler: .reginfo,
- .liblist, .conflict, .gptab, .got, .dynamic, .rel.dyn. */
-
/* No shared lib support, so we don't need to ensure externally
visible symbols can be overridden. */
#define EXTERN_FORCE_RELOC 0
diff --git a/gas/config/tc-mips.h b/gas/config/tc-mips.h
index 7afee94..fc96ef3 100644
--- a/gas/config/tc-mips.h
+++ b/gas/config/tc-mips.h
@@ -162,16 +162,6 @@ extern unsigned long mips_cprmask[4];
#define elf_tc_final_processing mips_elf_final_processing
extern void mips_elf_final_processing (void);
-#define ELF_TC_SPECIAL_SECTIONS \
- { ".sdata", SHT_PROGBITS, SHF_ALLOC + SHF_WRITE + SHF_MIPS_GPREL }, \
- { ".sbss", SHT_NOBITS, SHF_ALLOC + SHF_WRITE + SHF_MIPS_GPREL }, \
- { ".lit4", SHT_PROGBITS, SHF_ALLOC + SHF_WRITE + SHF_MIPS_GPREL }, \
- { ".lit8", SHT_PROGBITS, SHF_ALLOC + SHF_WRITE + SHF_MIPS_GPREL }, \
- { ".ucode", SHT_MIPS_UCODE, 0 }, \
- { ".mdebug", SHT_MIPS_DEBUG, 0 },
-/* Other special sections not generated by the assembler: .reginfo,
- .liblist, .conflict, .gptab, .got, .dynamic, .rel.dyn. */
-
#endif
extern void md_mips_end (void);
diff --git a/gas/config/tc-ppc.h b/gas/config/tc-ppc.h
index 3612f43..a1c74b2 100644
--- a/gas/config/tc-ppc.h
+++ b/gas/config/tc-ppc.h
@@ -222,22 +222,6 @@ extern int ppc_section_flags PARAMS ((int, int, int));
#define md_elf_section_word(STR, LEN) ppc_section_word (STR, LEN)
#define md_elf_section_flags(FLAGS, ATTR, TYPE) ppc_section_flags (FLAGS, ATTR, TYPE)
-/* 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. */
-#define ELF_TC_SPECIAL_SECTIONS \
- { ".tags", SHT_ORDERED, SHF_ALLOC }, \
- { ".sdata", SHT_PROGBITS, SHF_ALLOC + SHF_WRITE }, \
- { ".sbss", SHT_NOBITS, SHF_ALLOC + SHF_WRITE }, \
- { ".sdata2", SHT_PROGBITS, SHF_ALLOC }, \
- { ".sbss2", SHT_PROGBITS, SHF_ALLOC }, \
- { ".PPC.EMB.apuinfo", SHT_NOTE, 0 }, \
- { ".PPC.EMB.sdata0", SHT_PROGBITS, SHF_ALLOC }, \
- { ".PPC.EMB.sbss0", SHT_PROGBITS, SHF_ALLOC }, \
- /* Extra sections for 64-bit ELF PPC. */ \
- { ".toc", SHT_PROGBITS, SHF_ALLOC + SHF_WRITE}, \
- { ".tocbss", SHT_NOBITS, SHF_ALLOC + SHF_WRITE},
-
#define tc_comment_chars ppc_comment_chars
extern const char *ppc_comment_chars;
diff --git a/gas/config/tc-sh64.h b/gas/config/tc-sh64.h
index 888ad99..8280c94 100644
--- a/gas/config/tc-sh64.h
+++ b/gas/config/tc-sh64.h
@@ -174,9 +174,6 @@ extern void sh64_flush_pending_output PARAMS ((void));
#define tc_frob_section(sec) shmedia_frob_section_type (sec)
extern void shmedia_frob_section_type PARAMS ((asection *));
-#define ELF_TC_SPECIAL_SECTIONS \
- { ".cranges", SHT_PROGBITS, 0 },
-
/* We need to emit fixups relative to the frag in which the instruction
resides. Safest way without calculating max fragment growth or making
it a fixed number is to provide a pointer to the opcode frag.
diff --git a/gas/config/tc-v850.h b/gas/config/tc-v850.h
index 7130760..26b1bf1 100644
--- a/gas/config/tc-v850.h
+++ b/gas/config/tc-v850.h
@@ -74,28 +74,6 @@ extern const struct relax_type md_relax_table[];
#define HANDLE_ALIGN(frag) v850_handle_align (frag)
extern void v850_handle_align PARAMS ((fragS *));
-/* This section must be in the small data area (pointed to by GP). */
-#define SHF_V850_GPREL 0x10000000
-/* This section must be in the tiny data area (pointed to by EP). */
-#define SHF_V850_EPREL 0x20000000
-/* This section must be in the zero data area (pointed to by R0). */
-#define SHF_V850_R0REL 0x40000000
-
-#define ELF_TC_SPECIAL_SECTIONS \
- { ".sdata", SHT_PROGBITS, SHF_ALLOC + SHF_WRITE + SHF_V850_GPREL }, \
- { ".rosdata", SHT_PROGBITS, SHF_ALLOC + SHF_V850_GPREL }, \
- { ".sbss", SHT_NOBITS, SHF_ALLOC + SHF_WRITE + SHF_V850_GPREL }, \
- { ".scommon", SHT_V850_SCOMMON, SHF_ALLOC + SHF_WRITE + SHF_V850_GPREL }, \
- { ".tdata", SHT_PROGBITS, SHF_ALLOC + SHF_WRITE + SHF_V850_EPREL }, \
- { ".tbss", SHT_NOBITS, SHF_ALLOC + SHF_WRITE + SHF_V850_EPREL }, \
- { ".tcommon", SHT_V850_TCOMMON, SHF_ALLOC + SHF_WRITE + SHF_V850_R0REL }, \
- { ".zdata", SHT_PROGBITS, SHF_ALLOC + SHF_WRITE + SHF_V850_R0REL }, \
- { ".rozdata", SHT_PROGBITS, SHF_ALLOC + SHF_V850_R0REL }, \
- { ".zbss", SHT_NOBITS, SHF_ALLOC + SHF_WRITE + SHF_V850_R0REL }, \
- { ".zcommon", SHT_V850_ZCOMMON, SHF_ALLOC + SHF_WRITE + SHF_V850_R0REL }, \
- { ".call_table_data", SHT_PROGBITS, SHF_ALLOC + SHF_WRITE }, \
- { ".call_table_text", SHT_PROGBITS, SHF_ALLOC + SHF_WRITE + SHF_EXECINSTR },
-
#define MD_PCREL_FROM_SECTION(FIX, SEC) v850_pcrel_from_section (FIX, SEC)
extern long v850_pcrel_from_section PARAMS ((struct fix *, asection *));
diff --git a/gas/config/tc-xtensa.h b/gas/config/tc-xtensa.h
index c6bc09d..2f317b0 100644
--- a/gas/config/tc-xtensa.h
+++ b/gas/config/tc-xtensa.h
@@ -189,12 +189,4 @@ extern long xtensa_relax_frag
#define MD_APPLY_SYM_VALUE(FIX) 0
-/* 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. */
-#define ELF_TC_SPECIAL_SECTIONS \
- { ".literal", SHT_PROGBITS, SHF_ALLOC + SHF_EXECINSTR }, \
- { ".init.literal", SHT_PROGBITS, SHF_ALLOC + SHF_EXECINSTR }, \
- { ".fini.literal", SHT_PROGBITS, SHF_ALLOC + SHF_EXECINSTR },
-
#endif /* TC_XTENSA */
diff --git a/gas/subsegs.c b/gas/subsegs.c
index dfdb000..0fe11e7 100644
--- a/gas/subsegs.c
+++ b/gas/subsegs.c
@@ -422,6 +422,10 @@ subseg_get (segname, force_new)
else
secptr = bfd_make_section_anyway (stdoutput, segname);
+#ifdef obj_sec_set_private_data
+ obj_sec_set_private_data (stdoutput, secptr);
+#endif
+
seginfo = seg_info (secptr);
if (! seginfo)
{
diff --git a/include/elf/ChangeLog b/include/elf/ChangeLog
index 7bcecd2..1d8ab86 100644
--- a/include/elf/ChangeLog
+++ b/include/elf/ChangeLog
@@ -1,3 +1,9 @@
+2003-07-25 H.J. Lu <hongjiu.lu@intel.com>
+
+ * v850.h (SHF_V850_GPREL): New.
+ (SHF_V850_EPREL): Likewise.
+ (SHF_V850_R0REL): Likewise.
+
2003-07-09 Alexandre Oliva <aoliva@redhat.com>
2001-05-16 Alexandre Oliva <aoliva@redhat.com>
diff --git a/include/elf/v850.h b/include/elf/v850.h
index c949ab0..db5b2d9 100644
--- a/include/elf/v850.h
+++ b/include/elf/v850.h
@@ -104,4 +104,15 @@ END_RELOC_NUMBERS (R_V850_max)
/* Section contains the .scommon data. */
#define SHT_V850_ZCOMMON 0x70000002
+/* Processor specific section flags. */
+
+/* This section must be in the small data area (pointed to by GP). */
+#define SHF_V850_GPREL 0x10000000
+
+/* This section must be in the tiny data area (pointed to by EP). */
+#define SHF_V850_EPREL 0x20000000
+
+/* This section must be in the zero data area (pointed to by R0). */
+#define SHF_V850_R0REL 0x40000000
+
#endif /* _ELF_V850_H */