BSD 4_3_Net_2 release
[unix-history] / usr / src / usr.bin / ld / ld.c
index 98339da..ff89ac2 100644 (file)
@@ -1,6 +1,13 @@
-/*     @(#)ld.c        6.5 (Berkeley) %G%
+/*-
+ * This code is derived from software copyrighted by the Free Software
+ * Foundation.
+ *
+ * Modified 1991 by Donn Seeley at UUNET Technologies, Inc.
+ */
 
 
-Modified for Berkeley Unix by Donn Seeley, donn@okeeffe.berkeley.edu  */
+#ifndef lint
+static char sccsid[] = "@(#)ld.c       6.10 (Berkeley) 5/22/91";
+#endif /* not lint */
 
 /* Linker `ld' for GNU
    Copyright (C) 1988 Free Software Foundation, Inc.
 
 /* Linker `ld' for GNU
    Copyright (C) 1988 Free Software Foundation, Inc.
@@ -68,13 +75,6 @@ char *progname;
 #define DEFAULT_MAGIC ZMAGIC
 #endif
 
 #define DEFAULT_MAGIC ZMAGIC
 #endif
 
-/* Ordinary 4.3bsd lacks these macros in a.out.h.  */
-
-#define N_TXTADDR(X) 0
-#define N_DATADDR(x) \
-    (((x).a_magic==OMAGIC)? (N_TXTADDR(x)+(x).a_text) \
-    : (page_size+((N_TXTADDR(x)+(x).a_text-1) & ~(page_size-1))))
-
 #ifdef hp300
 #define        INITIALIZE_HEADER       outheader.a_mid = MID_HP300
 #endif
 #ifdef hp300
 #define        INITIALIZE_HEADER       outheader.a_mid = MID_HP300
 #endif
@@ -982,6 +982,7 @@ decode_command (argc, argv)
 {
   register int i;
   register struct file_entry *p;
 {
   register int i;
   register struct file_entry *p;
+  char *cp;
 
   number_of_files = 0;
   output_filename = "a.out";
 
   number_of_files = 0;
   output_filename = "a.out";
@@ -1045,7 +1046,15 @@ decode_command (argc, argv)
            }
          if (argv[i][1] == 'l')
            {
            }
          if (argv[i][1] == 'l')
            {
-             p->filename = concat ("lib", string, ".a");
+             if (cp = rindex(string, '/'))
+               {
+                 *cp++ = '\0';
+                 cp = concat (string, "/lib", cp);
+                 p->filename = concat (cp, ".a", "");
+               }
+             else
+               p->filename = concat ("lib", string, ".a");
+
              p->local_sym_name = concat ("-l", string, "");
              p->search_dirs_flag = 1;
              p++;
              p->local_sym_name = concat ("-l", string, "");
              p->search_dirs_flag = 1;
              p++;
@@ -2336,11 +2345,7 @@ digest_symbols ()
   /* If necessary, pad text section to full page in the file.
      Include the padding in the text segment size.  */
 
   /* If necessary, pad text section to full page in the file.
      Include the padding in the text segment size.  */
 
-#ifdef NMAGIC
-  if (magic == ZMAGIC || magic == NMAGIC)
-#else
   if (magic == ZMAGIC)
   if (magic == ZMAGIC)
-#endif
     {
       int text_end = text_size + N_TXTOFF (outheader);
       text_pad = ((text_end + page_size - 1) & (- page_size)) - text_end;
     {
       int text_end = text_size + N_TXTOFF (outheader);
       text_pad = ((text_end + page_size - 1) & (- page_size)) - text_end;
@@ -4204,7 +4209,7 @@ write_file_syms (entry, syms_written_addr)
     {
       struct nlist nl;
 
     {
       struct nlist nl;
 
-      nl.n_type = N_TEXT;
+      nl.n_type = N_FN | N_EXT;
       nl.n_un.n_strx = assign_string_table_index (entry->local_sym_name);
       nl.n_value = entry->text_start_address;
       nl.n_desc = 0;
       nl.n_un.n_strx = assign_string_table_index (entry->local_sym_name);
       nl.n_value = entry->text_start_address;
       nl.n_desc = 0;