Updated to newest ld from pk.

lib.c:
Pull in archives containing definitions needed by shared objects.
warnings.c:
Less spurious "undefined symbol" msgs for shared library defined
symbols.
ld.c:
Do a better job of recognising data in text segments, eg. `const char []'.
shlib.c,ld/rtld/{Makefile rtld.c}
Use strsep() in stead of strtok() and restore colons in eg. env. vars.
This commit is contained in:
Paul Richards 1993-11-09 04:19:36 +00:00
parent bde1866a63
commit 3923b0019c
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=740
13 changed files with 61 additions and 39 deletions

View file

@ -1,9 +1,9 @@
# $Id: Makefile,v 1.2 1993/11/03 23:40:52 paul Exp $
# $Id: Makefile,v 1.8 1993/11/03 13:01:36 cgd Exp $
#
PROG= ld
SRCS= ld.c symbol.c lib.c shlib.c warnings.c etc.c rrs.c xbits.c md.c
CFLAGS += -I$(.CURDIR) -I$(.CURDIR)/$(MACHINE)
CFLAGS += -g -I$(.CURDIR) -I$(.CURDIR)/$(MACHINE)
LDADD+= -lgnumalloc
DPADD+= /usr/lib/libgnumalloc.a

View file

@ -29,13 +29,10 @@ static char sccsid[] = "@(#)ld.c 6.10 (Berkeley) 5/22/91";
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
/* Written by Richard Stallman with some help from Eric Albert.
Set, indirect, and warning symbol features added by Randy Smith.
NOTE: Set and indirect symbols are no longer supported by this
version. (pk) */
Set, indirect, and warning symbol features added by Randy Smith. */
/*
* $Id: ld.c,v 1.10 1993/11/01 16:26:13 pk Exp $
* $Id: ld.c,v 1.11 1993/11/05 12:47:11 pk Exp $
*/
/* Define how to initialize system-dependent header fields. */
@ -1597,7 +1594,7 @@ digest_pass2()
/*
* It's data from shared object with size info.
*/
if (sp->so_defined != (N_DATA + N_EXT))
if (!sp->so_defined)
fatal("%s: Bogus N_SIZE item", sp->name);
} else
@ -1761,14 +1758,24 @@ consider_relocation (entry, dataseg)
continue;
}
if (force_alias_definition &&
/*
* Only allocate an alias for function calls. Use
* sp->size here as a heuristic to discriminate
* between function definitions and data residing
* in the text segment.
* NOTE THAT THE COMPILER MUST NOT GENERATE ".size"
* DIRECTIVES FOR FUNCTIONS.
* In the future we might go for ".type" directives.
*/
if (force_alias_definition && sp->size == 0 &&
sp->so_defined == N_TEXT + N_EXT) {
/* Call to shared library procedure */
alloc_rrs_jmpslot(sp);
} else if (sp->size &&
sp->so_defined == N_DATA + N_EXT) {
(sp->so_defined == N_DATA + N_EXT ||
sp->so_defined == N_TEXT + N_EXT)) {
/* Reference to shared library data */
alloc_rrs_cpy_reloc(sp);

View file

@ -1,4 +1,4 @@
# $Id: Makefile,v 1.1 1993/11/03 23:41:32 paul Exp $
# $Id: Makefile,v 1.2 1993/11/03 05:20:49 cgd Exp $
PROG= ldconfig
SRCS= ldconfig.c shlib.c etc.c
@ -6,7 +6,7 @@ LDDIR?= $(.CURDIR)/..
LDFLAGS += -static
CFLAGS += -I$(LDDIR) -I$(.CURDIR) -I$(LDDIR)/$(MACHINE) -O
BINDIR= ${DESTDIR}/sbin
MAN8 = ldconfig.8
MAN8 = ldconfig.0
.PATH: $(LDDIR) $(LDDIR)/$(MACHINE)

View file

@ -1,5 +1,5 @@
/*
* $Id: lib.c,v 1.3 1993/11/01 16:26:17 pk Exp $ - library routines
* $Id: lib.c,v 1.4 1993/11/05 12:43:11 pk Exp $ - library routines
*/
#include <sys/param.h>
@ -228,7 +228,8 @@ symdef_library(desc, entry, member_length)
* global common 'utime' linked to a function).
*/
if (!(link_mode & FORCEARCHIVE) &&
(!sp || !sp->referenced || sp->defined))
(!sp || sp->defined ||
(!sp->referenced && !sp->sorefs)) )
continue;
/*
@ -478,14 +479,16 @@ subfile_wanted_p(entry)
if ( (type & N_EXT) &&
(type & N_STAB) == 0 &&
type != (N_UNDF | N_EXT))
goto xxx;
break; /* We need it */
}
if (lsp != NULL)
continue; /* We don't need it */
if (write_map) {
print_file_name(entry, stdout);
fprintf(stdout, " needed due to shared lib ref %s\n", sp->name);
}
return 1;
xxx: ;
}
}

View file

@ -1,4 +1,4 @@
# $Id: Makefile,v 1.1 1993/11/03 23:41:46 paul Exp $
# $Id: Makefile,v 1.3 1993/11/08 13:20:39 pk Exp $
PROG= ld.so
SRCS= mdprologue.S rtld.c shlib.c etc.c md.c
@ -8,7 +8,7 @@ LDDIR?= $(.CURDIR)/..
PICFLAG=-fpic
CFLAGS += -I$(LDDIR) -I$(.CURDIR) -I$(LDDIR)/$(MACHINE) -O $(PICFLAG) -DRTLD
LDFLAGS = -Bshareable -Bsymbolic -assert nosymbolic
LIBS = -lc_pic -lgcc_pic
LIBS = -lc_pic
BINDIR= /usr/libexec
.PATH: $(LDDIR) $(LDDIR)/$(MACHINE)
@ -16,7 +16,7 @@ BINDIR= /usr/libexec
.SUFFIXES: .S
$(PROG):
$(LD) -o $(PROG) $(LDFLAGS) $(OBJS) $(LIBS)
$(LD) -o $(PROG) $(LDFLAGS) $(OBJS) $(LIBS) $(LDADD)
.S.o:
$(CPP) $(.IMPSRC) | $(AS) -k -o $(.TARGET) -

View file

@ -27,7 +27,7 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* $Id: rtld.c,v 1.7 1993/11/03 21:35:54 pk Exp $
* $Id: rtld.c,v 1.8 1993/11/08 13:20:40 pk Exp $
*/
#include <sys/param.h>
@ -888,10 +888,11 @@ int *usehints;
if (ld_path != NULL) {
/* Prefer paths from LD_LIBRARY_PATH */
while ((cp = strtok(ld_path, ":")) != NULL) {
while ((cp = strsep(&ld_path, ":")) != NULL) {
ld_path = NULL;
hint = findhint(name, major, minor, cp);
if (ld_path)
*(ld_path-1) = ':';
if (hint)
return hint;
}

View file

@ -1,5 +1,5 @@
/*
* $Id: shlib.c,v 1.3 1993/10/23 00:34:26 pk Exp $
* $Id: shlib.c,v 1.4 1993/11/08 13:21:23 pk Exp $
*/
#include <sys/param.h>
@ -48,9 +48,10 @@ char *paths;
if (paths != NULL)
/* Add search directories from `paths' */
while ((cp = strtok(paths, ":")) != NULL) {
paths = NULL;
while ((cp = strsep(&paths, ":")) != NULL) {
add_search_dir(cp);
if (paths)
*(paths-1) = ':';
}
/* Append standard search directories */

View file

@ -1,5 +1,5 @@
/*
* $Id: md.c,v 1.2 1993/10/27 00:56:17 pk Exp $
* $Id: md.c,v 1.3 1993/11/06 19:15:31 pk Exp $
*/
#include <sys/param.h>
@ -148,6 +148,13 @@ md_init_header(hp, magic, flags)
struct exec *hp;
int magic, flags;
{
#ifdef NetBSD
N_SETMAGIC((*hp), magic, MID_MACHINE, flags);
/* TEXT_START depends on the value of outheader.a_entry. */
if (!(link_mode & SHAREABLE)) /*WAS: if (entry_symbol) */
hp->a_entry = PAGSIZ;
#else
hp->a_magic = magic;
hp->a_machtype = M_SPARC;
hp->a_toolversion = 1;
@ -156,6 +163,7 @@ int magic, flags;
/* SunOS 4.1 N_TXTADDR depends on the value of outheader.a_entry. */
if (!(link_mode & SHAREABLE)) /*WAS: if (entry_symbol) */
hp->a_entry = N_PAGSIZ(*hp);
#endif
}
/*

View file

@ -1,5 +1,5 @@
/*
* $Id: warnings.c,v 1.3 1993/11/01 16:26:20 pk Exp $
* $Id: warnings.c,v 1.4 1993/11/05 12:45:25 pk Exp $
*/
#include <sys/param.h>
@ -685,7 +685,7 @@ do_file_warnings (entry, outfile)
} else if (BIT_SET_P (nlist_bitvector, i))
continue;
else if (list_unresolved_refs && !g->defined) {
else if (list_unresolved_refs && !g->defined && !g->so_defined) {
if (g->undef_refs >= MAX_UREFS_PRINTED)
continue;

View file

@ -1,4 +1,4 @@
# $Id: Makefile,v 1.1 1993/11/03 23:41:46 paul Exp $
# $Id: Makefile,v 1.3 1993/11/08 13:20:39 pk Exp $
PROG= ld.so
SRCS= mdprologue.S rtld.c shlib.c etc.c md.c
@ -8,7 +8,7 @@ LDDIR?= $(.CURDIR)/..
PICFLAG=-fpic
CFLAGS += -I$(LDDIR) -I$(.CURDIR) -I$(LDDIR)/$(MACHINE) -O $(PICFLAG) -DRTLD
LDFLAGS = -Bshareable -Bsymbolic -assert nosymbolic
LIBS = -lc_pic -lgcc_pic
LIBS = -lc_pic
BINDIR= /usr/libexec
.PATH: $(LDDIR) $(LDDIR)/$(MACHINE)
@ -16,7 +16,7 @@ BINDIR= /usr/libexec
.SUFFIXES: .S
$(PROG):
$(LD) -o $(PROG) $(LDFLAGS) $(OBJS) $(LIBS)
$(LD) -o $(PROG) $(LDFLAGS) $(OBJS) $(LIBS) $(LDADD)
.S.o:
$(CPP) $(.IMPSRC) | $(AS) -k -o $(.TARGET) -

View file

@ -27,7 +27,7 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* $Id: rtld.c,v 1.7 1993/11/03 21:35:54 pk Exp $
* $Id: rtld.c,v 1.8 1993/11/08 13:20:40 pk Exp $
*/
#include <sys/param.h>
@ -888,10 +888,11 @@ int *usehints;
if (ld_path != NULL) {
/* Prefer paths from LD_LIBRARY_PATH */
while ((cp = strtok(ld_path, ":")) != NULL) {
while ((cp = strsep(&ld_path, ":")) != NULL) {
ld_path = NULL;
hint = findhint(name, major, minor, cp);
if (ld_path)
*(ld_path-1) = ':';
if (hint)
return hint;
}

View file

@ -1,5 +1,5 @@
/*
* $Id: shlib.c,v 1.3 1993/10/23 00:34:26 pk Exp $
* $Id: shlib.c,v 1.4 1993/11/08 13:21:23 pk Exp $
*/
#include <sys/param.h>
@ -48,9 +48,10 @@ char *paths;
if (paths != NULL)
/* Add search directories from `paths' */
while ((cp = strtok(paths, ":")) != NULL) {
paths = NULL;
while ((cp = strsep(&paths, ":")) != NULL) {
add_search_dir(cp);
if (paths)
*(paths-1) = ':';
}
/* Append standard search directories */

View file

@ -1,4 +1,4 @@
# $Id: Makefile,v 1.1 1993/11/03 23:41:32 paul Exp $
# $Id: Makefile,v 1.2 1993/11/03 05:20:49 cgd Exp $
PROG= ldconfig
SRCS= ldconfig.c shlib.c etc.c
@ -6,7 +6,7 @@ LDDIR?= $(.CURDIR)/..
LDFLAGS += -static
CFLAGS += -I$(LDDIR) -I$(.CURDIR) -I$(LDDIR)/$(MACHINE) -O
BINDIR= ${DESTDIR}/sbin
MAN8 = ldconfig.8
MAN8 = ldconfig.0
.PATH: $(LDDIR) $(LDDIR)/$(MACHINE)