* Re: An ELF ld bug?
[not found] <199504142245.SAA13478@churchy.gnu.ai.mit.edu>
@ 1995-04-19 22:36 ` H.J. Lu
0 siblings, 0 replies; only message in thread
From: H.J. Lu @ 1995-04-19 22:36 UTC (permalink / raw)
To: Roland McGrath; +Cc: bfd, gas2
>
> > ctype is a bad example. Try other locale catetories.
>
> What is wrong with ctype? It demonstrates exactly the usage I am talking
> about.
Those ctype files will be needed for other reasons. Please try
the enclosed test case.
>
> > > > BTW, why do you want to mark _nl_xxxxx as weak symbols?
> > >
> > > So that if a program calls setlocale, but uses only (e.g.) the ctype data,
> > > then all the built-in "C" locale data for the other categories need not be
> > > linked in, and setlocale in fact will avoid reading the locale data files
> > > at run time for the unused categories. It makes the program smaller (if
> > > statically linked) and faster.
> > >
> >
> > I am not sure if weak symbol is used for that purpose.
>
> I just told you I am using it for that purpose! And it works fine!
>
> > How does a linker know what categories a setlocal () will use?
>
> Of course the linker doesn't know anything about it! If the program uses
> the locale data, it will refer to _nl_current_LC_* which is defined in
> lc-*.o, and those references will be strong refs not weak ones. Those
> references cause the necessary files to be linked in, regardless of setlocale.
>
> This is why nl_langinfo.c goes to special pains to produce a strong
> reference to each _nl_current_LC_* symbol, because the run-time argument to
> nl_langinfo determines which categories are involved, so all the data is
> potentially needed.
>
As of gas-950417, the ld bug was still not fixed. BTW, I couldn't find
the ChangeLog entry for that fix.
--
H.J. Lu
NYNEX Science and Technology, Inc. hjl@nynexst.com
------
#! /bin/sh
# This is a shell archive. Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file". To overwrite existing
# files, type "sh file -c". You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g.. If this archive is complete, you
# will see the following message at the end:
# "End of shell archive."
# Contents: Makefile bar.c foo.c main.c x.c
# Wrapped by hjl@jalod on Thu Apr 20 01:28:58 1995
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'Makefile' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'Makefile'\"
else
echo shar: Extracting \"'Makefile'\" \(281 characters\)
sed "s/^X//" >'Makefile' <<'END_OF_FILE'
XSRCS= foo.c x.c bar.c
XOBJS=$(SRCS:.c=.o)
XAR=ar
XRANLIB =ranlib
X
X.c.o:
X $(CC) $(CFLAGS) -c $<
X
Xall: f1 f2
X
Xf1: libfoo.a
X $(CC) -o $@ main.c -L. -lfoo
X
Xf2: libfoo.a
X $(CC) -o $@ main.c x.o -L. -lfoo
X
Xlibfoo.a:$(OBJS)
X $(AR) ucvr $@ $(OBJS)
X $(RANLIB) $@
X
Xclean:
X -rm -f *.o *.a f1 f2
END_OF_FILE
if test 281 -ne `wc -c <'Makefile'`; then
echo shar: \"'Makefile'\" unpacked with wrong size!
fi
# end of 'Makefile'
fi
if test -f 'bar.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'bar.c'\"
else
echo shar: Extracting \"'bar.c'\" \(68 characters\)
sed "s/^X//" >'bar.c' <<'END_OF_FILE'
X#include <stdio.h>
X
Xextern int x;
X
Xbar ()
X{
X printf ("%d\n", x);
X}
END_OF_FILE
if test 68 -ne `wc -c <'bar.c'`; then
echo shar: \"'bar.c'\" unpacked with wrong size!
fi
# end of 'bar.c'
fi
if test -f 'foo.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'foo.c'\"
else
echo shar: Extracting \"'foo.c'\" \(85 characters\)
sed "s/^X//" >'foo.c' <<'END_OF_FILE'
X#include <stdio.h>
X
X#pragma weak x
X
Xextern int x;
X
Xfoo ()
X{
X printf ("%d\n", x);
X}
END_OF_FILE
if test 85 -ne `wc -c <'foo.c'`; then
echo shar: \"'foo.c'\" unpacked with wrong size!
fi
# end of 'foo.c'
fi
if test -f 'main.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'main.c'\"
else
echo shar: Extracting \"'main.c'\" \(32 characters\)
sed "s/^X//" >'main.c' <<'END_OF_FILE'
Xmain ()
X{
X foo ();
X bar ();
X}
END_OF_FILE
if test 32 -ne `wc -c <'main.c'`; then
echo shar: \"'main.c'\" unpacked with wrong size!
fi
# end of 'main.c'
fi
if test -f 'x.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'x.c'\"
else
echo shar: Extracting \"'x.c'\" \(12 characters\)
sed "s/^X//" >'x.c' <<'END_OF_FILE'
Xint x = 20;
END_OF_FILE
if test 12 -ne `wc -c <'x.c'`; then
echo shar: \"'x.c'\" unpacked with wrong size!
fi
# end of 'x.c'
fi
echo shar: End of shell archive.
exit 0
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~1995-04-19 22:36 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <199504142245.SAA13478@churchy.gnu.ai.mit.edu>
1995-04-19 22:36 ` An ELF ld bug? H.J. Lu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).