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

Collapse All | Expand All

(-)file_not_specified_in_diff (-10 / +115 lines)
Line  Link Here
0
-- csu/libc-start.c
0
++ csu/libc-start.c
Lines 28-33 Link Here
28
extern int __libc_multiple_libcs;
28
extern int __libc_multiple_libcs;
29
29
30
#include <tls.h>
30
#include <tls.h>
31
#include <sysdep.h>
31
#ifndef SHARED
32
#ifndef SHARED
32
# include <dl-osinfo.h>
33
# include <dl-osinfo.h>
33
extern void __pthread_initialize_minimal (void);
34
extern void __pthread_initialize_minimal (void);
Lines 129-134 Link Here
129
#  endif
130
#  endif
130
  _dl_aux_init (auxvec);
131
  _dl_aux_init (auxvec);
131
# endif
132
# endif
133
# ifdef INTERNAL_SYSCALL_NOSYSENTER
134
  /* Do the initial TLS initialization before _dl_osversion,
135
     since the latter uses the uname syscall.  */
136
  __pthread_initialize_minimal ();
137
# endif
132
# ifdef DL_SYSDEP_OSCHECK
138
# ifdef DL_SYSDEP_OSCHECK
133
  if (!__libc_multiple_libcs)
139
  if (!__libc_multiple_libcs)
134
    {
140
    {
Lines 138-147 Link Here
138
    }
144
    }
139
# endif
145
# endif
140
146
147
# ifndef INTERNAL_SYSCALL_NOSYSENTER
141
  /* Initialize the thread library at least a bit since the libgcc
148
  /* Initialize the thread library at least a bit since the libgcc
142
     functions are using thread functions if these are available and
149
     functions are using thread functions if these are available and
143
     we need to setup errno.  */
150
     we need to setup errno.  */
144
  __pthread_initialize_minimal ();
151
  __pthread_initialize_minimal ();
152
# endif
145
153
146
  /* Set up the stack checker's canary.  */
154
  /* Set up the stack checker's canary.  */
147
  uintptr_t stack_chk_guard = _dl_setup_stack_chk_guard ();
155
  uintptr_t stack_chk_guard = _dl_setup_stack_chk_guard ();
148
-- csu/libc-tls.c
156
++ csu/libc-tls.c
Lines 23-28 Link Here
23
#include <unistd.h>
23
#include <unistd.h>
24
#include <stdio.h>
24
#include <stdio.h>
25
#include <sys/param.h>
25
#include <sys/param.h>
26
#include <sysdep.h>
26
27
27
28
28
#ifdef SHARED
29
#ifdef SHARED
Lines 29-34 Link Here
29
 #error makefile bug, this file is for static only
30
 #error makefile bug, this file is for static only
30
#endif
31
#endif
31
32
33
#ifdef INTERNAL_SYSCALL_NOSYSENTER
34
extern void *__sbrk_nosysenter (intptr_t __delta);
35
#endif
32
extern ElfW(Phdr) *_dl_phdr;
36
extern ElfW(Phdr) *_dl_phdr;
33
extern size_t _dl_phnum;
37
extern size_t _dl_phnum;
34
38
Lines 141-154 Link Here
141
145
142
     The initialized value of _dl_tls_static_size is provided by dl-open.c
146
     The initialized value of _dl_tls_static_size is provided by dl-open.c
143
     to request some surplus that permits dynamic loading of modules with
147
     to request some surplus that permits dynamic loading of modules with
144
     IE-model TLS.  */
148
     IE-model TLS.
149
     
150
     Where the normal sbrk would use a syscall that needs the TLS (i386)
151
     use the special non-sysenter version instead.  */
145
#if TLS_TCB_AT_TP
152
#if TLS_TCB_AT_TP
146
  tcb_offset = roundup (memsz + GL(dl_tls_static_size), tcbalign);
153
  tcb_offset = roundup (memsz + GL(dl_tls_static_size), tcbalign);
154
# ifdef INTERNAL_SYSCALL_NOSYSENTER
155
  tlsblock = __sbrk_nosysenter (tcb_offset + tcbsize + max_align);
156
# else
147
  tlsblock = __sbrk (tcb_offset + tcbsize + max_align);
157
  tlsblock = __sbrk (tcb_offset + tcbsize + max_align);
158
# endif
148
#elif TLS_DTV_AT_TP
159
#elif TLS_DTV_AT_TP
149
  tcb_offset = roundup (tcbsize, align ?: 1);
160
  tcb_offset = roundup (tcbsize, align ?: 1);
161
# ifdef INTERNAL_SYSCALL_NOSYSENTER
162
  tlsblock = __sbrk_nosysenter (tcb_offset + memsz + max_align
163
		     + TLS_PRE_TCB_SIZE + GL(dl_tls_static_size));
164
# else
150
  tlsblock = __sbrk (tcb_offset + memsz + max_align
165
  tlsblock = __sbrk (tcb_offset + memsz + max_align
151
		     + TLS_PRE_TCB_SIZE + GL(dl_tls_static_size));
166
		     + TLS_PRE_TCB_SIZE + GL(dl_tls_static_size));
