diff options
author | Joern Rennecke <joern.rennecke@arc.com> | 2004-05-28 12:32:09 +0000 |
---|---|---|
committer | Joern Rennecke <joern.rennecke@arc.com> | 2004-05-28 12:32:09 +0000 |
commit | 265fe8b986ba6063f9b6e472c5b2070ff2d58a4e (patch) | |
tree | bd7e2e34392be1ec6a5f1ea2ca2ec87185d795c5 /bfd/elf32-sh.c | |
parent | e325852d1a2db45e2a03c0e336977bc2ec6fdcde (diff) | |
download | gdb-265fe8b986ba6063f9b6e472c5b2070ff2d58a4e.tar.gz |
2004-05-28 Andrew Stubbs <andrew.stubbs@superh.com>
bfd:
* Makefile.am: Regenerate dependencies.
* Makefile.in: Regenerate.
* archures.c: Add bfd_mach_sh3_nommu .
* bfd-in2.h: Regenerate.
* cpu-sh.c: Add sh3-nommu architecture.
(bfd_to_arch_table): Create new table.
(sh_get_arch_from_bfd_mach): Create new function.
(sh_get_arch_up_from_bfd_mach): Create new function.
(sh_merge_bfd_arch): Create new function.
* elf32-sh.c (sh_ef_bfd_table): Add table.
(sh_elf_check_relocs): Replace switch statement with
use of sh_ef_bfd_table .
(sh_elf_get_flags_from_mach): Add new function.
(sh_find_elf_flags): Likewise.
(sh_elf_copy_private_data): Replace most of non-elf contents
with a call to sh_merge_bfd_arch() .
gas:
* Makefile.am: Regenerate dependecies.
* Makefile.in: Regenerate.
* config/tc-sh.c (valid_arch): Make unsigned.
(preset_target_arch): Likewise.
(md_begin): Use new architecture flags system.
(get_specific): Likewise.
(assemble_ppi): Likewise.
(md_assemble): Likewise. Also fix error check for bad opcodes.
(md_parse_option): Likewise. Also generate -isa values according
to the table in bfd/cpu-sh.c instead of just constants. Also
allow <arch>-up ISA variants.
(sh_elf_final_processing): Replace if-else chain with a call to
sh_find_elf_flags().
* testsuite/gas/sh/arch: New directory.
* testsuite/gas/sh/arch/arch.exp: New test script.
* testsuite/gas/sh/arch/arch_expected.txt: New file.
* testsuite/gas/sh/arch/sh.s: New file.
* testsuite/gas/sh/arch/sh2.s: New file.
* testsuite/gas/sh/arch/sh-dsp.s: New file.
* testsuite/gas/sh/arch/sh2e.s: New file.
* testsuite/gas/sh/arch/sh3-nommu.s: New file.
* testsuite/gas/sh/arch/sh3.s: New file.
* testsuite/gas/sh/arch/sh3-dsp.s: New file.
* testsuite/gas/sh/arch/sh3e.s: New file.
* testsuite/gas/sh/arch/sh4-nommu-nofpu.s: New file.
* testsuite/gas/sh/arch/sh4-nofpu.s: New file.
* testsuite/gas/sh/arch/sh4.s: New file.
* testsuite/gas/sh/arch/sh4a-nofpu.s: New file.
* testsuite/gas/sh/arch/sh4al-dsp.s: New file.
* testsuite/gas/sh/arch/sh4a.s: New file.
include/elf:
* sh.h (EF_SH_HAS_DSP): Remove.
(EF_SH_HAS_FP): Remove.
(EF_SH_MERGE_MACH): Remove.
(EF_SH4_NOFPU): Convert to decimal.
(EF_SH4A_NOFPU): Likewise.
(EF_SH4_NOMMU_NOFPU): Likewise.
(EF_SH3_NOMMU): Add new macro.
(EF_SH_BFD_TABLE): Likewise.
(sh_find_elf_flags): Add prototype.
(sh_elf_get_flags_from_mach): Likewise.
opcodes:
* sh-dis.c (target_arch): Make unsigned.
(print_insn_sh): Replace (most of) switch with a call to
sh_get_arch_from_bfd_mach(). Also use new architecture flags system.
* sh-opc.h: Redefine architecture flags values.
Add sh3-nommu architecture.
Reorganise <arch>_up macros so they make more visual sense.
(SH_MERGE_ARCH_SET): Define new macro.
(SH_VALID_BASE_ARCH_SET): Likewise.
(SH_VALID_MMU_ARCH_SET): Likewise.
(SH_VALID_CO_ARCH_SET): Likewise.
(SH_VALID_ARCH_SET): Likewise.
(SH_MERGE_ARCH_SET_VALID): Likewise.
(SH_ARCH_SET_HAS_FPU): Likewise.
(SH_ARCH_SET_HAS_DSP): Likewise.
(SH_ARCH_UNKNOWN_ARCH): Likewise.
(sh_get_arch_from_bfd_mach): Add prototype.
(sh_get_arch_up_from_bfd_mach): Likewise.
(sh_get_bfd_mach_from_arch_set): Likewise.
(sh_merge_bfd_arc): Likewise.
ld:
* testsuite/ld-sh/arch/arch.exp: New test script.
* testsuite/ld-sh/arch/arch_expected.txt: New file.
* testsuite/ld-sh/arch/sh.s: New file.
* testsuite/ld-sh/arch/sh2.s: New file.
* testsuite/ld-sh/arch/sh-dsp.s: New file.
* testsuite/ld-sh/arch/sh2e.s: New file.
* testsuite/ld-sh/arch/sh3-nommu.s: New file.
* testsuite/ld-sh/arch/sh3.s: New file.
* testsuite/ld-sh/arch/sh3-dsp.s: New file.
* testsuite/ld-sh/arch/sh3e.s: New file.
* testsuite/ld-sh/arch/sh4-nommu-nofpu.s: New file.
* testsuite/ld-sh/arch/sh4-nofpu.s: New file.
* testsuite/ld-sh/arch/sh4.s: New file.
* testsuite/ld-sh/arch/sh4a-nofpu.s: New file.
* testsuite/ld-sh/arch/sh4al-dsp.s: New file.
* testsuite/ld-sh/arch/sh4a.s: New file.
Diffstat (limited to 'bfd/elf32-sh.c')
-rw-r--r-- | bfd/elf32-sh.c | 123 |
1 files changed, 55 insertions, 68 deletions
diff --git a/bfd/elf32-sh.c b/bfd/elf32-sh.c index d69457fbd2b..480fa4bea66 100644 --- a/bfd/elf32-sh.c +++ b/bfd/elf32-sh.c @@ -25,6 +25,7 @@ #include "libbfd.h" #include "elf-bfd.h" #include "elf/sh.h" +#include "libiberty.h" static bfd_reloc_status_type sh_elf_reloc (bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **); @@ -6819,58 +6820,44 @@ sh_elf_check_relocs (bfd *abfd, struct bfd_link_info *info, asection *sec, } #ifndef sh_elf_set_mach_from_flags +static unsigned int sh_ef_bfd_table[] = { EF_SH_BFD_TABLE }; + static bfd_boolean sh_elf_set_mach_from_flags (bfd *abfd) { - flagword flags = elf_elfheader (abfd)->e_flags; + flagword flags = elf_elfheader (abfd)->e_flags & EF_SH_MACH_MASK; + + if (flags >= sizeof(sh_ef_bfd_table)) + return FALSE; + + if (sh_ef_bfd_table[flags] == 0) + return FALSE; + + bfd_default_set_arch_mach (abfd, bfd_arch_sh, sh_ef_bfd_table[flags]); - switch (flags & EF_SH_MACH_MASK) - { - case EF_SH1: - bfd_default_set_arch_mach (abfd, bfd_arch_sh, bfd_mach_sh); - break; - case EF_SH2: - bfd_default_set_arch_mach (abfd, bfd_arch_sh, bfd_mach_sh2); - break; - case EF_SH2E: - bfd_default_set_arch_mach (abfd, bfd_arch_sh, bfd_mach_sh2e); - break; - case EF_SH_DSP: - bfd_default_set_arch_mach (abfd, bfd_arch_sh, bfd_mach_sh_dsp); - break; - case EF_SH3: - bfd_default_set_arch_mach (abfd, bfd_arch_sh, bfd_mach_sh3); - break; - case EF_SH3_DSP: - bfd_default_set_arch_mach (abfd, bfd_arch_sh, bfd_mach_sh3_dsp); - break; - case EF_SH3E: - bfd_default_set_arch_mach (abfd, bfd_arch_sh, bfd_mach_sh3e); - break; - case EF_SH_UNKNOWN: - case EF_SH4: - bfd_default_set_arch_mach (abfd, bfd_arch_sh, bfd_mach_sh4); - break; - case EF_SH4_NOFPU: - bfd_default_set_arch_mach (abfd, bfd_arch_sh, bfd_mach_sh4_nofpu); - break; - case EF_SH4A: - bfd_default_set_arch_mach (abfd, bfd_arch_sh, bfd_mach_sh4a); - break; - case EF_SH4A_NOFPU: - bfd_default_set_arch_mach (abfd, bfd_arch_sh, bfd_mach_sh4a_nofpu); - break; - case EF_SH4AL_DSP: - bfd_default_set_arch_mach (abfd, bfd_arch_sh, bfd_mach_sh4al_dsp); - break; - case EF_SH4_NOMMU_NOFPU: - bfd_default_set_arch_mach (abfd, bfd_arch_sh, bfd_mach_sh4_nommu_nofpu); - break; - default: - return FALSE; - } return TRUE; } + + +/* Reverse table lookup for sh_ef_bfd_table[]. + Given a bfd MACH value from archures.c + return the equivalent ELF flags from the table. + Return -1 if no match is found. */ + +int +sh_elf_get_flags_from_mach (unsigned long mach) +{ + int i = ARRAY_SIZE (sh_ef_bfd_table); + + for (; i>0; i--) + if (sh_ef_bfd_table[i] == mach) + return i; + + /* shouldn't get here */ + BFD_FAIL(); + + return -1; +} #endif /* not sh_elf_set_mach_from_flags */ #ifndef sh_elf_set_private_flags @@ -6903,17 +6890,24 @@ sh_elf_copy_private_data (bfd * ibfd, bfd * obfd) #endif /* not sh_elf_copy_private_data */ #ifndef sh_elf_merge_private_data -/* This routine checks for linking big and little endian objects - together, and for linking sh-dsp with sh3e / sh4 objects. */ -static bfd_boolean -sh_elf_merge_private_data (bfd *ibfd, bfd *obfd) +/* This function returns the ELF architecture number that + corresponds to the given arch_sh* flags. */ +int +sh_find_elf_flags (unsigned int arch_set) { - flagword old_flags, new_flags; + unsigned long bfd_mach = sh_get_bfd_mach_from_arch_set (arch_set); - if (! _bfd_generic_verify_endian_match (ibfd, obfd)) - return FALSE; + return sh_elf_get_flags_from_mach (bfd_mach); +} + + +/* This routine initialises the elf flags when required and + calls sh_merge_bfd_arch() to check dsp/fpu compatibility. */ +static bfd_boolean +sh_elf_merge_private_data (bfd *ibfd, bfd *obfd) +{ if ( bfd_get_flavour (ibfd) != bfd_target_elf_flavour || bfd_get_flavour (obfd) != bfd_target_elf_flavour) return TRUE; @@ -6923,23 +6917,16 @@ sh_elf_merge_private_data (bfd *ibfd, bfd *obfd) /* This happens when ld starts out with a 'blank' output file. */ elf_flags_init (obfd) = TRUE; elf_elfheader (obfd)->e_flags = EF_SH1; + sh_elf_set_mach_from_flags (obfd); } - old_flags = elf_elfheader (obfd)->e_flags; - new_flags = elf_elfheader (ibfd)->e_flags; - if ((EF_SH_HAS_DSP (old_flags) && EF_SH_HAS_FP (new_flags)) - || (EF_SH_HAS_DSP (new_flags) && EF_SH_HAS_FP (old_flags))) - { - (*_bfd_error_handler) - ("%s: uses %s instructions while previous modules use %s instructions", - bfd_archive_filename (ibfd), - EF_SH_HAS_DSP (new_flags) ? "dsp" : "floating point", - EF_SH_HAS_DSP (new_flags) ? "floating point" : "dsp"); - bfd_set_error (bfd_error_bad_value); - return FALSE; - } - elf_elfheader (obfd)->e_flags = EF_SH_MERGE_MACH (old_flags, new_flags); - return sh_elf_set_mach_from_flags (obfd); + if ( ! sh_merge_bfd_arch (ibfd, obfd) ) + return FALSE; + + elf_elfheader (obfd)->e_flags = + sh_elf_get_flags_from_mach (bfd_get_mach (obfd)); + + return TRUE; } #endif /* not sh_elf_merge_private_data */ |