From fe4ff5157082ed2f95422a1414ddcc30bab8d4d2 Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Tue, 8 Oct 1996 15:41:08 +0000 Subject: [PATCH 1/1] * elf32-mips.c (elf_mips_isa): New static function. (_bfd_mips_elf_merge_private_bfd_data): Don't warn about linking -mips1 and -mips2 code together, or -mips3 and -mips4 code. --- bfd/ChangeLog | 6 ++++ bfd/elf32-mips.c | 71 ++++++++++++++++++++++++++++++++++++++++-------- 2 files changed, 65 insertions(+), 12 deletions(-) diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 3a0fff75b3..96b7417502 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,9 @@ +Tue Oct 8 11:40:16 1996 Ian Lance Taylor + + * elf32-mips.c (elf_mips_isa): New static function. + (_bfd_mips_elf_merge_private_bfd_data): Don't warn about linking + -mips1 and -mips2 code together, or -mips3 and -mips4 code. + Mon Oct 7 11:44:17 1996 Ian Lance Taylor * archive.c (do_slurp_coff_armap): Only treat archive as little diff --git a/bfd/elf32-mips.c b/bfd/elf32-mips.c index 6dc1091402..1e136554a8 100644 --- a/bfd/elf32-mips.c +++ b/bfd/elf32-mips.c @@ -56,6 +56,7 @@ static boolean mips_elf_create_procedure_table struct ecoff_debug_info *)); static int mips_elf_additional_program_headers PARAMS ((bfd *)); static boolean mips_elf_modify_segment_map PARAMS ((bfd *)); +static INLINE int elf_mips_isa PARAMS ((flagword)); static boolean mips_elf32_section_from_shdr PARAMS ((bfd *, Elf32_Internal_Shdr *, char *)); static boolean mips_elf32_section_processing @@ -1485,7 +1486,7 @@ _bfd_mips_elf_object_p (abfd) { default: case E_MIPS_ARCH_1: - /* Just use the default, which was set in elfcode.h. */ + (void) bfd_default_set_arch_mach (abfd, bfd_arch_mips, 3000); break; case E_MIPS_ARCH_2: @@ -1648,10 +1649,8 @@ _bfd_mips_elf_copy_private_bfd_data (ibfd, obfd) bfd *ibfd; bfd *obfd; { - /* This function is selected based on the input vector. We only - want to copy information over if the output BFD also uses Elf - format. */ - if (bfd_get_flavour (obfd) != bfd_target_elf_flavour) + if (bfd_get_flavour (ibfd) != bfd_target_elf_flavour + || bfd_get_flavour (obfd) != bfd_target_elf_flavour) return true; BFD_ASSERT (!elf_flags_init (obfd) @@ -1664,6 +1663,26 @@ _bfd_mips_elf_copy_private_bfd_data (ibfd, obfd) return true; } +/* Return the ISA for a MIPS e_flags value. */ + +static INLINE int +elf_mips_isa (flags) + flagword flags; +{ + switch (flags & EF_MIPS_ARCH) + { + case E_MIPS_ARCH_1: + return 1; + case E_MIPS_ARCH_2: + return 2; + case E_MIPS_ARCH_3: + return 3; + case E_MIPS_ARCH_4: + return 4; + } + return 4; +} + /* Merge backend specific data from an object file to the output object file when linking. */ @@ -1689,10 +1708,8 @@ _bfd_mips_elf_merge_private_bfd_data (ibfd, obfd) return false; } - /* This function is selected based on the input vector. We only - want to copy information over if the output BFD also uses Elf - format. */ - if (bfd_get_flavour (obfd) != bfd_target_elf_flavour) + if (bfd_get_flavour (ibfd) != bfd_target_elf_flavour + || bfd_get_flavour (obfd) != bfd_target_elf_flavour) return true; new_flags = elf_elfheader (ibfd)->e_flags; @@ -1703,6 +1720,9 @@ _bfd_mips_elf_merge_private_bfd_data (ibfd, obfd) { elf_flags_init (obfd) = true; elf_elfheader (obfd)->e_flags = new_flags; + if (bfd_get_arch (obfd) == bfd_get_arch (ibfd) + && bfd_get_arch_info (obfd)->the_default) + bfd_set_arch_mach (obfd, bfd_get_arch (ibfd), bfd_get_mach (ibfd)); } else if (((new_flags ^ old_flags) & ~EF_MIPS_NOREORDER) == 0) /* Compatible flags are ok */ @@ -1713,6 +1733,7 @@ _bfd_mips_elf_merge_private_bfd_data (ibfd, obfd) if ((new_flags & EF_MIPS_PIC) != (old_flags & EF_MIPS_PIC)) { new_flags &= ~EF_MIPS_PIC; + old_flags &= ~EF_MIPS_PIC; (*_bfd_error_handler) ("%s: needs all files compiled with -fPIC", bfd_get_filename (ibfd)); @@ -1721,11 +1742,32 @@ _bfd_mips_elf_merge_private_bfd_data (ibfd, obfd) if ((new_flags & EF_MIPS_CPIC) != (old_flags & EF_MIPS_CPIC)) { new_flags &= ~EF_MIPS_CPIC; + old_flags &= ~EF_MIPS_CPIC; (*_bfd_error_handler) ("%s: needs all files compiled with -mabicalls", bfd_get_filename (ibfd)); } + /* Don't warn about mixing -mips1 and -mips2 code, or mixing + -mips3 and -mips4 code. They will normally use the same data + sizes and calling conventions. */ + if ((new_flags & EF_MIPS_ARCH) != (old_flags & EF_MIPS_ARCH)) + { + int new_isa, old_isa; + + new_isa = elf_mips_isa (new_flags); + old_isa = elf_mips_isa (old_flags); + if ((new_isa == 1 || new_isa == 2) + ? (old_isa != 1 && old_isa != 2) + : (old_isa == 1 || old_isa == 2)) + (*_bfd_error_handler) + ("%s: ISA mismatch (-mips%d) with previous modules (-mips%d)", + bfd_get_filename (ibfd), new_isa, old_isa); + + new_flags &= ~ EF_MIPS_ARCH; + old_flags &= ~ EF_MIPS_ARCH; + } + /* Warn about any other mismatches */ if (new_flags != old_flags) (*_bfd_error_handler) @@ -4988,9 +5030,14 @@ mips_elf_check_relocs (abfd, info, sec, relocs) else { sgot = bfd_get_section_by_name (dynobj, ".got"); - BFD_ASSERT (elf_section_data (sgot) != NULL); - g = (struct mips_got_info *) elf_section_data (sgot)->tdata; - BFD_ASSERT (g != NULL); + if (sgot == NULL) + g = NULL; + else + { + BFD_ASSERT (elf_section_data (sgot) != NULL); + g = (struct mips_got_info *) elf_section_data (sgot)->tdata; + BFD_ASSERT (g != NULL); + } } sreloc = NULL; -- 2.34.1