+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.
/* 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;
(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 *);
#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
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 *
};
#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
}
#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
#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 '_'
}
\f
#define ELF_ARCH bfd_arch_cris
+#define ELF_TARGET_ID CRIS_ELF_DATA
#define ELF_MACHINE_CODE EM_CRIS
#define ELF_MAXPAGESIZE 0x2000
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
#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. */
#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
#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
#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
#define ELF_ARCH bfd_arch_lm32
+#define ELF_TARGET_ID LM32_ELF_DATA
#define ELF_MACHINE_CODE EM_LATTICEMICO32
#define ELF_MAXPAGESIZE 0x1000
}
\f
#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. */
};
\f
#define ELF_ARCH bfd_arch_m68hc11
+#define ELF_TARGET_ID M68HC11_ELF_DATA
#define ELF_MACHINE_CODE EM_68HC11
#define ELF_MAXPAGESIZE 0x1000
};
\f
#define ELF_ARCH bfd_arch_m68hc12
+#define ELF_TARGET_ID M68HC11_ELF_DATA
#define ELF_MACHINE_CODE EM_68HC12
#define ELF_MAXPAGESIZE 0x1000
#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
\f
/* Functions for the m68k ELF linker. */
#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. */
};
\f
#define ELF_ARCH bfd_arch_mips
+#define ELF_TARGET_ID MIPS_ELF_DATA
#define ELF_MACHINE_CODE EM_MIPS
#define elf_backend_collect TRUE
#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
#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
#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
#endif
#define ELF_ARCH bfd_arch_sh
+#define ELF_TARGET_ID SH_ELF_DATA
#define ELF_MACHINE_CODE EM_SH
#ifdef __QNXTARGET__
#define ELF_MAXPAGESIZE 0x1000
#define TARGET_BIG_SYM bfd_elf32_sparc_vec
#define TARGET_BIG_NAME "elf32-sparc"
#define ELF_ARCH bfd_arch_sparc
+#define ELF_TARGET_ID SPARC_ELF_DATA
#define ELF_MACHINE_CODE EM_SPARC
#define ELF_MACHINE_ALT1 EM_SPARC32PLUS
#define ELF_MAXPAGESIZE 0x10000
#define TARGET_BIG_SYM bfd_elf32_spu_vec
#define TARGET_BIG_NAME "elf32-spu"
#define ELF_ARCH bfd_arch_spu
+#define ELF_TARGET_ID SPU_ELF_DATA
#define ELF_MACHINE_CODE EM_SPU
/* This matches the alignment need for DMA. */
#define ELF_MAXPAGESIZE 0x80
#define TARGET_BIG_SYM bfd_elf32_tic6x_be_vec
#define TARGET_BIG_NAME "elf32-tic6x-be"
#define ELF_ARCH bfd_arch_tic6x
+#define ELF_TARGET_ID TIC6X_ELF_DATA
#define ELF_MACHINE_CODE EM_TI_C6000
#define ELF_MAXPAGESIZE 1
#define bfd_elf32_bfd_reloc_type_lookup elf32_tic6x_reloc_type_lookup
{ NULL, 0, 0, 0, 0 }
};
\f
+#define ELF_TARGET_ID XTENSA_ELF_DATA
#ifndef ELF_ARCH
#define TARGET_LITTLE_SYM bfd_elf32_xtensa_le_vec
#define TARGET_LITTLE_NAME "elf32-xtensa-le"
#define TARGET_LITTLE_SYM bfd_elf64_alpha_vec
#define TARGET_LITTLE_NAME "elf64-alpha"
#define ELF_ARCH bfd_arch_alpha
+#define ELF_TARGET_ID ALPHA_ELF_DATA
#define ELF_MACHINE_CODE EM_ALPHA
#define ELF_MAXPAGESIZE 0x10000
#define ELF_COMMONPAGESIZE 0x2000
#define TARGET_BIG_SYM bfd_elf64_hppa_vec
#define TARGET_BIG_NAME "elf64-hppa"
#define ELF_ARCH bfd_arch_hppa
+#define ELF_TARGET_ID HPPA64_ELF_DATA
#define ELF_MACHINE_CODE EM_PARISC
/* This is not strictly correct. The maximum page size for PA2.0 is
64M. But everything still uses 4k. */
};
#define ELF_ARCH bfd_arch_mips
+#define ELF_TARGET_ID MIPS_ELF_DATA
#define ELF_MACHINE_CODE EM_MIPS
#define elf_backend_collect TRUE
#define bfd_elf64_set_section_contents _bfd_mips_elf_set_section_contents
#define bfd_elf64_bfd_get_relocated_section_contents \
_bfd_elf_mips_get_relocated_section_contents
-#define bfd_elf64_mkobject _bfd_mips_elf_mkobject
#define bfd_elf64_bfd_link_hash_table_create \
_bfd_mips_elf_link_hash_table_create
#define bfd_elf64_bfd_final_link _bfd_mips_elf_final_link
#define TARGET_BIG_SYM bfd_elf64_powerpc_vec
#define TARGET_BIG_NAME "elf64-powerpc"
#define ELF_ARCH bfd_arch_powerpc
+#define ELF_TARGET_ID PPC64_ELF_DATA
#define ELF_MACHINE_CODE EM_PPC64
#define ELF_MAXPAGESIZE 0x10000
#define ELF_COMMONPAGESIZE 0x1000
#define TARGET_BIG_SYM bfd_elf64_s390_vec
#define TARGET_BIG_NAME "elf64-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
#define TARGET_LITTLE_SYM bfd_elf64_x86_64_vec
#define TARGET_LITTLE_NAME "elf64-x86-64"
#define ELF_ARCH bfd_arch_i386
+#define ELF_TARGET_ID X86_64_ELF_DATA
#define ELF_MACHINE_CODE EM_X86_64
#define ELF_MAXPAGESIZE 0x200000
#define ELF_MINPAGESIZE 0x1000
};
\f
#define ELF_ARCH bfd_arch_mips
+#define ELF_TARGET_ID MIPS_ELF_DATA
#define ELF_MACHINE_CODE EM_MIPS
#define elf_backend_collect TRUE
#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
#define TARGET_BIG_SYM bfd_elfNN_ia64_big_vec
#define TARGET_BIG_NAME "elfNN-ia64-big"
#define ELF_ARCH bfd_arch_ia64
+#define ELF_TARGET_ID IA64_ELF_DATA
#define ELF_MACHINE_CODE EM_IA_64
#define ELF_MACHINE_ALT1 1999 /* EAS2.3 */
#define ELF_MACHINE_ALT2 1998 /* EAS2.2 */
return NULL;
}
\f
-/* Allocate ABFD's target-dependent data. */
-
-bfd_boolean
-_bfd_mips_elf_mkobject (bfd *abfd)
-{
- return bfd_elf_allocate_object (abfd, sizeof (struct elf_obj_tdata),
- MIPS_ELF_DATA);
-}
-
/* Create a MIPS ELF linker hash table. */
struct bfd_link_hash_table *
extern bfd_byte *_bfd_elf_mips_get_relocated_section_contents
(bfd *, struct bfd_link_info *, struct bfd_link_order *,
bfd_byte *, bfd_boolean, asymbol **);
-extern bfd_boolean _bfd_mips_elf_mkobject
- (bfd *);
extern struct bfd_link_hash_table *_bfd_mips_elf_link_hash_table_create
(bfd *);
extern struct bfd_link_hash_table *_bfd_mips_vxworks_link_hash_table_create
#endif
#ifndef bfd_elfNN_mkobject
-#define bfd_elfNN_mkobject bfd_elf_make_generic_object
+#define bfd_elfNN_mkobject bfd_elf_make_object
#endif
#ifndef bfd_elfNN_mkcorefile
#define elf_info_to_howto_rel 0
#endif
+#ifndef ELF_TARGET_ID
+#define ELF_TARGET_ID GENERIC_ELF_DATA
+#endif
+
#ifndef ELF_OSABI
#define ELF_OSABI ELFOSABI_NONE
#endif
static struct elf_backend_data elfNN_bed =
{
ELF_ARCH, /* arch */
+ ELF_TARGET_ID, /* target_id */
ELF_MACHINE_CODE, /* elf_machine_code */
ELF_OSABI, /* elf_osabi */
ELF_MAXPAGESIZE, /* maxpagesize */