This is the mail archive of the libc-alpha@sourceware.cygnus.com mailing list for the glibc project.


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

Problem in rtld.c with gcc-2.95pre


Hi,

in rtld.c is the following code:

  /* Relocate ourselves so we can do normal function calls and
     data access using the global offset table.  */

  ELF_DYNAMIC_RELOCATE (&bootstrap_map, 0, 0);

  /* Please note that we don't allow profiling of this object and
     therefore need not test whether we have to allocate the array
     for the relocation results (as done in dl-reloc.c).  */

  /* Now life is sane; we can call functions and access global data.
     Set up to use the operating system facilities, and find out from
     the operating system's program loader where to find the program
     header table in core.  */

  if (HP_TIMING_AVAIL)
    {
      /* If it hasn't happen yet record the startup time.  */
      if (! HP_TIMING_INLINE)
        HP_TIMING_NOW (start_time);

      /* Initialize the timing functions.  */
      HP_TIMING_DIFF_INIT ();
    }

  /* Transfer data about ourselves to the permanent link_map structure.  */
  _dl_rtld_map.l_addr = bootstrap_map.l_addr;


With gcc-2.95pre the loading of the address of _dl_rtld_map into a register is
moved _before_ the call to ELF_DYNAMIC_RELOCATE()! This lets ld.so crash
immediately when it tries to access _dl_rtld_map.l_addr, because it still uses
the address loaded out of GOT before the relocation.
I tried to surround ELF_DYNAMIC_RELOCATE() with 

asm volatile ("" : : : "memory");

but this had no effect, maybe because gcc doesn't consider the GOT as normal
memory?

My platform is as usual powerpc-linux-gnu with glibc-2.1.1.

Franz.

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