Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 114008 | Differences between
and this patch

Collapse All | Expand All

(-)glibc-2.3.6.orig/elf/dl-close.c (+3 lines)
Lines 506-511 Link Here
506
	  /* Remove the searchlists.  */
506
	  /* Remove the searchlists.  */
507
	  free (imap->l_initfini);
507
	  free (imap->l_initfini);
508
508
509
	  /* Remove the dtneeded list */
510
	  free (imap->l_dtneeded.r_list);
511
509
	  /* Remove the scope array if we allocated it.  */
512
	  /* Remove the scope array if we allocated it.  */
510
	  if (imap->l_scope != imap->l_scope_mem)
513
	  if (imap->l_scope != imap->l_scope_mem)
511
	    free (imap->l_scope);
514
	    free (imap->l_scope);
(-)glibc-2.3.6.orig/elf/dl-deps.c (+73 lines)
Lines 39-44 Link Here
39
#define FILTERTAG (DT_NUM + DT_THISPROCNUM + DT_VERSIONTAGNUM \
39
#define FILTERTAG (DT_NUM + DT_THISPROCNUM + DT_VERSIONTAGNUM \
40
		   + DT_EXTRATAGIDX (DT_FILTER))
40
		   + DT_EXTRATAGIDX (DT_FILTER))
41
41
42
#ifndef SUSEIDX
43
# define SUSEIDX(sym)	(DT_NUM + DT_THISPROCNUM + DT_VERSIONTAGNUM + \
44
			 DT_EXTRANUM + DT_VALNUM + DT_ADDRNUM + DT_SUSE_TAGIDX (sym))
45
#endif
42
46
43
/* When loading auxiliary objects we must ignore errors.  It's ok if
47
/* When loading auxiliary objects we must ignore errors.  It's ok if
44
   an object is missing.  */
48
   an object is missing.  */
Lines 139-144 Link Here
139
    __result; })
143
    __result; })
140
144
141
145
146
static void
147
setup_direct (struct link_map *map, struct r_scope_elem *scope)
148
{
149
  if (map->l_info[SUSEIDX(DT_SUSE_DIRECT)] && map->l_info[DT_NEEDED])
150
    {
151
      const ElfW(Dyn) *d;
152
      unsigned int i;
153
      const char *strtab = (const void *) D_PTR (map, l_info[DT_STRTAB]);
154
155
      if (GLRO(dl_debug_mask) & DL_DEBUG_DIRECT)
156
	 _dl_debug_printf ("** direct linkage section in '%s' **\n",
157
			map->l_name ? map->l_name : "<null>");
158
159
      map->l_dtneeded.r_nlist = 1;
160
      for (d = map->l_ld; d->d_tag != DT_NULL; ++d)
161
        {
162
	  if (__builtin_expect (d->d_tag, DT_NEEDED) == DT_NEEDED)
163
	    map->l_dtneeded.r_nlist++;
164
	}
165
166
      map->l_dtneeded.r_list = (struct link_map **)
167
	malloc (map->l_dtneeded.r_nlist * sizeof (struct link_map *));
168
169
      map->l_dtneeded.r_list[0] = map;
170
      for (i = 1, d = map->l_ld; d->d_tag != DT_NULL; ++d)
171
        {
172
	  const char *name;
173
	  unsigned int j;
174
175
	  if (d->d_tag != DT_NEEDED)
176
	    continue;
177
178
	  name = expand_dst (map, strtab + d->d_un.d_val, 0);
179
          if (GLRO(dl_debug_mask) & DL_DEBUG_DIRECT)
180
	      _dl_debug_printf (" direct index %u object '%s'\n", i, name);
181
	  for (j = 0; j < scope->r_nlist; j++)
182
	    {
183
	      if (scope->r_list[j] &&
184
		  _dl_name_match_p (name, scope->r_list[j]))
185
	        {
186
	          map->l_dtneeded.r_list[i] = scope->r_list[j];
187
		  break;
188
		}
189
	    }
190
          if (!map->l_dtneeded.r_list[i])
191
	    _dl_debug_printf (" impossible error - can't find '%s'\n", name);
192
	  i++;
193
	}
194
    }
195
  else
196
    {
197
      if (GLRO(dl_debug_mask) & DL_DEBUG_DIRECT)
198
        _dl_debug_printf ("no direct linkage section in '%s'\n",
199
			  map->l_name ? map->l_name : "<null>");
200
      map->l_dtneeded.r_nlist = 0;
201
      map->l_dtneeded.r_list = NULL;
202
    }
203
}
204
142
void
205
void
143
internal_function
206
internal_function
144
_dl_map_object_deps (struct link_map *map,
207
_dl_map_object_deps (struct link_map *map,
Lines 555-560 Link Here
555
	}
618
	}
