All of lore.kernel.org
 help / color / mirror / Atom feed
* Q: -fpic and $_GLOBAL_OFFSET_TABLE_
@ 2003-07-15 13:19 Oleg Nesterov
  2003-07-15 23:24 ` hp
  2003-07-16 10:03 ` Keyboard and Mouse library jeff
  0 siblings, 2 replies; 18+ 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] 18+ messages in thread
* Re: Q: -fpic and $_GLOBAL_OFFSET_TABLE_
@ 2003-07-16 13:51 Oleg Nesterov
  0 siblings, 0 replies; 18+ 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] 18+ messages in thread
* Q: -fpic and $_GLOBAL_OFFSET_TABLE_
@ 2003-07-16 14:30 Oleg Nesterov
  0 siblings, 0 replies; 18+ 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] 18+ messages in thread

end of thread, other threads:[~2003-07-17 22:12 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-07-15 13:19 Q: -fpic and $_GLOBAL_OFFSET_TABLE_ Oleg Nesterov
2003-07-15 23:24 ` hp
2003-07-16 10:03 ` Keyboard and Mouse library jeff
2003-07-15 19:54   ` Luciano Miguel Ferreira Rocha
2003-07-15 23:15   ` hp
2003-07-16  6:49     ` hp
2003-07-17  7:17     ` jeff
2003-07-16  3:09   ` linuxassembly
2003-07-16  6:46     ` hp
2003-07-16  8:07       ` linuxassembly
2003-07-17 16:45         ` Maciej Hrebien
2003-07-17 19:26           ` linuxassembly
2003-07-17 20:11             ` Maciej Hrebien
2003-07-17 22:12             ` hp
2003-07-17 12:29     ` jeff
2003-07-17 20:14       ` Konstantin Boldyshev
2003-07-16 13:51 Q: -fpic and $_GLOBAL_OFFSET_TABLE_ Oleg Nesterov
2003-07-16 14:30 Oleg Nesterov

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.