Back to index

glibc  2.9
Classes | Defines | Functions | Variables
dl-machine.h File Reference
#include <sys/param.h>
#include <assert.h>
#include <string.h>
#include <link.h>
#include <errno.h>
#include <dl-fptr.h>
#include <abort-instr.h>
#include <tls.h>
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  fdesc

Defines

#define ELF_MACHINE_NAME   "hppa"
#define VALID_ELF_OSABI(osabi)   ((osabi == ELFOSABI_SYSV) || (osabi == ELFOSABI_LINUX))
#define VALID_ELF_ABIVERSION(ver)   (ver == 0)
#define VALID_ELF_HEADER(hdr, exp, size)
#define SIZEOF_PLT_STUB   (7*4)
#define GOT_FROM_PLT_STUB   (4*4)
#define PLT_ENTRY_SIZE   (2*4)
#define ELF_MACHINE_BEFORE_RTLD_RELOC(dynamic_info)   __hppa_init_bootstrap_fdesc_table (&bootstrap_map);
#define ARCH_LA_PLTENTER   hppa_gnu_pltenter
#define ARCH_LA_PLTEXIT   hppa_gnu_pltexit
#define RTLD_START
#define elf_machine_type_class(type)
#define ELF_MACHINE_JMP_SLOT   R_PARISC_IPLT
#define ELF_MACHINE_SIZEOF_JMP_SLOT   PLT_ENTRY_SIZE
#define ELF_MACHINE_NO_REL   1
#define ELF_MACHINE_START_ADDRESS(map, start)   DL_STATIC_FUNCTION_ADDRESS (map, start)
#define DL_PLATFORM_INIT   dl_platform_init ()

Functions

static void __hppa_init_bootstrap_fdesc_table (struct link_map *map)
static int elf_machine_matches_host (const Elf32_Ehdr *ehdr)
static Elf32_Addr elf_machine_dynamic (void) __attribute__((const ))
static Elf32_Addr elf_machine_load_address (void) __attribute__((const ))
static struct fdesc __attribute__ ((always_inline)) elf_machine_fixup_plt(struct link_map *map
static struct fdesc lookup_t
const Elf32_Rela Elf32_Addr
struct fdesc 
elf_machine_plt_value (struct link_map *map, const Elf32_Rela *reloc, struct fdesc value)
static int elf_machine_runtime_setup (struct link_map *l, int lazy, int profile)
static void __attribute__ ((unused)) dl_platform_init(void)

Variables

static struct fdesc lookup_t t
static struct fdesc lookup_t
const Elf32_Rela
reloc
static struct fdesc lookup_t
const Elf32_Rela Elf32_Addr
reloc_addr
volatile Elf32_Addrrfdesc = reloc_addr
return value

Define Documentation

#define ARCH_LA_PLTENTER   hppa_gnu_pltenter

Definition at line 310 of file dl-machine.h.

#define ARCH_LA_PLTEXIT   hppa_gnu_pltexit

Definition at line 311 of file dl-machine.h.

#define DL_PLATFORM_INIT   dl_platform_init ()

Definition at line 465 of file dl-machine.h.

Definition at line 73 of file dl-machine.h.

Definition at line 453 of file dl-machine.h.

#define ELF_MACHINE_NAME   "hppa"

Definition at line 25 of file dl-machine.h.

#define ELF_MACHINE_NO_REL   1

Definition at line 457 of file dl-machine.h.

Definition at line 454 of file dl-machine.h.

Definition at line 460 of file dl-machine.h.

Value:

Definition at line 445 of file dl-machine.h.

#define GOT_FROM_PLT_STUB   (4*4)

Definition at line 57 of file dl-machine.h.

#define PLT_ENTRY_SIZE   (2*4)

Definition at line 58 of file dl-machine.h.

#define RTLD_START

Definition at line 317 of file dl-machine.h.

#define SIZEOF_PLT_STUB   (7*4)

Definition at line 56 of file dl-machine.h.

#define VALID_ELF_ABIVERSION (   ver)    (ver == 0)

Definition at line 37 of file dl-machine.h.

#define VALID_ELF_HEADER (   hdr,
  exp,
  size 
)
Value:

Definition at line 38 of file dl-machine.h.

#define VALID_ELF_OSABI (   osabi)    ((osabi == ELFOSABI_SYSV) || (osabi == ELFOSABI_LINUX))

Definition at line 36 of file dl-machine.h.


Function Documentation

static struct fdesc __attribute__ ( (always_inline)  ) [static, read]
static void __attribute__ ( (unused)  ) [inline, static]