167
# endif
152
  tlsblock += TLS_PRE_TCB_SIZE;
168
  tlsblock += TLS_PRE_TCB_SIZE;
153
#else
169
#else
154
  /* In case a model with a different layout for the TCB and DTV
170
  /* In case a model with a different layout for the TCB and DTV
155
-- misc/sbrk.c
171
++ misc/sbrk.c
Lines 18-23 Link Here
18
#include <errno.h>
18
#include <errno.h>
19
#include <stdint.h>
19
#include <stdint.h>
20
#include <unistd.h>
20
#include <unistd.h>
21
#include <sysdep.h>
21
22
22
/* Defined in brk.c.  */
23
/* Defined in brk.c.  */
23
extern void *__curbrk;
24
extern void *__curbrk;
Lines 29-34 Link Here
29
/* Extend the process's data space by INCREMENT.
30
/* Extend the process's data space by INCREMENT.
30
   If INCREMENT is negative, shrink data space by - INCREMENT.
31
   If INCREMENT is negative, shrink data space by - INCREMENT.
31
   Return start of new space allocated, or -1 for errors.  */
32
   Return start of new space allocated, or -1 for errors.  */
33
#ifdef INTERNAL_SYSCALL_NOSYSENTER
34
/* This version is used by csu/libc-tls.c whem initialising the TLS
35
   if the SYSENTER version requires the TLS (which it does on i386).
36
   Obviously using the TLS before it is initialised is broken. */
