public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* RFH/RFC: symbol index overflow in MIPS linker stubs...
@ 2006-06-07 19:29 David Daney
  2006-06-07 19:38 ` Thiemo Seufer
  2006-06-08 18:21 ` Richard Sandiford
  0 siblings, 2 replies; 14+ messages in thread
From: David Daney @ 2006-06-07 19:29 UTC (permalink / raw)
  To: binutils

I am doing some testing of the gcj java compiler that is part of 
gcc-4.2, and have come across a problem.

This is the ld version I am using:
$ mipsel-linux-ld --version
GNU ld version 2.16.91 20050817

libgcj.so.7 contains more than 2^15 symbols in its symbol table.  If a 
linker stub requires an index for a symbol that has an index greater 
than 2^15, then the index gets sign extended into a negative number. 
The result is a SIGSEGV at runtime when ld.so tries to look up the 
symbol with a negative index.

Here is a dissassembly that shows the problem:


  # objdump -d -z -j .MIPS.stubs /lib/libgcj.so.7

/lib/libgcj.so.7:     file format elf32-tradlittlemips

Disassembly of section .MIPS.stubs:

01597f40 <.MIPS.stubs>:
  1597f40:       8f998010        lw      t9,-32752(gp)
  1597f44:       03e07821        move    t7,ra
  1597f48:       0320f809        jalr    t9
  1597f4c:       241897cd        li      t8,-26675
  1597f50:       8f998010        lw      t9,-32752(gp)
  1597f54:       03e07821        move    t7,ra
  1597f58:       0320f809        jalr    t9
  1597f5c:       241897b2        li      t8,-26702


Note that the symbol index loaded into t8 is negative.

I think we could easily change the stubs so that they used ori (an 
unsigned immediate load), instead of li.  This would work for symbol 
tables of size up to 2^16.

FWIW: I tested this theory by hand editing the stubs to use the unsigned 
immediate load and the library now runs correctly.

A second option might be to use a two instruction sequence to load t8, 
but that would change the size of the stubs.  I don't know if that would 
be portable or possible.

Comments please.

David Daney

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2006-06-08 18:50 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-06-07 19:29 RFH/RFC: symbol index overflow in MIPS linker stubs David Daney
2006-06-07 19:38 ` Thiemo Seufer
2006-06-07 19:45   ` David Daney
2006-06-07 20:05   ` Daniel Jacobowitz
2006-06-07 20:10     ` Thiemo Seufer
2006-06-07 20:39       ` Daniel Jacobowitz
2006-06-07 20:45         ` David Daney
2006-06-07 23:22         ` Thiemo Seufer
2006-06-08 18:21 ` Richard Sandiford
2006-06-08 18:50   ` Thiemo Seufer
2006-06-08 19:35   ` David Daney
2006-06-08 18:27     ` Richard Sandiford
2006-06-08 18:35       ` David Daney
2006-06-08 18:44         ` Richard Sandiford

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).