This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Re: libc/1818: pthread problem with dlcose()
- To: drepper at cygnus dot com, binutils at sourceware dot cygnus dot com,kettenis at wins dot uva dot nl, libc-hacker at sourceware dot cygnus dot com
- Subject: Re: libc/1818: pthread problem with dlcose()
- From: "H . J . Lu" <hjl at lucon dot org>
- Date: Tue, 18 Jul 2000 23:51:48 -0700
- References: <200007190007.e6J07gm14827@delius.kettenis.local> <m3r98r0y8e.fsf@otr.mynet.cygnus.com> <20000718212703.A614@lucon.org> <20000719043514.1575.qmail@daffy.airs.com>
On Tue, Jul 18, 2000 at 09:35:14PM -0700, Ian Lance Taylor wrote:
> Date: Tue, 18 Jul 2000 21:27:03 -0700
> From: "H . J . Lu" <hjl@lucon.org>
>
> > Solaris solves the problem (they also don't allow unloading the thread
> > library) is by having the flag DF_1_NODELETE set in the FLAGS_1 word
> > of the thread library. This is a much more worthwhile way to handle
> > this.
>
> Here is the patch for binutils. Ian, any comments?
>
> Parsing a string inside BFD seems very weird to me. The linker should
> handle parsing, and should tell BFD what to do.
>
I include "elf/common.h" in elf32.em. Is that ok?
> gcc will sometimes pass -z text to the Solaris linker. I believe that
> this patch will cause the linker to produce a fatal error when that
> happens. Without this patch, the -z option will be ignored.
I will ignore the unrecognized the -z options.
>
> Are these -z options compatible with existing Solaris options? That
> is, has Solaris added these to the set of -z options? Or are you
> making them up? If the latter, how does the Solaris linker decide
> when to set these flag bits.
I looked up the ld man page on Solaris 2.7. I believe my interpretation
is correct. I only kept the options which say "marks the object" in
the mag page.
>
> You need to add documentation to ld.texinfo for these new options. I
> personally have no idea what they mean.
>
Here is the new patch.
Thanks.
H.J.
---
2000-07-18 H.J. Lu <hjl@gnu.org>
* bfd/elflink.h (NAME(bfd_elf,size_dynamic_sections)): Also
set DF_SYMBOLIC for symbolic link.
Set the DT_FLAGS and DT_FLAGS_1 entries if necessary.
Index: bfd/elflink.h
===================================================================
RCS file: /work/cvs/gnu/binutils/bfd/elflink.h,v
retrieving revision 1.34
diff -u -p -r1.34 elflink.h
--- bfd/elflink.h 2000/07/19 00:30:54 1.34
+++ bfd/elflink.h 2000/07/19 06:41:53
@@ -2837,6 +2837,7 @@ NAME(bfd_elf,size_dynamic_sections) (out
{
if (! elf_add_dynamic_entry (info, DT_SYMBOLIC, 0))
return false;
+ info->flags |= DF_SYMBOLIC;
}
if (rpath != NULL)
@@ -3133,6 +3134,22 @@ NAME(bfd_elf,size_dynamic_sections) (out
return false;
elf_tdata (output_bfd)->cverdefs = cdefs;
+ }
+
+ if (info->flags)
+ {
+ if (! elf_add_dynamic_entry (info, DT_FLAGS, info->flags))
+ return false;
+ }
+
+ if (info->flags_1)
+ {
+ if (! info->shared)
+ info->flags_1 &= ~ (DF_1_INITFIRST
+ | DF_1_NODELETE
+ | DF_1_NOOPEN);
+ if (! elf_add_dynamic_entry (info, DT_FLAGS_1, info->flags_1))
+ return false;
}
/* Work out the size of the version reference section. */
2000-07-18 H.J. Lu (hjl@gnu.org)
* (bfd_link_info): Add flags and flags_1.
Index: include/bfdlink.h
===================================================================
RCS file: /work/cvs/gnu/binutils/include/bfdlink.h,v
retrieving revision 1.7
diff -u -p -r1.7 bfdlink.h
--- include/bfdlink.h 2000/05/18 22:10:35 1.7
+++ include/bfdlink.h 2000/07/19 03:19:57
@@ -246,6 +246,12 @@ struct bfd_link_info
/* The function to call when the executable or shared object is
unloaded. */
const char *fini_function;
+
+ /* May be used to set DT_FLAGS for ELF. */
+ bfd_vma flags;
+
+ /* May be used to set DT_FLAGS_1 for ELF. */
+ bfd_vma flags_1;
};
/* This structures holds a set of callback functions. These are
2000-07-18 H.J. Lu <hjl@gnu.org>
* ldmain.c (main): Clear link_info.flags and link_info.flags_1.
* lexsup.c (ld_options): Comment out 'z'.
(parse_args): Likewise.
* emultempl/elf32.em: Include "elf/common.h".
(gld_${EMULATION_NAME}_parse_args): Defined. Handle some -z
options.
(gld_${EMULATION_NAME}_list_options): Likewise.
* ld.texinfo: Add documentation for the recognized -z options.
Index: ld/ld.texinfo
===================================================================
RCS file: /work/cvs/gnu/binutils/ld/ld.texinfo,v
retrieving revision 1.4
diff -u -p -r1.4 ld.texinfo
--- ld/ld.texinfo 2000/06/20 17:47:43 1.4
+++ ld/ld.texinfo 2000/07/19 06:33:20
@@ -737,7 +737,15 @@ for Solaris compatibility.
@kindex -z @var{keyword}
@item -z @var{keyword}
-This option is ignored for Solaris compatibility.
+The recognized keywords are @var{initfirst}, @var{loadfltr},
+@var{now}, @var{nodlopen}, @var{nodelete} and @var{origin}. The other
+keywords are ignored for Solaris compatibility. @var{initfirst}
+marks the object to be initialized first at runtime before any other
+objects. @var{loadfltr} marks the object that its filtees be processed
+immediately at runtime. @var{now} marks the object with the non-lazy
+runtime binding. @var{nodlopen} marks the object not available to
+dlopen. @var{nodelete} marks the object shouldn't be unloaded at
+runtime. @var{origin} marks the object may contain $ORIGIN.
@kindex -(
@cindex groups of archives
Index: ld/ldmain.c
===================================================================
RCS file: /work/cvs/gnu/binutils/ld/ldmain.c,v
retrieving revision 1.13
diff -u -p -r1.13 ldmain.c
--- ld/ldmain.c 2000/07/13 16:00:36 1.13
+++ ld/ldmain.c 2000/07/19 03:26:51
@@ -238,6 +238,8 @@ main (argc, argv)
and _fini symbols. We are compatible. */
link_info.init_function = "_init";
link_info.fini_function = "_fini";
+ link_info.flags = (bfd_vma) 0;
+ link_info.flags_1 = (bfd_vma) 0;
ldfile_add_arch ("");
Index: ld/lexsup.c
===================================================================
RCS file: /work/cvs/gnu/binutils/ld/lexsup.c,v
retrieving revision 1.17
diff -u -p -r1.17 lexsup.c
--- ld/lexsup.c 2000/07/09 23:42:05 1.17
+++ ld/lexsup.c 2000/07/19 01:48:46
@@ -241,8 +241,10 @@ static const struct ld_option ld_options
'y', N_("SYMBOL"), N_("Trace mentions of SYMBOL"), TWO_DASHES },
{ {NULL, required_argument, NULL, '\0'},
'Y', N_("PATH"), N_("Default search path for Solaris compatibility"), ONE_DASH },
+#if 0
{ {NULL, required_argument, NULL, '\0'},
'z', N_("KEYWORD"), N_("Ignored for Solaris compatibility"), ONE_DASH },
+#endif
{ {"start-group", no_argument, NULL, '('},
'(', NULL, N_("Start a group"), TWO_DASHES },
{ {"end-group", no_argument, NULL, ')'},
@@ -1015,11 +1017,13 @@ the GNU General Public License. This pr
case 'y':
add_ysym (optarg);
break;
+#if 0
case 'z':
/* We accept and ignore this option for Solaris
compatibility. Actually, on Solaris, optarg is not
ignored. Someday we should handle it correctly. FIXME. */
break;
+#endif
case OPTION_SPLIT_BY_RELOC:
config.split_by_reloc = strtoul (optarg, NULL, 0);
break;
Index: ld/emultempl/elf32.em
===================================================================
RCS file: /work/cvs/gnu/binutils/ld/emultempl/elf32.em,v
retrieving revision 1.18
diff -u -p -r1.18 elf32.em
--- ld/emultempl/elf32.em 2000/07/19 00:15:32 1.18
+++ ld/emultempl/elf32.em 2000/07/19 06:39:26
@@ -45,6 +45,7 @@ Foundation, Inc., 59 Temple Place - Suit
#include "ldfile.h"
#include "ldemul.h"
#include "ldgram.h"
+#include "elf/common.h"
static void gld${EMULATION_NAME}_before_parse PARAMS ((void));
static boolean gld${EMULATION_NAME}_open_dynamic_archive
@@ -1188,20 +1189,91 @@ cat >>e${EMULATION_NAME}.c <<EOF
else
return "ldscripts/${EMULATION_NAME}.x";
}
-EOF
-if test -n "$PARSE_AND_LIST_ARGS" ; then
-cat >>e${EMULATION_NAME}.c <<EOF
static int gld_${EMULATION_NAME}_parse_args PARAMS ((int, char **));
static void gld_${EMULATION_NAME}_list_options PARAMS ((FILE * file));
+EOF
+
+if test -n "$PARSE_AND_LIST_ARGS" ; then
+cat >>e${EMULATION_NAME}.c <<EOF
$PARSE_AND_LIST_ARGS
EOF
else
cat >>e${EMULATION_NAME}.c <<EOF
-#define gld_${EMULATION_NAME}_parse_args NULL
-#define gld_${EMULATION_NAME}_list_options NULL
+
+#include "getopt.h"
+
+static struct option longopts[] =
+{
+ {NULL, required_argument, NULL, 'z'},
+ {NULL, no_argument, NULL, 0}
+};
+
+static int
+gld_${EMULATION_NAME}_parse_args (argc, argv)
+ int argc;
+ char ** argv;
+{
+ int longind, optc;
+ int prevoptind = optind;
+ int prevopterr = opterr;
+ int wanterror;
+ static int lastoptind = -1;
+
+ if (lastoptind != optind)
+ opterr = 0;
+
+ wanterror = opterr;
+ optc = getopt_long_only (argc, argv, "-z:", longopts, &longind);
+ opterr = prevopterr;
+
+ switch (optc)
+ {
+ default:
+ if (wanterror)
+ xexit (1);
+ optind = prevoptind;
+ return 0;
+
+ case 'z':
+ if (strcmp (optarg, "initfirst") == 0)
+ link_info.flags_1 |= (bfd_vma) DF_1_INITFIRST;
+ else if (strcmp (optarg, "loadfltr") == 0)
+ link_info.flags_1 |= (bfd_vma) DF_1_LOADFLTR;
+ else if (strcmp (optarg, "now") == 0)
+ {
+ link_info.flags |= (bfd_vma) DF_BIND_NOW;
+ link_info.flags_1 |= (bfd_vma) DF_1_NOW;
+ }
+ else if (strcmp (optarg, "nodlopen") == 0)
+ link_info.flags_1 |= (bfd_vma) DF_1_NOOPEN;
+ else if (strcmp (optarg, "nodelete") == 0)
+ link_info.flags_1 |= (bfd_vma) DF_1_NODELETE;
+ else if (strcmp (optarg, "origin") == 0)
+ {
+ link_info.flags |= (bfd_vma) DF_ORIGIN;
+ link_info.flags_1 |= (bfd_vma) DF_1_ORIGIN;
+ }
+ /* What about the other Solaris -z options? FIXME. */
+ break;
+ }
+
+ return 1;
+}
+
+static void
+gld_${EMULATION_NAME}_list_options (file)
+ FILE * file;
+{
+ fprintf (file, _(" -z initfirst\tMark DSO be initialized first at rutime\n"));
+ fprintf (file, _(" -z loadfltr\tMark object requiring immediate process\n"));
+ fprintf (file, _(" -z now\tMark object non-lazy runtime binding\n"));
+ fprintf (file, _(" -z nodlopen\tMark DSO not availale to dlopen\n"));
+ fprintf (file, _(" -z nodelete\tMark DSO as non-deletable at runtime\n"));
+ fprintf (file, _(" -z origin\tMark object as requiring immediate \$ORIGIN processing at runtime\n"));
+}
EOF
fi