This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
How to link object file with library to generate new relocatable object file
- From: "Hotmail" <will7125 at hotmail dot com>
- To: <binutils at sources dot redhat dot com>
- Date: Tue, 10 Feb 2009 14:15:21 +0800
- Subject: How to link object file with library to generate new relocatable object file
Hi guys,
I am trying to link object files and libraries to generate new object file
now and I know that we could link object files to new object file with '-r'
option.
But when I try to link an object file which uses external function with the
library contains the function code with '-r' option, the library function
code will not be included in the output object file.
For example, I have a C source file named 'foo.c' in which there is a
function 'A' invokes a library function 'B'. Then I use the command below to
generate object file contain the code of function B:
gcc -o foo.o foo.c
ld -r -o newobj.o foo.o -lmylib
(libmylib is the library contain the code of functionB)
Eventually the output file newobj.o is not the one that I expected but as
same as foo.o, the original one.
I know that it may not be applicable to do so but I just wanna know if there
is any solution.
Any help will be greatly appreciated.
Thank you,
Will Huang