556
    }
619
    }
557
620
621
  if (__builtin_expect (GLRO(dl_direct), 0) && npreloads == 0)
622
    {
623
      /* Setup direct linkage dtneeded table */
624
      for (i = 0; i < nlist; ++i)
625
        setup_direct (map->l_searchlist.r_list[i], &map->l_searchlist);
626
    }
627
  else
628
    if (GLRO(dl_debug_mask) & DL_DEBUG_DIRECT)
629
        _dl_debug_printf (" no dl_direct set %u\n", GLRO(dl_direct));
630
558
  /* Maybe we can remove some relocation dependencies now.  */
631
  /* Maybe we can remove some relocation dependencies now.  */
559
  assert (map->l_searchlist.r_list[0] == map);
632
  assert (map->l_searchlist.r_list[0] == map);
560
  for (i = 0; i < map->l_reldepsact; ++i)
633
  for (i = 0; i < map->l_reldepsact; ++i)
(-)glibc-2.3.6.orig/elf/dl-lookup.c (-2 / +82 lines)
Lines 32-37 Link Here
32
32
33
#define VERSTAG(tag)	(DT_NUM + DT_THISPROCNUM + DT_VERSIONTAGIDX (tag))
33
#define VERSTAG(tag)	(DT_NUM + DT_THISPROCNUM + DT_VERSIONTAGIDX (tag))
34
34
35
#ifndef SUSEIDX
36
# define SUSEIDX(sym)	(DT_NUM + DT_THISPROCNUM + DT_VERSIONTAGNUM + \
37
			 DT_EXTRANUM + DT_VALNUM + DT_ADDRNUM + DT_SUSE_TAGIDX (sym))
38
#endif
39
35
/* We need this string more than once.  */
40
/* We need this string more than once.  */
36
static const char undefined_msg[] = "undefined symbol: ";
41
static const char undefined_msg[] = "undefined symbol: ";
37
42
Lines 209-214 Link Here
209
  unsigned long int hash;
214
  unsigned long int hash;
210
  struct sym_val current_value = { NULL, NULL };
215
  struct sym_val current_value = { NULL, NULL };
211
  struct r_scope_elem **scope = symbol_scope;
216
  struct r_scope_elem **scope = symbol_scope;
217
  size_t i = 0;
212
218
213
  /* This sucks mostly - but people sadly don't pass a symtab index, or hashvals ptr in */
219
  /* This sucks mostly - but people sadly don't pass a symtab index, or hashvals ptr in */
214
  const Elf_Symndx *hashvals;
220
  const Elf_Symndx *hashvals;
Lines 244-250 Link Here
244
     up a versioned symbol.  */
250
     up a versioned symbol.  */
245
  assert (version == NULL || flags == 0 || flags == DL_LOOKUP_ADD_DEPENDENCY);
251
  assert (version == NULL || flags == 0 || flags == DL_LOOKUP_ADD_DEPENDENCY);
246
252
247
  size_t i = 0;
253
  if (__builtin_expect (undef_map != NULL, 1) &&
254
      __builtin_expect (undef_map->l_dtneeded.r_nlist != NULL, 0) &&
255
      __builtin_expect (*ref != NULL, 1))
