This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

dup3 PLT usage (was: GNU C Library master sources branch, master, updated. glibc-2.15-829-gf42d41d)


Hi!

On 10 May 2012 23:18:22 -0000, roland@sourceware.org wrote:
> http://sources.redhat.com/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=5aa3a74a59916b489e9cf7c4dce9eb149e106c6c
> 
> commit 5aa3a74a59916b489e9cf7c4dce9eb149e106c6c
> Author: Thomas Schwinge <thomas@schwinge.name>
> Date:   Thu May 10 13:15:40 2012 -0700
> 
>     Hurd: dup3
> 
> diff --git a/ChangeLog b/ChangeLog
> index cab0489..9e747cd 100644
> --- a/ChangeLog
> +++ b/ChangeLog
> @@ -1,3 +1,12 @@
> +2012-05-10  Thomas Schwinge  <thomas@schwinge.name>
> +
> +	dup3 for GNU Hurd.
> +	* include/unistd.h: Declare __dup3 and use libc_hidden_proto on it.
> +	* sysdeps/mach/hurd/dup3.c: New file, copy from dup2.c.  Evolve it to
> +	implement dup3 and do some further code clean-ups.
> +	* sysdeps/mach/hurd/dup2.c (__dup2): Reimplement using __dup3.
> +	* sysdeps/mach/hurd/kernel-features.h (__ASSUME_DUP3): Define.

This causes ÂExtra PLT reference: libc.so: dup3Â for GNU/Linux; here is a
patch, tested for x86 and x86_64.  OK to commit?

2012-05-11  Thomas Schwinge  <thomas@codesourcery.com>

	* 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.

diff --git a/io/dup3.c b/io/dup3.c
index 90a3d60..7e97bf7 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 <stub-tag.h>
diff --git a/libio/freopen.c b/libio/freopen.c
index 025c55b..fa89c27 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 24d0360..c28a992 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 5c696b3..39c40ed 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


GrÃÃe,
 Thomas

Attachment: pgp00000.pgp
Description: PGP signature


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]