How to link object file with library to generate new relocatable object file
Hotmail
will7125@hotmail.com
Tue Feb 10 06:15:00 GMT 2009
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
More information about the Binutils
mailing list