* Q: -fpic and $_GLOBAL_OFFSET_TABLE_
@ 2003-07-16 14:30 Oleg Nesterov
0 siblings, 0 replies; 4+ messages in thread
From: Oleg Nesterov @ 2003-07-16 14:30 UTC (permalink / raw)
To: linux-gcc
Hello.
I thought, that &GOT == $_GLOBAL_OFFSET_TABLE_ + .
$ cat test.c
void test(void)
{
asm volatile (
"addl $_GLOBAL_OFFSET_TABLE_, %eax\n"
"addl $_GLOBAL_OFFSET_TABLE_, %ecx\n"
);
}
$ cc -c -fpic -fomit-frame-pointer test.c && ld -shared -o test.so test.o && objdump -d test.so
test.so: file format elf32-i386
Disassembly of section .text:
0000018c <test>:
18c: 05 0d 10 00 00 addl $0x100d,%eax ==> &GOT = 0x18c + 0x100d = 0x1199
191: 81 c1 07 10 00 00 addl $0x1007,%ecx ==> &GOT = 0x191 + 0x1007 = 0x1198
197: c3 ret
How can it be?
Oleg.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Q: -fpic and $_GLOBAL_OFFSET_TABLE_
@ 2003-07-16 13:51 Oleg Nesterov
0 siblings, 0 replies; 4+ messages in thread
From: Oleg Nesterov @ 2003-07-16 13:51 UTC (permalink / raw)
To: linux-assembly, lx
Hello.
hp <lx () lxhp ! in-berlin ! de> wrote:
>
> Oleg Nesterov am Dienstag, 15. Juli 2003 14:19:
> > Hello.
> >
> > I thought, that &GOT == $_GLOBAL_OFFSET_TABLE_ + .
> ^^^^^^^^^^^^^^^^^^^^^
> thus your GOT would be at a different place whenever fetched at a different
> address in your code - not very likely...
There is R_386_GOTPC relocation item for _GLOBAL_OFFSET_TABLE_.
Look at this code produced by gcc to load &GOT in ebx:
call .L3
.L3:
popl %ebx
addl $_GLOBAL_OFFSET_TABLE_+[.-.L3],%ebx
So &GOT = .L3 + $_GLOBAL_OFFSET_TABLE_+ . - .L3 = $_GLOBAL_OFFSET_TABLE_+ .
Thank you for response,
Oleg.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Q: -fpic and $_GLOBAL_OFFSET_TABLE_
2003-07-15 13:19 Oleg Nesterov
@ 2003-07-15 23:24 ` hp
0 siblings, 0 replies; 4+ messages in thread
From: hp @ 2003-07-15 23:24 UTC (permalink / raw)
To: Oleg Nesterov, linux-assembly
Oleg Nesterov am Dienstag, 15. Juli 2003 14:19:
> Hello.
>
> I thought, that &GOT == $_GLOBAL_OFFSET_TABLE_ + .
^^^^^^^^^^^^^^^^^^^^^
thus your GOT would be at a different place whenever fetched at a different
address in your code - not very likely...
and, more in the ELF standard description, re links at
http://www.lxhp.in-berlin.de/lhplinks.html#elf
>
> $ cat test.c
>
> void test(void)
> {
> asm volatile (
> "addl $_GLOBAL_OFFSET_TABLE_, %eax\n"
> "addl $_GLOBAL_OFFSET_TABLE_, %ecx\n"
> );
> }
>
> $ cc -c -fpic -fomit-frame-pointer test.c && ld -shared -o test.so test.o
> && objdump -d test.so
>
> test.so: file format elf32-i386
>
> Disassembly of section .text:
>
> 0000018c <test>:
> 18c: 05 0d 10 00 00 addl $0x100d,%eax ==> &GOT = 0x18c + 0x100d =
> 0x1199 191: 81 c1 07 10 00 00 addl $0x1007,%ecx ==> &GOT = 0x191 +
> 0x1007 = 0x1198 197: c3 ret
>
> How can it be?
>
> Oleg.
> -
> To unsubscribe from this list: send the line "unsubscribe linux-assembly"
> in the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
--
Linux,Assembly,Forth: http://www.lxhp.in-berlin.de/index-lx.shtml en/de
FAQ(s) + DOCs at http://linuxassembly.org
pse, reply to << lx -at- lxhp -dot- in-berlin -dot- de >>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Q: -fpic and $_GLOBAL_OFFSET_TABLE_
@ 2003-07-15 13:19 Oleg Nesterov
2003-07-15 23:24 ` hp
0 siblings, 1 reply; 4+ messages in thread
From: Oleg Nesterov @ 2003-07-15 13:19 UTC (permalink / raw)
To: linux-assembly
Hello.
I thought, that &GOT == $_GLOBAL_OFFSET_TABLE_ + .
$ cat test.c
void test(void)
{
asm volatile (
"addl $_GLOBAL_OFFSET_TABLE_, %eax\n"
"addl $_GLOBAL_OFFSET_TABLE_, %ecx\n"
);
}
$ cc -c -fpic -fomit-frame-pointer test.c && ld -shared -o test.so test.o && objdump -d test.so
test.so: file format elf32-i386
Disassembly of section .text:
0000018c <test>:
18c: 05 0d 10 00 00 addl $0x100d,%eax ==> &GOT = 0x18c + 0x100d = 0x1199
191: 81 c1 07 10 00 00 addl $0x1007,%ecx ==> &GOT = 0x191 + 0x1007 = 0x1198
197: c3 ret
How can it be?
Oleg.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2003-07-16 14:30 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-07-16 14:30 Q: -fpic and $_GLOBAL_OFFSET_TABLE_ Oleg Nesterov
-- strict thread matches above, loose matches on Subject: below --
2003-07-16 13:51 Oleg Nesterov
2003-07-15 13:19 Oleg Nesterov
2003-07-15 23:24 ` hp
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.