[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
use of __gen_tempname
From: |
Bruno Haible |
Subject: |
use of __gen_tempname |
Date: |
Tue, 7 Nov 2006 14:40:31 +0100 |
User-agent: |
KMail/1.9.1 |
Hi Eric,
Sorry for the late remark. (I haven't been able to follow the tempname
thread.)
In lib/tempname.c you added code that uses the function __gen_tempname from
libc if it is present. I assume this is for glibc? This __gen_tempname
function is not part of the public ABI of glibc: it is not listed in any
of the 'Versions' files in glibc-2.3.6 nor glibc-2.5. In fact, on a
glibc-2.3.6 system where glibc was built with sufficiently recent gcc
and binutils, the symbol is not exported:
$ nm /lib/libc.so.6 | grep gen_tempname
000554b0 t __gen_tempname
$ nm --dynamic /lib/libc.so.6 | grep gen_tempname
$
This means that when a user builds binaries from this code on an older
glibc, the binaries refer to __gen_tempname and will refuse to run when
the user upgrades to glibc-2.3.6 or newer.
The same mistake has been made by the Sun engineers responsible for the
JDK 1.3.1 for Linux. They shipped hundreds of thousands of copies of a 'java'
binary referring to the symbol __libc_wait. Users then had a bad surprise
when they switched to a newer Linux distribution: their JDK stopped working.
Some of them asked me for advice, because they found my name in related
postings...
I think it is preferable to build a binary that is 1 KB bigger but
continues working after an OS upgrade. Hence this proposed patch.
2006-11-06 Bruno Haible <address@hidden>
* lib/tempname.c (gen_tempname): Remove variant that invokes
__gen_tempname.
* m4/tempname.m4 (gl_FUNC_GEN_TEMPNAME): Don't test for __gen_tempname.
*** gnulib-20061106/lib/tempname.c 2006-11-07 01:19:06.000000000 +0100
--- gnulib-20061106-modified/lib/tempname.c 2006-11-07 01:31:01.000000000
+0100
***************
*** 200,206 ****
__GT_DIR: create a directory, which will be mode 0700.
We use a clever algorithm to get hard-to-predict names. */
- #if _LIBC || !HAVE___GEN_TEMPNAME
int
__gen_tempname (char *tmpl, int kind)
{
--- 200,205 ----
***************
*** 321,335 ****
__set_errno (EEXIST);
return -1;
}
-
- #else /* !_LIBC && HAVE___GEN_TEMPNAME */
-
- # undef __gen_tempname
- extern int __gen_tempname (char *, int);
- int
- gen_tempname (char *tmpl, int kind)
- {
- return __gen_tempname (tmpl, kind);
- }
-
- #endif /* !_LIBC && HAVE___GEN_TEMPNAME */
--- 320,322 ----
*** gnulib-20061106/m4/tempname.m4 2006-10-27 15:51:23.000000000 +0200
--- gnulib-20061106-modified/m4/tempname.m4 2006-11-07 01:31:38.000000000
+0100
***************
*** 1,16 ****
! #serial 1
# Copyright (C) 2006 Free Software Foundation, Inc.
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
- # glibc provides __gen_tempname as a wrapper for mk[ds]temp. Expose
- # it as a public API, and provide it on systems that are lacking.
AC_DEFUN([gl_FUNC_GEN_TEMPNAME],
[
AC_REQUIRE([AC_SYS_LARGEFILE])
- AC_CHECK_FUNCS_ONCE([__gen_tempname])
AC_LIBOBJ([tempname])
gl_PREREQ_TEMPNAME
--- 1,13 ----
! #serial 2
# Copyright (C) 2006 Free Software Foundation, Inc.
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
AC_DEFUN([gl_FUNC_GEN_TEMPNAME],
[
AC_REQUIRE([AC_SYS_LARGEFILE])
AC_LIBOBJ([tempname])
gl_PREREQ_TEMPNAME
- use of __gen_tempname,
Bruno Haible <=