/* Target OS. */
ENUM_BITFIELD (elf_target_os) target_os : 2;
+ /* True if object files must have exactly matching osabi. False if
+ other osabi values are allowed. */
+ unsigned osabi_exact : 1;
+
/* The maximum page size for this backend. */
unsigned maxpagesize;
Elf_Internal_Ehdr *i_ehdrp = elf_elfheader (abfd);
elf_backend_data *bed = get_elf_backend_data (abfd);
- if (i_ehdrp->e_ident[EI_OSABI] == ELFOSABI_NONE)
+ if (bed->osabi_exact && i_ehdrp->e_ident[EI_OSABI] == ELFOSABI_NONE)
i_ehdrp->e_ident[EI_OSABI] = bed->elf_osabi;
if (i_ehdrp->e_ident[EI_OSABI] == ELFOSABI_SOLARIS
#define elf_match_priority 128
#undef ELF_OSABI
#define ELF_OSABI ELFOSABI_ARM_FDPIC
+#undef ELF_OSABI_EXACT
+#define ELF_OSABI_EXACT 1
/* Like elf32_arm_link_hash_table_create -- but overrides
appropriately for FDPIC. */
#undef elf_match_priority
#undef ELF_OSABI
+#undef ELF_OSABI_EXACT
#undef elf_backend_omit_section_dynsym
/* VxWorks Targets. */
#define ELF_MACHINE_CODE EM_PARISC
#define ELF_MAXPAGESIZE 0x1000
#define ELF_OSABI ELFOSABI_HPUX
+#define ELF_OSABI_EXACT 1
#define elf32_bed elf32_hppa_hpux_bed
#include "elf32-target.h"
#define TARGET_LITTLE_NAME "elf32-i386-freebsd"
#undef ELF_OSABI
#define ELF_OSABI ELFOSABI_FREEBSD
+#undef ELF_OSABI_EXACT
+#define ELF_OSABI_EXACT 1
/* The kernel recognizes executables as valid only if they carry a
"FreeBSD" label in the ELF header. So we put this label on all
/* Restore default: we cannot use ELFOSABI_SOLARIS, otherwise ELFOSABI_NONE
objects won't be recognized. */
#undef ELF_OSABI
+#undef ELF_OSABI_EXACT
#undef elf32_bed
#define elf32_bed elf32_i386_sol2_bed
#undef ELF_TARGET_OS
#undef ELF_OSABI
+#undef ELF_OSABI_EXACT
#undef elf32_bed
#define elf32_bed elf32_iamcu_bed
#define TARGET_LITTLE_SYM i386_elf32_vxworks_vec
#undef TARGET_LITTLE_NAME
#define TARGET_LITTLE_NAME "elf32-i386-vxworks"
-#undef ELF_OSABI
#undef ELF_MAXPAGESIZE
#define ELF_MAXPAGESIZE 0x1000
#undef elf_backend_plt_alignment
#undef ELF_TARGET_OS
#define ELF_TARGET_OS is_vxworks
+#undef ELF_OSABI
+#undef ELF_OSABI_EXACT
#undef elf_backend_relocs_compatible
#undef elf_backend_add_symbol_hook
#undef ELF_OSABI
#define ELF_OSABI ELFOSABI_FREEBSD
+#undef ELF_OSABI_EXACT
+#define ELF_OSABI_EXACT 1
#undef elf32_bed
#define elf32_bed elf32_fbsd_tradbed
#define TARGET_BIG_SYM mips_elf32_vxworks_be_vec
#define TARGET_BIG_NAME "elf32-bigmips-vxworks"
#undef ELF_OSABI
+#undef ELF_OSABI_EXACT
#undef elf32_bed
#define elf32_bed elf32_mips_vxworks_bed
#define ELF_MACHINE_ALT1 EM_MSP430_OLD
#define ELF_MAXPAGESIZE 4
#define ELF_OSABI ELFOSABI_STANDALONE
+#define ELF_OSABI_EXACT 1
#define TARGET_LITTLE_SYM msp430_elf32_vec
#define TARGET_LITTLE_NAME "elf32-msp430"
#define elf32_bed elf32_msp430_ti_bed
#undef ELF_OSABI
-#define ELF_OSABI ELFOSABI_NONE
+#undef ELF_OSABI_EXACT
static const struct bfd_elf_special_section msp430_ti_elf_special_sections[] =
{
#undef ELF_OSABI
#define ELF_OSABI ELFOSABI_FREEBSD
+#undef ELF_OSABI_EXACT
+#define ELF_OSABI_EXACT 1
#undef elf32_bed
#define elf32_bed elf32_powerpc_fbsd_bed
#define TARGET_BIG_NAME "elf32-powerpc-vxworks"
#undef ELF_OSABI
+#undef ELF_OSABI_EXACT
#undef ELF_TARGET_OS
#define ELF_TARGET_OS is_vxworks
#define TARGET_BIG_NAME "elf32-tic6x-linux-be"
#undef ELF_OSABI
#define ELF_OSABI ELFOSABI_C6000_LINUX
+#undef ELF_OSABI_EXACT
+#define ELF_OSABI_EXACT 1
#include "elf32-target.h"
#define TARGET_BIG_NAME "elf32-tic6x-elf-be"
#undef ELF_OSABI
#define ELF_OSABI ELFOSABI_C6000_ELFABI
+#undef ELF_OSABI_EXACT
+#define ELF_OSABI_EXACT 1
#include "elf32-target.h"
#define ELF_ARCH bfd_arch_visium
#define ELF_MACHINE_CODE EM_VISIUM
#define ELF_OSABI ELFOSABI_STANDALONE
+#define ELF_OSABI_EXACT 1
#define ELF_MAXPAGESIZE 1
#define TARGET_BIG_SYM visium_elf32_vec
#define TARGET_LITTLE_NAME "elf64-alpha-freebsd"
#undef ELF_OSABI
#define ELF_OSABI ELFOSABI_FREEBSD
+#undef ELF_OSABI_EXACT
+#define ELF_OSABI_EXACT 1
/* The kernel recognizes executables as valid only if they carry a
"FreeBSD" label in the ELF header. So we put this label on all
64M. But everything still uses 4k. */
#define ELF_MAXPAGESIZE 0x1000
#define ELF_OSABI ELFOSABI_HPUX
+#define ELF_OSABI_EXACT 1
#define bfd_elf64_bfd_reloc_type_lookup elf_hppa_reloc_type_lookup
#define bfd_elf64_bfd_reloc_name_lookup elf_hppa_reloc_name_lookup
#undef ELF_OSABI
#define ELF_OSABI ELFOSABI_OPENVMS
+#undef ELF_OSABI_EXACT
+#define ELF_OSABI_EXACT 1
#undef ELF_MAXPAGESIZE
#define ELF_MAXPAGESIZE 0x10000 /* 64KB */
#undef ELF_OSABI
#define ELF_OSABI ELFOSABI_FREEBSD
+#undef ELF_OSABI_EXACT
+#define ELF_OSABI_EXACT 1
#undef elf64_bed
#define elf64_bed elf64_fbsd_tradbed
#undef ELF_OSABI
#define ELF_OSABI ELFOSABI_FREEBSD
+#undef ELF_OSABI_EXACT
+#define ELF_OSABI_EXACT 1
#undef elf64_bed
#define elf64_bed elf64_powerpc_fbsd_bed
#define TARGET_BIG_NAME "elf64-sparc-freebsd"
#undef ELF_OSABI
#define ELF_OSABI ELFOSABI_FREEBSD
+#undef ELF_OSABI_EXACT
+#define ELF_OSABI_EXACT 1
#undef elf64_bed
#define elf64_bed elf64_sparc_fbsd_bed
/* Restore default: we cannot use ELFOSABI_SOLARIS, otherwise ELFOSABI_NONE
objects won't be recognized. */
#undef ELF_OSABI
+#undef ELF_OSABI_EXACT
#undef elf64_bed
#define elf64_bed elf64_sparc_sol2_bed
#undef ELF_OSABI
#define ELF_OSABI ELFOSABI_FREEBSD
+#undef ELF_OSABI_EXACT
+#define ELF_OSABI_EXACT 1
#undef elf64_bed
#define elf64_bed elf64_x86_64_fbsd_bed
/* Restore default: we cannot use ELFOSABI_SOLARIS, otherwise ELFOSABI_NONE
objects won't be recognized. */
#undef ELF_OSABI
+#undef ELF_OSABI_EXACT
#undef elf64_bed
#define elf64_bed elf64_x86_64_sol2_bed
/* Restore defaults. */
#undef ELF_OSABI
+#undef ELF_OSABI_EXACT
#undef elf_backend_static_tls_alignment
#undef elf_backend_want_plt_sym
#define elf_backend_want_plt_sym 0
#undef ELF_TARGET_OS
#undef ELF_OSABI
+#undef ELF_OSABI_EXACT
#define bfd_elf32_bfd_copy_private_section_data \
elf_x86_64_copy_private_section_data
goto got_no_match;
}
- if (ebd->elf_machine_code != EM_NONE
- && i_ehdrp->e_ident[EI_OSABI] != ebd->elf_osabi
- && ebd->elf_osabi != ELFOSABI_NONE)
+ if (ebd->osabi_exact && i_ehdrp->e_ident[EI_OSABI] != ebd->elf_osabi)
goto got_wrong_format_error;
if (i_ehdrp->e_shoff >= sizeof (x_ehdr))
&& ebd->elf_machine_code != EM_NONE)
goto wrong;
- if (ebd->elf_machine_code != EM_NONE
- && i_ehdrp->e_ident[EI_OSABI] != ebd->elf_osabi
- && ebd->elf_osabi != ELFOSABI_NONE)
+ if (ebd->osabi_exact && i_ehdrp->e_ident[EI_OSABI] != ebd->elf_osabi)
goto wrong;
/* If there is no program header, or the type is not a core file, then
#undef ELF_OSABI
#define ELF_OSABI ELFOSABI_FREEBSD
+#undef ELF_OSABI_EXACT
+#define ELF_OSABI_EXACT 1
#undef elf32_bed
#define elf32_bed elf32_fbsd_tradbed
#undef ELF_COMMONPAGESIZE
#undef ELF_OSABI
#define ELF_OSABI ELFOSABI_HPUX
+#undef ELF_OSABI_EXACT
+#define ELF_OSABI_EXACT 1
#undef elfNN_bed
#define elfNN_bed elfNN_ia64_hpux_bed
#define ELF_OSABI ELFOSABI_NONE
#endif
+#ifndef ELF_OSABI_EXACT
+#define ELF_OSABI_EXACT 0
+#endif
+
#ifndef ELF_MAXPAGESIZE
# error ELF_MAXPAGESIZE is not defined
#define ELF_MAXPAGESIZE 1
#ifndef elf_match_priority
#define elf_match_priority \
- (ELF_ARCH == bfd_arch_unknown ? 2 : ELF_OSABI == ELFOSABI_NONE ? 1 : 0)
+ (ELF_ARCH == bfd_arch_unknown ? 2 \
+ : ELF_OSABI == ELFOSABI_NONE || !ELF_OSABI_EXACT ? 1 \
+ : 0)
#endif
extern const struct elf_size_info _bfd_elfNN_size_info ATTRIBUTE_HIDDEN;
ELF_MACHINE_CODE,
ELF_TARGET_ID,
ELF_TARGET_OS,
+ ELF_OSABI_EXACT,
ELF_MAXPAGESIZE,
ELF_MINPAGESIZE,
ELF_COMMONPAGESIZE,