From: Gavin Romig-Koch Date: Tue, 15 Dec 1998 14:10:46 +0000 (+0000) Subject: This adds ABI flags to MIPS/ELF object files. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=02650bd0a97e;p=binutils-gdb.git This adds ABI flags to MIPS/ELF object files. For bfd: * elf32-mips.c (elf_mips_abi_name): New. (_bfd_mips_elf_merge_private_bfd_data): Compare EF_MIPS_ABI flags. For gas: * config/tc-mips.c (mips_abi_string): New. (md_parse_option,md_longopts): Add mabi. (mips_elf_final_processing): Set e_flags based on mabi flag. For gcc: * config/mips/mips.h (GAS_ASM_SPEC): Pass mabi to gas. (ABI_GAS_ASM_SPEC,abi_gas_asm_spec): New. (EXTRA_SPECS): Added ABI_GAS_ASM_SPEC,abi_gas_asm_spec. For include/elf: * mips.h (EF_MIPS_ABI,E_MIPS_ABI_O32,E_MIPS_ABI_O64, E_MIPS_ABI_EABI32,E_MIPS_ABI_EABI64): --- diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 4b4fabd4846..7a39879c70e 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,8 @@ +1998-12-15 Gavin Romig-Koch + + * elf32-mips.c (elf_mips_abi_name): New. + (_bfd_mips_elf_merge_private_bfd_data): Compare EF_MIPS_ABI flags. + start-sanitize-vr4xxx 1998-12-13 Gavin Romig-Koch diff --git a/bfd/elf32-mips.c b/bfd/elf32-mips.c index 70d12a91000..b9f90fdafe9 100644 --- a/bfd/elf32-mips.c +++ b/bfd/elf32-mips.c @@ -60,6 +60,7 @@ 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 INLINE int elf_mips_mach PARAMS ((flagword)); +static INLINE char* elf_mips_abi_name PARAMS ((flagword)); static boolean mips_elf32_section_from_shdr PARAMS ((bfd *, Elf32_Internal_Shdr *, char *)); static boolean mips_elf32_section_processing @@ -1716,6 +1717,29 @@ elf_mips_mach (flags) return 0; } +/* Return printable name for ABI from flagword. */ + +static INLINE char* +elf_mips_abi_name (flags) + flagword flags; +{ + switch (flags & EF_MIPS_ABI) + { + case 0: + return "none"; + case E_MIPS_ABI_O32: + return "O32"; + case E_MIPS_ABI_O64: + return "O64"; + case E_MIPS_ABI_EABI32: + return "EABI32"; + case E_MIPS_ABI_EABI64: + return "EABI64"; + default: + return "unknown abi"; + } +} + /* A mapping from BFD reloc types to MIPS ELF reloc types. */ struct elf_reloc_map { @@ -2388,6 +2412,24 @@ _bfd_mips_elf_merge_private_bfd_data (ibfd, obfd) old_flags &= ~ (EF_MIPS_ARCH | EF_MIPS_MACH); } + /* Compare ABI's */ + if ((new_flags & EF_MIPS_ABI) != (old_flags & EF_MIPS_ABI)) + { + /* Only error if both are set (to different values). */ + if ((new_flags & EF_MIPS_ABI) + && (old_flags & EF_MIPS_ABI)) + { + (*_bfd_error_handler) + (_("%s: ABI mismatch: linking %s module with previous %s modules"), + bfd_get_filename (ibfd), + elf_mips_abi_name (new_flags), + elf_mips_abi_name (old_flags)); + ok = false; + } + new_flags &= ~EF_MIPS_ABI; + old_flags &= ~EF_MIPS_ABI; + } + /* Warn about any other mismatches */ if (new_flags != old_flags) { diff --git a/gas/ChangeLog b/gas/ChangeLog index 3a6a5ecef65..253c06137c8 100644 --- a/gas/ChangeLog +++ b/gas/ChangeLog @@ -1,3 +1,9 @@ +1998-12-15 Gavin Romig-Koch + + * config/tc-mips.c (mips_abi_string): New. + (md_parse_option,md_longopts): Add mabi. + (mips_elf_final_processing): Set e_flags based on mabi flag. + start-sanitize-vr4xxx 1998-12-15 Gavin Romig-Koch diff --git a/gas/config/tc-mips.c b/gas/config/tc-mips.c index 674464e509e..3de536d86e3 100644 --- a/gas/config/tc-mips.c +++ b/gas/config/tc-mips.c @@ -198,6 +198,9 @@ static int file_mips_isa; /* The CPU type as a number: 2000, 3000, 4000, 4400, etc. */ static int mips_cpu = -1; +/* The argument of the -mabi= flag. */ +static char* mips_abi_string = 0; + /* Whether the 4650 instructions (mad/madu) are permitted. */ static int mips_4650 = -1; @@ -9449,8 +9452,8 @@ struct option md_longopts[] = { {"fix-4011-branch-bug", no_argument, NULL, OPTION_FIX_4011_BRANCH_BUG}, #define OPTION_NO_FIX_4011_BRANCH_BUG (OPTION_MD_BASE + 35) {"no-fix-4011-branch-bug", no_argument, NULL, OPTION_NO_FIX_4011_BRANCH_BUG}, - /* end-sanitize-branchbug4011 */ + /* end-sanitize-branchbug4011 */ /* start-sanitize-vr4xxx */ #define OPTION_M4121 (OPTION_MD_BASE + 36) {"m4121", no_argument, NULL, OPTION_M4121}, @@ -9458,6 +9461,9 @@ struct option md_longopts[] = { {"no-m4121", no_argument, NULL, OPTION_NO_M4121}, /* end-sanitize-vr4xxx */ +#define OPTION_MABI (OPTION_MD_BASE + 38) + {"mabi", required_argument, NULL, OPTION_MABI}, + #define OPTION_CALL_SHARED (OPTION_MD_BASE + 7) #define OPTION_NON_SHARED (OPTION_MD_BASE + 8) #define OPTION_XGOT (OPTION_MD_BASE + 19) @@ -9868,6 +9874,16 @@ md_parse_option (c, arg) break; /* end-sanitize-branchbug4011 */ + + case OPTION_MABI: + if (strcmp (arg,"32") == 0 + || strcmp (arg,"n32") == 0 + || strcmp (arg,"64") == 0 + || strcmp (arg,"o64") == 0 + || strcmp (arg,"eabi") == 0) + mips_abi_string = arg; + break; + default: return 0; } @@ -12066,6 +12082,21 @@ mips_elf_final_processing () elf_elfheader (stdoutput)->e_flags |= EF_MIPS_NOREORDER; if (mips_pic != NO_PIC) elf_elfheader (stdoutput)->e_flags |= EF_MIPS_PIC; + + /* Set the MIPS ELF ABI flags. */ + if (mips_abi_string == 0) + ; + else if (strcmp (mips_abi_string,"32") == 0) + elf_elfheader (stdoutput)->e_flags |= E_MIPS_ABI_O32; + else if (strcmp (mips_abi_string,"o64") == 0) + elf_elfheader (stdoutput)->e_flags |= E_MIPS_ABI_O64; + else if (strcmp (mips_abi_string,"eabi") == 0) + { + if (mips_opts.isa > 2) + elf_elfheader (stdoutput)->e_flags |= E_MIPS_ABI_EABI32; + else + elf_elfheader (stdoutput)->e_flags |= E_MIPS_ABI_EABI64; + } } #endif /* OBJ_ELF || OBJ_MAYBE_ELF */ diff --git a/include/elf/ChangeLog b/include/elf/ChangeLog index d00a8eeed0a..8501c7920d5 100644 --- a/include/elf/ChangeLog +++ b/include/elf/ChangeLog @@ -1,3 +1,8 @@ +1998-12-15 Gavin Romig-Koch + + * mips.h (EF_MIPS_ABI,E_MIPS_ABI_O32,E_MIPS_ABI_O64, + E_MIPS_ABI_EABI32,E_MIPS_ABI_EABI64): + start-sanitize-vr4xxx 1998-12-13 Gavin Romig-Koch diff --git a/include/elf/mips.h b/include/elf/mips.h index a895d597f33..6d3816e7ca8 100644 --- a/include/elf/mips.h +++ b/include/elf/mips.h @@ -121,6 +121,22 @@ END_RELOC_NUMBERS /* -mips4 code. */ #define E_MIPS_ARCH_4 0x30000000 +/* The ABI of the file. Also see EF_MIPS_ABI2 above. */ +#define EF_MIPS_ABI 0x0000F000 + +/* The original o32 abi. */ +#define E_MIPS_ABI_O32 0x00001000 + +/* O32 extended to work on 64 bit architectures */ +#define E_MIPS_ABI_O64 0x00002000 + +/* EABI in 32 bit mode */ +#define E_MIPS_ABI_EABI32 0x00003000 + +/* EABI in 64 bit mode */ +#define E_MIPS_ABI_EABI64 0x00004000 + + /* Machine variant if we know it. This field was invented at Cygnus, but it is hoped that other vendors will adopt it. If some standard is developed, this code should be changed to follow it. */