Back to index

glibc  2.9
Defines | Functions
dynamic-link.h File Reference
#include <elf.h>
#include <assert.h>
#include <dl-machine.h>
#include "do-rel.h"
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Defines

#define CHECK_STATIC_TLS(map, sym_map)
#define TRY_STATIC_TLS(map, sym_map)
#define DL_RO_DYN_TEMP_CNT   8
#define ADJUST_DYN_INFO(tag)
#define ELF_DURING_STARTUP   (0)
#define _ELF_DYNAMIC_DO_RELOC(RELOC, reloc, map, do_lazy, test_rel)
#define _ELF_CHECK_REL   1
#define ELF_DYNAMIC_DO_REL(map, lazy)   _ELF_DYNAMIC_DO_RELOC (REL, rel, map, lazy, _ELF_CHECK_REL)
#define DO_RELA
#define ELF_DYNAMIC_DO_RELA(map, lazy)   _ELF_DYNAMIC_DO_RELOC (RELA, rela, map, lazy, _ELF_CHECK_REL)
#define ELF_DYNAMIC_RELOCATE(map, lazy, consider_profile)
#define CHECK_STATIC_TLS(map, sym_map)
#define TRY_STATIC_TLS(map, sym_map)
#define DL_RO_DYN_TEMP_CNT   8
#define ADJUST_DYN_INFO(tag)
#define ELF_DURING_STARTUP   (0)
#define _ELF_DYNAMIC_DO_RELOC(RELOC, reloc, map, do_lazy, test_rel)
#define _ELF_CHECK_REL   1
#define ELF_DYNAMIC_DO_REL(map, lazy)   _ELF_DYNAMIC_DO_RELOC (REL, rel, map, lazy, _ELF_CHECK_REL)
#define DO_RELA
#define ELF_DYNAMIC_DO_RELA(map, lazy)   _ELF_DYNAMIC_DO_RELOC (RELA, rela, map, lazy, _ELF_CHECK_REL)
#define ELF_DYNAMIC_RELOCATE(map, lazy, consider_profile)
#define CHECK_STATIC_TLS(map, sym_map)
#define TRY_STATIC_TLS(map, sym_map)
#define VERSYMIDX(sym)   (DT_NUM + DT_THISPROCNUM + DT_VERSIONTAGIDX (sym))
#define DL_RO_DYN_TEMP_CNT   8
#define ADJUST_DYN_INFO(tag)
#define CHECK_STATIC_TLS(map, sym_map)
#define TRY_STATIC_TLS(map, sym_map)
#define DL_RO_DYN_TEMP_CNT   8
#define ADJUST_DYN_INFO(tag)
#define ELF_DURING_STARTUP   (1)
#define _ELF_DYNAMIC_DO_RELOC(RELOC, reloc, map, do_lazy, test_rel)
#define _ELF_CHECK_REL   1
#define ELF_DYNAMIC_DO_REL(map, lazy)   _ELF_DYNAMIC_DO_RELOC (REL, rel, map, lazy, _ELF_CHECK_REL)
#define DO_RELA
#define ELF_DYNAMIC_DO_RELA(map, lazy)   _ELF_DYNAMIC_DO_RELOC (RELA, rela, map, lazy, _ELF_CHECK_REL)
#define ELF_DYNAMIC_RELOCATE(map, lazy, consider_profile)

Functions

int internal_function _dl_try_allocate_static_tls (struct link_map *map)
static void __attribute__ ((unused, always_inline)) elf_get_dynamic_info(struct link_map *l
static void ElfW (Dyn)*temp)

Define Documentation

