This repository has been archived by the owner on Sep 5, 2023. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This patch adds support for dynamic PAGE_SIZE values. It is a little bit invasive in several aspects: * it modifies the startup code. We need to know the position of the elf-info auxilary table which is located after 'environ'. We can not use 'environ' directly because it might be modified by the application. Hence, an additional __elfinfo variable is placed into .bss and filled in the startup code. Depending on platform, this adds 4-8 instructions and an additional pointer to .bss. I tested only the i386 and x86_64 modifications; it would be nice when people with corresponding hardware would test the other ones. I am especially uncertain regarding the parisc changes. The elf-info stuff (which might be interesting e.g. for dynamic linking or sysconf(_SC_CLK_TCK)) can be enabled without the dynamic pagesize too. * it removes the 'PAGE_SIZE' macro from <sys/shm.h>; this will break compilation of existing userspace application which are using this deprecated macro * I added a new internal 'dietpagesize.h' header which defines | __DIET_PAGE_SIZE | __DIET_PAGE_SHIFT macros. These return either builtin constants (when WANT_DYN_PAGESIZE is not selected), or values derived from __libc_getpagesize(). Every usage of PAGE_SIZE in dietlibc code was replaced by these macros. * due to the previous point, the internal 'struct __dirstream' was modified. I replaced | getdents64(d->fd,(struct dirent64*)d->buf, sizeof (d->buf)-1); with | getdents64(d->fd,(struct dirent64*)d->buf, __DIRSTREAM_BUF_SIZE-1); literally but I am not sure where the '-1' is coming from. There is one hunk, where this '-1' is missing so I think the '-1' should be removed from all calls to getdents64(). * changes affect the *alloc() functions too; on x86_64 around 64 bytes were added to .text of alloc.o * the new testprogramm requires a 'getconf' binary which returns the correct values for PAGE_SIZE and CLK_TCK Patch seems to work fine on i386, x86_64, ppc and ppc64. Things went a little bit complicated with linux 2.6.25; previous kernels exported a elf_addr_t type in <linux/elf.h> which is used in the auxilary elf-info table. Now, this is not available anymore and I use a type derived from __WORD_SIZE.
- Loading branch information
Showing
36 changed files
with
432 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#include "dietfeatures.h" | ||
|
||
#ifdef WANT_ELFINFO | ||
#include <elf.h> | ||
#include <endian.h> | ||
#include <stdint.h> | ||
|
||
/* TODO: exported interface from <linux/elf.h> has been changed in 2.6.25 so | ||
* the 'elf_addr_t' type is not available anymore. Hence, derive it from | ||
* __WORDSIZE__. */ | ||
|
||
#if __WORDSIZE == 64 | ||
typedef uint64_t __diet_elf_addr_t; | ||
#elif __WORDSIZE == 32 | ||
typedef uint32_t __diet_elf_addr_t; | ||
#endif | ||
|
||
__diet_elf_addr_t const * __get_elf_aux_value(unsigned int tag) | ||
__attribute__((__visibility__("hidden"),__const__)) __pure; | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#ifndef H_DIETLIBC_DIETPAGESIZE_H | ||
#define H_DIETLIBC_DIETPAGESIZE_H | ||
|
||
#include <strings.h> | ||
#include "dietfeatures.h" | ||
|
||
extern size_t __libc_getpagesize(void) __attribute__((__const__)) __pure; | ||
|
||
#if defined(WANT_STATIC_PAGESIZE) | ||
# define __DIET_PAGE_SIZE_PREDEF (WANT_STATIC_PAGESIZE) | ||
# define __DIET_PAGE_SHIFT_PREDEF (ffs(__DIET_PAGE_SIZE_PREDEF)-1) | ||
#elif defined(__alpha__) || defined(__sparc__) | ||
# define __DIET_PAGE_SIZE_PREDEF (8192UL) | ||
# define __DIET_PAGE_SHIFT_PREDEF (13) | ||
#elif defined(__powerpc64__) | ||
# define __DIET_PAGE_SIZE_PREDEF (65536UL) | ||
# define __DIET_PAGE_SHIFT_PREDEF (16) | ||
#else | ||
# define __DIET_PAGE_SIZE_PREDEF (4096UL) | ||
# define __DIET_PAGE_SHIFT_PREDEF (12) | ||
#endif | ||
|
||
#ifdef WANT_DYN_PAGESIZE | ||
# define __DIET_PAGE_SIZE (__libc_getpagesize()) | ||
# define __DIET_PAGE_SHIFT (ffs(__DIET_PAGE_SIZE)-1) | ||
#else | ||
# define __DIET_PAGE_SIZE __DIET_PAGE_SIZE_PREDEF | ||
# define __DIET_PAGE_SHIFT __DIET_PAGE_SHIFT_PREDEF | ||
#endif | ||
|
||
#endif /* H_DIETLIBC_DIETPAGESIZE_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#include "dietfeatures.h" | ||
|
||
#ifdef WANT_ELFINFO | ||
#include <stdlib.h> | ||
#include "../dietelfinfo.h" | ||
|
||
__diet_elf_addr_t const *__get_elf_aux_value(unsigned int tag) | ||
{ | ||
extern __diet_elf_addr_t const * const __elfinfo; | ||
__diet_elf_addr_t const *aux_ptr; | ||
|
||
for (aux_ptr = __elfinfo; aux_ptr[0]!=AT_NULL; aux_ptr += 2) | ||
if (aux_ptr[0]==tag) | ||
return aux_ptr+1; | ||
|
||
return NULL; | ||
} | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.