Commit ae95ffa6 authored by H.J. Lu's avatar H.J. Lu
Browse files

Add target_id to elf_backend_data.

2010-08-25  H.J. Lu  <hongjiu.lu@intel.com>

	PR ld/11944
	* elf-bfd.h (elf_backend_data): Add target_id.
	(bfd_elf_make_generic_object): Renamed to ...
	(bfd_elf_make_object): This.

	* elf.c (bfd_elf_make_generic_object): Removed.
	(bfd_elf_make_object): New.
	(bfd_elf_mkcorefile): Really treat it as an object file.

	* elf-m10300.c (ELF_TARGET_ID): New.
	* elf32-arm.c (ELF_TARGET_ID): Likewise.
	* elf32-bfin.c (ELF_TARGET_ID): Likewise.
	* elf32-cris.c (ELF_TARGET_ID): Likewise.
	* elf32-frv.c (ELF_TARGET_ID): Likewise.
	* elf32-i386.c (ELF_TARGET_ID): Likewise.
	* elf32-lm32.c (ELF_TARGET_ID): Likewise.
	* elf32-m32r.c (ELF_TARGET_ID): Likewise.
	* elf32-m68hc11.c (ELF_TARGET_ID): Likewise.
	* elf32-m68hc12.c (ELF_TARGET_ID): Likewise.
	* elf32-m68k.c (ELF_TARGET_ID): Likewise.
	* elf32-microblaze.c (ELF_TARGET_ID): Likewise.
	* elf32-ppc.c (ELF_TARGET_ID): Likewise.
	* elf32-s390.c (ELF_TARGET_ID): Likewise.
	* elf32-sh.c (ELF_TARGET_ID): Likewise.
	* elf32-sparc.c (ELF_TARGET_ID): Likewise.
	* elf32-spu.c (ELF_TARGET_ID): Likewise.
	* elf32-tic6x.c (ELF_TARGET_ID): Likewise.
	* elf32-xtensa.c (ELF_TARGET_ID): Likewise.
	* elf64-alpha.c (ELF_TARGET_ID): Likewise.
	* elf64-hppa.c (ELF_TARGET_ID): Likewise.
	* elf64-ppc.c (ELF_TARGET_ID): Likewise.
	* elf64-s390.c (ELF_TARGET_ID): Likewise.
	* elf64-x86-64.c (ELF_TARGET_ID): Likewise.
	* elfxx-ia64.c (ELF_TARGET_ID): Likewise.

	* elf32-hppa.c (elf32_hppa_mkobject): Removed.
	(bfd_elf32_mkobject): Likewise.
	(ELF_TARGET_ID): New.

	* elf32-mips.c (ELF_TARGET_ID): New.
	(bfd_elf32_mkobject): Removed.

	* elf64-mips.c (ELF_TARGET_ID): New.
	(bfd_elf64_mkobject): Removed.

	* elfn32-mips.c (ELF_TARGET_ID): New.
	(bfd_elf32_mkobject): Removed.

	* elfxx-mips.c (_bfd_mips_elf_mkobject): Removed.
	* elfxx-mips.h (_bfd_mips_elf_mkobject): Likewise.

	* elfxx-target.h (bfd_elfNN_mkobject): Default to
	bfd_elf_make_object.
	(ELF_TARGET_ID): New.  Default to GENERIC_ELF_DATA.
	(elfNN_bed): Initialize target_id.
