This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
[PATCH] Some MIPS NewABI handling fixes in BFD
- From: Thiemo Seufer <ica2_ts at csv dot ica dot uni-stuttgart dot de>
- To: binutils at sources dot redhat dot com
- Date: Wed, 17 Apr 2002 21:13:45 +0200
- Subject: [PATCH] Some MIPS NewABI handling fixes in BFD
Hi All,
this patch fixes some things which are obviously wrong for NewABI,
e.g. special handling of _gp_disp.
Tested for mips-elf, mips64-elf, mips-linux, mips64-linux without
getting new regressions.
Thiemo
2002-04-17 Thiemo Seufer <seufer@csv.ica.uni-stuttgart.de>
/bfd/ChangeLog
* elfxx-mips.c (ABI_EABI_P): New macro.
(NEWABI_P): Include EABI as NewABI derivative.
(mips_elf_output_extsym): Do not handle _gp_disp as special symbol in
NewABI.
(_bfd_mips_elf_finish_dynamic_symbol): Likewise.
(_bfd_mips_elf_relocate_section): Don't do special R_MIPS_64 handling
for any NewABI.
diff -BurpN source-orig/bfd/elfxx-mips.c source/bfd/elfxx-mips.c
--- source-orig/bfd/elfxx-mips.c Thu Apr 4 21:53:37 2002
+++ source/bfd/elfxx-mips.c Wed Apr 10 19:12:24 2002
@@ -370,15 +370,23 @@ static bfd *reldyn_sorting_bfd;
#define ABI_N32_P(abfd) \
((elf_elfheader (abfd)->e_flags & EF_MIPS_ABI2) != 0)
-/* Nonzero if ABFD is using the 64-bit ABI. */
+/* Nonzero if ABFD is using the EABI ABI. */
+#define ABI_EABI_P(abfd) \
+ (((elf_elfheader (abfd)->e_flags & E_MIPS_ABI_EABI32) != 0) \
+ || ((elf_elfheader (abfd)->e_flags & E_MIPS_ABI_EABI64) != 0))
+
+/* Nonzero if ABFD is using the N64 ABI. */
#define ABI_64_P(abfd) \
((elf_elfheader (abfd)->e_ident[EI_CLASS] == ELFCLASS64) != 0)
+/* Nonzero if ABFD is using NewABI conventions. */
+#define NEWABI_P(abfd) \
+ (ABI_N32_P (abfd) || ABI_EABI_P (abfd) || ABI_64_P (abfd))
+
+/* The IRIX compatibility level we are striving for. */
#define IRIX_COMPAT(abfd) \
(get_elf_backend_data (abfd)->elf_backend_mips_irix_compat (abfd))
-#define NEWABI_P(abfd) (ABI_N32_P(abfd) || ABI_64_P(abfd))
-
/* Whether we are trying to be compatible with IRIX at all. */
#define SGI_COMPAT(abfd) \
(IRIX_COMPAT (abfd) != ict_none)
@@ -1239,7 +1247,7 @@ mips_elf_output_extsym (h, data)
h->esym.asym.value =
mips_elf_hash_table (einfo->info)->procedure_count;
}
- else if (strcmp (name, "_gp_disp") == 0)
+ else if (strcmp (name, "_gp_disp") == 0 && ! NEWABI_P (einfo->abfd))
{
h->esym.asym.sc = scAbs;
h->esym.asym.st = stLabel;
@@ -4984,7 +4992,7 @@ _bfd_mips_elf_relocate_section (output_b
const char * msg = (const char *) NULL;
/* Find the relocation howto for this relocation. */
- if (r_type == R_MIPS_64 && !ABI_64_P (output_bfd))
+ if (r_type == R_MIPS_64 && ! NEWABI_P (input_bfd))
{
/* Some 32-bit code uses R_MIPS_64. In particular, people use
64-bit code, but make sure all their addresses are in the
@@ -4992,8 +5000,7 @@ _bfd_mips_elf_relocate_section (output_b
space. Thus, when they use an R_MIPS_64 they mean what is
usually meant by R_MIPS_32, with the exception that the
stored value is sign-extended to 64 bits. */
- howto = MIPS_ELF_RTYPE_TO_HOWTO (input_bfd, R_MIPS_32,
- NEWABI_P (input_bfd));
+ howto = MIPS_ELF_RTYPE_TO_HOWTO (input_bfd, R_MIPS_32, false);
/* On big-endian systems, we need to lie about the position
of the reloc. */
@@ -5512,7 +5519,7 @@ _bfd_mips_elf_finish_dynamic_symbol (out
sym->st_info = ELF_ST_INFO (STB_GLOBAL, STT_SECTION);
sym->st_value = 1;
}
- else if (strcmp (name, "_gp_disp") == 0)
+ else if (strcmp (name, "_gp_disp") == 0 && ! NEWABI_P (output_bfd))
{
sym->st_shndx = SHN_ABS;
sym->st_info = ELF_ST_INFO (STB_GLOBAL, STT_SECTION);