Updated to newest ld from pk.
authorPaul Richards <paul@isl.cf.ac.uk>
Tue, 9 Nov 1993 04:19:36 +0000 (04:19 +0000)
committerPaul Richards <paul@isl.cf.ac.uk>
Tue, 9 Nov 1993 04:19:36 +0000 (04:19 +0000)
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.

gnu/usr.bin/ld/Makefile
gnu/usr.bin/ld/ld.c
gnu/usr.bin/ld/ldconfig/Makefile
gnu/usr.bin/ld/lib.c
gnu/usr.bin/ld/rtld/Makefile
gnu/usr.bin/ld/rtld/rtld.c
gnu/usr.bin/ld/shlib.c
gnu/usr.bin/ld/sparc/md.c
gnu/usr.bin/ld/warnings.c

index 8b43337..ff87a39 100644 (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
 #
 
 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
 
 LDADD+=        -lgnumalloc
 DPADD+= /usr/lib/libgnumalloc.a
index a22d256..00de228 100644 (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.
    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.  */
  */
    
 /* Define how to initialize system-dependent header fields.  */
@@ -1597,7 +1594,7 @@ digest_pass2()
                        /*
                         * It's data from shared object with size info.
                         */
                        /*
                         * 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
                                fatal("%s: Bogus N_SIZE item", sp->name);
 
                } else
@@ -1761,14 +1758,24 @@ consider_relocation (entry, dataseg)
                                continue;
                        }
 
                                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_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);
 
                                /* Reference to shared library data */
                                alloc_rrs_cpy_reloc(sp);
index 231fec0..e655e26 100644 (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
 
 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
 LDFLAGS += -static
 CFLAGS += -I$(LDDIR) -I$(.CURDIR) -I$(LDDIR)/$(MACHINE) -O
 BINDIR= ${DESTDIR}/sbin
-MAN8 = ldconfig.8
+MAN8 = ldconfig.0
 
 .PATH: $(LDDIR) $(LDDIR)/$(MACHINE)
 
 
 .PATH: $(LDDIR) $(LDDIR)/$(MACHINE)
 
index 2ce8efb..d66f3df 100644 (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>
  */
 
 #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) &&
                         * global common 'utime' linked to a function).
                         */
                        if (!(link_mode & FORCEARCHIVE) &&
-                                       (!sp || !sp->referenced || sp->defined))
+                                       (!sp || sp->defined ||
+                                       (!sp->referenced && !sp->sorefs)) )
                                continue;
 
                        /*
                                continue;
 
                        /*
@@ -478,14 +479,16 @@ subfile_wanted_p(entry)
                                if (    (type & N_EXT) &&
                                        (type & N_STAB) == 0 &&
                                        type != (N_UNDF | N_EXT))
                                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;
                        if (write_map) {
                                print_file_name(entry, stdout);
                                fprintf(stdout, " needed due to shared lib ref %s\n", sp->name);
                        }
                        return 1;
-                       xxx: ;
                }
        }
 
                }
        }
 
index 31283d7..a7975f6 100644 (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
 
 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
 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)
 BINDIR= /usr/libexec
 
 .PATH: $(LDDIR) $(LDDIR)/$(MACHINE)
@@ -16,7 +16,7 @@ BINDIR= /usr/libexec
 .SUFFIXES: .S
 
 $(PROG):
 .SUFFIXES: .S
 
 $(PROG):
-       $(LD) -o $(PROG) $(LDFLAGS) $(OBJS) $(LIBS)
+       $(LD) -o $(PROG) $(LDFLAGS) $(OBJS) $(LIBS) $(LDADD)
 
 .S.o:
        $(CPP) $(.IMPSRC) | $(AS) -k -o $(.TARGET) -
 
 .S.o:
        $(CPP) $(.IMPSRC) | $(AS) -k -o $(.TARGET) -
index 433820a..e833787 100644 (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.
  *
  * (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>
  */
 
 #include <sys/param.h>
@@ -888,10 +888,11 @@ int       *usehints;
 
        if (ld_path != NULL) {
                /* Prefer paths from LD_LIBRARY_PATH */
 
        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);
                        hint = findhint(name, major, minor, cp);
+                       if (ld_path)
+                               *(ld_path-1) = ':';
                        if (hint)
                                return hint;
                }
                        if (hint)
                                return hint;
                }
index 4be8354..55cd8c3 100644 (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>
  */
 
 #include <sys/param.h>
@@ -48,9 +48,10 @@ char *paths;
 
        if (paths != NULL)
                /* Add search directories from `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);
                        add_search_dir(cp);
+                       if (paths)
+                               *(paths-1) = ':';
                }
 
        /* Append standard search directories */
                }
 
        /* Append standard search directories */
index 2fe093b..5424f15 100644 (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>
  */
 
 #include <sys/param.h>
@@ -148,6 +148,13 @@ md_init_header(hp, magic, flags)
 struct exec    *hp;
 int            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;
        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);
        /* 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
 }
 
 /*
 }
 
 /*
index abce79e..e191074 100644 (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>
  */
 
 #include <sys/param.h>
@@ -685,7 +685,7 @@ do_file_warnings (entry, outfile)
 
                } else if (BIT_SET_P (nlist_bitvector, i))
                        continue;
 
                } 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;
 
                        if (g->undef_refs >= MAX_UREFS_PRINTED)
                                continue;