parent 964e4306
2010-08-25 H.J. Lu <hongjiu.lu@intel.com>
PR ld/11944
* elf-bfd.h (elf_backend_data): Add target_id.
(bfd_elf_make_generic_object): Renamed to ...
(bfd_elf_make_object): This.
* elf.c (bfd_elf_make_generic_object): Removed.
(bfd_elf_make_object): New.
(bfd_elf_mkcorefile): Really treat it as an object file.
* elf-m10300.c (ELF_TARGET_ID): New.
* elf32-arm.c (ELF_TARGET_ID): Likewise.
* elf32-bfin.c (ELF_TARGET_ID): Likewise.
* elf32-cris.c (ELF_TARGET_ID): Likewise.
* elf32-frv.c (ELF_TARGET_ID): Likewise.
* elf32-i386.c (ELF_TARGET_ID): Likewise.
* elf32-lm32.c (ELF_TARGET_ID): Likewise.
* elf32-m32r.c (ELF_TARGET_ID): Likewise.
* elf32-m68hc11.c (ELF_TARGET_ID): Likewise.
* elf32-m68hc12.c (ELF_TARGET_ID): Likewise.
* elf32-m68k.c (ELF_TARGET_ID): Likewise.
* elf32-microblaze.c (ELF_TARGET_ID): Likewise.
* elf32-ppc.c (ELF_TARGET_ID): Likewise.
* elf32-s390.c (ELF_TARGET_ID): Likewise.
* elf32-sh.c (ELF_TARGET_ID): Likewise.
* elf32-sparc.c (ELF_TARGET_ID): Likewise.
* elf32-spu.c (ELF_TARGET_ID): Likewise.
* elf32-tic6x.c (ELF_TARGET_ID): Likewise.
* elf32-xtensa.c (ELF_TARGET_ID): Likewise.
* elf64-alpha.c (ELF_TARGET_ID): Likewise.
* elf64-hppa.c (ELF_TARGET_ID): Likewise.
* elf64-ppc.c (ELF_TARGET_ID): Likewise.
* elf64-s390.c (ELF_TARGET_ID): Likewise.
* elf64-x86-64.c (ELF_TARGET_ID): Likewise.
* elfxx-ia64.c (ELF_TARGET_ID): Likewise.
* elf32-hppa.c (elf32_hppa_mkobject): Removed.
(bfd_elf32_mkobject): Likewise.
(ELF_TARGET_ID): New.
* elf32-mips.c (ELF_TARGET_ID): New.
(bfd_elf32_mkobject): Removed.
* elf64-mips.c (ELF_TARGET_ID): New.
(bfd_elf64_mkobject): Removed.
* elfn32-mips.c (ELF_TARGET_ID): New.
(bfd_elf32_mkobject): Removed.
* elfxx-mips.c (_bfd_mips_elf_mkobject): Removed.
* elfxx-mips.h (_bfd_mips_elf_mkobject): Likewise.
* elfxx-target.h (bfd_elfNN_mkobject): Default to
bfd_elf_make_object.
(ELF_TARGET_ID): New. Default to GENERIC_ELF_DATA.
(elfNN_bed): Initialize target_id.
2010-08-25 Julian Brown <julian@codesourcery.com>
* elf32-arm.c (arm_stub_required_alignment): New.
......
......@@ -689,6 +689,10 @@ struct elf_backend_data
/* The architecture for this backend. */
enum bfd_architecture arch;
/* An identifier used to distinguish different target specific
extensions to elf_obj_tdata and elf_link_hash_table structures. */
enum elf_target_id target_id;
/* The ELF machine code (EM_xxxx) for this backend. */
int elf_machine_code;
......@@ -1739,7 +1743,7 @@ extern bfd_reloc_status_type bfd_elf_generic_reloc
(bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **);
extern bfd_boolean bfd_elf_allocate_object
(bfd *, size_t, enum elf_target_id);
extern bfd_boolean bfd_elf_make_generic_object
extern bfd_boolean bfd_elf_make_object
(bfd *);
extern bfd_boolean bfd_elf_mkcorefile
(bfd *);
......
......@@ -4893,6 +4893,7 @@ _bfd_mn10300_elf_reloc_type_class (const Elf_Internal_Rela *rela)
#define TARGET_LITTLE_SYM bfd_elf32_mn10300_vec
#define TARGET_LITTLE_NAME "elf32-mn10300"
#define ELF_ARCH bfd_arch_mn10300
#define ELF_TARGET_ID MN10300_ELF_DATA
#define ELF_MACHINE_CODE EM_MN10300
#define ELF_MACHINE_ALT1 EM_CYGNUS_MN10300
#define ELF_MAXPAGESIZE 0x1000
......
......@@ -250,17 +250,18 @@ bfd_elf_allocate_object (bfd *abfd,
bfd_boolean
bfd_elf_make_generic_object (bfd *abfd)
bfd_elf_make_object (bfd *abfd)
{
const struct elf_backend_data *bed = get_elf_backend_data (abfd);
return bfd_elf_allocate_object (abfd, sizeof (struct elf_obj_tdata),
GENERIC_ELF_DATA);
bed->target_id);
}
bfd_boolean
bfd_elf_mkcorefile (bfd *abfd)
{
/* I think this can be done just like an object file. */
return bfd_elf_make_generic_object (abfd);
return abfd->xvec->_bfd_set_format[(int) bfd_object] (abfd);
}
static char *
......
......@@ -13900,6 +13900,7 @@ const struct elf_size_info elf32_arm_size_info =
};
#define ELF_ARCH bfd_arch_arm
#define ELF_TARGET_ID ARM_ELF_DATA
#define ELF_MACHINE_CODE EM_ARM
#ifdef __QNXTARGET__
#define ELF_MAXPAGESIZE 0x1000
......
......@@ -2991,6 +2991,7 @@ elf32_avr_build_stubs (struct bfd_link_info *info)
}
#define ELF_ARCH bfd_arch_avr
#define ELF_TARGET_ID AVR_ELF_DATA
#define ELF_MACHINE_CODE EM_AVR
#define ELF_MACHINE_ALT1 EM_AVR_OLD
#define ELF_MAXPAGESIZE 1
......
......@@ -5764,6 +5764,7 @@ struct bfd_elf_special_section const elf32_bfin_special_sections[] =
#define TARGET_LITTLE_SYM bfd_elf32_bfin_vec
#define TARGET_LITTLE_NAME "elf32-bfin"
#define ELF_ARCH bfd_arch_bfin
#define ELF_TARGET_ID BFIN_ELF_DATA
#define ELF_MACHINE_CODE EM_BLACKFIN
#define ELF_MAXPAGESIZE 0x1000
#define elf_symbol_leading_char '_'
......
......@@ -4364,6 +4364,7 @@ elf_cris_got_elt_size (bfd *abfd ATTRIBUTE_UNUSED,
}
#define ELF_ARCH bfd_arch_cris
#define ELF_TARGET_ID CRIS_ELF_DATA
#define ELF_MACHINE_CODE EM_CRIS
#define ELF_MAXPAGESIZE 0x2000
......
......@@ -6994,6 +6994,7 @@ elf32_frv_grok_psinfo (bfd *abfd, Elf_Internal_Note *note)
return TRUE;
}
#define ELF_ARCH bfd_arch_frv
#define ELF_TARGET_ID FRV_ELF_DATA
#define ELF_MACHINE_CODE EM_CYGNUS_FRV
#define ELF_MAXPAGESIZE 0x1000
......
......@@ -336,15 +336,6 @@ struct elf32_hppa_link_hash_table
#define eh_name(eh) \
(eh ? eh->root.root.string : "<undef>")
/* Override the generic function because we want to mark our BFDs. */
static bfd_boolean
elf32_hppa_mkobject (bfd *abfd)
{
return bfd_elf_allocate_object (abfd, sizeof (struct elf_obj_tdata),
HPPA32_ELF_DATA);
}
/* Assorted hash table functions. */
/* Initialize an entry in the stub hash table. */
......@@ -4649,7 +4640,6 @@ elf32_hppa_elf_get_symbol_type (Elf_Internal_Sym *elf_sym, int type)
#define elf_info_to_howto_rel elf_hppa_info_to_howto_rel
/* Stuff for the BFD linker. */
#define bfd_elf32_mkobject elf32_hppa_mkobject
#define bfd_elf32_bfd_final_link elf32_hppa_final_link
#define bfd_elf32_bfd_link_hash_table_create elf32_hppa_link_hash_table_create
#define bfd_elf32_bfd_link_hash_table_free elf32_hppa_link_hash_table_free
......@@ -4687,6 +4677,7 @@ elf32_hppa_elf_get_symbol_type (Elf_Internal_Sym *elf_sym, int type)
#define TARGET_BIG_SYM bfd_elf32_hppa_vec
#define TARGET_BIG_NAME "elf32-hppa"
#define ELF_ARCH bfd_arch_hppa
#define ELF_TARGET_ID HPPA32_ELF_DATA
#define ELF_MACHINE_CODE EM_PARISC
#define ELF_MAXPAGESIZE 0x1000
#define ELF_OSABI ELFOSABI_HPUX
......
......@@ -4692,6 +4692,7 @@ elf_i386_add_symbol_hook (bfd * abfd,
#define TARGET_LITTLE_SYM bfd_elf32_i386_vec
#define TARGET_LITTLE_NAME "elf32-i386"
#define ELF_ARCH bfd_arch_i386
#define ELF_TARGET_ID I386_ELF_DATA
#define ELF_MACHINE_CODE EM_386
#define ELF_MAXPAGESIZE 0x1000
......
......@@ -2853,6 +2853,7 @@ lm32_elf_fdpic_copy_private_bfd_data (bfd *ibfd, bfd *obfd)
#define ELF_ARCH bfd_arch_lm32
#define ELF_TARGET_ID LM32_ELF_DATA
#define ELF_MACHINE_CODE EM_LATTICEMICO32
#define ELF_MAXPAGESIZE 0x1000
......
......@@ -4080,6 +4080,7 @@ m32r_elf_reloc_type_class (const Elf_Internal_Rela *rela)
}
#define ELF_ARCH bfd_arch_m32r
#define ELF_TARGET_ID M32R_ELF_DATA
#define ELF_MACHINE_CODE EM_M32R
#define ELF_MACHINE_ALT1 EM_CYGNUS_M32R
#define ELF_MAXPAGESIZE 0x1 /* Explicitly requested by Mitsubishi. */
......
......@@ -1285,6 +1285,7 @@ static const struct bfd_elf_special_section elf32_m68hc11_special_sections[] =
};
#define ELF_ARCH bfd_arch_m68hc11
#define ELF_TARGET_ID M68HC11_ELF_DATA
#define ELF_MACHINE_CODE EM_68HC11
#define ELF_MAXPAGESIZE 0x1000
......
......@@ -564,6 +564,7 @@ static const struct bfd_elf_special_section elf32_m68hc12_special_sections[] =
};
#define ELF_ARCH bfd_arch_m68hc12
#define ELF_TARGET_ID M68HC11_ELF_DATA
#define ELF_MACHINE_CODE EM_68HC12
#define ELF_MAXPAGESIZE 0x1000
......
......@@ -469,6 +469,7 @@ reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED, const char *r_name)
#define bfd_elf32_bfd_reloc_type_lookup reloc_type_lookup
#define bfd_elf32_bfd_reloc_name_lookup reloc_name_lookup
#define ELF_ARCH bfd_arch_m68k
#define ELF_TARGET_ID M68K_ELF_DATA
/* Functions for the m68k ELF linker. */
......
......@@ -3026,6 +3026,7 @@ microblaze_elf_add_symbol_hook (bfd *abfd,
#define TARGET_BIG_NAME "elf32-microblaze"
#define ELF_ARCH bfd_arch_microblaze
#define ELF_TARGET_ID MICROBLAZE_ELF_DATA
#define ELF_MACHINE_CODE EM_MICROBLAZE
#define ELF_MACHINE_ALT1 EM_MICROBLAZE_OLD
#define ELF_MAXPAGESIZE 0x4 /* 4k, if we ever have 'em. */
......
......@@ -1605,6 +1605,7 @@ static const struct ecoff_debug_swap mips_elf32_ecoff_debug_swap = {
};
#define ELF_ARCH bfd_arch_mips
#define ELF_TARGET_ID MIPS_ELF_DATA
#define ELF_MACHINE_CODE EM_MIPS
#define elf_backend_collect TRUE
......@@ -1676,7 +1677,6 @@ static const struct ecoff_debug_swap mips_elf32_ecoff_debug_swap = {
#define bfd_elf32_set_section_contents _bfd_mips_elf_set_section_contents
#define bfd_elf32_bfd_get_relocated_section_contents \
_bfd_elf_mips_get_relocated_section_contents
#define bfd_elf32_mkobject _bfd_mips_elf_mkobject
#define bfd_elf32_bfd_link_hash_table_create \
_bfd_mips_elf_link_hash_table_create
#define bfd_elf32_bfd_final_link _bfd_mips_elf_final_link
......
......@@ -8927,6 +8927,7 @@ ppc_elf_finish_dynamic_sections (bfd *output_bfd,
#define TARGET_BIG_SYM bfd_elf32_powerpc_vec
#define TARGET_BIG_NAME "elf32-powerpc"
#define ELF_ARCH bfd_arch_powerpc
#define ELF_TARGET_ID PPC32_ELF_DATA
#define ELF_MACHINE_CODE EM_PPC
#ifdef __QNXTARGET__
#define ELF_MAXPAGESIZE 0x1000
......
......@@ -3496,6 +3496,7 @@ elf32_s390_merge_private_bfd_data (bfd *ibfd, bfd *obfd)
#define TARGET_BIG_SYM bfd_elf32_s390_vec
#define TARGET_BIG_NAME "elf32-s390"
#define ELF_ARCH bfd_arch_s390
#define ELF_TARGET_ID S390_ELF_DATA
#define ELF_MACHINE_CODE EM_S390
#define ELF_MACHINE_ALT1 EM_S390_OLD
#define ELF_MAXPAGESIZE 0x1000
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment