This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]