37
extern int __brk_nosysenter (void *addr);
38
void *
39
__sbrk_nosysenter (intptr_t increment)
40
{
41
  void *oldbrk;
42
43
  /* If this is not part of the dynamic library or the library is used
44
     via dynamic loading in a statically linked program update
45
     __curbrk from the kernel's brk value.  That way two separate
46
     instances of __brk and __sbrk can share the heap, returning
47
     interleaved pieces of it.  */
48
  if (__curbrk == NULL || __libc_multiple_libcs)
49
    if (__brk_nosysenter (0) < 0)		/* Initialize the break.  */
50
      return (void *) -1;
51
52
  if (increment == 0)
53
    return __curbrk;
54
55
  oldbrk = __curbrk;
56
  if (__brk_nosysenter (oldbrk + increment) < 0)
57
    return (void *) -1;
58
59
  return oldbrk;
60
}
61
#endif
32
void *
62
void *
33
__sbrk (intptr_t increment)
63
__sbrk (intptr_t increment)
34
{
64
{
35
-- sysdeps/unix/sysv/linux/i386/brk.c
65
++ sysdeps/unix/sysv/linux/i386/brk.c
Lines 31-36 Link Here
31
   linker.  */
31
   linker.  */
32
weak_alias (__curbrk, ___brk_addr)
32
weak_alias (__curbrk, ___brk_addr)
33
33
34
#ifdef INTERNAL_SYSCALL_NOSYSENTER
35
/* This version is used by csu/libc-tls.c whem initialising the TLS
36
 * if the SYSENTER version requires the TLS (which it does on i386).
37
 * Obviously using the TLS before it is initialised is broken. */
38
int
39
__brk_nosysenter (void *addr)
40
{
41
  void *__unbounded newbrk;
42
43
  INTERNAL_SYSCALL_DECL (err);
44
  newbrk = (void *__unbounded) INTERNAL_SYSCALL_NOSYSENTER (brk, err, 1,
45
						 __ptrvalue (addr));
46
47
  __curbrk = newbrk;
48
49
  if (newbrk < addr)
50
    {
51
      __set_errno (ENOMEM);
52
      return -1;
53
    }
54
55
  return 0;
56
}
57
#endif
34
int
58
int
35
__brk (void *addr)
59
__brk (void *addr)
36
{
60
{
37
-- sysdeps/unix/sysv/linux/i386/sysdep.h
61
++ sysdeps/unix/sysv/linux/i386/sysdep.h
Lines 187-193 Link Here
187
/* The original calling convention for system calls on Linux/i386 is
187
/* The original calling convention for system calls on Linux/i386 is
188
   to use int $0x80.  */
188
   to use int $0x80.  */
189
#ifdef I386_USE_SYSENTER
189
#ifdef I386_USE_SYSENTER
190
# ifdef SHARED
190
# if defined SHARED || defined __PIC__
191
#  define ENTER_KERNEL call *%gs:SYSINFO_OFFSET
191
#  define ENTER_KERNEL call *%gs:SYSINFO_OFFSET
192
# else
192
# else
193
#  define ENTER_KERNEL call *_dl_sysinfo
193
#  define ENTER_KERNEL call *_dl_sysinfo
Lines 358-364 Link Here
358
   possible to use more than four parameters.  */
358
   possible to use more than four parameters.  */
359
#undef INTERNAL_SYSCALL
359
#undef INTERNAL_SYSCALL
360
#ifdef I386_USE_SYSENTER
360
#ifdef I386_USE_SYSENTER
361
# ifdef SHARED
361
# if defined SHARED || defined __PIC__
362
#  define INTERNAL_SYSCALL(name, err, nr, args...) \
362
#  define INTERNAL_SYSCALL(name, err, nr, args...) \
363
  ({									      \
363
  ({									      \
364
    register unsigned int resultvar;					      \
364
    register unsigned int resultvar;					      \
Lines 384-389 Link Here
384
    : "0" (name), "i" (offsetof (tcbhead_t, sysinfo))			      \
384
    : "0" (name), "i" (offsetof (tcbhead_t, sysinfo))			      \
385
      ASMFMT_##nr(args) : "memory", "cc");				      \
385
      ASMFMT_##nr(args) : "memory", "cc");				      \
386
    (int) resultvar; })
386
    (int) resultvar; })
387
#  define INTERNAL_SYSCALL_NOSYSENTER(name, err, nr, args...) \
388
  ({									      \
389
    register unsigned int resultvar;					      \
390
    EXTRAVAR_##nr							      \
391
    asm volatile (							      \
392
    LOADARGS_NOSYSENTER_##nr						      \
393
    "movl %1, %%eax\n\t"						      \
394
    "int $0x80\n\t"							      \
395
    RESTOREARGS_NOSYSENTER_##nr						      \
396
    : "=a" (resultvar)							      \
397
    : "i" (__NR_##name) ASMFMT_##nr(args) : "memory", "cc");		      \
398
    (int) resultvar; })
387
# else
399
# else
388
#  define INTERNAL_SYSCALL(name, err, nr, args...) \
400
#  define INTERNAL_SYSCALL(name, err, nr, args...) \
389
  ({									      \
401
  ({									      \
Lines 447-458 Link Here
447
459
448
#define LOADARGS_0
460
#define LOADARGS_0
449
#ifdef __PIC__
461
#ifdef __PIC__
450
# if defined I386_USE_SYSENTER && defined SHARED
462
# if defined I386_USE_SYSENTER && ( defined SHARED || defined __PIC__ )
451
#  define LOADARGS_1 \
463
#  define LOADARGS_1 \
452
    "bpushl .L__X'%k3, %k3\n\t"
464
    "bpushl .L__X'%k3, %k3\n\t"
453
#  define LOADARGS_5 \
465
#  define LOADARGS_5 \
454
    "movl %%ebx, %4\n\t"						      \
466
    "movl %%ebx, %4\n\t"						      \
455
    "movl %3, %%ebx\n\t"
467
    "movl %3, %%ebx\n\t"
468
#  define LOADARGS_NOSYSENTER_1 \
469
    "bpushl .L__X'%k2, %k2\n\t"
470
#  define LOADARGS_NOSYSENTER_2	LOADARGS_NOSYSENTER_1
471
#  define LOADARGS_NOSYSENTER_3	LOADARGS_3
472
#  define LOADARGS_NOSYSENTER_4	LOADARGS_3
473
#  define LOADARGS_NOSYSENTER_5 \
474
    "movl %%ebx, %3\n\t"						      \
475
    "movl %2, %%ebx\n\t"
456
# else
476
# else
457
#  define LOADARGS_1 \
477
#  define LOADARGS_1 \
458
    "bpushl .L__X'%k2, %k2\n\t"
478
    "bpushl .L__X'%k2, %k2\n\t"
Lines 474-484 Link Here
474
495
475
#define RESTOREARGS_0
496
#define RESTOREARGS_0
476
#ifdef __PIC__
497
#ifdef __PIC__
477
# if defined I386_USE_SYSENTER && defined SHARED
498
# if defined I386_USE_SYSENTER && ( defined SHARED || defined __PIC__ )
478
#  define RESTOREARGS_1 \
499
#  define RESTOREARGS_1 \
479
    "bpopl .L__X'%k3, %k3\n\t"
500
    "bpopl .L__X'%k3, %k3\n\t"
480
#  define RESTOREARGS_5 \
501
#  define RESTOREARGS_5 \
481
    "movl %4, %%ebx"
502
    "movl %4, %%ebx"
503
#  define RESTOREARGS_NOSYSENTER_1 \
504
    "bpopl .L__X'%k2, %k2\n\t"
505
#  define RESTOREARGS_NOSYSENTER_2	RESTOREARGS_NOSYSENTER_1
506
#  define RESTOREARGS_NOSYSENTER_3	RESTOREARGS_3
507
#  define RESTOREARGS_NOSYSENTER_4	RESTOREARGS_3
508
#  define RESTOREARGS_NOSYSENTER_5 \
509
    "movl %3, %%ebx"
482
# else
510
# else
483
#  define RESTOREARGS_1 \
511
#  define RESTOREARGS_1 \
484
    "bpopl .L__X'%k2, %k2\n\t"
512
    "bpopl .L__X'%k2, %k2\n\t"

Return to bug 270274