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: turning (part of) an executable into a shared object


On Wed, Oct 01, 2003 at 12:39:27AM -0700, Ben Liblit wrote:
> It looks like the ".rel.dyn" section contains relocation information. 
> Perhaps I need to keep that too?  No luck:
> 
>     % gcc -Wl,--emit-relocs -o executable ...
>     % objcopy -j .debug_cfg -j .rodata -j .rel.dyn executable \
>     extracted-data
>     % gcc -shared -o extracted-data.so extracted-data
>     /usr/bin/ld: simple-cfg.sec(.debug_cfg+0x8048400): reloc against \
>     `.rodata': error 2
> 
> Is there any way to make this alchemical trick work?  How can I extract 
> selected data sections from a linked executable and turn them back into 
> a shared, dynamically loadable object with properly adjusted pointers?

The trouble here is that .rel.dyn contains relocs for _all_ sections,
not just for your .debug_cfg section.  What's more, the relocs have
been sorted.  You would need to write a utility to select just the
relevant relocs.  An easier alternative might be to link "executable"
using -znocombreloc.

-- 
Alan Modra
IBM OzLabs - Linux Technology Centre


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