#define _ELF_CHECK_REL   1
#define _ELF_CHECK_REL   1
#define _ELF_CHECK_REL   1
#define _ELF_DYNAMIC_DO_RELOC (   RELOC,
  reloc,
  map,
  do_lazy,
  test_rel 
)
#define _ELF_DYNAMIC_DO_RELOC (   RELOC,
  reloc,
  map,
  do_lazy,
  test_rel 
)
#define _ELF_DYNAMIC_DO_RELOC (   RELOC,
  reloc,
  map,
  do_lazy,
  test_rel 
)
#define ADJUST_DYN_INFO (   tag)
Value:
do                                                            \
       if (info[tag] != NULL)                                               \
         {                                                           \
           if (temp)                                                 \
             {                                                              \
              temp[cnt].d_tag = info[tag]->d_tag;                           \
              temp[cnt].d_un.d_ptr = info[tag]->d_un.d_ptr + l_addr;        \
              info[tag] = temp + cnt++;                              \
             }                                                              \
           else                                                      \
             info[tag]->d_un.d_ptr += l_addr;                               \
         }                                                           \
      while (0)
#define ADJUST_DYN_INFO (   tag)
Value:
do                                                            \
       if (info[tag] != NULL)                                               \
         {                                                           \
           if (temp)                                                 \
             {                                                              \
              temp[cnt].d_tag = info[tag]->d_tag;                           \
              temp[cnt].d_un.d_ptr = info[tag]->d_un.d_ptr + l_addr;        \
              info[tag] = temp + cnt++;                              \
             }                                                              \
           else                                                      \
             info[tag]->d_un.d_ptr += l_addr;                               \
         }                                                           \
      while (0)
#define ADJUST_DYN_INFO (   tag)
Value:
do                                                            \
       if (info[tag] != NULL)                                               \
         {                                                           \
           if (temp)                                                 \
             {                                                              \
              temp[cnt].d_tag = info[tag]->d_tag;                           \
              temp[cnt].d_un.d_ptr = info[tag]->d_un.d_ptr + l_addr;        \
              info[tag] = temp + cnt++;                              \
             }                                                              \
           else                                                      \
             info[tag]->d_un.d_ptr += l_addr;                               \
         }                                                           \
      while (0)
#define ADJUST_DYN_INFO (   tag)
Value:
do                                                            \
       if (info[tag] != NULL)                                               \
         {                                                           \
           if (temp)                                                 \
             {                                                              \
              temp[cnt].d_tag = info[tag]->d_tag;                           \
              temp[cnt].d_un.d_ptr = info[tag]->d_un.d_ptr + l_addr;        \
              info[tag] = temp + cnt++;                              \
             }                                                              \
           else                                                      \
             info[tag]->d_un.d_ptr += l_addr;                               \
         }                                                           \
      while (0)
#define CHECK_STATIC_TLS (   map,
  sym_map 
)
Value:
do {                                                    \
      if (__builtin_expect ((sym_map)->l_tls_offset == NO_TLS_OFFSET  \
                         || ((sym_map)->l_tls_offset                  \
                            == FORCED_DYNAMIC_TLS_OFFSET), 0)) \
       _dl_allocate_static_tls (sym_map);                      \
    } while (0)
#define CHECK_STATIC_TLS (   map,
  sym_map 
)
Value:
do {                                                    \
      if (__builtin_expect ((sym_map)->l_tls_offset == NO_TLS_OFFSET  \
                         || ((sym_map)->l_tls_offset                  \
                            == FORCED_DYNAMIC_TLS_OFFSET), 0)) \
       _dl_allocate_static_tls (sym_map);                      \
    } while (0)

Definition at line 29 of file dynamic-link.h.

#define CHECK_STATIC_TLS (   map,
  sym_map 
)
Value:
do {                                                    \
      if (__builtin_expect ((sym_map)->l_tls_offset == NO_TLS_OFFSET  \
                         || ((sym_map)->l_tls_offset                  \
                            == FORCED_DYNAMIC_TLS_OFFSET), 0)) \
       _dl_allocate_static_tls (sym_map);                      \
    } while (0)
#define CHECK_STATIC_TLS (   map,
  sym_map 
)
Value:
do {                                                    \
      if (__builtin_expect ((sym_map)->l_tls_offset == NO_TLS_OFFSET  \
                         || ((sym_map)->l_tls_offset                  \
                            == FORCED_DYNAMIC_TLS_OFFSET), 0)) \
       _dl_allocate_static_tls (sym_map);                      \
    } while (0)
