linux-c-programming.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* library calls relocation
@ 2004-12-30 14:25 Daniel Souza
  2004-12-31  4:17 ` Amit Dang
  0 siblings, 1 reply; 2+ messages in thread
From: Daniel Souza @ 2004-12-30 14:25 UTC (permalink / raw)
  To: linux-c-programming

anyone knows any docs about how library relocations works ?
for example, i have a library called

/usr/lib/mylib.so.0

that has a function called mylib_init(), and a program that was linked
to use it, like (gcc -o test test.c -lmylib). I know that when the
program is executed, the ld-linux is called to load the required
libraries (that I believe, are listed in some ELF section). The
question is, supposing that in my binary i have a call to
mylib_init(), so it looks something like in objdump -D

pushl (%eax)
call 0x484763ec <mylib_init>

and I know that there is a symbol table that tells that 0x484763ec is
mylib_init from mylib.so.0. The question is: if i increment the
library with other things, etc, and recompile it (maybe in another
machine), the size and addresses of library symbols will get changed.
But, if I copy the compiled library back to the original system, and
run the program, it still working. If the address of mylib_init in the
library has changed, why the 'static' address 0x484763ec used in the
binary still get pointing to the mylib_init in the changed library ?

thanks guys =)

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: library calls relocation
  2004-12-30 14:25 library calls relocation Daniel Souza
@ 2004-12-31  4:17 ` Amit Dang
  0 siblings, 0 replies; 2+ messages in thread
From: Amit Dang @ 2004-12-31  4:17 UTC (permalink / raw)
  To: Daniel Souza, linux-c-programming

Hi Daniel, you can get more detail about code relocation, dynamic linking
etc .... from the Book Linkers and Loaders By Morgan-Kaufman. Soft copy of
this book is available at http://www.iecc.com/linker/. Refer Chapter 7
Relocation , Chapter 8 Shared Libraries and Chapter 9 Dynamic Linking and
Loading. I hope this will give you a detailed knowledge.

Thanks,
Amit Dang
----- Original Message ----- 
From: "Daniel Souza" <thehazard@gmail.com>
To: <linux-c-programming@vger.kernel.org>
Sent: Thursday, December 30, 2004 7:55 PM
Subject: library calls relocation


> anyone knows any docs about how library relocations works ?
> for example, i have a library called
>
> /usr/lib/mylib.so.0
>
> that has a function called mylib_init(), and a program that was linked
> to use it, like (gcc -o test test.c -lmylib). I know that when the
> program is executed, the ld-linux is called to load the required
> libraries (that I believe, are listed in some ELF section). The
> question is, supposing that in my binary i have a call to
> mylib_init(), so it looks something like in objdump -D
>
> pushl (%eax)
> call 0x484763ec <mylib_init>
>
> and I know that there is a symbol table that tells that 0x484763ec is
> mylib_init from mylib.so.0. The question is: if i increment the
> library with other things, etc, and recompile it (maybe in another
> machine), the size and addresses of library symbols will get changed.
> But, if I copy the compiled library back to the original system, and
> run the program, it still working. If the address of mylib_init in the
> library has changed, why the 'static' address 0x484763ec used in the
> binary still get pointing to the mylib_init in the changed library ?
>
> thanks guys =)
> -
> To unsubscribe from this list: send the line "unsubscribe
linux-c-programming" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2004-12-31  4:17 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-12-30 14:25 library calls relocation Daniel Souza
2004-12-31  4:17 ` Amit Dang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).