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]

Re: The static linking with -fPIC is broken now


On Wed, Jun 20, 2001 at 12:01:30AM -0700, H . J . Lu wrote:
> Hi,
> 
> I believe this patch breaks the static linking using .o compiled with
> -fPIC under Linux/x86. I noticed it when I recompiled anaconda, the
> RedHat installer. I don't have a small testcase. I am working on it
> now.

It is quite hard to find a small testcase.

> 
> 
> H.J.
> ----
> 2001-06-05  Alan Modra  <amodra@bigpond.net.au>

> 	(allocate_plt_and_got): ..instead do it all here.  New function.

There is at least one possible bug in allocate_plt_and_got:

  if (h->got.refcount > 0)
    {
      boolean dyn;

      s = htab->sgot;
      h->got.offset = s->_raw_size;
      s->_raw_size += 4;
      dyn = htab->root.dynamic_sections_created;
      if (WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn, info, h))
        htab->srelgot->_raw_size += sizeof (Elf32_External_Rel);
    }

What happens if h->got.refcount > 0 and s->_raw_size == 0? When it does

h->got.offset = s->_raw_size;

it sets

h->got.refcount = 0;

It happens on the bad relocation in anaconda. As the result, I got
a global data symbol instead of a pointer to a static function.


H.J.


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