#define DL_RO_DYN_TEMP_CNT   8
#define DL_RO_DYN_TEMP_CNT   8
#define DL_RO_DYN_TEMP_CNT   8
#define DL_RO_DYN_TEMP_CNT   8
#define DO_RELA
#define DO_RELA
#define DO_RELA
#define ELF_DURING_STARTUP   (1)
#define ELF_DURING_STARTUP   (0)
#define ELF_DURING_STARTUP   (0)
#define ELF_DYNAMIC_DO_REL (   map,
  lazy 
)    _ELF_DYNAMIC_DO_RELOC (REL, rel, map, lazy, _ELF_CHECK_REL)
#define ELF_DYNAMIC_DO_REL (   map,
  lazy 
)    _ELF_DYNAMIC_DO_RELOC (REL, rel, map, lazy, _ELF_CHECK_REL)
#define ELF_DYNAMIC_DO_REL (   map,
  lazy 
)    _ELF_DYNAMIC_DO_RELOC (REL, rel, map, lazy, _ELF_CHECK_REL)
#define ELF_DYNAMIC_DO_RELA (   map,
  lazy 
)    _ELF_DYNAMIC_DO_RELOC (RELA, rela, map, lazy, _ELF_CHECK_REL)
#define ELF_DYNAMIC_DO_RELA (   map,
  lazy 
)    _ELF_DYNAMIC_DO_RELOC (RELA, rela, map, lazy, _ELF_CHECK_REL)
#define ELF_DYNAMIC_DO_RELA (   map,
  lazy 
)    _ELF_DYNAMIC_DO_RELOC (RELA, rela, map, lazy, _ELF_CHECK_REL)
#define ELF_DYNAMIC_RELOCATE (   map,
  lazy,
  consider_profile 
)
Value:
do {                                                                 \
    int edr_lazy = elf_machine_runtime_setup ((map), (lazy),                \
                                         (consider_profile));        \
    ELF_DYNAMIC_DO_REL ((map), edr_lazy);                            \
    ELF_DYNAMIC_DO_RELA ((map), edr_lazy);                                  \
  } while (0)
#define ELF_DYNAMIC_RELOCATE (   map,
  lazy,
  consider_profile 
)
Value:
do {                                                                 \
    int edr_lazy = elf_machine_runtime_setup ((map), (lazy),                \
                                         (consider_profile));        \
    ELF_DYNAMIC_DO_REL ((map), edr_lazy);                            \
    ELF_DYNAMIC_DO_RELA ((map), edr_lazy);                                  \
  } while (0)
#define ELF_DYNAMIC_RELOCATE (   map,
  lazy,
  consider_profile 
)
Value:
do {                                                                 \
    int edr_lazy = elf_machine_runtime_setup ((map), (lazy),                \
                                         (consider_profile));        \
    ELF_DYNAMIC_DO_REL ((map), edr_lazy);                            \
    ELF_DYNAMIC_DO_RELA ((map), edr_lazy);                                  \
  } while (0)
#define TRY_STATIC_TLS (   map,
  sym_map 
)
Value:
#define TRY_STATIC_TLS (   map,
  sym_map 
)
Value:

Definition at line 37 of file dynamic-link.h.

#define TRY_STATIC_TLS (   map,
  sym_map 
)
Value:
#define TRY_STATIC_TLS (   map,
  sym_map 
)
Value:
#define VERSYMIDX (   sym)    (DT_NUM + DT_THISPROCNUM + DT_VERSIONTAGIDX (sym))

Definition at line 91 of file dynamic-link.h.


Function Documentation

static void __attribute__ ( (unused, always_inline)  ) [inline, static]

Definition at line 48 of file dl-reloc.c.

