diff options
Diffstat (limited to 'libc/sysdeps/linux/common')
33 files changed, 114 insertions, 50 deletions
diff --git a/libc/sysdeps/linux/common/__syscall_sigaction.c b/libc/sysdeps/linux/common/__syscall_sigaction.c index 6c33b2802..4333a6a1a 100644 --- a/libc/sysdeps/linux/common/__syscall_sigaction.c +++ b/libc/sysdeps/linux/common/__syscall_sigaction.c @@ -13,7 +13,7 @@ #define __NR___syscall_sigaction __NR_sigaction #include <signal.h> #undef sigaction -_syscall3(int, __syscall_sigaction, int, signum, const struct sigaction *, +attribute_hidden _syscall3(int, __syscall_sigaction, int, signum, const struct sigaction *, act, struct sigaction *, oldact); #endif diff --git a/libc/sysdeps/linux/common/adjtimex.c b/libc/sysdeps/linux/common/adjtimex.c index 28ad442e8..ef33051e8 100644 --- a/libc/sysdeps/linux/common/adjtimex.c +++ b/libc/sysdeps/linux/common/adjtimex.c @@ -9,7 +9,9 @@ #include "syscalls.h" #include <sys/timex.h> -_syscall1(int, adjtimex, struct timex *, buf); -weak_alias(adjtimex, __adjtimex); -weak_alias(adjtimex, ntp_adjtime); +#define __NR___adjtimex __NR_adjtimex +attribute_hidden _syscall1(int, __adjtimex, struct timex *, buf); + +strong_alias(__adjtimex, adjtimex) +weak_alias(__adjtimex, ntp_adjtime) diff --git a/libc/sysdeps/linux/common/alarm.c b/libc/sysdeps/linux/common/alarm.c index 7e554fcbf..eec941d07 100644 --- a/libc/sysdeps/linux/common/alarm.c +++ b/libc/sysdeps/linux/common/alarm.c @@ -7,6 +7,8 @@ * GNU Library General Public License (LGPL) version 2 or later. */ +#define setitimer __setitimer + #include "syscalls.h" #include <unistd.h> #ifdef __NR_alarm diff --git a/libc/sysdeps/linux/common/bits/uClibc_uintmaxtostr.h b/libc/sysdeps/linux/common/bits/uClibc_uintmaxtostr.h index 726558ad8..92633ffa6 100644 --- a/libc/sysdeps/linux/common/bits/uClibc_uintmaxtostr.h +++ b/libc/sysdeps/linux/common/bits/uClibc_uintmaxtostr.h @@ -100,7 +100,7 @@ typedef enum { * Otherwise, you could overflow your buffer. */ extern char *_uintmaxtostr(char * __restrict bufend, uintmax_t uval, - int base, __UIM_CASE alphacase); + int base, __UIM_CASE alphacase) attribute_hidden; /* TODO -- make this either a (possibly inline) function? */ #ifndef __BCC__ diff --git a/libc/sysdeps/linux/common/clock_settime.c b/libc/sysdeps/linux/common/clock_settime.c index 40dadc78d..e2ec03f78 100644 --- a/libc/sysdeps/linux/common/clock_settime.c +++ b/libc/sysdeps/linux/common/clock_settime.c @@ -19,6 +19,8 @@ * */ +#define settimeofday __settimeofday + #define _GNU_SOURCE #include "syscalls.h" #include <time.h> diff --git a/libc/sysdeps/linux/common/cmsg_nxthdr.c b/libc/sysdeps/linux/common/cmsg_nxthdr.c index cc17c28f5..771f5172b 100644 --- a/libc/sysdeps/linux/common/cmsg_nxthdr.c +++ b/libc/sysdeps/linux/common/cmsg_nxthdr.c @@ -21,9 +21,8 @@ #include <features.h> #include <sys/socket.h> - struct cmsghdr attribute_hidden * -__libc_cmsg_nxthdr (struct msghdr *mhdr, struct cmsghdr *cmsg) +__cmsg_nxthdr_internal (struct msghdr *mhdr, struct cmsghdr *cmsg) { if ((size_t) cmsg->cmsg_len < sizeof (struct cmsghdr)) /* The kernel header does this so there may be a reason. */ @@ -39,4 +38,4 @@ __libc_cmsg_nxthdr (struct msghdr *mhdr, struct cmsghdr *cmsg) return NULL; return cmsg; } -strong_alias(__libc_cmsg_nxthdr,__cmsg_nxthdr) +strong_alias(__cmsg_nxthdr_internal,__cmsg_nxthdr) diff --git a/libc/sysdeps/linux/common/execve.c b/libc/sysdeps/linux/common/execve.c index cb5e86da7..8a95746ee 100644 --- a/libc/sysdeps/linux/common/execve.c +++ b/libc/sysdeps/linux/common/execve.c @@ -16,7 +16,8 @@ static inline _syscall3(int, __syscall_execve, const char *, filename, char *const *, argv, char *const *, envp); -int execve(const char * filename, char *const * argv, char *const * envp) +int attribute_hidden __execve(const char * filename, char *const * argv, char *const * envp) { return __syscall_execve(filename, argv, envp); } +strong_alias(__execve,execve) diff --git a/libc/sysdeps/linux/common/fchdir.c b/libc/sysdeps/linux/common/fchdir.c index 55ee3a2a8..f4692cc2c 100644 --- a/libc/sysdeps/linux/common/fchdir.c +++ b/libc/sysdeps/linux/common/fchdir.c @@ -9,4 +9,6 @@ #include "syscalls.h" #include <unistd.h> -_syscall1(int, fchdir, int, fd); +#define __NR___fchdir __NR_fchdir +attribute_hidden _syscall1(int, __fchdir, int, fd); +strong_alias(__fchdir,fchdir) diff --git a/libc/sysdeps/linux/common/getdents.c b/libc/sysdeps/linux/common/getdents.c index 24ce2c8ba..25b77fe39 100644 --- a/libc/sysdeps/linux/common/getdents.c +++ b/libc/sysdeps/linux/common/getdents.c @@ -28,8 +28,9 @@ #include <sys/types.h> #include <sys/syscall.h> -#undef offsetof +#ifndef offsetof #define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER) +#endif struct kernel_dirent { diff --git a/libc/sysdeps/linux/common/getdents64.c b/libc/sysdeps/linux/common/getdents64.c index a475c948a..d6410262d 100644 --- a/libc/sysdeps/linux/common/getdents64.c +++ b/libc/sysdeps/linux/common/getdents64.c @@ -31,8 +31,9 @@ #if defined __UCLIBC_HAS_LFS__ && defined __NR_getdents64 -#undef offsetof +#ifndef offsetof #define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER) +#endif struct kernel_dirent64 { diff --git a/libc/sysdeps/linux/common/getdirname.c b/libc/sysdeps/linux/common/getdirname.c index d0865fba5..486ee9335 100644 --- a/libc/sysdeps/linux/common/getdirname.c +++ b/libc/sysdeps/linux/common/getdirname.c @@ -37,7 +37,7 @@ get_current_dir_name (void) struct stat dotstat, pwdstat; #endif - pwd = getenv ("PWD"); + pwd = __getenv ("PWD"); if (pwd != NULL #if defined __UCLIBC_HAS_LFS__ && stat64 (".", &dotstat) == 0 diff --git a/libc/sysdeps/linux/common/getdtablesize.c b/libc/sysdeps/linux/common/getdtablesize.c index 8cbcebdce..de3af63d7 100644 --- a/libc/sysdeps/linux/common/getdtablesize.c +++ b/libc/sysdeps/linux/common/getdtablesize.c @@ -27,7 +27,7 @@ /* Return the maximum number of file descriptors the current process could possibly have. */ -int getdtablesize (void) +int attribute_hidden __getdtablesize (void) { struct rlimit ru; @@ -36,4 +36,4 @@ int getdtablesize (void) returns -1. */ return getrlimit (RLIMIT_NOFILE, &ru) < 0 ? __LOCAL_OPEN_MAX : ru.rlim_cur; } - +strong_alias(__getdtablesize,getdtablesize) diff --git a/libc/sysdeps/linux/common/geteuid.c b/libc/sysdeps/linux/common/geteuid.c index 10bcce735..3936739b3 100644 --- a/libc/sysdeps/linux/common/geteuid.c +++ b/libc/sysdeps/linux/common/geteuid.c @@ -7,19 +7,22 @@ * GNU Library General Public License (LGPL) version 2 or later. */ +#define getuid __getuid + #include "syscalls.h" #include <unistd.h> #ifdef __NR_geteuid #define __NR___syscall_geteuid __NR_geteuid static inline _syscall0(int, __syscall_geteuid); -uid_t geteuid(void) +uid_t attribute_hidden __geteuid(void) { return (__syscall_geteuid()); } #else -uid_t geteuid(void) +uid_t attribute_hidden __geteuid(void) { return (getuid()); } #endif +strong_alias(__geteuid,geteuid) diff --git a/libc/sysdeps/linux/common/getpagesize.c b/libc/sysdeps/linux/common/getpagesize.c index 8469cbb76..669cdb075 100644 --- a/libc/sysdeps/linux/common/getpagesize.c +++ b/libc/sysdeps/linux/common/getpagesize.c @@ -22,7 +22,8 @@ extern size_t __pagesize; /* Return the system page size. */ -int attribute_hidden __libc_getpagesize(void) +/* couldn't make __getpagesize hidden, because shm.h uses it in a macro */ +int attribute_hidden __getpagesize_internal(void) { if (__pagesize != 0) return __pagesize; @@ -40,6 +41,6 @@ int attribute_hidden __libc_getpagesize(void) #endif /* NBPG. */ #endif /* EXEC_PAGESIZE. */ } -strong_alias(__libc_getpagesize, __getpagesize) -weak_alias(__getpagesize, getpagesize) +strong_alias(__getpagesize_internal, __getpagesize) +weak_alias(__getpagesize_internal, getpagesize) diff --git a/libc/sysdeps/linux/common/getppid.c b/libc/sysdeps/linux/common/getppid.c index efd542863..b2944e5e0 100644 --- a/libc/sysdeps/linux/common/getppid.c +++ b/libc/sysdeps/linux/common/getppid.c @@ -14,6 +14,6 @@ _syscall0(pid_t, getppid); # else pid_t getppid(void) { - return (getpid()); + return (__getpid()); } # endif diff --git a/libc/sysdeps/linux/common/gettimeofday.c b/libc/sysdeps/linux/common/gettimeofday.c index 88f7f9999..478a4e84d 100644 --- a/libc/sysdeps/linux/common/gettimeofday.c +++ b/libc/sysdeps/linux/common/gettimeofday.c @@ -13,4 +13,3 @@ #define __NR___gettimeofday __NR_gettimeofday attribute_hidden _syscall2(int, __gettimeofday, struct timeval *, tv, struct timezone *, tz); strong_alias(__gettimeofday,gettimeofday) -weak_alias(__gettimeofday,__libc_gettimeofday) diff --git a/libc/sysdeps/linux/common/getuid.c b/libc/sysdeps/linux/common/getuid.c index 40d20f2dd..7c81ccf48 100644 --- a/libc/sysdeps/linux/common/getuid.c +++ b/libc/sysdeps/linux/common/getuid.c @@ -17,7 +17,8 @@ static inline _syscall0(int, __syscall_getuid); -uid_t getuid(void) +uid_t attribute_hidden __getuid(void) { return (__syscall_getuid()); } +strong_alias(__getuid,getuid) diff --git a/libc/sysdeps/linux/common/kill.c b/libc/sysdeps/linux/common/kill.c index d8033fabc..2d1d9ae8a 100644 --- a/libc/sysdeps/linux/common/kill.c +++ b/libc/sysdeps/linux/common/kill.c @@ -14,7 +14,8 @@ #define __NR___syscall_kill __NR_kill static inline _syscall2(int, __syscall_kill, __kernel_pid_t, pid, int, sig); -int kill(pid_t pid, int sig) +int attribute_hidden __kill(pid_t pid, int sig) { return (__syscall_kill(pid, sig)); } +strong_alias(__kill,kill) diff --git a/libc/sysdeps/linux/common/munmap.c b/libc/sysdeps/linux/common/munmap.c index ff94f2235..be631060a 100644 --- a/libc/sysdeps/linux/common/munmap.c +++ b/libc/sysdeps/linux/common/munmap.c @@ -10,4 +10,6 @@ #include "syscalls.h" #include <unistd.h> #include <sys/mman.h> -_syscall2(int, munmap, void *, start, size_t, length); +#define __NR___munmap __NR_munmap +attribute_hidden _syscall2(int, __munmap, void *, start, size_t, length); +strong_alias(__munmap,munmap) diff --git a/libc/sysdeps/linux/common/ntp_gettime.c b/libc/sysdeps/linux/common/ntp_gettime.c index 07f380402..0c4d1549f 100644 --- a/libc/sysdeps/linux/common/ntp_gettime.c +++ b/libc/sysdeps/linux/common/ntp_gettime.c @@ -16,6 +16,8 @@ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ +#define adjtimex __adjtimex + #include <sys/timex.h> int ntp_gettime(struct ntptimeval *ntv) diff --git a/libc/sysdeps/linux/common/poll.c b/libc/sysdeps/linux/common/poll.c index 87d0dbb27..f021e0269 100644 --- a/libc/sysdeps/linux/common/poll.c +++ b/libc/sysdeps/linux/common/poll.c @@ -17,6 +17,8 @@ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ +#define getdtablesize __getdtablesize + #include "syscalls.h" #include <sys/poll.h> diff --git a/libc/sysdeps/linux/common/setitimer.c b/libc/sysdeps/linux/common/setitimer.c index 981f1a158..be51cb5c5 100644 --- a/libc/sysdeps/linux/common/setitimer.c +++ b/libc/sysdeps/linux/common/setitimer.c @@ -9,5 +9,7 @@ #include "syscalls.h" #include <sys/time.h> -_syscall3(int, setitimer, __itimer_which_t, which, +#define __NR___setitimer __NR_setitimer +attribute_hidden _syscall3(int, __setitimer, __itimer_which_t, which, const struct itimerval *, new, struct itimerval *, old); +strong_alias(__setitimer,setitimer) diff --git a/libc/sysdeps/linux/common/settimeofday.c b/libc/sysdeps/linux/common/settimeofday.c index b63c421c7..4e88b3edb 100644 --- a/libc/sysdeps/linux/common/settimeofday.c +++ b/libc/sysdeps/linux/common/settimeofday.c @@ -9,5 +9,7 @@ #include "syscalls.h" #include <sys/time.h> -_syscall2(int, settimeofday, const struct timeval *, tv, +#define __NR___settimeofday __NR_settimeofday +attribute_hidden _syscall2(int, __settimeofday, const struct timeval *, tv, const struct timezone *, tz); +strong_alias(__settimeofday,settimeofday) diff --git a/libc/sysdeps/linux/common/ssp.c b/libc/sysdeps/linux/common/ssp.c index 4c52d070f..7a977f56a 100644 --- a/libc/sysdeps/linux/common/ssp.c +++ b/libc/sysdeps/linux/common/ssp.c @@ -16,12 +16,29 @@ * Mike Frysinger <vapier[@]gentoo.org> */ +#if defined __SSP__ || defined __SSP_ALL__ +#error "file must not be compiled with stack protection enabled on it. Use -fno-stack-protector" +#endif + +#ifdef __PROPOLICE_BLOCK_SEGV__ +# define SSP_SIGTYPE SIGSEGV +#else +# define SSP_SIGTYPE SIGABRT +#endif + +#define openlog __openlog +#define syslog __syslog +#define closelog __closelog +#define sigfillset __sigfillset_internal +#define sigdelset __sigdelset_internal +#define sigaction __sigaction_internal +#define kill __kill + #include <string.h> #include <unistd.h> +#include <signal.h> #include <sys/syslog.h> -#include <ssp-internal.h> - static __always_inline void block_signals(void) { struct sigaction sa; @@ -37,7 +54,7 @@ static __always_inline void block_signals(void) sigfillset(&sa.sa_mask); /* Block all signals */ sa.sa_flags = 0; sa.sa_handler = SIG_DFL; - SIGACTION(SSP_SIGTYPE, &sa, NULL); + sigaction(SSP_SIGTYPE, &sa, NULL); } static __always_inline void ssp_write(int fd, const char *msg1, const char *msg2, const char *msg3) @@ -46,15 +63,15 @@ static __always_inline void ssp_write(int fd, const char *msg1, const char *msg2 __write(fd, msg2, __strlen(msg2)); __write(fd, msg3, __strlen(msg3)); __write(fd, "()\n", 3); - openlog("ssp", LOG_CONS | LOG_PID, LOG_USER); - syslog(LOG_INFO, "%s%s%s()", msg1, msg2, msg3); - closelog(); + __openlog("ssp", LOG_CONS | LOG_PID, LOG_USER); + __syslog(LOG_INFO, "%s%s%s()", msg1, msg2, msg3); + __closelog(); } -static __always_inline void terminate(void) +static __always_inline attribute_noreturn void terminate(void) { - (void) KILL(GETPID(), SSP_SIGTYPE); - EXIT(127); + (void) kill(__getpid(), SSP_SIGTYPE); + _exit(127); } void attribute_noreturn __stack_smash_handler(char func[], int damaged __attribute__ ((unused))); diff --git a/libc/sysdeps/linux/common/stime.c b/libc/sysdeps/linux/common/stime.c index 586088695..bfb7682d0 100644 --- a/libc/sysdeps/linux/common/stime.c +++ b/libc/sysdeps/linux/common/stime.c @@ -7,6 +7,8 @@ * GNU Library General Public License (LGPL) version 2 or later. */ +#define settimeofday __settimeofday + #include "syscalls.h" #include <time.h> #include <sys/time.h> diff --git a/libc/sysdeps/linux/common/time.c b/libc/sysdeps/linux/common/time.c index 0c37c375c..506850ff9 100644 --- a/libc/sysdeps/linux/common/time.c +++ b/libc/sysdeps/linux/common/time.c @@ -11,9 +11,10 @@ #include <time.h> #include <sys/time.h> #ifdef __NR_time -_syscall1(time_t, time, time_t *, t); +#define __NR___time __NR_time +attribute_hidden _syscall1(time_t, __time, time_t *, t); #else -time_t time(time_t * t) +time_t attribute_hidden __time(time_t * t) { time_t result; struct timeval tv; @@ -29,3 +30,4 @@ time_t time(time_t * t) return result; } #endif +strong_alias(__time,time) diff --git a/libc/sysdeps/linux/common/times.c b/libc/sysdeps/linux/common/times.c index beb07fb35..0fefdca10 100644 --- a/libc/sysdeps/linux/common/times.c +++ b/libc/sysdeps/linux/common/times.c @@ -9,4 +9,6 @@ #include "syscalls.h" #include <sys/times.h> -_syscall1(clock_t, times, struct tms *, buf); +#define __NR___times __NR_times +attribute_hidden _syscall1(clock_t, __times, struct tms *, buf); +strong_alias(__times,times) diff --git a/libc/sysdeps/linux/common/utime.c b/libc/sysdeps/linux/common/utime.c index d7a71d690..5515488cd 100644 --- a/libc/sysdeps/linux/common/utime.c +++ b/libc/sysdeps/linux/common/utime.c @@ -7,14 +7,17 @@ * GNU Library General Public License (LGPL) version 2 or later. */ +#define utimes __utimes + #include "syscalls.h" #include <utime.h> #ifdef __NR_utime -_syscall2(int, utime, const char *, file, const struct utimbuf *, times); +#define __NR___utime __NR_utime +attribute_hidden _syscall2(int, __utime, const char *, file, const struct utimbuf *, times); #else #include <stdlib.h> #include <sys/time.h> -int utime(const char *file, const struct utimbuf *times) +int attribute_hidden __utime(const char *file, const struct utimbuf *times) { struct timeval timevals[2]; @@ -32,3 +35,4 @@ int utime(const char *file, const struct utimbuf *times) return utimes(file, timevals); } #endif +strong_alias(__utime,utime) diff --git a/libc/sysdeps/linux/common/utimes.c b/libc/sysdeps/linux/common/utimes.c index ef0fffe11..ca45204c7 100644 --- a/libc/sysdeps/linux/common/utimes.c +++ b/libc/sysdeps/linux/common/utimes.c @@ -7,14 +7,17 @@ * GNU Library General Public License (LGPL) version 2 or later. */ +#define utime __utime + #include "syscalls.h" #include <utime.h> #ifdef __NR_utimes -_syscall2(int, utimes, const char *, file, const struct timeval *, tvp); +#define __NR___utimes __NR_utimes +attribute_hidden _syscall2(int, __utimes, const char *, file, const struct timeval *, tvp); #else #include <stdlib.h> #include <sys/time.h> -int utimes(const char *file, const struct timeval tvp[2]) +int attribute_hidden __utimes(const char *file, const struct timeval tvp[2]) { struct utimbuf buf, *times; @@ -28,3 +31,4 @@ int utimes(const char *file, const struct timeval tvp[2]) return utime(file, times); } #endif +strong_alias(__utimes,utimes) diff --git a/libc/sysdeps/linux/common/wait.c b/libc/sysdeps/linux/common/wait.c index 6c46d0caa..b2a6d2295 100644 --- a/libc/sysdeps/linux/common/wait.c +++ b/libc/sysdeps/linux/common/wait.c @@ -1,3 +1,5 @@ +#define wait4 __wait4 + #include <stdlib.h> #include <syscall.h> #include <sys/types.h> @@ -6,8 +8,8 @@ /* Wait for a child to die. When one does, put its status in *STAT_LOC * and return its process ID. For errors, return (pid_t) -1. */ -__pid_t __libc_wait (__WAIT_STATUS_DEFN stat_loc) +__pid_t wait (__WAIT_STATUS_DEFN stat_loc) { - return wait4 (WAIT_ANY, stat_loc, 0, (struct rusage *) NULL); + return __wait4 (WAIT_ANY, stat_loc, 0, (struct rusage *) NULL); } -weak_alias(__libc_wait, wait) +weak_alias(wait,__libc_wait) diff --git a/libc/sysdeps/linux/common/wait3.c b/libc/sysdeps/linux/common/wait3.c index 6a8bc77fc..4b4d6aef1 100644 --- a/libc/sysdeps/linux/common/wait3.c +++ b/libc/sysdeps/linux/common/wait3.c @@ -1,3 +1,5 @@ +#define wait4 __wait4 + #include <syscall.h> #include <sys/types.h> #include <sys/wait.h> diff --git a/libc/sysdeps/linux/common/wait4.c b/libc/sysdeps/linux/common/wait4.c index 5434a009e..b5a2c5933 100644 --- a/libc/sysdeps/linux/common/wait4.c +++ b/libc/sysdeps/linux/common/wait4.c @@ -14,7 +14,8 @@ static inline _syscall4(int, __syscall_wait4, __kernel_pid_t, pid, int *, status, int, opts, struct rusage *, rusage); -pid_t wait4(pid_t pid, int *status, int opts, struct rusage *rusage) +pid_t attribute_hidden __wait4(pid_t pid, int *status, int opts, struct rusage *rusage) { return (__syscall_wait4(pid, status, opts, rusage)); } +strong_alias(__wait4,wait4) diff --git a/libc/sysdeps/linux/common/waitpid.c b/libc/sysdeps/linux/common/waitpid.c index fef93173b..612917fcf 100644 --- a/libc/sysdeps/linux/common/waitpid.c +++ b/libc/sysdeps/linux/common/waitpid.c @@ -1,11 +1,14 @@ +#define wait4 __wait4 + #include <stdlib.h> #include <sys/types.h> #include <sys/types.h> #include <sys/wait.h> #include <sys/resource.h> -__pid_t __libc_waitpid(__pid_t pid, int *wait_stat, int options) +__pid_t attribute_hidden __waitpid(__pid_t pid, int *wait_stat, int options) { - return wait4(pid, wait_stat, options, NULL); + return __wait4(pid, wait_stat, options, NULL); } -weak_alias(__libc_waitpid, waitpid) +strong_alias(__waitpid,waitpid) +weak_alias(__waitpid,__libc_waitpid) |
