This is the mail archive of the binutils@sourceware.org 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] |
Hi Folks,
I have a question about the value held in $gp pointing to the GOT in MIPS generated code after static linking. I'm not sure whether this is/was an issue with binutils (i'm stuck with ld version 2.13.90.0.20 for a couple of reasons), or whether I've just missed something from the MIPS/SysV abi. Apologies if this is the wrong place to solicit an answer to my question.
My question is why the gp computed in the statically linked code is 0x10 off what i expected it to be.
For example, given the following source (in functions.c)I don't know. Are you having some problem? Or are you just trying to understand how it works?
int sum(int a, int b) { return a + b; } [snip]
I get the following code after doing a gcc -c functions.c followed by an objdump
00000000 <sum>: 0: 3c1c0000 lui gp,0x0 0: R_MIPS_HI16 _gp_disp 4: 279c0000 addiu gp,gp,0 4: R_MIPS_LO16 _gp_disp 8: 0399e021 addu gp,gp,t9 [snip]
after static linking against uClibc (and an objdump -D), this becomes:
00400300 <sum>: 400300: 3c1c0005 lui gp,0x5 400304: 279c8660 addiu gp,gp,-31136 # distance between start of sum and the middle of the got now in gp 400308: 0399e021 addu gp,gp,t9 # virtual address of sum is in $t9, so gp now points to middle of got [...] 00440970 <_GLOBAL_OFFSET_TABLE_>: 440970: 00000000 nop 440974: 80000000 lb zero,0(zero)
It evaluates $gp to 0x448960 in 'sum' rather than the middle of the GOT, which would be 0x440970 + 2^15 (which is 0x448970)? Have I missed something obvious?
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |