This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[patch] current: MIPS/ELF: Use backend's data to check for a 64-bit ABI


Hello,

 The check for a 64-bit ABI for MIPS/ELF seems incorrect.  It checks for
ELFCLASS64 in the output's file ELF header, but depending on inputs it may
be unset.  E.g. the following fails: 

$ mips64el-linux-ar rcs stage0.o
$ mips64el-linux-ld -m elf64ltsmip -r -o stage1.o stage0.o
$ mips64el-linux-readelf -s stage1.o

Symbol table '.symtab' contains 4 entries:
   Num:    Value          Size Type    Bind   Vis      Ndx Name
     0: 0000000000000000     0 NOTYPE  LOCAL  DEFAULT  UND
     1: 0000000000000000 ++0 SECTION LOCAL  DEFAULT    1
     2: 0003000300000000 ++27 NOTYPE  LOCAL  DEFAULT  UND
     3: 0000000000000000     0 NOTYPE  LOCAL  DEFAULT  UND

See how the symbol table is corrupted due to choosing a 32-bit ABI (ELF
class is set to 0 in this case).

 The following patch seems to work for me -- the symbol table now looks
as follows:

Symbol table '.symtab' contains 4 entries:
   Num:    Value          Size Type    Bind   Vis      Ndx Name
     0: 0000000000000000     0 NOTYPE  LOCAL  DEFAULT  UND
     1: 0000000000000000     0 SECTION LOCAL  DEFAULT    1
     2: 0000000000000000     0 SECTION LOCAL  DEFAULT    2
     3: 0000000000000000     0 SECTION LOCAL  DEFAULT    3

 Please apply.

2002-05-27  Maciej W. Rozycki  <macro@ds2.pg.gda.pl>

	* elfxx-mips.c (ABI_64_P): Use backend's data to determine the
	ABI.

  Maciej

-- 
+  Maciej W. Rozycki, Technical University of Gdansk, Poland   +
+--------------------------------------------------------------+
+        e-mail: macro@ds2.pg.gda.pl, PGP key available        +

binutils-2.12.90-20020520-mips64-bfd-abi
diff -up --recursive --new-file binutils.macro/bfd/elfxx-mips.c binutils/bfd/elfxx-mips.c
--- binutils.macro/bfd/elfxx-mips.c	2002-05-15 03:25:25.000000000 +0000
+++ binutils/bfd/elfxx-mips.c	2002-05-27 00:44:17.000000000 +0000
@@ -375,7 +375,7 @@ static bfd *reldyn_sorting_bfd;
 
 /* Nonzero if ABFD is using the 64-bit ABI. */
 #define ABI_64_P(abfd) \
-  ((elf_elfheader (abfd)->e_ident[EI_CLASS] == ELFCLASS64) != 0)
+  ((get_elf_backend_data (abfd)->s->elfclass == ELFCLASS64) != 0)
 
 #define IRIX_COMPAT(abfd) \
   (get_elf_backend_data (abfd)->elf_backend_mips_irix_compat (abfd))


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]