This is the mail archive of the
mailing list for the binutils project.
runtime linking .o/.so files [Re: Free linker hash table from bfd_close]
- From: Jan Kratochvil <jan dot kratochvil at redhat dot com>
- To: binutils at sourceware dot org
- Cc: Tom Tromey <tromey at redhat dot com>
- Date: Mon, 30 Jun 2014 22:40:30 +0200
- Subject: runtime linking .o/.so files [Re: Free linker hash table from bfd_close]
- Authentication-results: sourceware.org; auth=none
- References: <20140613095201 dot GH7683 at bubble dot grove dot modra dot org> <87k38edjkw dot fsf at fleche dot redhat dot com> <20140619005828 dot GN3462 at bubble dot grove dot modra dot org> <8738f1dmzm dot fsf at fleche dot redhat dot com> <20140621000700 dot GP3462 at bubble dot grove dot modra dot org>
On Sat, 21 Jun 2014 02:07:00 +0200, Alan Modra wrote:
> On Thu, Jun 19, 2014 at 07:53:33AM -0600, Tom Tromey wrote:
> > Alan> However, I think you're going to be sorely disappointed in the
> > Alan> linker's ability to relocate final linked binaries.
> > I think we're only relocating .o files.
This is because for .so file bfd will not process its relocation table (as
.rel* do not point to .symtab/.dynsym). This means for .so GDB would have to
re-implement some part of ld.so to get its arch-dependent relocationing part.
> And then running the code? Ick. Won't work for PIC that uses the
It is using -mcmodel=large for 64-bit targets, that way no GOT is needed.
I am not aware if any target can have incompatible ABI due to using -mcmodel.
To avoid -mcmodel one could build the code as non-PIC but then one would need
to reserve very large space in the inferior in advance to get the final address.
But in such case I had some difficulties specifying the fixed address using
default system linker scripts. Customizing linker scripts I tried seemed to
me as even more incompatible across target platforms than just using -mcmodel.
I was also generating GOT by hand (and not using the 64-bit -mcmodel) but it
had some other disadvantage I cannot remember now, I could try it again.
I was considering patching bfd so that it could parse relocation tables even
for .so and implementing some simple ld.so-like relocator. But in the end
I find -mcmodel=large much easier/safer and so far compatible enough.
Thanks for possible advice,