This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


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

Is this a bug in GNU ld?



  I've run across a situation using a egcs MIPS-on-x86 cross compiler which 
I think may be a GNU ld bug.  GCC looks like it has 2 ways to generate 
function calls in MIPS, using an address in the GOT (for general calls) or 
by offsetting from the beginning of the current function (for local calls).  
On my platform the latter doesn't get the correct address or offset to reach 
the callee.
  When I look at the assembly code output from gcc (using objdump) the 
function call is as follows:

  48:   8f990000        lw      $t9,0($gp)
  4c:   00000000        nop
  50:   273902b0        addiu   $t9,$t9,688
  54:   00000000        nop
  58:   0320f809        jalr    $t9

688 is the offset from the beginning of the caller to the beginning of the 
callee (they're in the same file).  Presumably, then, ld will change the lw 
into $t9 to load the address of the caller.  What actually gets generated, 
though, is

    cd28:       8f99801c        lw      $t9,-32740($gp)
    cd2c:       00000000        nop
    cd30:       2739cf90        addiu   $t9,$t9,-12400
    cd34:       00000000        nop
    cd38:       0320f809        jalr    $t9

The offset -32740 points to an uninitialized memory location, and -12400 
would be the offset to the callee from the start of the text section if it 
weren't sign-extended.

I'm running Redhat 6.0, gcc version egcs-2.90.29 980515 (egcs-1.0.3 
release), and binutils version 2.8.1 (mips-linux), using BFD version 2.8.1.

Is there something I'm not doing correctly?

John


______________________________________________________
Get Your Private, Free Email at http://www.hotmail.com


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