puzzle about loading small global data

Can Finner can.finner@gmail.com
Tue Mar 17 08:26:00 GMT 2009

Hi All:
   This is my first message to this list, So please forgive me if I
break any rules unconsciously.

I built newlib for mipsel-elf target, and found that the insns
generated from ../stdio/puts.c is
some kinda like following:
000000d4 <puts>:
  d4:    27bdffe8     addiu    sp,sp,-24
  d8:    afbf0014     sw    ra,20(sp)
  dc:    afbe0010     sw    s8,16(sp)
  e0:    03a0f021     move    s8,sp
  e4:    afc40018     sw    a0,24(s8)
  e8:    8f820000     lw    v0,0(gp)
            e8: R_MIPS_GPREL16    _impure_ptr
  ec:    00000000     nop
  f0:    00402021     move    a0,v0
  f4:    8fc50018     lw    a1,24(s8)
  f8:    0c000000     jal    0 <_puts_r>
            f8: R_MIPS_26    _puts_r
  fc:    00000000     nop
 100:    03c0e821     move    sp,s8
 104:    8fbf0014     lw    ra,20(sp)
 108:    8fbe0010     lw    s8,16(sp)
 10c:    27bd0018     addiu    sp,sp,24
 110:    03e00008     jr    ra
 114:    00000000     nop

It seems that it loads _impure_ptr by using register gp. So how should
I do to avoid putting
global data(no matter how small it is) in gp area?

I tried to compile newlib with "-G0" option but nothing changed.

Could anyone give me a hand? any reply will be appreciated!


More information about the Newlib mailing list