Vampirise two more patches against uClibc-0.9.29 from buildroot.
author"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
Sat Jul 21 20:31:26 2007 +0000 (2007-07-21)
changeset 2817039139a912a
parent 280 295b38f682fe
child 282 e1f3b337ca6a
Vampirise two more patches against uClibc-0.9.29 from buildroot.
patches/uClibc/0.9.29/000-fix-mmap.patch
patches/uClibc/0.9.29/200-fix-internal_function-definition.patch
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/patches/uClibc/0.9.29/000-fix-mmap.patch	Sat Jul 21 20:31:26 2007 +0000
     1.3 @@ -0,0 +1,91 @@
     1.4 +--- uClibc-0.9.29.oorig/test/mmap/mmap2.c	(revision 0)
     1.5 ++++ uClibc-0.9.29/test/mmap/mmap2.c	(revision 18616)
     1.6 +@@ -0,0 +1,41 @@
     1.7 ++/* When trying to map /dev/mem with offset 0xFFFFF000 on the ARM platform, mmap
     1.8 ++ * returns -EOVERFLOW.
     1.9 ++ *
    1.10 ++ * Since off_t is defined as a long int and the sign bit is set in the address,
    1.11 ++ * the shift operation shifts in ones instead of zeroes
    1.12 ++ * from the left. This results the offset sent to the kernel function becomes
    1.13 ++ * 0xFFFFFFFF instead of 0x000FFFFF with MMAP2_PAGE_SHIFT set to 12.
    1.14 ++ */
    1.15 ++
    1.16 ++#include <unistd.h>
    1.17 ++#include <stdio.h>
    1.18 ++#include <stdlib.h>
    1.19 ++#include <string.h>
    1.20 ++#include <errno.h>
    1.21 ++#include <fcntl.h>
    1.22 ++#include <sys/mman.h>
    1.23 ++
    1.24 ++#define FATAL do { fprintf(stderr, "Error at line %d, file %s (%d) [%s]\n", \
    1.25 ++  __LINE__, __FILE__, errno, strerror(errno)); exit(1); } while(0)
    1.26 ++
    1.27 ++#define MAP_SIZE 4096UL
    1.28 ++#define MAP_MASK (MAP_SIZE - 1)
    1.29 ++
    1.30 ++int main(int argc, char **argv) {
    1.31 ++    void* map_base = 0;
    1.32 ++    int fd;
    1.33 ++    off_t target = 0xfffff000;
    1.34 ++    if((fd = open("/dev/mem", O_RDWR | O_SYNC)) == -1) FATAL;
    1.35 ++    printf("/dev/mem opened.\n");
    1.36 ++    fflush(stdout);
    1.37 ++
    1.38 ++   /* Map one page */
    1.39 ++    map_base = mmap(0, MAP_SIZE, PROT_READ | PROT_WRITE, MAP_SHARED,
    1.40 ++                        fd, target & ~MAP_MASK);
    1.41 ++    if(map_base == (void *) -1) FATAL;
    1.42 ++    printf("Memory mapped at address %p.\n", map_base);
    1.43 ++    fflush(stdout);
    1.44 ++    if(munmap(map_base, MAP_SIZE) == -1) FATAL;
    1.45 ++    close(fd);
    1.46 ++    return 0;
    1.47 ++}
    1.48 +--- uClibc-0.9.29.oorig/libc/sysdeps/linux/arm/mmap.c	(revision 18615)
    1.49 ++++ uClibc-0.9.29/libc/sysdeps/linux/arm/mmap.c	(revision 18616)
    1.50 +@@ -27,7 +27,6 @@ __ptr_t mmap(__ptr_t addr, size_t len, i
    1.51 + 
    1.52 + #elif defined  (__NR_mmap2)
    1.53 + #define __NR__mmap __NR_mmap2
    1.54 +-
    1.55 + #ifndef MMAP2_PAGE_SHIFT
    1.56 + # define MMAP2_PAGE_SHIFT 12
    1.57 + #endif
    1.58 +@@ -39,9 +38,17 @@ __ptr_t mmap(__ptr_t addr, size_t len, i
    1.59 + {
    1.60 +   /* check if offset is page aligned */
    1.61 +     if (offset & ((1 << MMAP2_PAGE_SHIFT) - 1))
    1.62 ++    {
    1.63 ++        __set_errno(EINVAL);
    1.64 +         return MAP_FAILED;
    1.65 ++    }
    1.66 ++#ifdef __USE_FILE_OFFSET64
    1.67 ++  return (__ptr_t) _mmap (addr, len, prot, flags,
    1.68 ++						  fd,((__u_quad_t) offset >> MMAP2_PAGE_SHIFT));
    1.69 ++#else
    1.70 +   return (__ptr_t) _mmap (addr, len, prot, flags,
    1.71 +-						  fd,(off_t) (offset >> MMAP2_PAGE_SHIFT));
    1.72 ++                          fd,((__u_long) offset >> MMAP2_PAGE_SHIFT));
    1.73 ++#endif
    1.74 + }
    1.75 + #elif defined (__NR_mmap)
    1.76 + # define __NR__mmap __NR_mmap
    1.77 +--- uClibc-0.9.29.oorig/libc/sysdeps/linux/common/mmap64.c	(revision 18615)
    1.78 ++++ uClibc-0.9.29/libc/sysdeps/linux/common/mmap64.c	(revision 18616)
    1.79 +@@ -58,8 +58,13 @@ __ptr_t mmap64(__ptr_t addr, size_t len,
    1.80 + 		__set_errno(EINVAL);
    1.81 + 		return MAP_FAILED;
    1.82 + 	}
    1.83 +-
    1.84 +-	return __syscall_mmap2(addr, len, prot, flags, fd, (off_t) (offset >> MMAP2_PAGE_SHIFT));
    1.85 ++#ifdef __USE_FILE_OFFSET64
    1.86 ++  return __syscall_mmap2(addr, len, prot, flags,
    1.87 ++                         fd,((__u_quad_t)offset >> MMAP2_PAGE_SHIFT));
    1.88 ++#else
    1.89 ++   return __syscall_mmap2(addr, len, prot, flags,
    1.90 ++                          fd,((__ulong_t)offset >> MMAP2_PAGE_SHIFT));
    1.91 ++#endif
    1.92 + }
    1.93 + 
    1.94 + # endif
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/patches/uClibc/0.9.29/200-fix-internal_function-definition.patch	Sat Jul 21 20:31:26 2007 +0000
     2.3 @@ -0,0 +1,51 @@
     2.4 +Index: uClibc/libc/sysdeps/linux/i386/bits/uClibc_arch_features.h
     2.5 +===================================================================
     2.6 +--- uClibc/libc/sysdeps/linux/i386/bits/uClibc_arch_features.h	(revision 18898)
     2.7 ++++ uClibc/libc/sysdeps/linux/i386/bits/uClibc_arch_features.h	(working copy)
     2.8 +@@ -42,6 +42,8 @@
     2.9 + /* define if target supports IEEE signed zero floats */
    2.10 + #define __UCLIBC_HAVE_SIGNED_ZERO__
    2.11 + 
    2.12 ++#if defined _LIBC
    2.13 + #define internal_function __attribute__ ((regparm (3), stdcall))
    2.14 ++#endif
    2.15 + 
    2.16 + #endif /* _BITS_UCLIBC_ARCH_FEATURES_H */
    2.17 +Index: uClibc/include/libc-symbols.h
    2.18 +===================================================================
    2.19 +--- uClibc/include/libc-symbols.h	(revision 18898)
    2.20 ++++ uClibc/include/libc-symbols.h	(working copy)
    2.21 +@@ -22,6 +22,16 @@
    2.22 + #ifndef _LIBC_SYMBOLS_H
    2.23 + #define _LIBC_SYMBOLS_H	1
    2.24 + 
    2.25 ++/* This is defined for the compilation of all C library code.  features.h
    2.26 ++   tests this to avoid inclusion of stubs.h while compiling the library,
    2.27 ++   before stubs.h has been generated.  Some library code that is shared
    2.28 ++   with other packages also tests this symbol to see if it is being
    2.29 ++   compiled as part of the C library.  We must define this before including
    2.30 ++   config.h, because it makes some definitions conditional on whether libc
    2.31 ++   itself is being compiled, or just some generator program.  */
    2.32 ++#define _LIBC	1
    2.33 ++
    2.34 ++
    2.35 + /* This file's macros are included implicitly in the compilation of every
    2.36 +    file in the C library by -imacros.
    2.37 + 
    2.38 +@@ -40,16 +50,6 @@
    2.39 + 
    2.40 + #include <bits/uClibc_arch_features.h>
    2.41 + 
    2.42 +-
    2.43 +-/* This is defined for the compilation of all C library code.  features.h
    2.44 +-   tests this to avoid inclusion of stubs.h while compiling the library,
    2.45 +-   before stubs.h has been generated.  Some library code that is shared
    2.46 +-   with other packages also tests this symbol to see if it is being
    2.47 +-   compiled as part of the C library.  We must define this before including
    2.48 +-   config.h, because it makes some definitions conditional on whether libc
    2.49 +-   itself is being compiled, or just some generator program.  */
    2.50 +-#define _LIBC	1
    2.51 +-
    2.52 + /* Enable declarations of GNU extensions, since we are compiling them.  */
    2.53 + #define _GNU_SOURCE	1
    2.54 +