256
    {
257
      unsigned int idx, noffset;
258
      const ElfW(Sym) *symtab;
259
      ElfW(Addr) direct;
260
261
      /* We need a dynsym index ... */
262
      symtab = (const void *) D_PTR (undef_map, l_info[DT_SYMTAB]);
263
      direct = D_PTR (undef_map, l_info[SUSEIDX(DT_SUSE_DIRECT)]);
264
265
      idx = *ref - symtab;
266
      if (__builtin_expect ((GLRO(dl_debug_mask) & DL_DEBUG_DIRECT) != 0, 0))
267
        _dl_debug_printf ("dynamic symbol index %u from '%s' for %s base direct 0x%x start 0x%x\n", idx,
268
			  undef_map->l_name ? undef_map->l_name : "<noname>",
269
			  undef_name ? undef_name : "<undef>",
270
			  (int) direct, (int) undef_map->l_map_start);
271
      direct += idx * 2;
272
      if (direct >= undef_map->l_map_end || direct <= undef_map->l_map_start)
273
        _dl_debug_printf ("broken: off end of map 0x%x\n", (int) direct);
274
      else
275
        {
276
          noffset = *(uint16_t *)direct;
277
	  if (__builtin_expect ((GLRO(dl_debug_mask) & DL_DEBUG_DIRECT) != 0, 0))
278
	    _dl_debug_printf ("dynamic symbol offset %u from 0x%x\n", noffset, (int) direct);
279
	  if (noffset & DT_SUSE_DIRECT_VAGUE)
280
	    {
281
	      if (__builtin_expect ((GLRO(dl_debug_mask) & DL_DEBUG_DIRECT) != 0, 0))
282
	        _dl_debug_printf ("vague symbol\n");
283
	      goto normal_lookup;
284
	    }
285
286
	  noffset &= DT_SUSE_DIRECT_MASK;
287
288
	  if (__builtin_expect (noffset < undef_map->l_dtneeded.r_nlist, 1))
289
	    {
290
	      int res;
291
	      struct r_scope_elem direct_elem;
292
293
	      /* FIXME - requires LD_PRELOAD support ... */
294
	      direct_elem.r_list = undef_map->l_dtneeded.r_list + noffset;
295
	      direct_elem.r_nlist = 1;
296
297
	      if (direct_elem.r_list[0] == skip_map)
298
	        goto normal_lookup; /* FIXME - correct ? */
299
300
	      res = do_lookup_x (undef_name, hash, *ref, &current_value, &direct_elem,
301
				 0, version, flags, skip_map, type_class);
302
	      if (res > 0)
303
	        {
304
		  if (__builtin_expect ((GLRO(dl_debug_mask) & DL_DEBUG_DIRECT) != 0, 0))
305
		    _dl_debug_printf ("direct lookup ...\n");
306
	          goto match;
307
		}
308
	      else
309
		_dl_debug_printf ("Error in lookup %u - missing (?) - fallback "
310
				  "to deps & then global ? ...\n", res);
311
	    }
312
	  else if (noffset == DT_SUSE_DIRECT_UNKNOWN)
313
	    { 
314
	      if (__builtin_expect ((GLRO(dl_debug_mask) & DL_DEBUG_DIRECT) != 0, 0))
315
	        _dl_debug_printf ("unknown/undefined symbol '%s'\n",
316
				  undef_name ? undef_name : "<undef>");
317
	    }
318
	  else
319
	    {
320
	      _dl_debug_printf ("Error: foo symbol '%s' 0 < %u < %u\n",
321
				undef_name ? undef_name : "<undef>",
322
				noffset, undef_map->l_dtneeded.r_nlist);
323
	    }
324
	}
325
    }
326
 normal_lookup:
327
248
  if (__builtin_expect (skip_map != NULL, 0))
328
  if (__builtin_expect (skip_map != NULL, 0))
249
    {
329
    {
250
      /* Search the relevant loaded objects for a definition.  */
330
      /* Search the relevant loaded objects for a definition.  */
Lines 286-292 Link Here
286
	  return 0;
366
	  return 0;
287
	}
367
	}
288
    }
368
    }
289
369
 match:
290
  if (__builtin_expect (current_value.s == NULL, 0))
370
  if (__builtin_expect (current_value.s == NULL, 0))
