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.
This commit is contained in:
H.J. Lu
2003-07-25 14:35:56 +00:00
parent 2065057979
commit 2f89ff8d8e
35 changed files with 628 additions and 250 deletions

View File

@ -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

View File

@ -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];

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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));

View File

@ -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 */

View File

@ -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

View File

@ -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);

View File

@ -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;

View File

@ -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.

View File

@ -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 *));

View File

@ -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 */

View File

@ -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)
{