diff options
author | Waldemar Brodkorb <wbx@openadk.org> | 2011-04-27 10:27:09 +0200 |
---|---|---|
committer | Waldemar Brodkorb <wbx@openadk.org> | 2011-04-27 10:27:09 +0200 |
commit | 63c6929d36e5b5802c0983932a3d69e23f330bb5 (patch) | |
tree | 57de1bd67fa01fb35ced66d8907fd926c66adfe5 /toolchain/uClibc | |
parent | c4ef12b64426763670dcae46219b766ba2f490cd (diff) |
fix allconfig for foxg20
Diffstat (limited to 'toolchain/uClibc')
-rw-r--r-- | toolchain/uClibc/patches/cris-vfork.patch | 49 | ||||
-rw-r--r-- | toolchain/uClibc/patches/uClibc-26042011-git.patch | 2506 |
2 files changed, 2506 insertions, 49 deletions
diff --git a/toolchain/uClibc/patches/cris-vfork.patch b/toolchain/uClibc/patches/cris-vfork.patch deleted file mode 100644 index 8e0faa2f3..000000000 --- a/toolchain/uClibc/patches/cris-vfork.patch +++ /dev/null @@ -1,49 +0,0 @@ -diff -Nur uClibc-0.9.32-rc2.orig/libc/sysdeps/linux/cris/Makefile.arch uClibc-0.9.32-rc2/libc/sysdeps/linux/cris/Makefile.arch ---- uClibc-0.9.32-rc2.orig/libc/sysdeps/linux/cris/Makefile.arch 2011-01-20 15:49:47.000000000 +0100 -+++ uClibc-0.9.32-rc2/libc/sysdeps/linux/cris/Makefile.arch 2011-02-07 23:01:26.000000000 +0100 -@@ -7,7 +7,7 @@ - - CSRC := __init_brk.c brk.c sbrk.c - --SSRC := setjmp.S __longjmp.S clone.S sysdep.S syscall.S -+SSRC := setjmp.S __longjmp.S clone.S sysdep.S syscall.S vfork.S - ifeq ($(UNIFIED_SYSCALL),y) - SSRC += __uClibc_syscall.S - endif -diff -Nur uClibc-0.9.32-rc2.orig/libc/sysdeps/linux/cris/vfork.S uClibc-0.9.32-rc2/libc/sysdeps/linux/cris/vfork.S ---- uClibc-0.9.32-rc2.orig/libc/sysdeps/linux/cris/vfork.S 1970-01-01 01:00:00.000000000 +0100 -+++ uClibc-0.9.32-rc2/libc/sysdeps/linux/cris/vfork.S 2011-02-08 00:39:10.000000000 +0100 -@@ -0,0 +1,33 @@ -+/* -+ * vfork.S -+ * -+ * On cris, r9 contains the syscall number (set by generated stub); -+ * r10..r13 contain arguments 0-3 per the standard calling convention. -+ * The return address is in $srp; so we just need to avoid the stack -+ * usage of the normal syscall stubs. -+ */ -+ -+#include <asm/unistd.h> -+#include <sys/syscall.h> -+ -+ .section ".text","ax" -+ .balign 4 -+ .globl __vfork -+ .type __vfork,@function -+__vfork: -+ move.d __NR_vfork, $r9 -+ break 13 -+ -+ cmps.w -4096,$r10 -+ blo 1f -+ neg.d $r10,$r11 -+ move.d $r11,[errno] -+ moveq -1,$r10 -+1: -+ ret -+ nop -+ -+ .size __vfork,.-__vfork -+ -+weak_alias(__vfork,vfork) -+libc_hidden_weak(vfork) diff --git a/toolchain/uClibc/patches/uClibc-26042011-git.patch b/toolchain/uClibc/patches/uClibc-26042011-git.patch new file mode 100644 index 000000000..bbf4d06f0 --- /dev/null +++ b/toolchain/uClibc/patches/uClibc-26042011-git.patch @@ -0,0 +1,2506 @@ +diff -Nur uClibc-0.9.32-rc3/extra/Configs/Config.in uClibc/extra/Configs/Config.in +--- uClibc-0.9.32-rc3/extra/Configs/Config.in 2011-03-16 20:11:13.000000000 +0100 ++++ uClibc/extra/Configs/Config.in 2011-04-26 16:18:21.707661578 +0200 +@@ -1898,6 +1898,18 @@ + This interface is rarely used, and adds around 4.5k. Unless you have + a pressing need for ftw(), you should probably answer N. + ++config UCLIBC_HAS_FTS ++ bool "Support the fts() interface (bsd-compat)" ++ default n ++ help ++ The fts functions are provided for traversing UNIX file hierarchies. ++ ++ This interface is currently used by the elfutils and adds ++ around 7.5k. ++ You should port your application to use the POSIX nftw() ++ interface. ++ ++ Unless you need to build/use elfutils, you should prolly answer N. + + config UCLIBC_HAS_GLOB + bool "Support the glob() interface" +@@ -2322,7 +2334,7 @@ + + config UCLIBC_HAS_BACKTRACE + bool "Add support for application self-debugging" +- depends on HAVE_SHARED && TARGET_sh ++ depends on HAVE_SHARED + default n + help + Answer Y here to compile support for application self-debugging, by adding +diff -Nur uClibc-0.9.32-rc3/include/fts.h uClibc/include/fts.h +--- uClibc-0.9.32-rc3/include/fts.h 1970-01-01 01:00:00.000000000 +0100 ++++ uClibc/include/fts.h 2011-04-26 16:18:21.727663221 +0200 +@@ -0,0 +1,131 @@ ++/* ++ * Copyright (c) 1989, 1993 ++ * The Regents of the University of California. All rights reserved. ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in the ++ * documentation and/or other materials provided with the distribution. ++ * 4. Neither the name of the University nor the names of its contributors ++ * may be used to endorse or promote products derived from this software ++ * without specific prior written permission. ++ * ++ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND ++ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE ++ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ++ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE ++ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL ++ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS ++ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ++ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT ++ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY ++ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF ++ * SUCH DAMAGE. ++ * ++ * @(#)fts.h 8.3 (Berkeley) 8/14/94 ++ */ ++ ++#ifndef _FTS_H ++#define _FTS_H 1 ++ ++#include <features.h> ++#include <sys/types.h> ++ ++/* The fts interface is incompatible with the LFS interface which ++ transparently uses the 64-bit file access functions. */ ++#ifdef __USE_FILE_OFFSET64 ++# error "<fts.h> cannot be used with -D_FILE_OFFSET_BITS==64" ++#endif ++ ++ ++typedef struct { ++ struct _ftsent *fts_cur; /* current node */ ++ struct _ftsent *fts_child; /* linked list of children */ ++ struct _ftsent **fts_array; /* sort array */ ++ dev_t fts_dev; /* starting device # */ ++ char *fts_path; /* path for this descent */ ++ int fts_rfd; /* fd for root */ ++ int fts_pathlen; /* sizeof(path) */ ++ int fts_nitems; /* elements in the sort array */ ++ int (*fts_compar) (const void *, const void *); /* compare fn */ ++ ++#define FTS_COMFOLLOW 0x0001 /* follow command line symlinks */ ++#define FTS_LOGICAL 0x0002 /* logical walk */ ++#define FTS_NOCHDIR 0x0004 /* don't change directories */ ++#define FTS_NOSTAT 0x0008 /* don't get stat info */ ++#define FTS_PHYSICAL 0x0010 /* physical walk */ ++#define FTS_SEEDOT 0x0020 /* return dot and dot-dot */ ++#define FTS_XDEV 0x0040 /* don't cross devices */ ++#define FTS_WHITEOUT 0x0080 /* return whiteout information */ ++#define FTS_OPTIONMASK 0x00ff /* valid user option mask */ ++ ++#define FTS_NAMEONLY 0x0100 /* (private) child names only */ ++#define FTS_STOP 0x0200 /* (private) unrecoverable error */ ++ int fts_options; /* fts_open options, global flags */ ++} FTS; ++ ++typedef struct _ftsent { ++ struct _ftsent *fts_cycle; /* cycle node */ ++ struct _ftsent *fts_parent; /* parent directory */ ++ struct _ftsent *fts_link; /* next file in directory */ ++ long fts_number; /* local numeric value */ ++ void *fts_pointer; /* local address value */ ++ char *fts_accpath; /* access path */ ++ char *fts_path; /* root path */ ++ int fts_errno; /* errno for this node */ ++ int fts_symfd; /* fd for symlink */ ++ u_short fts_pathlen; /* strlen(fts_path) */ ++ u_short fts_namelen; /* strlen(fts_name) */ ++ ++ ino_t fts_ino; /* inode */ ++ dev_t fts_dev; /* device */ ++ nlink_t fts_nlink; /* link count */ ++ ++#define FTS_ROOTPARENTLEVEL -1 ++#define FTS_ROOTLEVEL 0 ++ short fts_level; /* depth (-1 to N) */ ++ ++#define FTS_D 1 /* preorder directory */ ++#define FTS_DC 2 /* directory that causes cycles */ ++#define FTS_DEFAULT 3 /* none of the above */ ++#define FTS_DNR 4 /* unreadable directory */ ++#define FTS_DOT 5 /* dot or dot-dot */ ++#define FTS_DP 6 /* postorder directory */ ++#define FTS_ERR 7 /* error; errno is set */ ++#define FTS_F 8 /* regular file */ ++#define FTS_INIT 9 /* initialized only */ ++#define FTS_NS 10 /* stat(2) failed */ ++#define FTS_NSOK 11 /* no stat(2) requested */ ++#define FTS_SL 12 /* symbolic link */ ++#define FTS_SLNONE 13 /* symbolic link without target */ ++#define FTS_W 14 /* whiteout object */ ++ u_short fts_info; /* user flags for FTSENT structure */ ++ ++#define FTS_DONTCHDIR 0x01 /* don't chdir .. to the parent */ ++#define FTS_SYMFOLLOW 0x02 /* followed a symlink to get here */ ++ u_short fts_flags; /* private flags for FTSENT structure */ ++ ++#define FTS_AGAIN 1 /* read node again */ ++#define FTS_FOLLOW 2 /* follow symbolic link */ ++#define FTS_NOINSTR 3 /* no instructions */ ++#define FTS_SKIP 4 /* discard node */ ++ u_short fts_instr; /* fts_set() instructions */ ++ ++ struct stat *fts_statp; /* stat(2) information */ ++ char fts_name[1]; /* file name */ ++} FTSENT; ++ ++__BEGIN_DECLS ++FTSENT *fts_children (FTS *, int); ++int fts_close (FTS *); ++FTS *fts_open (char * const *, int, ++ int (*)(const FTSENT **, const FTSENT **)); ++FTSENT *fts_read (FTS *); ++int fts_set (FTS *, FTSENT *, int) __THROW; ++__END_DECLS ++ ++#endif /* fts.h */ +diff -Nur uClibc-0.9.32-rc3/ldso/include/dl-elf.h uClibc/ldso/include/dl-elf.h +--- uClibc-0.9.32-rc3/ldso/include/dl-elf.h 2011-03-16 20:11:13.000000000 +0100 ++++ uClibc/ldso/include/dl-elf.h 2011-04-26 16:18:21.747664948 +0200 +@@ -184,7 +184,7 @@ + ADJUST_DYN_INFO(DT_DSBT_BASE_IDX, load_off); + + /* Initialize loadmap dsbt info. */ +- load_off.map->dsbt_table = dynamic_info[DT_DSBT_BASE_IDX]; ++ load_off.map->dsbt_table = (void *)dynamic_info[DT_DSBT_BASE_IDX]; + load_off.map->dsbt_size = dynamic_info[DT_DSBT_SIZE_IDX]; + load_off.map->dsbt_index = dynamic_info[DT_DSBT_INDEX_IDX]; + #endif +diff -Nur uClibc-0.9.32-rc3/ldso/include/ldso.h uClibc/ldso/include/ldso.h +--- uClibc-0.9.32-rc3/ldso/include/ldso.h 2011-03-16 20:11:13.000000000 +0100 ++++ uClibc/ldso/include/ldso.h 2011-04-26 16:18:21.747664948 +0200 +@@ -34,6 +34,8 @@ + #include <sys/types.h> + /* Pull in the arch specific page size */ + #include <bits/uClibc_page.h> ++/* Pull in the MIN macro */ ++#include <sys/param.h> + /* Pull in the ldso syscalls and string functions */ + #ifndef __ARCH_HAS_NO_SHARED__ + #include <dl-syscall.h> +diff -Nur uClibc-0.9.32-rc3/ldso/ldso/bfin/dl-inlines.h uClibc/ldso/ldso/bfin/dl-inlines.h +--- uClibc-0.9.32-rc3/ldso/ldso/bfin/dl-inlines.h 2011-03-16 20:11:13.000000000 +0100 ++++ uClibc/ldso/ldso/bfin/dl-inlines.h 2011-04-26 16:18:21.747664948 +0200 +@@ -88,14 +88,39 @@ + segdata->p_memsz = phdr->p_memsz; + + #if defined (__SUPPORT_LD_DEBUG__) +- { +- extern char *_dl_debug; +- extern int _dl_debug_file; +- if (_dl_debug) +- _dl_dprintf(_dl_debug_file, "%i: mapped %x at %x, size %x\n", +- loadaddr.map->nsegs-1, +- segdata->p_vaddr, segdata->addr, segdata->p_memsz); +- } ++ if (_dl_debug) ++ _dl_dprintf(_dl_debug_file, "%i: mapped %x at %x, size %x\n", ++ loadaddr.map->nsegs-1, ++ segdata->p_vaddr, segdata->addr, segdata->p_memsz); ++#endif ++} ++ ++/* Replace an existing entry in the load map. */ ++static __always_inline void ++__dl_update_loadaddr_hdr (struct elf32_fdpic_loadaddr loadaddr, void *addr, ++ Elf32_Phdr *phdr) ++{ ++ struct elf32_fdpic_loadseg *segdata; ++ void *oldaddr; ++ int i; ++ ++ for (i = 0; i < loadaddr.map->nsegs; i++) ++ if (loadaddr.map->segs[i].p_vaddr == phdr->p_vaddr ++ && loadaddr.map->segs[i].p_memsz == phdr->p_memsz) ++ break; ++ if (i == loadaddr.map->nsegs) ++ _dl_exit (-1); ++ ++ segdata = loadaddr.map->segs + i; ++ oldaddr = (void *)segdata->addr; ++ _dl_munmap (oldaddr, segdata->p_memsz); ++ segdata->addr = (Elf32_Addr) addr; ++ ++#if defined (__SUPPORT_LD_DEBUG__) ++ if (_dl_debug) ++ _dl_dprintf(_dl_debug_file, "%i: changed mapping %x at %x (old %x), size %x\n", ++ loadaddr.map->nsegs-1, ++ segdata->p_vaddr, segdata->addr, oldaddr, segdata->p_memsz); + #endif + } + +diff -Nur uClibc-0.9.32-rc3/ldso/ldso/bfin/dl-sysdep.h uClibc/ldso/ldso/bfin/dl-sysdep.h +--- uClibc-0.9.32-rc3/ldso/ldso/bfin/dl-sysdep.h 2011-03-16 20:11:13.000000000 +0100 ++++ uClibc/ldso/ldso/bfin/dl-sysdep.h 2011-04-26 16:18:21.747664948 +0200 +@@ -120,6 +120,8 @@ + #define DL_INIT_LOADADDR_HDR(LOADADDR, ADDR, PHDR) \ + (__dl_init_loadaddr_hdr ((LOADADDR), (ADDR), (PHDR), \ + dl_init_loadaddr_load_count)) ++#define DL_UPDATE_LOADADDR_HDR(LOADADDR, ADDR, PHDR) \ ++ (__dl_update_loadaddr_hdr ((LOADADDR), (ADDR), (PHDR))) + #define DL_LOADADDR_UNMAP(LOADADDR, LEN) \ + (__dl_loadaddr_unmap ((LOADADDR), (NULL))) + #define DL_LIB_UNMAP(LIB, LEN) \ +diff -Nur uClibc-0.9.32-rc3/ldso/ldso/c6x/dl-inlines.h uClibc/ldso/ldso/c6x/dl-inlines.h +--- uClibc-0.9.32-rc3/ldso/ldso/c6x/dl-inlines.h 2011-03-16 20:11:13.000000000 +0100 ++++ uClibc/ldso/ldso/c6x/dl-inlines.h 2011-04-26 16:18:21.747664948 +0200 +@@ -74,6 +74,35 @@ + #endif + } + ++/* Replace an existing entry in the load map. */ ++static __always_inline void ++__dl_update_loadaddr_hdr (struct elf32_dsbt_loadaddr loadaddr, void *addr, ++ Elf32_Phdr *phdr) ++{ ++ struct elf32_dsbt_loadseg *segdata; ++ void *oldaddr; ++ int i; ++ ++ for (i = 0; i < loadaddr.map->nsegs; i++) ++ if (loadaddr.map->segs[i].p_vaddr == phdr->p_vaddr ++ && loadaddr.map->segs[i].p_memsz == phdr->p_memsz) ++ break; ++ if (i == loadaddr.map->nsegs) ++ _dl_exit (-1); ++ ++ segdata = loadaddr.map->segs + i; ++ oldaddr = (void *)segdata->addr; ++ _dl_munmap (oldaddr, segdata->p_memsz); ++ segdata->addr = (Elf32_Addr) addr; ++ ++#if defined (__SUPPORT_LD_DEBUG__) ++ if (_dl_debug) ++ _dl_dprintf(_dl_debug_file, "%i: changed mapping %x at %x (old %x), size %x\n", ++ loadaddr.map->nsegs-1, ++ segdata->p_vaddr, segdata->addr, oldaddr, segdata->p_memsz); ++#endif ++} ++ + static __always_inline void + __dl_loadaddr_unmap (struct elf32_dsbt_loadaddr loadaddr) + { +diff -Nur uClibc-0.9.32-rc3/ldso/ldso/c6x/dl-sysdep.h uClibc/ldso/ldso/c6x/dl-sysdep.h +--- uClibc-0.9.32-rc3/ldso/ldso/c6x/dl-sysdep.h 2011-03-16 20:11:13.000000000 +0100 ++++ uClibc/ldso/ldso/c6x/dl-sysdep.h 2011-04-26 16:18:21.747664948 +0200 +@@ -104,6 +104,9 @@ + (__dl_init_loadaddr_hdr ((LOADADDR), (ADDR), (PHDR), \ + dl_init_loadaddr_load_count)) + ++#define DL_UPDATE_LOADADDR_HDR(LOADADDR, ADDR, PHDR) \ ++ (__dl_update_loadaddr_hdr ((LOADADDR), (ADDR), (PHDR))) ++ + #define DL_LOADADDR_UNMAP(LOADADDR, LEN) \ + (__dl_loadaddr_unmap ((LOADADDR))) + +diff -Nur uClibc-0.9.32-rc3/ldso/ldso/c6x/elfinterp.c uClibc/ldso/ldso/c6x/elfinterp.c +--- uClibc-0.9.32-rc3/ldso/ldso/c6x/elfinterp.c 2011-03-16 20:11:13.000000000 +0100 ++++ uClibc/ldso/ldso/c6x/elfinterp.c 2011-04-26 16:18:21.747664948 +0200 +@@ -198,6 +198,10 @@ + new_val = sym_val; + *reloc_addr = sym_val; + break; ++ case R_C6000_DSBT_INDEX: ++ new_val = (old_val & ~0x007fff00) | ((tpnt->loadaddr.map->dsbt_index & 0x7fff) << 8); ++ *reloc_addr = new_val; ++ break; + case R_C6000_ABS_L16: + new_val = (old_val & ~0x007fff80) | ((sym_val & 0xffff) << 7); + *reloc_addr = new_val; +@@ -224,7 +228,7 @@ + (char *)symbol_addr, + symtab[symtab_index].st_size); + } +- break; ++ return 0; + default: + return -1; /*call _dl_exit(1) */ + } +diff -Nur uClibc-0.9.32-rc3/ldso/ldso/dl-elf.c uClibc/ldso/ldso/dl-elf.c +--- uClibc-0.9.32-rc3/ldso/ldso/dl-elf.c 2011-03-16 20:11:13.000000000 +0100 ++++ uClibc/ldso/ldso/dl-elf.c 2011-04-26 16:18:21.747664948 +0200 +@@ -314,6 +314,121 @@ + return NULL; + } + ++/* ++ * Make a writeable mapping of a segment, regardless of whether PF_W is ++ * set or not. ++ */ ++static void * ++map_writeable (int infile, ElfW(Phdr) *ppnt, int piclib, int flags, ++ unsigned long libaddr) ++{ ++ int prot_flags = ppnt->p_flags | PF_W; ++ char *status, *retval; ++ char *tryaddr; ++ ssize_t size; ++ unsigned long map_size; ++ char *cpnt; ++ char *piclib2map = NULL; ++ ++ if (piclib == 2 && ++ /* We might be able to avoid this call if memsz doesn't ++ require an additional page, but this would require mmap ++ to always return page-aligned addresses and a whole ++ number of pages allocated. Unfortunately on uClinux ++ may return misaligned addresses and may allocate ++ partial pages, so we may end up doing unnecessary mmap ++ calls. ++ ++ This is what we could do if we knew mmap would always ++ return aligned pages: ++ ++ ((ppnt->p_vaddr + ppnt->p_filesz + ADDR_ALIGN) & ++ PAGE_ALIGN) < ppnt->p_vaddr + ppnt->p_memsz) ++ ++ Instead, we have to do this: */ ++ ppnt->p_filesz < ppnt->p_memsz) ++ { ++ piclib2map = (char *) ++ _dl_mmap(0, (ppnt->p_vaddr & ADDR_ALIGN) + ppnt->p_memsz, ++ LXFLAGS(prot_flags), flags | MAP_ANONYMOUS, -1, 0); ++ if (_dl_mmap_check_error(piclib2map)) ++ return 0; ++ } ++ ++ tryaddr = piclib == 2 ? piclib2map ++ : ((char*) (piclib ? libaddr : 0) + ++ (ppnt->p_vaddr & PAGE_ALIGN)); ++ ++ size = (ppnt->p_vaddr & ADDR_ALIGN) + ppnt->p_filesz; ++ ++ /* For !MMU, mmap to fixed address will fail. ++ So instead of desperately call mmap and fail, ++ we set status to MAP_FAILED to save a call ++ to mmap (). */ ++#ifndef __ARCH_USE_MMU__ ++ if (piclib2map == 0) ++#endif ++ status = (char *) _dl_mmap ++ (tryaddr, size, LXFLAGS(prot_flags), ++ flags | (piclib2map ? MAP_FIXED : 0), ++ infile, ppnt->p_offset & OFFS_ALIGN); ++#ifndef __ARCH_USE_MMU__ ++ else ++ status = MAP_FAILED; ++#endif ++#ifdef _DL_PREAD ++ if (_dl_mmap_check_error(status) && piclib2map ++ && (_DL_PREAD (infile, tryaddr, size, ++ ppnt->p_offset & OFFS_ALIGN) == size)) ++ status = tryaddr; ++#endif ++ if (_dl_mmap_check_error(status) || (tryaddr && tryaddr != status)) ++ return 0; ++ ++ if (piclib2map) ++ retval = piclib2map; ++ else ++ retval = status; ++ ++ /* Now we want to allocate and zero-out any data from the end ++ of the region we mapped in from the file (filesz) to the ++ end of the loadable segment (memsz). We may need ++ additional pages for memsz, that we map in below, and we ++ can count on the kernel to zero them out, but we have to ++ zero out stuff in the last page that we mapped in from the ++ file. However, we can't assume to have actually obtained ++ full pages from the kernel, since we didn't ask for them, ++ and uClibc may not give us full pages for small ++ allocations. So only zero out up to memsz or the end of ++ the page, whichever comes first. */ ++ ++ /* CPNT is the beginning of the memsz portion not backed by ++ filesz. */ ++ cpnt = (char *) (status + size); ++ ++ /* MAP_SIZE is the address of the ++ beginning of the next page. */ ++ map_size = (ppnt->p_vaddr + ppnt->p_filesz ++ + ADDR_ALIGN) & PAGE_ALIGN; ++ ++ _dl_memset (cpnt, 0, ++ MIN (map_size ++ - (ppnt->p_vaddr ++ + ppnt->p_filesz), ++ ppnt->p_memsz ++ - ppnt->p_filesz)); ++ ++ if (map_size < ppnt->p_vaddr + ppnt->p_memsz && !piclib2map) { ++ tryaddr = map_size + (char*)(piclib ? libaddr : 0); ++ status = (char *) _dl_mmap(tryaddr, ++ ppnt->p_vaddr + ppnt->p_memsz - map_size, ++ LXFLAGS(prot_flags), ++ flags | MAP_ANONYMOUS | MAP_FIXED, -1, 0); ++ if (_dl_mmap_check_error(status) || tryaddr != status) ++ return NULL; ++ } ++ return retval; ++} + + /* + * Read one ELF library into memory, mmap it into the correct locations and +@@ -475,6 +590,7 @@ + status = (char *) _dl_mmap((char *) (piclib ? 0 : minvma), + maxvma - minvma, PROT_NONE, flags | MAP_ANONYMOUS, -1, 0); + if (_dl_mmap_check_error(status)) { ++ cant_map: + _dl_dprintf(2, "%s:%i: can't map '%s'\n", _dl_progname, __LINE__, libname); + _dl_internal_error_number = LD_ERROR_MMAP_FAILED; + _dl_close(infile); +@@ -495,8 +611,11 @@ + char *addr; + + addr = DL_MAP_SEGMENT (epnt, ppnt, infile, flags); +- if (addr == NULL) ++ if (addr == NULL) { ++ cant_map1: ++ DL_LOADADDR_UNMAP (lib_loadaddr, maxvma - minvma); + goto cant_map; ++ } + + DL_INIT_LOADADDR_HDR (lib_loadaddr, addr, ppnt); + ppnt++; +@@ -517,141 +636,9 @@ + } + + if (ppnt->p_flags & PF_W) { +- unsigned long map_size; +- char *cpnt; +- char *piclib2map = 0; +- +- if (piclib == 2 && +- /* We might be able to avoid this +- call if memsz doesn't require +- an additional page, but this +- would require mmap to always +- return page-aligned addresses +- and a whole number of pages +- allocated. Unfortunately on +- uClinux may return misaligned +- addresses and may allocate +- partial pages, so we may end up +- doing unnecessary mmap calls. +- +- This is what we could do if we +- knew mmap would always return +- aligned pages: +- +- ((ppnt->p_vaddr + ppnt->p_filesz +- + ADDR_ALIGN) +- & PAGE_ALIGN) +- < ppnt->p_vaddr + ppnt->p_memsz) +- +- Instead, we have to do this: */ +- ppnt->p_filesz < ppnt->p_memsz) +- { +- piclib2map = (char *) +- _dl_mmap(0, (ppnt->p_vaddr & ADDR_ALIGN) +- + ppnt->p_memsz, +- LXFLAGS(ppnt->p_flags), +- flags | MAP_ANONYMOUS, -1, 0); +- if (_dl_mmap_check_error(piclib2map)) +- goto cant_map; +- DL_INIT_LOADADDR_HDR +- (lib_loadaddr, piclib2map +- + (ppnt->p_vaddr & ADDR_ALIGN), ppnt); +- } +- +- tryaddr = piclib == 2 ? piclib2map +- : ((char*) (piclib ? libaddr : 0) + +- (ppnt->p_vaddr & PAGE_ALIGN)); +- +- size = (ppnt->p_vaddr & ADDR_ALIGN) +- + ppnt->p_filesz; +- +- /* For !MMU, mmap to fixed address will fail. +- So instead of desperately call mmap and fail, +- we set status to MAP_FAILED to save a call +- to mmap (). */ +-#ifndef __ARCH_USE_MMU__ +- if (piclib2map == 0) +-#endif +- status = (char *) _dl_mmap +- (tryaddr, size, LXFLAGS(ppnt->p_flags), +- flags | (piclib2map ? MAP_FIXED : 0), +- infile, ppnt->p_offset & OFFS_ALIGN); +-#ifndef __ARCH_USE_MMU__ +- else +- status = MAP_FAILED; +-#endif +-#ifdef _DL_PREAD +- if (_dl_mmap_check_error(status) && piclib2map +- && (_DL_PREAD (infile, tryaddr, size, +- ppnt->p_offset & OFFS_ALIGN) +- == size)) +- status = tryaddr; +-#endif +- if (_dl_mmap_check_error(status) +- || (tryaddr && tryaddr != status)) { +- cant_map: +- _dl_dprintf(2, "%s:%i: can't map '%s'\n", +- _dl_progname, __LINE__, libname); +- _dl_internal_error_number = LD_ERROR_MMAP_FAILED; +- DL_LOADADDR_UNMAP (lib_loadaddr, maxvma - minvma); +- _dl_close(infile); +- _dl_munmap(header, _dl_pagesize); +- return NULL; +- } +- +- if (! piclib2map) { +- DL_INIT_LOADADDR_HDR +- (lib_loadaddr, status +- + (ppnt->p_vaddr & ADDR_ALIGN), ppnt); +- } +- /* Now we want to allocate and +- zero-out any data from the end of +- the region we mapped in from the +- file (filesz) to the end of the +- loadable segment (memsz). We may +- need additional pages for memsz, +- that we map in below, and we can +- count on the kernel to zero them +- out, but we have to zero out stuff +- in the last page that we mapped in +- from the file. However, we can't +- assume to have actually obtained +- full pages from the kernel, since +- we didn't ask for them, and uClibc +- may not give us full pages for +- small allocations. So only zero +- out up to memsz or the end of the +- page, whichever comes first. */ +- +- /* CPNT is the beginning of the memsz +- portion not backed by filesz. */ +- cpnt = (char *) (status + size); +- +- /* MAP_SIZE is the address of the +- beginning of the next page. */ +- map_size = (ppnt->p_vaddr + ppnt->p_filesz +- + ADDR_ALIGN) & PAGE_ALIGN; +- +-#ifndef MIN +-# define MIN(a,b) ((a) < (b) ? (a) : (b)) +-#endif +- _dl_memset (cpnt, 0, +- MIN (map_size +- - (ppnt->p_vaddr +- + ppnt->p_filesz), +- ppnt->p_memsz +- - ppnt->p_filesz)); +- +- if (map_size < ppnt->p_vaddr + ppnt->p_memsz +- && !piclib2map) { +- tryaddr = map_size + (char*)(piclib ? libaddr : 0); +- status = (char *) _dl_mmap(tryaddr, +- ppnt->p_vaddr + ppnt->p_memsz - map_size, +- LXFLAGS(ppnt->p_flags), flags | MAP_ANONYMOUS | MAP_FIXED, -1, 0); +- if (_dl_mmap_check_error(status) +- || tryaddr != status) +- goto cant_map; +- } ++ status = map_writeable (infile, ppnt, piclib, flags, libaddr); ++ if (status == NULL) ++ goto cant_map1; + } else { + tryaddr = (piclib == 2 ? 0 + : (char *) (ppnt->p_vaddr & PAGE_ALIGN) +@@ -664,11 +651,11 @@ + infile, ppnt->p_offset & OFFS_ALIGN); + if (_dl_mmap_check_error(status) + || (tryaddr && tryaddr != status)) +- goto cant_map; +- DL_INIT_LOADADDR_HDR +- (lib_loadaddr, status +- + (ppnt->p_vaddr & ADDR_ALIGN), ppnt); ++ goto cant_map1; + } ++ DL_INIT_LOADADDR_HDR(lib_loadaddr, ++ status + (ppnt->p_vaddr & ADDR_ALIGN), ++ ppnt); + + /* if (libaddr == 0 && piclib) { + libaddr = (unsigned long) status; +@@ -677,7 +664,6 @@ + } + ppnt++; + } +- _dl_close(infile); + + /* For a non-PIC library, the addresses are all absolute */ + if (piclib) { +@@ -696,6 +682,7 @@ + _dl_dprintf(2, "%s: '%s' is missing a dynamic section\n", + _dl_progname, libname); + _dl_munmap(header, _dl_pagesize); ++ _dl_close(infile); + return NULL; + } + +@@ -711,10 +698,23 @@ + ppnt = (ElfW(Phdr) *)(intptr_t) & header[epnt->e_phoff]; + for (i = 0; i < epnt->e_phnum; i++, ppnt++) { + if (ppnt->p_type == PT_LOAD && !(ppnt->p_flags & PF_W)) { ++#ifdef __ARCH_USE_MMU__ + _dl_mprotect((void *) ((piclib ? libaddr : 0) + + (ppnt->p_vaddr & PAGE_ALIGN)), + (ppnt->p_vaddr & ADDR_ALIGN) + (unsigned long) ppnt->p_filesz, + PROT_READ | PROT_WRITE | PROT_EXEC); ++#else ++ void *new_addr; ++ new_addr = map_writeable (infile, ppnt, piclib, flags, libaddr); ++ if (!new_addr) { ++ _dl_dprintf(_dl_debug_file, "Can't modify %s's text section.", ++ libname); ++ _dl_exit(1); ++ } ++ DL_UPDATE_LOADADDR_HDR(lib_loadaddr, ++ new_addr + (ppnt->p_vaddr & ADDR_ALIGN), ++ ppnt); ++#endif + } + } + #else +@@ -725,6 +725,8 @@ + #endif + } + ++ _dl_close(infile); ++ + tpnt = _dl_add_elf_hash_table(libname, lib_loadaddr, dynamic_info, + dynamic_addr, 0); + tpnt->relro_addr = relro_addr; +@@ -809,20 +811,44 @@ + #ifdef __DSBT__ + /* Handle DSBT initialization */ + { +- struct elf_resolve *t, *ref = NULL; ++ struct elf_resolve *t, *ref; + int idx = tpnt->loadaddr.map->dsbt_index; + unsigned *dsbt = tpnt->loadaddr.map->dsbt_table; + + if (idx == 0) { +- /* This DSO has not been assigned an index */ +- _dl_dprintf(2, "%s: '%s' is missing a dsbt index assignment!\n", +- _dl_progname, libname); +- _dl_exit(1); ++ if (!dynamic_info[DT_TEXTREL]) { ++ /* This DSO has not been assigned an index. */ ++ _dl_dprintf(2, "%s: '%s' is missing a dsbt index assignment!\n", ++ _dl_progname, libname); ++ _dl_exit(1); ++ } ++ /* Find a dsbt table from another module. */ ++ ref = NULL; ++ for (t = _dl_loaded_modules; t; t = t->next) { ++ if (ref == NULL && t != tpnt) { ++ ref = t; ++ break; ++ } ++ } ++ idx = tpnt->loadaddr.map->dsbt_size; ++ while (idx-- > 0) ++ if (!ref || ref->loadaddr.map->dsbt_table[idx] == NULL) ++ break; ++ if (idx <= 0) { ++ _dl_dprintf(2, "%s: '%s' caused DSBT table overflow!\n", ++ _dl_progname, libname); ++ _dl_exit(1); ++ } ++ _dl_if_debug_dprint("\n\tfile='%s'; assigned index %d\n", ++ libname, idx); ++ tpnt->loadaddr.map->dsbt_index = idx; ++ + } + + /* + * Setup dsbt slot for this module in dsbt of all modules. + */ ++ ref = NULL; + for (t = _dl_loaded_modules; t; t = t->next) { + /* find a dsbt table from another module */ + if (ref == NULL && t != tpnt) { +diff -Nur uClibc-0.9.32-rc3/ldso/ldso/dl-startup.c uClibc/ldso/ldso/dl-startup.c +--- uClibc-0.9.32-rc3/ldso/ldso/dl-startup.c 2011-03-16 20:11:13.000000000 +0100 ++++ uClibc/ldso/ldso/dl-startup.c 2011-04-26 16:18:21.747664948 +0200 +@@ -32,8 +32,8 @@ + + /* + * The main trick with this program is that initially, we ourselves are not +- * dynamicly linked. This means that we cannot access any global variables or +- * call any functions. No globals initially, since the Global Offset Table ++ * dynamically linked. This means that we cannot access any global variables ++ * or call any functions. No globals initially, since the Global Offset Table + * (GOT) is initialized by the linker assuming a virtual address of 0, and no + * function calls initially since the Procedure Linkage Table (PLT) is not yet + * initialized. +@@ -55,12 +55,12 @@ + * + * Fortunately, the linker itself leaves a few clues lying around, and when the + * kernel starts the image, there are a few further clues. First of all, there +- * is Auxiliary Vector Table information sitting on which is provided to us by +- * the kernel, and which includes information about the load address that the +- * program interpreter was loaded at, the number of sections, the address the +- * application was loaded at and so forth. Here this information is stored in +- * the array auxvt. For details see linux/fs/binfmt_elf.c where it calls +- * NEW_AUX_ENT() a bunch of time.... ++ * is Auxiliary Vector Table information sitting on the stack which is provided ++ * to us by the kernel, and which includes information about the address ++ * that the program interpreter was loaded at, the number of sections, the ++ * address the application was loaded at, and so forth. Here this information ++ * is stored in the array auxvt. For details see linux/fs/binfmt_elf.c where ++ * it calls NEW_AUX_ENT() a bunch of times.... + * + * Next, we need to find the GOT. On most arches there is a register pointing + * to the GOT, but just in case (and for new ports) I've added some (slow) C +diff -Nur uClibc-0.9.32-rc3/ldso/ldso/frv/dl-inlines.h uClibc/ldso/ldso/frv/dl-inlines.h +--- uClibc-0.9.32-rc3/ldso/ldso/frv/dl-inlines.h 2011-03-16 20:11:13.000000000 +0100 ++++ uClibc/ldso/ldso/frv/dl-inlines.h 2011-04-26 16:18:21.757661905 +0200 +@@ -72,14 +72,39 @@ + segdata->p_memsz = phdr->p_memsz; + + #if defined (__SUPPORT_LD_DEBUG__) +- { +- extern char *_dl_debug; +- extern int _dl_debug_file; +- if (_dl_debug) +- _dl_dprintf(_dl_debug_file, "%i: mapped %x at %x, size %x\n", +- loadaddr.map->nsegs-1, +- segdata->p_vaddr, segdata->addr, segdata->p_memsz); +- } ++ if (_dl_debug) ++ _dl_dprintf(_dl_debug_file, "%i: mapped %x at %x, size %x\n", ++ loadaddr.map->nsegs-1, ++ segdata->p_vaddr, segdata->addr, segdata->p_memsz); ++#endif ++} ++ ++/* Replace an existing entry in the load map. */ ++static __always_inline void ++__dl_update_loadaddr_hdr (struct elf32_fdpic_loadaddr loadaddr, void *addr, ++ Elf32_Phdr *phdr) ++{ ++ struct elf32_fdpic_loadseg *segdata; ++ void *oldaddr; ++ int i; ++ ++ for (i = 0; i < loadaddr.map->nsegs; i++) ++ if (loadaddr.map->segs[i].p_vaddr == phdr->p_vaddr ++ && loadaddr.map->segs[i].p_memsz == phdr->p_memsz) ++ break; ++ if (i == loadaddr.map->nsegs) ++ _dl_exit (-1); ++ ++ segdata = loadaddr.map->segs + i; ++ oldaddr = (void *)segdata->addr; ++ _dl_munmap (oldaddr, segdata->p_memsz); ++ segdata->addr = (Elf32_Addr) addr; ++ ++#if defined (__SUPPORT_LD_DEBUG__) ++ if (_dl_debug) ++ _dl_dprintf(_dl_debug_file, "%i: changed mapping %x at %x (old %x), size %x\n", ++ loadaddr.map->nsegs-1, ++ segdata->p_vaddr, segdata->addr, oldaddr, segdata->p_memsz); + #endif + } + +diff -Nur uClibc-0.9.32-rc3/ldso/ldso/frv/dl-sysdep.h uClibc/ldso/ldso/frv/dl-sysdep.h +--- uClibc-0.9.32-rc3/ldso/ldso/frv/dl-sysdep.h 2011-03-16 20:11:13.000000000 +0100 ++++ uClibc/ldso/ldso/frv/dl-sysdep.h 2011-04-26 16:18:21.757661905 +0200 +@@ -95,6 +95,8 @@ + #define DL_INIT_LOADADDR_HDR(LOADADDR, ADDR, PHDR) \ + (__dl_init_loadaddr_hdr ((LOADADDR), (ADDR), (PHDR), \ + dl_init_loadaddr_load_count)) ++#define DL_UPDATE_LOADADDR_HDR(LOADADDR, ADDR, PHDR) \ ++ (__dl_update_loadaddr_hdr ((LOADADDR), (ADDR), (PHDR))) + #define DL_LOADADDR_UNMAP(LOADADDR, LEN) \ + (__dl_loadaddr_unmap ((LOADADDR), (NULL))) + #define DL_LIB_UNMAP(LIB, LEN) \ +diff -Nur uClibc-0.9.32-rc3/ldso/ldso/mips/elfinterp.c uClibc/ldso/ldso/mips/elfinterp.c +--- uClibc-0.9.32-rc3/ldso/ldso/mips/elfinterp.c 2011-03-16 20:11:13.000000000 +0100 ++++ uClibc/ldso/ldso/mips/elfinterp.c 2011-04-26 16:18:21.757661905 +0200 +@@ -378,8 +378,11 @@ + *got_entry += (unsigned long) tpnt->loadaddr; + } + else { ++ struct symbol_ref sym_ref; ++ sym_ref.sym = sym; ++ sym_ref.tpnt = NULL; + *got_entry = (unsigned long) _dl_find_hash(strtab + +- sym->st_name, tpnt->symbol_scope, tpnt, ELF_RTYPE_CLASS_PLT, NULL); ++ sym->st_name, tpnt->symbol_scope, tpnt, ELF_RTYPE_CLASS_PLT, &sym_ref); + } + + got_entry++; +diff -Nur uClibc-0.9.32-rc3/libc/inet/resolv.c uClibc/libc/inet/resolv.c +--- uClibc-0.9.32-rc3/libc/inet/resolv.c 2011-03-16 20:11:13.000000000 +0100 ++++ uClibc/libc/inet/resolv.c 2011-04-26 16:18:21.767661585 +0200 +@@ -3009,7 +3009,7 @@ + int m = 0; + /* free nsaddrs[m] if they do not point to nsaddr_list[x] */ + while (m < ARRAY_SIZE(_res._u._ext.nsaddrs)) { +- char *p2 = (char*)(_res._u._ext.nsaddrs[m]); ++ char *p2 = (char*)(_res._u._ext.nsaddrs[m++]); + if (p2 < p1 || (p2 - p1) > sizeof(_res.nsaddr_list)) + free(p2); + } +diff -Nur uClibc-0.9.32-rc3/libc/misc/fts/fts.c uClibc/libc/misc/fts/fts.c +--- uClibc-0.9.32-rc3/libc/misc/fts/fts.c 1970-01-01 01:00:00.000000000 +0100 ++++ uClibc/libc/misc/fts/fts.c 2011-04-26 16:18:21.777663244 +0200 +@@ -0,0 +1,1145 @@ ++/*- ++ * Copyright (c) 1990, 1993, 1994 ++ * The Regents of the University of California. All rights reserved. ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in the ++ * documentation and/or other materials provided with the distribution. ++ * 4. Neither the name of the University nor the names of its contributors ++ * may be used to endorse or promote products derived from this software ++ * without specific prior written permission. ++ * ++ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND ++ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE ++ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ++ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE ++ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL ++ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS ++ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ++ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT ++ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY ++ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF ++ * SUCH DAMAGE. ++ */ ++ ++#include <sys/param.h> ++#include <sys/stat.h> ++#include <fcntl.h> ++#include <dirent.h> ++#include <errno.h> ++#include <fts.h> ++#include <stdlib.h> ++#include <string.h> ++#include <unistd.h> ++ ++#ifdef __UCLIBC_HAS_LFS__ ++# include <_lfs_64.h> ++#else ++# define stat64 stat ++# define fstat64 fstat ++#endif ++ ++/* Largest alignment size needed, minus one. ++ Usually long double is the worst case. */ ++#ifndef ALIGNBYTES ++#define ALIGNBYTES (__alignof__ (long double) - 1) ++#endif ++/* Align P to tha |