291
    {
371
    {
292
      if ((*ref == NULL || ELFW(ST_BIND) ((*ref)->st_info) != STB_WEAK)
372
      if ((*ref == NULL || ELFW(ST_BIND) ((*ref)->st_info) != STB_WEAK)
(-)glibc-2.3.6.orig/elf/dl-support.c (+3 lines)
Lines 41-46 Link Here
41
41
42
int _dl_debug_mask;
42
int _dl_debug_mask;
43
int _dl_lazy;
43
int _dl_lazy;
44
int _dl_direct;
44
ElfW(Addr) _dl_use_load_bias = -2;
45
ElfW(Addr) _dl_use_load_bias = -2;
45
int _dl_dynamic_weak;
46
int _dl_dynamic_weak;
46
47
Lines 240-245 Link Here
240
241
241
  _dl_lazy = *(getenv ("LD_BIND_NOW") ?: "") == '\0';
242
  _dl_lazy = *(getenv ("LD_BIND_NOW") ?: "") == '\0';
242
243
244
  _dl_direct = *(getenv ("LD_BIND_DIRECT") ?: "") == '\0';
245
243
  _dl_bind_not = *(getenv ("LD_BIND_NOT") ?: "") != '\0';
246
  _dl_bind_not = *(getenv ("LD_BIND_NOT") ?: "") != '\0';
244
247
245
  _dl_dynamic_weak = *(getenv ("LD_DYNAMIC_WEAK") ?: "") == '\0';
248
  _dl_dynamic_weak = *(getenv ("LD_DYNAMIC_WEAK") ?: "") == '\0';
(-)glibc-2.3.6.orig/elf/elf.h (+5 lines)
Lines 764-769 Link Here
764
#define DF_BIND_NOW	0x00000008	/* No lazy binding for this object */
764
#define DF_BIND_NOW	0x00000008	/* No lazy binding for this object */
765
#define DF_STATIC_TLS	0x00000010	/* Module uses the static TLS model */
765
#define DF_STATIC_TLS	0x00000010	/* Module uses the static TLS model */
766
766
767
/* Constants for the DT_SUSE_DIRECT entries. */
768
#define DT_SUSE_DIRECT_VAGUE   (1<<15)
769
#define DT_SUSE_DIRECT_MASK     0xfff
770
#define DT_SUSE_DIRECT_UNKNOWN  DT_SUSE_DIRECT_MASK
771
767
/* State flags selectable in the `d_un.d_val' element of the DT_FLAGS_1
772
/* State flags selectable in the `d_un.d_val' element of the DT_FLAGS_1
768
   entry in the dynamic section.  */
773
   entry in the dynamic section.  */
769
#define DF_1_NOW	0x00000001	/* Set RTLD_NOW for this object.  */
774
#define DF_1_NOW	0x00000001	/* Set RTLD_NOW for this object.  */
(-)glibc-2.3.6.orig/elf/rtld.c (-1 / +6 lines)
Lines 123-128 Link Here
123
    ._dl_correct_cache_id = _DL_CACHE_DEFAULT_ID,
123
    ._dl_correct_cache_id = _DL_CACHE_DEFAULT_ID,
124
    ._dl_hwcap_mask = HWCAP_IMPORTANT,
124
    ._dl_hwcap_mask = HWCAP_IMPORTANT,
125
    ._dl_lazy = 1,
125
    ._dl_lazy = 1,
126
    ._dl_direct = 0,
126
    ._dl_fpu_control = _FPU_DEFAULT,
127
    ._dl_fpu_control = _FPU_DEFAULT,
127
128
128
    /* Function pointers.  */
129
    /* Function pointers.  */
Lines 2005-2015 Link Here
2005
	DL_DEBUG_SYMBOLS | DL_DEBUG_IMPCALLS },
2006
	DL_DEBUG_SYMBOLS | DL_DEBUG_IMPCALLS },
2006
      { LEN_AND_STR ("bindings"), "display information about symbol binding",
2007
      { LEN_AND_STR ("bindings"), "display information about symbol binding",
2007
	DL_DEBUG_BINDINGS | DL_DEBUG_IMPCALLS },
2008
	DL_DEBUG_BINDINGS | DL_DEBUG_IMPCALLS },
2009
      { LEN_AND_STR ("direct"), "display information about direct binding",
2010
	DL_DEBUG_DIRECT | DL_DEBUG_IMPCALLS },
2008
      { LEN_AND_STR ("versions"), "display version dependencies",
2011
      { LEN_AND_STR ("versions"), "display version dependencies",
2009
	DL_DEBUG_VERSIONS | DL_DEBUG_IMPCALLS },
2012
	DL_DEBUG_VERSIONS | DL_DEBUG_IMPCALLS },
2010
      { LEN_AND_STR ("all"), "all previous options combined",
2013
      { LEN_AND_STR ("all"), "all previous options combined",
2011
	DL_DEBUG_LIBS | DL_DEBUG_RELOC | DL_DEBUG_FILES | DL_DEBUG_SYMBOLS
2014
	DL_DEBUG_LIBS | DL_DEBUG_RELOC | DL_DEBUG_FILES | DL_DEBUG_SYMBOLS
2012
	| DL_DEBUG_BINDINGS | DL_DEBUG_VERSIONS | DL_DEBUG_IMPCALLS },
2015
	| DL_DEBUG_BINDINGS | DL_DEBUG_DIRECT | DL_DEBUG_VERSIONS | DL_DEBUG_IMPCALLS },
2013
      { LEN_AND_STR ("statistics"), "display relocation statistics",
2016
      { LEN_AND_STR ("statistics"), "display relocation statistics",
2014
	DL_DEBUG_STATISTICS },
2017
	DL_DEBUG_STATISTICS },
2015
      { LEN_AND_STR ("unused"), "determined unused DSOs",
2018
      { LEN_AND_STR ("unused"), "determined unused DSOs",
Lines 2171-2176 Link Here
2171
	  if (!INTUSE(__libc_enable_secure)
2174
	  if (!INTUSE(__libc_enable_secure)
2172
	      && memcmp (envline, "ORIGIN_PATH", 11) == 0)
2175
	      && memcmp (envline, "ORIGIN_PATH", 11) == 0)
2173
	    GLRO(dl_origin_path) = &envline[12];
2176
	    GLRO(dl_origin_path) = &envline[12];
2177
	  if (memcmp (envline, "BIND_DIRECT", 11) == 0)
2178
	    GLRO(dl_direct) = envline[12] != '\0';
2174
	  break;
2179
	  break;
2175
2180
2176
	case 12:
2181
	case 12:
(-)glibc-2.3.6.orig/include/link.h (+3 lines)
Lines 299-304 Link Here
299
       done.  */
299
       done.  */
300
    ElfW(Addr) l_relro_addr;
300
    ElfW(Addr) l_relro_addr;
301
    size_t l_relro_size;
301
    size_t l_relro_size;
302
    /* Array of DT_NEEDED dependencies in order for use in
303
    direct linkage - l_dtneeded[0] entry is self  */
304
    struct r_scope_elem l_dtneeded;
302
  };
305
  };
303
306
304
struct dl_phdr_info
307
struct dl_phdr_info
(-)glibc-2.3.6.orig/sysdeps/generic/ldsodefs.h (+4 lines)
Lines 388-393 Link Here
388
/* These two are used only internally.  */
388
/* These two are used only internally.  */
389
#define DL_DEBUG_HELP       (1 << 9)
389
#define DL_DEBUG_HELP       (1 << 9)
390
#define DL_DEBUG_PRELINK    (1 << 10)
390
#define DL_DEBUG_PRELINK    (1 << 10)
391
#define DL_DEBUG_DIRECT     (1 << 11)
391
392
392
  /* Cached value of `getpagesize ()'.  */
393
  /* Cached value of `getpagesize ()'.  */
393
  EXTERN size_t _dl_pagesize;
394
  EXTERN size_t _dl_pagesize;
Lines 413-418 Link Here
413
  /* Do we do lazy relocations?  */
414
  /* Do we do lazy relocations?  */
414
  EXTERN int _dl_lazy;
415
  EXTERN int _dl_lazy;
415
416
417
  /* Do we do direct relocations?  */
418
  EXTERN int _dl_direct;
419
416
  /* Nonzero if runtime lookups should not update the .got/.plt.  */
420
  /* Nonzero if runtime lookups should not update the .got/.plt.  */
417
  EXTERN int _dl_bind_not;
421
  EXTERN int _dl_bind_not;
418
422

Return to bug 114008