This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
[PATCH] Change libc internal use of dup2 to __dup2 to avoid PLTcall.
On Thu, 2011-05-19 at 12:25 -0400, Carlos O'Donell wrote:
> On 5/8/2011 11:37 PM, Ulrich Drepper wrote:
> > In the next days 2.14 should probably be released. I've fixed a few
> > more bugs and might do some more work tomorrow. If you have a chance
> > give the current git tree a twirl.
>
> When enabling lower linux kernel versions I see the following.
>
> In libio/freopen64.c and libio/freopen.c the use of dup2 regresses the
> check-localplt test with:
>
> --- ../scripts/data/localplt-i386-linux-gnu.data 2011-02-17
> 16:54:08.071056456 -0500
> +++ - 2011-05-18 21:32:21.236155128 -0400
> @@ -1,5 +1,6 @@
> libc.so: _Unwind_Find_FDE
> libc.so: calloc
> +libc.so: dup2
> libc.so: free
> libc.so: malloc
> libc.so: memalign
>
> The code in libio/freopen64.c and libio/freopen.c should call __dup2.
>
> Cheers,
> Carlos.
Here's a patch to make it easy. I added Carlos to the ChangeLog since
he found the place to make the change.
Ryan S. Arnold
IBM Linux Technology Center
2011-05-19 Carlos O'Donell <carlos@codesourcery.com>
Ryan S. Arnold <rsa@us.ibm.com>
* libio/freopen.c (freopen): Remove libc internal PLT call by changing
dup2 to __dup2.
* libio/freopen64.c (freopen64): Likewise.
diff --git a/libio/freopen.c b/libio/freopen.c
index 20eda9d..ee98b6e 100644
--- a/libio/freopen.c
+++ b/libio/freopen.c
@@ -102,7 +102,7 @@ freopen (filename, mode, fp)
if (errno == ENOSYS)
__have_dup3 = -1;
- dup2 (_IO_fileno (result), fd);
+ __dup2 (_IO_fileno (result), fd);
if ((result->_flags2 & _IO_FLAGS2_CLOEXEC) != 0)
__fcntl (fd, F_SETFD, FD_CLOEXEC);
}
diff --git a/libio/freopen64.c b/libio/freopen64.c
index 99045c6..6c4a20f 100644
--- a/libio/freopen64.c
+++ b/libio/freopen64.c
@@ -86,7 +86,7 @@ freopen64 (filename, mode, fp)
if (errno == ENOSYS)
__have_dup3 = -1;
- dup2 (_IO_fileno (result), fd);
+ __dup2 (_IO_fileno (result), fd);
if ((result->_flags2 & _IO_FLAGS2_CLOEXEC) != 0)
__fcntl (fd, F_SETFD, FD_CLOEXEC);
}