From dc70356cbfc649af8e39c9a8d509fefd766fa8ef Mon Sep 17 00:00:00 2001 From: Thomas Schwinge Date: Sat, 12 May 2012 10:53:04 +0800 Subject: [PATCH] Avoid dup3 PLT usage. Fixes fallout from 5aa3a74a59916b489e9cf7c4dce9eb149e106c6c. --- ChangeLog | 7 +++++++ io/dup3.c | 5 +++-- libio/freopen.c | 6 +++--- libio/freopen64.c | 6 +++--- sysdeps/unix/syscalls.list | 2 +- 5 files changed, 17 insertions(+), 9 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0c4a814167..8a10d6ab09 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2012-05-12 Thomas Schwinge + + * io/dup3.c (dup3): Rename to __dup3, add weak alias for dup3. + * sysdeps/unix/syscalls.list (dup3): Likewise. + * libio/freopen.c (freopen): Invoke __dup3 instead of dup3. + * libio/freopen64.c (freopen64): Invoke __dup3 instead of dup3. + 2012-05-11 H.J. Lu * elf/stackguard-macros.h (STACK_CHK_GUARD) [__x86_64__]: Use diff --git a/io/dup3.c b/io/dup3.c index 90a3d60898..7e97bf733c 100644 --- a/io/dup3.c +++ b/io/dup3.c @@ -24,7 +24,7 @@ open the same file as FD is which setting flags according to FLAGS. Return FD2 or -1. */ int -dup3 (fd, fd2, flags) +__dup3 (fd, fd2, flags) int fd; int fd2; int flags; @@ -42,7 +42,8 @@ dup3 (fd, fd2, flags) __set_errno (ENOSYS); return -1; } -libc_hidden_def (dup3) +libc_hidden_def (__dup3) +weak_alias (__dup3, dup3) stub_warning (dup3) #include diff --git a/libio/freopen.c b/libio/freopen.c index 025c55b655..fa89c277c6 100644 --- a/libio/freopen.c +++ b/libio/freopen.c @@ -89,9 +89,9 @@ freopen (filename, mode, fp) else newfd = # endif - dup3 (_IO_fileno (result), fd, - (result->_flags2 & _IO_FLAGS2_CLOEXEC) != 0 - ? O_CLOEXEC : 0); + __dup3 (_IO_fileno (result), fd, + (result->_flags2 & _IO_FLAGS2_CLOEXEC) != 0 + ? O_CLOEXEC : 0); #else # define newfd 1 #endif diff --git a/libio/freopen64.c b/libio/freopen64.c index 24d0360625..c28a9925f0 100644 --- a/libio/freopen64.c +++ b/libio/freopen64.c @@ -73,9 +73,9 @@ freopen64 (filename, mode, fp) else newfd = # endif - dup3 (_IO_fileno (result), fd, - (result->_flags2 & _IO_FLAGS2_CLOEXEC) != 0 - ? O_CLOEXEC : 0); + __dup3 (_IO_fileno (result), fd, + (result->_flags2 & _IO_FLAGS2_CLOEXEC) != 0 + ? O_CLOEXEC : 0); #else # define newfd 1 #endif diff --git a/sysdeps/unix/syscalls.list b/sysdeps/unix/syscalls.list index 5c696b31cb..39c40ed7f6 100644 --- a/sysdeps/unix/syscalls.list +++ b/sysdeps/unix/syscalls.list @@ -10,7 +10,7 @@ chroot - chroot i:s chroot close - close Ci:i __libc_close __close close dup - dup i:i __dup dup dup2 - dup2 i:ii __dup2 dup2 -dup3 - dup3 i:iii dup3 +dup3 - dup3 i:iii __dup3 dup3 fchdir - fchdir i:i __fchdir fchdir fchmod - fchmod i:ii __fchmod fchmod fchown - fchown i:iii __fchown fchown