PAGE_SIZE was hardcoded to 4096, which is historically what most
systems use, but on several archs it is a kernel config parameter,
user space can only know it at execution time from the aux vector.
PAGE_SIZE and PAGESIZE are not defined on archs where page size is
a runtime parameter, applications should use sysconf(_SC_PAGE_SIZE)
to query it. Internally libc code defines PAGE_SIZE to libc.page_size,
which is set to aux[AT_PAGESZ] in __init_libc and early in __dynlink
as well. (Note that libc.page_size can be accessed without GOT, ie.
before relocations are done)
Some fpathconf settings are hardcoded to 4096, these should be actually
queried from the filesystem using statfs.
19 files changed:
#if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \
|| defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
#if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \
|| defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
#define LONG_BIT 32
#endif
#define LONG_BIT 32
#endif
for (a+=c+1; *a; a++);
for (a++; *a; a+=2) if (*a<20) t[*a] = a[1];
base = (char *)t[AT_BASE];
for (a+=c+1; *a; a++);
for (a++; *a; a+=2) if (*a<20) t[*a] = a[1];
base = (char *)t[AT_BASE];
- if (!base) base = (char *)(t[AT_PHDR] & -4096);
+ if (!base) base = (char *)(t[AT_PHDR] & -t[AT_PAGESZ]);
for (a=dynv; *a; a+=2) if (*a<20) t[*a] = a[1];
n = t[DT_RELASZ];
for (a=(void *)(base+t[DT_RELA]); n; a+=3, n-=12)
for (a=dynv; *a; a+=2) if (*a<20) t[*a] = a[1];
n = t[DT_RELASZ];
for (a=(void *)(base+t[DT_RELA]); n; a+=3, n-=12)
#if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \
|| defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
#if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \
|| defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
#define LONG_BIT 32
#endif
#define LONG_BIT 32
#endif
for (a+=c+1; *a; a++);
for (a++; *a; a+=2) if (*a<20) t[*a] = a[1];
base = (char *)t[AT_BASE];
for (a+=c+1; *a; a++);
for (a++; *a; a+=2) if (*a<20) t[*a] = a[1];
base = (char *)t[AT_BASE];
- if (!base) base = (char *)(t[AT_PHDR] & -4096);
+ if (!base) base = (char *)(t[AT_PHDR] & -t[AT_PAGESZ]);
for (a=dynv; *a; a+=2) if (*a-0x70000000UL<20) t[*a&31] = a[1];
n = t[DT_MIPS_LOCAL_GOTNO - 0x70000000];
for (a=got; n; a++, n--) *a += (size_t)base;
for (a=dynv; *a; a+=2) if (*a-0x70000000UL<20) t[*a&31] = a[1];
n = t[DT_MIPS_LOCAL_GOTNO - 0x70000000];
for (a=got; n; a++, n--) *a += (size_t)base;
#if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \
|| defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
#if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \
|| defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
#define LONG_BIT 32
#endif
#define LONG_BIT 32
#endif
for (a+=c+1; *a; a++);
for (a++; *a; a+=2) if (*a<20) t[*a] = a[1];
base = (char *)t[AT_BASE];
for (a+=c+1; *a; a++);
for (a++; *a; a+=2) if (*a<20) t[*a] = a[1];
base = (char *)t[AT_BASE];
- if (!base) base = (char *)(t[AT_PHDR] & -4096);
+ if (!base) base = (char *)(t[AT_PHDR] & -t[AT_PAGESZ]);
for (a=dynv; *a; a+=2) if (*a<20) t[*a] = a[1];
n = t[DT_RELASZ];
for (a=(void *)(base+t[DT_RELA]); n; a+=3, n-=12)
for (a=dynv; *a; a+=2) if (*a<20) t[*a] = a[1];
n = t[DT_RELASZ];
for (a=(void *)(base+t[DT_RELA]); n; a+=3, n-=12)
|| defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
#define PIPE_BUF 4096
|| defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
#define PIPE_BUF 4096
#define PAGESIZE PAGE_SIZE
#define PAGESIZE PAGE_SIZE
#define FILESIZEBITS 64
#define NAME_MAX 255
#define SYMLINK_MAX 255
#define FILESIZEBITS 64
#define NAME_MAX 255
#define SYMLINK_MAX 255
#include <fcntl.h>
#include <errno.h>
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
#include <unistd.h>
#include "pthread_impl.h"
#include "pthread_impl.h"
static void dummy(void)
{
static void dummy(void)
{
#include <aio.h>
#include <errno.h>
#include <aio.h>
#include <errno.h>
#include <unistd.h>
#include <string.h>
#include "pthread_impl.h"
#include <unistd.h>
#include <string.h>
#include "pthread_impl.h"
struct lio_state {
struct sigevent *sev;
struct lio_state {
struct sigevent *sev;
[_PC_PRIO_IO] = -1,
[_PC_SOCK_MAXBUF] = -1,
[_PC_FILESIZEBITS] = FILESIZEBITS,
[_PC_PRIO_IO] = -1,
[_PC_SOCK_MAXBUF] = -1,
[_PC_FILESIZEBITS] = FILESIZEBITS,
- [_PC_REC_INCR_XFER_SIZE] = PAGE_SIZE,
- [_PC_REC_MAX_XFER_SIZE] = PAGE_SIZE,
- [_PC_REC_MIN_XFER_SIZE] = PAGE_SIZE,
- [_PC_REC_XFER_ALIGN] = PAGE_SIZE,
- [_PC_ALLOC_SIZE_MIN] = PAGE_SIZE,
+ [_PC_REC_INCR_XFER_SIZE] = 4096,
+ [_PC_REC_MAX_XFER_SIZE] = 4096,
+ [_PC_REC_MIN_XFER_SIZE] = 4096,
+ [_PC_REC_XFER_ALIGN] = 4096,
+ [_PC_ALLOC_SIZE_MIN] = 4096,
[_PC_SYMLINK_MAX] = SYMLINK_MAX,
[_PC_2_SYMLINKS] = 1
};
[_PC_SYMLINK_MAX] = SYMLINK_MAX,
[_PC_2_SYMLINKS] = 1
};
#include <errno.h>
#include <sys/resource.h>
#include "syscall.h"
#include <errno.h>
#include <sys/resource.h>
#include "syscall.h"
#define VER (-2)
#define OFLOW (-3)
#define VER (-2)
#define OFLOW (-3)
[_SC_MQ_OPEN_MAX] = -1,
[_SC_MQ_PRIO_MAX] = OFLOW,
[_SC_VERSION] = VER,
[_SC_MQ_OPEN_MAX] = -1,
[_SC_MQ_PRIO_MAX] = OFLOW,
[_SC_VERSION] = VER,
- [_SC_PAGE_SIZE] = PAGE_SIZE,
+ [_SC_PAGE_SIZE] = OFLOW,
[_SC_RTSIG_MAX] = 63, /* ?? */
[_SC_SEM_NSEMS_MAX] = SEM_NSEMS_MAX,
[_SC_SEM_VALUE_MAX] = OFLOW,
[_SC_RTSIG_MAX] = 63, /* ?? */
[_SC_SEM_NSEMS_MAX] = SEM_NSEMS_MAX,
[_SC_SEM_VALUE_MAX] = OFLOW,
if (name == _SC_ARG_MAX) return ARG_MAX;
if (name == _SC_SEM_VALUE_MAX) return SEM_VALUE_MAX;
if (name == _SC_MQ_PRIO_MAX) return MQ_PRIO_MAX;
if (name == _SC_ARG_MAX) return ARG_MAX;
if (name == _SC_SEM_VALUE_MAX) return SEM_VALUE_MAX;
if (name == _SC_MQ_PRIO_MAX) return MQ_PRIO_MAX;
+ /* name == _SC_PAGE_SIZE */
+ return PAGE_SIZE;
} else if (values[name] == CPUCNT) {
unsigned char set[128] = {1};
int i, cnt;
} else if (values[name] == CPUCNT) {
unsigned char set[128] = {1};
int i, cnt;
for (i=0; auxv[i]; i+=2) if (auxv[i]<AUX_CNT) aux[auxv[i]] = auxv[i+1];
__hwcap = aux[AT_HWCAP];
__sysinfo = aux[AT_SYSINFO];
for (i=0; auxv[i]; i+=2) if (auxv[i]<AUX_CNT) aux[auxv[i]] = auxv[i+1];
__hwcap = aux[AT_HWCAP];
__sysinfo = aux[AT_SYSINFO];
+ libc.page_size = aux[AT_PAGESZ];
if (pn) {
__progname = __progname_full = pn;
if (pn) {
__progname = __progname_full = pn;
#include <stdlib.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdio.h>
struct __libc {
void *main_thread;
struct __libc {
void *main_thread;
FILE *ofl_head;
int ofl_lock[2];
size_t tls_size;
FILE *ofl_head;
int ofl_lock[2];
size_t tls_size;
};
extern size_t __hwcap;
};
extern size_t __hwcap;
+#ifndef PAGE_SIZE
+#define PAGE_SIZE libc.page_size
+#endif
+
#if !defined(__PIC__) || (100*__GNUC__+__GNUC_MINOR__ >= 303 && !defined(__PCC__))
#ifdef __PIC__
#if !defined(__PIC__) || (100*__GNUC__+__GNUC_MINOR__ >= 303 && !defined(__PCC__))
#ifdef __PIC__
env_preload = 0;
libc.secure = 1;
}
env_preload = 0;
libc.secure = 1;
}
+ libc.page_size = aux[AT_PAGESZ];
/* If the dynamic linker was invoked as a program itself, AT_BASE
* will not be set. In that case, we assume the base address is
/* If the dynamic linker was invoked as a program itself, AT_BASE
* will not be set. In that case, we assume the base address is
#define _BSD_SOURCE
#include <stdlib.h>
#define _BSD_SOURCE
#include <stdlib.h>
void *valloc(size_t size)
{
void *valloc(size_t size)
{
#include "syscall.h"
int mprotect(void *addr, size_t len, int prot)
#include "syscall.h"
int mprotect(void *addr, size_t len, int prot)
#include "pthread_impl.h"
#include "stdio_impl.h"
#include "pthread_impl.h"
#include "stdio_impl.h"
#include <sys/mman.h>
static void dummy_0()
#include <sys/mman.h>
static void dummy_0()
#define _GNU_SOURCE
#include "pthread_impl.h"
#define _GNU_SOURCE
#include "pthread_impl.h"
#include <sys/mman.h>
int pthread_getattr_np(pthread_t t, pthread_attr_t *a)
#include <sys/mman.h>
int pthread_getattr_np(pthread_t t, pthread_attr_t *a)