This is the mail archive of the binutils@sources.redhat.com 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]

Re: restoring archive from execuable


Pavel Roskin wrote:

On Fri, 24 Oct 2003, Nicolae Mihalache wrote:



I have a program which has been statically linked with a library such
that the code from the library is now in the executable (I can see the
functions with 'nm'). The nasty thing is that I don't have the library
but I would like to build another executable to be linked with it. Is it
possible to somehow extract the code from the executable and rebuild my
library? I tried with objcopy but it does not seem to be obvious
probably because I'm not very familiar with these issues.

I'm using SuSE 7.3 and binutils 2.11.90.

Please answer directly because I'm not subscribed to the list.



I believe you are use it if you have relocation records. Try "objdump -r" on it. Otherwise it's probably impossible unless you make some kind of custom relocator that would load the original object code at the address it was configured to use.

Sorry, I cannot discuss it in details outside the mailing list.



Ok, I'm on the list now.
I tried to run "objdump -r", the results are not very encouraging:
exgse /tmp> objdump -r mon

mon: file format elf32-i386

Could you please point me to a document explaining how all these things work? In my ignorance I thought that a library is simply a collection of function code that is copied into the executable at linking time and moving them back in a library means only to know where exactly they have been copied. Now, I realise that they can not be copied just like that, the memory addresses that are used inside the objects have somehow to be changed to fit with the memory addresses used in the executable.

mache





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