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: [Gcl-devel] Re: relocation overflow


Greetings, and thanks as always for the discussion.

Daniel Jacobowitz <drow@mvista.com> writes:

> On Thu, Nov 21, 2002 at 01:53:07PM -0500, Camm Maguire wrote:
> > Greetings, and thanks for your reply!
> > 
> > 000024e8 g     F .text	00000054 Lidentity
> > 00000048 R_PPC_PLTREL24    setbuf
> > 00000058 R_PPC_PLTREL24    setbuf
> > ...
> > 00000024 R_PPC_ADDR32      system_directory
> > 000000b4 R_PPC_ADDR32      .data+0x00000024
> > 
> > Perhaps I need to pass each module through ld -shared too?
> 
> Yes.  That's an unlinked object, not a shared object.  Don't play the
> Linux kernel's nightmare game with loading .o files unless you
> absolutely must...
> 
> (I think this is one of the special cases where you can use ld -shared
> instead of gcc -shared, but if gcc -shared works for you it is
> definitely preferable.)

There is no apriori reason that we cannot use shared objects -- all we
need to be able to do is to load at a specified address.  I've just
tried a ppc build replacing the -c gcc command line option with
-shared -o .... .  .o files are now shared objects.  Problem is that
my previous strategy of calling bfd_get_relocated_section_contents to
relocate the object at my desired address appears far from working in
this scenario.  For example, we loop through the symbols of the bfd
looking for our init address.  Here is the symbol in the currently
correctly-working-save-for possible-overflows version:

3: *q[u] = {the_bfd = 0x109f4000, name = 0x109fcaa0 "init_code", value = 4, 
  flags = 18, section = 0x109f7018, udata = {p = 0x0, i = 0}}

Here is what it looks like when the .o is a shared object:

1: *q[u] = {the_bfd = 0x109f4000, name = 0x109f4a9c "init_code", 
  value = 18446744073430635048, flags = 18, section = 0x109f7618, udata = {
    p = 0x0, i = 0}}
(gdb) p/x q[u]->value
$10 = 0xef601228

How do I map the address back to 4 bytes into the .text section?

Take care,


> 
> -- 
> Daniel Jacobowitz
> MontaVista Software                         Debian GNU/Linux Developer
> 
> 

-- 
Camm Maguire			     			camm@enhanced.com
==========================================================================
"The earth is but one country, and mankind its citizens."  --  Baha'u'llah


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