Definition at line 467 of file dl-machine.h.

{
static void __hppa_init_bootstrap_fdesc_table ( struct link_map map) [inline, static]

Definition at line 62 of file dl-machine.h.

{
  ElfW(Addr) *boot_table;

  /* Careful: this will be called before got has been relocated... */
  ELF_MACHINE_LOAD_ADDRESS(boot_table,_dl_boot_fptr_table);

  map->l_mach.fptr_table_len = ELF_MACHINE_BOOT_FPTR_TABLE_LEN;
  map->l_mach.fptr_table = boot_table;
}
static Elf32_Addr elf_machine_dynamic ( void  ) const [inline, static]

Definition at line 88 of file dl-machine.h.

{
  Elf32_Addr dynamic;

  asm ("b,l   1f,%0\n"
"      depi   0,31,2,%0\n"
"1:    addil  L'_GLOBAL_OFFSET_TABLE_ - ($PIC_pcrel$0 - 8),%0\n"
"      ldw    R'_GLOBAL_OFFSET_TABLE_ - ($PIC_pcrel$0 - 12)(%%r1),%0\n"
       : "=r" (dynamic) : : "r1");

  return dynamic;
}

Here is the caller graph for this function:

static Elf32_Addr elf_machine_load_address ( void  ) const [inline, static]

Definition at line 106 of file dl-machine.h.

{
  Elf32_Addr dynamic;

  asm (
"      b,l    1f,%0\n"
"      depi   0,31,2,%0\n"
"1:    addil  L'_DYNAMIC - ($PIC_pcrel$0 - 8),%0\n"
"      ldo    R'_DYNAMIC - ($PIC_pcrel$0 - 12)(%%r1),%0\n"
   : "=r" (dynamic) : : "r1");

  return dynamic - elf_machine_dynamic ();
}

Here is the call graph for this function:

static int elf_machine_matches_host ( const Elf32_Ehdr ehdr) [inline, static]

Definition at line 78 of file dl-machine.h.

{
  return ehdr->e_machine == EM_PARISC;
}
static struct fdesc lookup_t const Elf32_Rela Elf32_Addr struct fdesc elf_machine_plt_value ( struct link_map map,
const Elf32_Rela reloc,
struct fdesc  value 
)

Definition at line 138 of file dl-machine.h.

{
  /* We are rela only, return a function descriptor as a plt entry. */
  return (struct fdesc) { value.ip + reloc->r_addend, value.gp };
}
static int elf_machine_runtime_setup ( struct link_map l,
int  lazy,
int  profile 
) [inline, static]

Definition at line 149 of file dl-machine.h.

{
  Elf32_Addr *got = NULL;
  Elf32_Addr l_addr, iplt, jmprel, end_jmprel, r_type, r_sym;
  const Elf32_Rela *reloc;
  struct fdesc *fptr;
  static union {
    unsigned char c[8];
    Elf32_Addr i[2];
  } sig = {{0x00,0xc0,0xff,0xee, 0xde,0xad,0xbe,0xef}};
              
  /* If we don't have a PLT we can just skip all this... */
  if (__builtin_expect (l->l_info[DT_JMPREL] == NULL,0))
    return lazy;
  
  /* All paths use these values */ 
  l_addr = l->l_addr;
  jmprel = D_PTR(l, l_info[DT_JMPREL]);
  end_jmprel = jmprel + l->l_info[DT_PLTRELSZ]->d_un.d_val;
  
  extern void _dl_runtime_resolve (void);
  extern void _dl_runtime_profile (void);
 
  /* Linking lazily */
  if (lazy)
    {
      /* FIXME: Search for the got, but backwards through the relocs, technically we should
         find it on the first try. However, assuming the relocs got out of order the 
         routine is made a bit more robust by searching them all in case of failure. */
      for (iplt = (end_jmprel - sizeof(Elf32_Rela)); iplt >= jmprel; iplt -= sizeof (Elf32_Rela))
        {
             
         reloc = (const Elf32_Rela *) iplt;
          r_type = ELF32_R_TYPE (reloc->r_info);
          r_sym = ELF32_R_SYM (reloc->r_info);

          got = (Elf32_Addr *) (reloc->r_offset + l_addr + PLT_ENTRY_SIZE + SIZEOF_PLT_STUB);

          /* If we aren't an IPLT, and we aren't NONE then it's a bad reloc */
          if (__builtin_expect (r_type != R_PARISC_IPLT, 0))
           {
             if (__builtin_expect (r_type != R_PARISC_NONE, 0))
               _dl_reloc_bad_type (l, r_type, 1);
             continue;
           }
       
          /* Check for the plt_stub that binutils placed here for us 
             to use with _dl_runtime_resolve  */
          if (got[-2] != sig.i[0] || got[-1] != sig.i[1])
            {
              got = NULL; /* Not the stub... keep looking */
            } 
          else 
           {
              /* Found the GOT! */        
              register Elf32_Addr ltp __asm__ ("%r19");
              
              /* Identify this shared object. Second entry in the got. */
              got[1] = (Elf32_Addr) l;
              
              /* This function will be called to perform the relocation. */
              if (__builtin_expect (!profile, 1))
                {
                  /* If a static application called us, then _dl_runtime_resolve is not
                   a function descriptor, but the *real* address of the function... */
                if((unsigned long) &_dl_runtime_resolve & 3)
                  {
                      got[-2] = (Elf32_Addr) ((struct fdesc *) 
                                  ((unsigned long) &_dl_runtime_resolve & ~3))->ip;
                  }
                else
                  {
                    /* Static executable! */
                      got[-2] = (Elf32_Addr) &_dl_runtime_resolve;
                  }
                }
              else
               {
                 if (GLRO(dl_profile) != NULL
                    && _dl_name_match_p (GLRO(dl_profile), l))
                   {
                    /* This is the object we are looking for.  Say that
                       we really want profiling and the timers are
                       started.  */
                      GL(dl_profile_map) = l;
                    }

                if((unsigned long) &_dl_runtime_resolve & 3)
                  {
                      got[-2] = (Elf32_Addr) ((struct fdesc *)
                                  ((unsigned long) &_dl_runtime_profile & ~3))->ip;
                  }
                else
                  {
                    /* Static executable */
                      got[-2] = (Elf32_Addr) &_dl_runtime_profile;
                  }
                }
              /* Plunk in the gp of this function descriptor so we 
                can make the call to _dl_runtime_xxxxxx */
              got[-1] = ltp;
              break;
              /* Done looking for the GOT, and stub is setup */
            } /* else we found the GOT */
        } /* for, walk the relocs backwards */

      if(!got) 
        return 0; /* No lazy linking for you! */
  
      /* Process all the relocs, now that we know the GOT... */    
      for (iplt = jmprel; iplt < end_jmprel; iplt += sizeof (Elf32_Rela))
       {
         reloc = (const Elf32_Rela *) iplt;
         r_type = ELF32_R_TYPE (reloc->r_info);
         r_sym = ELF32_R_SYM (reloc->r_info);

         if (__builtin_expect (r_type == R_PARISC_IPLT, 1))
           {
             fptr = (struct fdesc *) (reloc->r_offset + l_addr);
             if (r_sym != 0)
              {
                /* Relocate the pointer to the stub.  */
                fptr->ip = (Elf32_Addr) got - GOT_FROM_PLT_STUB;

                /* Instead of the LTP value, we put the reloc offset
                   here.  The trampoline code will load the proper
                   LTP and pass the reloc offset to the fixup
                   function.  */
                fptr->gp = iplt - jmprel;
              } /* r_sym != 0 */
             else
              {
                /* Relocate this *ABS* entry.  */
                fptr->ip = reloc->r_addend + l_addr;
                fptr->gp = D_PTR (l, l_info[DT_PLTGOT]);
              }
           } /* r_type == R_PARISC_IPLT */
       } /* for all the relocations */ 
    } /* if lazy */
  else
    {
      for (iplt = jmprel; iplt < end_jmprel; iplt += sizeof (Elf32_Rela))
        {
          reloc = (const Elf32_Rela *) iplt;
          r_type = ELF32_R_TYPE (reloc->r_info);
          r_sym = ELF32_R_SYM (reloc->r_info);

          if (__builtin_expect ((r_type == R_PARISC_IPLT) && (r_sym == 0), 1))
            {
              fptr = (struct fdesc *) (reloc->r_offset + l_addr);
              /* Relocate this *ABS* entry, set only the gp, the rest is set later
                 when elf_machine_rela_relative is called (WITHOUT the linkmap)  */
              fptr->gp = D_PTR (l, l_info[DT_PLTGOT]);
            } /* r_type == R_PARISC_IPLT */
        } /* for all the relocations */ 
    }    
  return lazy;
}

Here is the call graph for this function:


Variable Documentation

Definition at line 122 of file dl-machine.h.

Definition at line 122 of file dl-machine.h.

Definition at line 141 of file dl-machine.h.

static int t

Definition at line 122 of file dl-machine.h.

Definition at line 148 of file dl-machine.h.