{
  /* If we've already used the variable with dynamic access, or if the
     alignment requirements are too high, fail.  */
  if (map->l_tls_offset == FORCED_DYNAMIC_TLS_OFFSET
      || map->l_tls_align > GL(dl_tls_static_align))
    {
    fail:
      return -1;
    }

#if TLS_TCB_AT_TP
  size_t freebytes;
  size_t n;
  size_t blsize;

  freebytes = GL(dl_tls_static_size) - GL(dl_tls_static_used) - TLS_TCB_SIZE;

  blsize = map->l_tls_blocksize + map->l_tls_firstbyte_offset;
  if (freebytes < blsize)
    goto fail;

  n = (freebytes - blsize) / map->l_tls_align;

  size_t offset = GL(dl_tls_static_used) + (freebytes - n * map->l_tls_align
                                       - map->l_tls_firstbyte_offset);

  map->l_tls_offset = GL(dl_tls_static_used) = offset;
#elif TLS_DTV_AT_TP
  size_t used;
  size_t check;

  size_t offset = roundup (GL(dl_tls_static_used), map->l_tls_align);
  used = offset + map->l_tls_blocksize;
  check = used;
  /* dl_tls_static_used includes the TCB at the beginning.  */

  if (check > GL(dl_tls_static_size))
    goto fail;

  map->l_tls_offset = offset;
  GL(dl_tls_static_used) = used;
#else
# error "Either TLS_TCB_AT_TP or TLS_DTV_AT_TP must be defined"
#endif

  /* If the object is not yet relocated we cannot initialize the
     static TLS region.  Delay it.  */
  if (map->l_real->l_relocated)
    {
#ifdef SHARED
      if (__builtin_expect (THREAD_DTV()[0].counter != GL(dl_tls_generation),
                         0))
       /* Update the slot information data for at least the generation of
          the DSO we are allocating data for.  */
       (void) _dl_update_slotinfo (map->l_tls_modid);
#endif

      GL(dl_init_static_tls) (map);
    }
  else
    map->l_need_tls_init = 1;

  return 0;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void ElfW ( Dyn  )

Definition at line 102 of file dynamic-link.h.

{
  ElfW(Dyn) *dyn = l->l_ld;
  ElfW(Dyn) **info;

#ifndef RTLD_BOOTSTRAP
  if (dyn == NULL)
    return;
#endif

  info = l->l_info;

  while (dyn->d_tag != DT_NULL)
    {
      if (dyn->d_tag < DT_NUM)
       info[dyn->d_tag] = dyn;
      else if (dyn->d_tag >= DT_LOPROC &&
              dyn->d_tag < DT_LOPROC + DT_THISPROCNUM)
       info[dyn->d_tag - DT_LOPROC + DT_NUM] = dyn;
      else if ((Elf32_Word) DT_VERSIONTAGIDX (dyn->d_tag) < DT_VERSIONTAGNUM)
       info[VERSYMIDX (dyn->d_tag)] = dyn;
      else if ((Elf32_Word) DT_EXTRATAGIDX (dyn->d_tag) < DT_EXTRANUM)
       info[DT_EXTRATAGIDX (dyn->d_tag) + DT_NUM + DT_THISPROCNUM
            + DT_VERSIONTAGNUM] = dyn;
      else if ((Elf32_Word) DT_VALTAGIDX (dyn->d_tag) < DT_VALNUM)
       info[DT_VALTAGIDX (dyn->d_tag) + DT_NUM + DT_THISPROCNUM
            + DT_VERSIONTAGNUM + DT_EXTRANUM] = dyn;
      else if ((Elf32_Word) DT_ADDRTAGIDX (dyn->d_tag) < DT_ADDRNUM)
       info[DT_ADDRTAGIDX (dyn->d_tag) + DT_NUM + DT_THISPROCNUM
            + DT_VERSIONTAGNUM + DT_EXTRANUM + DT_VALNUM] = dyn;
      ++dyn;
    }

#define DL_RO_DYN_TEMP_CNT  8

#ifndef DL_RO_DYN_SECTION
  /* Don't adjust .dynamic unnecessarily.  */
  if (l->l_addr != 0)
    {
      ElfW(Addr) l_addr = l->l_addr;
      int cnt = 0;

# define ADJUST_DYN_INFO(tag) \
      do                                                             \
       if (info[tag] != NULL)                                               \
         {                                                           \
           if (temp)                                                 \
             {                                                              \
              temp[cnt].d_tag = info[tag]->d_tag;                           \
              temp[cnt].d_un.d_ptr = info[tag]->d_un.d_ptr + l_addr;        \
              info[tag] = temp + cnt++;                              \
             }                                                              \
           else                                                      \
             info[tag]->d_un.d_ptr += l_addr;                               \
         }                                                           \
      while (0)

      ADJUST_DYN_INFO (DT_HASH);
      ADJUST_DYN_INFO (DT_PLTGOT);
      ADJUST_DYN_INFO (DT_STRTAB);
      ADJUST_DYN_INFO (DT_SYMTAB);
# if ! ELF_MACHINE_NO_RELA
      ADJUST_DYN_INFO (DT_RELA);
# endif
# if ! ELF_MACHINE_NO_REL
      ADJUST_DYN_INFO (DT_REL);
# endif
      ADJUST_DYN_INFO (DT_JMPREL);
      ADJUST_DYN_INFO (VERSYMIDX (DT_VERSYM));
      ADJUST_DYN_INFO (DT_ADDRTAGIDX (DT_GNU_HASH) + DT_NUM + DT_THISPROCNUM
                     + DT_VERSIONTAGNUM + DT_EXTRANUM + DT_VALNUM);
# undef ADJUST_DYN_INFO
      assert (cnt <= DL_RO_DYN_TEMP_CNT);
    }
#endif
  if (info[DT_PLTREL] != NULL)
    {
#if ELF_MACHINE_NO_RELA
      assert (info[DT_PLTREL]->d_un.d_val == DT_REL);
#elif ELF_MACHINE_NO_REL
      assert (info[DT_PLTREL]->d_un.d_val == DT_RELA);
#else
      assert (info[DT_PLTREL]->d_un.d_val == DT_REL
             || info[DT_PLTREL]->d_un.d_val == DT_RELA);
#endif
    }
#if ! ELF_MACHINE_NO_RELA
  if (info[DT_RELA] != NULL)
    assert (info[DT_RELAENT]->d_un.d_val == sizeof (ElfW(Rela)));
# endif
# if ! ELF_MACHINE_NO_REL
  if (info[DT_REL] != NULL)
    assert (info[DT_RELENT]->d_un.d_val == sizeof (ElfW(Rel)));
#endif
#ifdef RTLD_BOOTSTRAP
  /* Only the bind now flags are allowed.  */
  assert (info[VERSYMIDX (DT_FLAGS_1)] == NULL
         || info[VERSYMIDX (DT_FLAGS_1)]->d_un.d_val == DF_1_NOW);
  assert (info[DT_FLAGS] == NULL
         || info[DT_FLAGS]->d_un.d_val == DF_BIND_NOW);
  /* Flags must not be set for ld.so.  */
  assert (info[DT_RUNPATH] == NULL);
  assert (info[DT_RPATH] == NULL);
#else
  if (info[DT_FLAGS] != NULL)
    {
      /* Flags are used.  Translate to the old form where available.
        Since these l_info entries are only tested for NULL pointers it
        is ok if they point to the DT_FLAGS entry.  */
      l->l_flags = info[DT_FLAGS]->d_un.d_val;

      if (l->l_flags & DF_SYMBOLIC)
       info[DT_SYMBOLIC] = info[DT_FLAGS];
      if (l->l_flags & DF_TEXTREL)
       info[DT_TEXTREL] = info[DT_FLAGS];
      if (l->l_flags & DF_BIND_NOW)
       info[DT_BIND_NOW] = info[DT_FLAGS];
    }
  if (info[VERSYMIDX (DT_FLAGS_1)] != NULL)
    {
      l->l_flags_1 = info[VERSYMIDX (DT_FLAGS_1)]->d_un.d_val;

      if (l->l_flags_1 & DF_1_NOW)
       info[DT_BIND_NOW] = info[VERSYMIDX (DT_FLAGS_1)];
    }
  if (info[DT_RUNPATH] != NULL)
    /* If both RUNPATH and RPATH are given, the latter is ignored.  */
    info[DT_RPATH] = NULL;
#endif
}