From mboxrd@z Thu Jan 1 00:00:00 1970 From: "H . J . Lu" To: David B Anderson Cc: rth@redhat.com, gdb@sourceware.cygnus.com, binutils@sourceware.cygnus.com Subject: Re: Why does mips define elf_backend_sign_extend_vma to true? Date: Tue, 07 Aug 2001 22:04:00 -0000 Message-id: <20010807220451.A18294@lucon.org> References: <200108080326.UAA19167@quasar.engr.sgi.com> X-SW-Source: 2001-08/msg00058.html On Tue, Aug 07, 2001 at 08:26:20PM -0700, David B Anderson wrote: > > > Andrew Cagney wrote > |> > Several ABI's have implied sign extension of addresses. MIPS is one. > > H . J . Lu wrote > |> Show me where it is documemnted in the 32bit SVR4 MIPS ABI. > > You have to know where to look :-) > It's not in the ABI, it's in the hardware. > When running MIPSIII or MIPSIV. > The hardware, on loading a 32bit integer value into a > 64 bit integer register, sign-extends to 64 bits. > (for example, with a lw instruction: any 32bit integer > load does this extension) > > gdb is simply reflecting the hardware action. > What does that have anything to do with ELF files for MIPS I/II? We get different values on the same 32bit mips ELF file for MIPS I/II: ELF Header: Magic: 7f 45 4c 46 01 01 01 00 00 00 00 00 00 00 00 00 Class: ELF32 Data: 2's complement, little endian Version: 1 (current) OS/ABI: UNIX - System V ABI Version: 0 Type: EXEC (Executable file) Machine: MIPS R3000 Version: 0x1 Entry point address: 0x8010074c Start of program headers: 52 (bytes into file) Start of section headers: 2178004 (bytes into file) Flags: 0x10000001, noreorder, mips2 UNKNOWN Size of this header: 52 (bytes) Size of program headers: 32 (bytes) Number of program headers: 3 Size of section headers: 40 (bytes) Number of section headers: 18 Section header string table index: 15 from 32bit bfd and 64bit bfd. I propose this patch to at least fix the SRV4 ABI. I think the better fix is to check the EF_MIPS field to only do sign extension for MIPS III/IV. But we don't support such encoding. I think it is the time to reconsider http://gcc.gnu.org/ml/gcc-patches/2000-08/msg00418.html I am willing to provide a patch for that. H.J. ---- 2001-08-07 H.J. Lu * elf32-mips.c (elf_backend_sign_extend_vma): Undefine for the SVR4 ABI. Index: elf32-mips.c =================================================================== RCS file: /work/cvs/gnu/binutils/bfd/elf32-mips.c,v retrieving revision 1.33 diff -u -p -r1.33 elf32-mips.c --- elf32-mips.c 2001/07/04 07:34:35 1.33 +++ elf32-mips.c 2001/08/08 04:44:51 @@ -9511,6 +9511,8 @@ static const struct ecoff_debug_swap mip #define INCLUDED_TARGET_FILE /* More a type of flag */ +#undef elf_backend_sign_extend_vma + #undef TARGET_LITTLE_SYM #undef TARGET_LITTLE_NAME #undef TARGET_BIG_SYM