-/* @(#)ld.c 6.3 (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) %G%";
+#endif /* not lint */
/* Linker `ld' for GNU
Copyright (C) 1988 Free Software Foundation, Inc.
#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
{
register int i;
register struct file_entry *p;
+ char *cp;
number_of_files = 0;
output_filename = "a.out";
}
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++;
if (length_of_strings < 0
|| number_of_symdefs * sizeof (struct symdef) + length_of_strings
- + 2 * sizeof (int) != member_length)
+ + 2 * sizeof (int) > member_length)
fatal_with_file ("malformatted __.SYMDEF in ", entry);
sym_name_base = sizeof (int) + (char *) (symdef_base + number_of_symdefs);
/* 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)
-#endif
{
int text_end = text_size + N_TXTOFF (outheader);
text_pad = ((text_end + page_size - 1) & (- page_size)) - text_end;
{
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;
#endif
-#if TARGET == SUN4
+#if defined(sun) && (TARGET == SUN4)
/* Don't use local pagesize to build for Sparc. */