Many internal changes, most notably in the symbol counting stuff.
`ld -r -x' now supported on all object files. Support for long archive member names (AR_EFMT1 format), thanks to Bill Sommerfeld/Mark Eichin Do the right(?) thing with symbol aliases (N_INDR) for POSIX lover, especially when equiping shared libraries with these (this was *not* fun). Handle silly archives (.sa) for people who needs them; turn on by `-Bsilly'.
This commit is contained in:
parent
a5087c82e2
commit
fa099af1f6
@ -1,4 +1,4 @@
|
||||
# $Id: Makefile,v 1.9 1993/12/05 00:54:41 cgd Exp $
|
||||
# $Id: Makefile,v 1.10 1993/12/08 10:13:47 pk Exp $
|
||||
#
|
||||
|
||||
PROG= ld
|
||||
@ -8,8 +8,11 @@ CFLAGS += -g -I$(.CURDIR) -I$(.CURDIR)/$(MACHINE_ARCH)
|
||||
LDADD+= -lgnumalloc
|
||||
DPADD+= /usr/lib/libgnumalloc.a
|
||||
|
||||
SUBDIR= ldconfig ldd rtld
|
||||
SUBDIR= ldconfig ldd
|
||||
.if !defined(NOPIC)
|
||||
SUBDIR+= rtld
|
||||
.endif
|
||||
|
||||
.PATH: $(.CURDIR)/$(MACHINE_ARCH)
|
||||
.PATH: $(.CURDIR)/$(MACHINE)
|
||||
|
||||
.include <bsd.prog.mk>
|
||||
|
@ -1,8 +1,10 @@
|
||||
|
||||
/*
|
||||
* $Id: md-static-funcs.c,v 1.2 1993/12/08 10:14:44 pk Exp $
|
||||
*
|
||||
* Called by ld.so when onanating.
|
||||
* This *must* be a static function, so it is not called through a jmpslot.
|
||||
*/
|
||||
|
||||
static void
|
||||
md_relocate_simple(r, relocation, addr)
|
||||
struct relocation_info *r;
|
||||
|
@ -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: md.c,v 1.5 1993/11/14 16:51:33 pk Exp $
|
||||
* $Id: md.c,v 1.6 1993/12/08 10:14:46 pk Exp $
|
||||
*/
|
||||
|
||||
#include <sys/param.h>
|
||||
@ -242,7 +242,7 @@ long where;
|
||||
long *savep;
|
||||
{
|
||||
*savep = *(long *)where;
|
||||
*(char *)where = BPT;
|
||||
*(char *)where = TRAP;
|
||||
}
|
||||
|
||||
#ifdef NEED_SWAP
|
||||
|
@ -1,5 +1,33 @@
|
||||
/*
|
||||
* $Id: md.h,v 1.4 1993/11/13 11:20:19 pk Exp $ - I386 dependent definitions
|
||||
* Copyright (c) 1993 Paul Kranenburg
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by Paul Kranenburg.
|
||||
* 4. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software withough specific prior written permission
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (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: md.h,v 1.5 1993/12/08 10:14:48 pk Exp $
|
||||
*/
|
||||
|
||||
|
||||
@ -50,7 +78,7 @@ typedef struct jmpslot {
|
||||
#define NOP 0x90
|
||||
#define CALL 0xe890 /* NOP + CALL opcode */
|
||||
#define JUMP 0xe990 /* NOP + JMP opcode */
|
||||
#define BPT 0xcc /* breakpoint: INT 3 */
|
||||
#define TRAP 0xcc /* INT 3 */
|
||||
|
||||
/*
|
||||
* Byte swap defs for cross linking
|
||||
|
@ -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: mdprologue.S,v 1.1 1993/10/16 21:53:16 pk Exp $
|
||||
* $Id: mdprologue.S,v 1.2 1993/12/08 10:14:50 pk Exp $
|
||||
*/
|
||||
|
||||
/*
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: etc.c,v 1.3 1993/12/07 01:44:23 mycroft Exp $
|
||||
* $Id: etc.c,v 1.4 1993/12/08 10:13:50 pk Exp $
|
||||
*/
|
||||
|
||||
#include <sys/param.h>
|
||||
@ -72,7 +72,7 @@ fatal(fmt, va_alist)
|
||||
(void)fprintf(stderr, "\n");
|
||||
va_end(ap);
|
||||
|
||||
if (outdesc >= 0)
|
||||
if (outdesc > 0)
|
||||
unlink(output_filename);
|
||||
exit(1);
|
||||
}
|
||||
@ -150,22 +150,6 @@ xrealloc(ptr, size)
|
||||
}
|
||||
|
||||
|
||||
#ifdef USG
|
||||
void
|
||||
bzero(p, n)
|
||||
char *p;
|
||||
{
|
||||
memset (p, 0, n);
|
||||
}
|
||||
|
||||
void
|
||||
bcopy(from, to, n)
|
||||
char *from, *to;
|
||||
{
|
||||
memcpy (to, from, n);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/* These must move */
|
||||
|
||||
@ -192,8 +176,10 @@ mywrite (buf, count, eltsize, desc)
|
||||
}
|
||||
}
|
||||
|
||||
/* Output PADDING zero-bytes to descriptor OUTDESC.
|
||||
PADDING may be negative; in that case, do nothing. */
|
||||
/*
|
||||
* Output PADDING zero-bytes to descriptor OUTDESC.
|
||||
* PADDING may be negative; in that case, do nothing.
|
||||
*/
|
||||
|
||||
void
|
||||
padfile (padding, outdesc)
|
||||
|
@ -1,4 +1,6 @@
|
||||
/* $Id: ld.h,v 1.6 1993/12/07 01:44:25 mycroft Exp $ */
|
||||
/*
|
||||
* $Id: ld.h,v 1.7 1993/12/08 10:13:59 pk Exp $
|
||||
*/
|
||||
/*-
|
||||
* This code is derived from software copyrighted by the Free Software
|
||||
* Foundation.
|
||||
@ -470,6 +472,12 @@ symbol *symtab[TABSIZE];
|
||||
/* Number of symbols in symbol hash table. */
|
||||
int num_hash_tab_syms;
|
||||
|
||||
/* Count number of nlist entries for global symbols */
|
||||
int global_sym_count;
|
||||
|
||||
/* Count number of N_SIZE nlist entries for output (relocatable_output only) */
|
||||
int size_sym_count;
|
||||
|
||||
/* Count the number of nlist entries that are for local symbols.
|
||||
This count and the three following counts
|
||||
are incremented as as symbols are entered in the symbol table. */
|
||||
@ -583,8 +591,10 @@ struct file_entry {
|
||||
|
||||
/* The file's a.out header. */
|
||||
struct exec header;
|
||||
#if 0
|
||||
/* Offset in file of GDB symbol segment, or 0 if there is none. */
|
||||
int symseg_offset;
|
||||
#endif
|
||||
|
||||
/* Describe data from the file loaded into core */
|
||||
|
||||
@ -600,6 +610,8 @@ struct file_entry {
|
||||
struct localsymbol *next;
|
||||
long gotslot_offset;
|
||||
char gotslot_claimed;
|
||||
char write;
|
||||
char is_L_symbol;
|
||||
char rename;
|
||||
int symbolnum;
|
||||
} *symbols;
|
||||
@ -640,11 +652,13 @@ struct file_entry {
|
||||
|
||||
/* Start of this file's bss seg in the output file core image. */
|
||||
int bss_start_address;
|
||||
#if 0
|
||||
/*
|
||||
* Offset in bytes in the output file symbol table of the first local
|
||||
* symbol for this file. Set by `write_file_symbols'.
|
||||
*/
|
||||
int local_syms_offset;
|
||||
#endif
|
||||
|
||||
/* For library members only */
|
||||
|
||||
@ -666,6 +680,11 @@ struct file_entry {
|
||||
/* For library member, points to next entry for next member. */
|
||||
struct file_entry *chain;
|
||||
|
||||
#ifdef SUN_COMPAT
|
||||
/* For shared libraries which have a .sa companion */
|
||||
struct file_entry *silly_archive;
|
||||
#endif
|
||||
|
||||
/* 1 if file is a library. */
|
||||
char library_flag;
|
||||
|
||||
@ -710,7 +729,8 @@ int number_of_files;
|
||||
#define FORCEARCHIVE 4 /* Force inclusion of all members
|
||||
of archives */
|
||||
#define SHAREABLE 8 /* Build a shared object */
|
||||
int link_mode;
|
||||
#define SILLYARCHIVE 16 /* Process .sa companions, if any */
|
||||
int link_mode;
|
||||
|
||||
/*
|
||||
* Runtime Relocation Section (RRS).
|
||||
@ -812,13 +832,14 @@ char **search_dirs;
|
||||
/* Length of the vector `search_dirs'. */
|
||||
int n_search_dirs;
|
||||
|
||||
void digest_symbols __P((void));
|
||||
void load_symbols __P((void));
|
||||
void decode_command __P((int, char **));
|
||||
void read_header __P((int, struct file_entry *));
|
||||
void read_entry_symbols __P((int, struct file_entry *));
|
||||
void read_entry_strings __P((int, struct file_entry *));
|
||||
void read_entry_relocation __P((int, struct file_entry *));
|
||||
void enter_file_symbols __P((struct file_entry *));
|
||||
void read_file_symbols __P((struct file_entry *));
|
||||
|
||||
void write_output __P((void));
|
||||
void write_header __P((void));
|
||||
void write_text __P((void));
|
||||
@ -857,18 +878,25 @@ void read_shared_object __P((int, struct file_entry *));
|
||||
int findlib __P((struct file_entry *));
|
||||
|
||||
/* In shlib.c: */
|
||||
char *findshlib __P((char *, int *, int *));
|
||||
char *findshlib __P((char *, int *, int *, int));
|
||||
void add_search_dir __P((char *));
|
||||
void std_search_dirs __P((char *));
|
||||
|
||||
/* In rrs.c: */
|
||||
void init_rrs __P((void));
|
||||
int rrs_add_shobj __P((struct file_entry *));
|
||||
void alloc_rrs_reloc __P((symbol *));
|
||||
void alloc_rrs_segment_reloc __P((struct relocation_info *));
|
||||
void alloc_rrs_jmpslot __P((symbol *));
|
||||
void alloc_rrs_gotslot __P((struct relocation_info *, localsymbol_t *));
|
||||
void alloc_rrs_copy_reloc __P((symbol *));
|
||||
void alloc_rrs_reloc __P((struct file_entry *, symbol *));
|
||||
void alloc_rrs_segment_reloc __P((struct file_entry *, struct relocation_info *));
|
||||
void alloc_rrs_jmpslot __P((struct file_entry *, symbol *));
|
||||
void alloc_rrs_gotslot __P((struct file_entry *, struct relocation_info *, localsymbol_t *));
|
||||
void alloc_rrs_cpy_reloc __P((struct file_entry *, symbol *));
|
||||
|
||||
int claim_rrs_reloc __P((struct file_entry *, struct relocation_info *, symbol *, long *));
|
||||
long claim_rrs_jmpslot __P((struct file_entry *, struct relocation_info *, symbol *, long));
|
||||
long claim_rrs_gotslot __P((struct file_entry *, struct relocation_info *, struct localsymbol *, long));
|
||||
long claim_rrs_internal_gotslot __P((struct file_entry *, struct relocation_info *, struct localsymbol *, long));
|
||||
void claim_rrs_cpy_reloc __P((struct file_entry *, struct relocation_info *, symbol *));
|
||||
void claim_rrs_segment_reloc __P((struct file_entry *, struct relocation_info *));
|
||||
|
||||
/* In <md>.c */
|
||||
void md_init_header __P((struct exec *, int, int));
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: shlib.c,v 1.6 1993/12/07 03:04:28 mycroft Exp $
|
||||
* $Id: shlib.c,v 1.7 1993/12/08 10:14:04 pk Exp $
|
||||
*/
|
||||
|
||||
#include <sys/param.h>
|
||||
@ -17,6 +17,10 @@
|
||||
|
||||
#include "ld.h"
|
||||
|
||||
#ifdef SUNOS4
|
||||
char *strsep();
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Standard directories to search for files specified by -l.
|
||||
*/
|
||||
@ -133,9 +137,10 @@ int n1, n2;
|
||||
#undef minor
|
||||
|
||||
char *
|
||||
findshlib(name, majorp, minorp)
|
||||
findshlib(name, majorp, minorp, do_dot_a)
|
||||
char *name;
|
||||
int *majorp, *minorp;
|
||||
int do_dot_a;
|
||||
{
|
||||
int dewey[MAXDEWEY];
|
||||
int ndewey;
|
||||
@ -155,6 +160,7 @@ int *majorp, *minorp;
|
||||
for (i = 0; i < n_search_dirs; i++) {
|
||||
DIR *dd = opendir(search_dirs[i]);
|
||||
struct dirent *dp;
|
||||
int found_dot_a = 0;
|
||||
|
||||
if (dd == NULL)
|
||||
continue;
|
||||
@ -162,6 +168,16 @@ int *majorp, *minorp;
|
||||
while ((dp = readdir(dd)) != NULL) {
|
||||
int n, j, might_take_it = 0;
|
||||
|
||||
if (do_dot_a && path == NULL &&
|
||||
dp->d_namlen == len + 2 &&
|
||||
strncmp(dp->d_name, lname, len) == 0 &&
|
||||
(dp->d_name+len)[0] == '.' &&
|
||||
(dp->d_name+len)[1] == 'a') {
|
||||
|
||||
path = concat(search_dirs[i], "/", dp->d_name);
|
||||
found_dot_a = 1;
|
||||
}
|
||||
|
||||
if (dp->d_namlen < len + 4)
|
||||
continue;
|
||||
if (strncmp(dp->d_name, lname, len) != 0)
|
||||
@ -172,6 +188,12 @@ int *majorp, *minorp;
|
||||
if ((n = getdewey(tmp, dp->d_name+len+4)) == 0)
|
||||
continue;
|
||||
|
||||
if (major != -1 && found_dot_a) { /* XXX */
|
||||
free(path);
|
||||
path = NULL;
|
||||
found_dot_a = 0;
|
||||
}
|
||||
|
||||
if (major == -1 && minor == -1) {
|
||||
might_take_it = 1;
|
||||
} else if (major != -1 && minor == -1) {
|
||||
@ -193,12 +215,19 @@ int *majorp, *minorp;
|
||||
if (path)
|
||||
free(path);
|
||||
path = concat(search_dirs[i], "/", dp->d_name);
|
||||
found_dot_a = 0;
|
||||
bcopy(tmp, dewey, sizeof(dewey));
|
||||
ndewey = n;
|
||||
*majorp = dewey[0];
|
||||
*minorp = dewey[1];
|
||||
}
|
||||
closedir(dd);
|
||||
|
||||
if (found_dot_a)
|
||||
/*
|
||||
* There's a .a archive here.
|
||||
*/
|
||||
return path;
|
||||
}
|
||||
|
||||
return path;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: etc.c,v 1.3 1993/12/07 01:44:23 mycroft Exp $
|
||||
* $Id: etc.c,v 1.4 1993/12/08 10:13:50 pk Exp $
|
||||
*/
|
||||
|
||||
#include <sys/param.h>
|
||||
@ -72,7 +72,7 @@ fatal(fmt, va_alist)
|
||||
(void)fprintf(stderr, "\n");
|
||||
va_end(ap);
|
||||
|
||||
if (outdesc >= 0)
|
||||
if (outdesc > 0)
|
||||
unlink(output_filename);
|
||||
exit(1);
|
||||
}
|
||||
@ -150,22 +150,6 @@ xrealloc(ptr, size)
|
||||
}
|
||||
|
||||
|
||||
#ifdef USG
|
||||
void
|
||||
bzero(p, n)
|
||||
char *p;
|
||||
{
|
||||
memset (p, 0, n);
|
||||
}
|
||||
|
||||
void
|
||||
bcopy(from, to, n)
|
||||
char *from, *to;
|
||||
{
|
||||
memcpy (to, from, n);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/* These must move */
|
||||
|
||||
@ -192,8 +176,10 @@ mywrite (buf, count, eltsize, desc)
|
||||
}
|
||||
}
|
||||
|
||||
/* Output PADDING zero-bytes to descriptor OUTDESC.
|
||||
PADDING may be negative; in that case, do nothing. */
|
||||
/*
|
||||
* Output PADDING zero-bytes to descriptor OUTDESC.
|
||||
* PADDING may be negative; in that case, do nothing.
|
||||
*/
|
||||
|
||||
void
|
||||
padfile (padding, outdesc)
|
||||
|
@ -1,8 +1,10 @@
|
||||
|
||||
/*
|
||||
* $Id: md-static-funcs.c,v 1.2 1993/12/08 10:14:44 pk Exp $
|
||||
*
|
||||
* Called by ld.so when onanating.
|
||||
* This *must* be a static function, so it is not called through a jmpslot.
|
||||
*/
|
||||
|
||||
static void
|
||||
md_relocate_simple(r, relocation, addr)
|
||||
struct relocation_info *r;
|
||||
|
@ -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: md.c,v 1.5 1993/11/14 16:51:33 pk Exp $
|
||||
* $Id: md.c,v 1.6 1993/12/08 10:14:46 pk Exp $
|
||||
*/
|
||||
|
||||
#include <sys/param.h>
|
||||
@ -242,7 +242,7 @@ long where;
|
||||
long *savep;
|
||||
{
|
||||
*savep = *(long *)where;
|
||||
*(char *)where = BPT;
|
||||
*(char *)where = TRAP;
|
||||
}
|
||||
|
||||
#ifdef NEED_SWAP
|
||||
|
@ -1,5 +1,33 @@
|
||||
/*
|
||||
* $Id: md.h,v 1.4 1993/11/13 11:20:19 pk Exp $ - I386 dependent definitions
|
||||
* Copyright (c) 1993 Paul Kranenburg
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by Paul Kranenburg.
|
||||
* 4. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software withough specific prior written permission
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (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: md.h,v 1.5 1993/12/08 10:14:48 pk Exp $
|
||||
*/
|
||||
|
||||
|
||||
@ -50,7 +78,7 @@ typedef struct jmpslot {
|
||||
#define NOP 0x90
|
||||
#define CALL 0xe890 /* NOP + CALL opcode */
|
||||
#define JUMP 0xe990 /* NOP + JMP opcode */
|
||||
#define BPT 0xcc /* breakpoint: INT 3 */
|
||||
#define TRAP 0xcc /* INT 3 */
|
||||
|
||||
/*
|
||||
* Byte swap defs for cross linking
|
||||
|
@ -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: mdprologue.S,v 1.1 1993/10/16 21:53:16 pk Exp $
|
||||
* $Id: mdprologue.S,v 1.2 1993/12/08 10:14:50 pk Exp $
|
||||
*/
|
||||
|
||||
/*
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,4 +1,6 @@
|
||||
/* $Id: ld.h,v 1.6 1993/12/07 01:44:25 mycroft Exp $ */
|
||||
/*
|
||||
* $Id: ld.h,v 1.7 1993/12/08 10:13:59 pk Exp $
|
||||
*/
|
||||
/*-
|
||||
* This code is derived from software copyrighted by the Free Software
|
||||
* Foundation.
|
||||
@ -470,6 +472,12 @@ symbol *symtab[TABSIZE];
|
||||
/* Number of symbols in symbol hash table. */
|
||||
int num_hash_tab_syms;
|
||||
|
||||
/* Count number of nlist entries for global symbols */
|
||||
int global_sym_count;
|
||||
|
||||
/* Count number of N_SIZE nlist entries for output (relocatable_output only) */
|
||||
int size_sym_count;
|
||||
|
||||
/* Count the number of nlist entries that are for local symbols.
|
||||
This count and the three following counts
|
||||
are incremented as as symbols are entered in the symbol table. */
|
||||
@ -583,8 +591,10 @@ struct file_entry {
|
||||
|
||||
/* The file's a.out header. */
|
||||
struct exec header;
|
||||
#if 0
|
||||
/* Offset in file of GDB symbol segment, or 0 if there is none. */
|
||||
int symseg_offset;
|
||||
#endif
|
||||
|
||||
/* Describe data from the file loaded into core */
|
||||
|
||||
@ -600,6 +610,8 @@ struct file_entry {
|
||||
struct localsymbol *next;
|
||||
long gotslot_offset;
|
||||
char gotslot_claimed;
|
||||
char write;
|
||||
char is_L_symbol;
|
||||
char rename;
|
||||
int symbolnum;
|
||||
} *symbols;
|
||||
@ -640,11 +652,13 @@ struct file_entry {
|
||||
|
||||
/* Start of this file's bss seg in the output file core image. */
|
||||
int bss_start_address;
|
||||
#if 0
|
||||
/*
|
||||
* Offset in bytes in the output file symbol table of the first local
|
||||
* symbol for this file. Set by `write_file_symbols'.
|
||||
*/
|
||||
int local_syms_offset;
|
||||
#endif
|
||||
|
||||
/* For library members only */
|
||||
|
||||
@ -666,6 +680,11 @@ struct file_entry {
|
||||
/* For library member, points to next entry for next member. */
|
||||
struct file_entry *chain;
|
||||
|
||||
#ifdef SUN_COMPAT
|
||||
/* For shared libraries which have a .sa companion */
|
||||
struct file_entry *silly_archive;
|
||||
#endif
|
||||
|
||||
/* 1 if file is a library. */
|
||||
char library_flag;
|
||||
|
||||
@ -710,7 +729,8 @@ int number_of_files;
|
||||
#define FORCEARCHIVE 4 /* Force inclusion of all members
|
||||
of archives */
|
||||
#define SHAREABLE 8 /* Build a shared object */
|
||||
int link_mode;
|
||||
#define SILLYARCHIVE 16 /* Process .sa companions, if any */
|
||||
int link_mode;
|
||||
|
||||
/*
|
||||
* Runtime Relocation Section (RRS).
|
||||
@ -812,13 +832,14 @@ char **search_dirs;
|
||||
/* Length of the vector `search_dirs'. */
|
||||
int n_search_dirs;
|
||||
|
||||
void digest_symbols __P((void));
|
||||
void load_symbols __P((void));
|
||||
void decode_command __P((int, char **));
|
||||
void read_header __P((int, struct file_entry *));
|
||||
void read_entry_symbols __P((int, struct file_entry *));
|
||||
void read_entry_strings __P((int, struct file_entry *));
|
||||
void read_entry_relocation __P((int, struct file_entry *));
|
||||
void enter_file_symbols __P((struct file_entry *));
|
||||
void read_file_symbols __P((struct file_entry *));
|
||||
|
||||
void write_output __P((void));
|
||||
void write_header __P((void));
|
||||
void write_text __P((void));
|
||||
@ -857,18 +878,25 @@ void read_shared_object __P((int, struct file_entry *));
|
||||
int findlib __P((struct file_entry *));
|
||||
|
||||
/* In shlib.c: */
|
||||
char *findshlib __P((char *, int *, int *));
|
||||
char *findshlib __P((char *, int *, int *, int));
|
||||
void add_search_dir __P((char *));
|
||||
void std_search_dirs __P((char *));
|
||||
|
||||
/* In rrs.c: */
|
||||
void init_rrs __P((void));
|
||||
int rrs_add_shobj __P((struct file_entry *));
|
||||
void alloc_rrs_reloc __P((symbol *));
|
||||
void alloc_rrs_segment_reloc __P((struct relocation_info *));
|
||||
void alloc_rrs_jmpslot __P((symbol *));
|
||||
void alloc_rrs_gotslot __P((struct relocation_info *, localsymbol_t *));
|
||||
void alloc_rrs_copy_reloc __P((symbol *));
|
||||
void alloc_rrs_reloc __P((struct file_entry *, symbol *));
|
||||
void alloc_rrs_segment_reloc __P((struct file_entry *, struct relocation_info *));
|
||||
void alloc_rrs_jmpslot __P((struct file_entry *, symbol *));
|
||||
void alloc_rrs_gotslot __P((struct file_entry *, struct relocation_info *, localsymbol_t *));
|
||||
void alloc_rrs_cpy_reloc __P((struct file_entry *, symbol *));
|
||||
|
||||
int claim_rrs_reloc __P((struct file_entry *, struct relocation_info *, symbol *, long *));
|
||||
long claim_rrs_jmpslot __P((struct file_entry *, struct relocation_info *, symbol *, long));
|
||||
long claim_rrs_gotslot __P((struct file_entry *, struct relocation_info *, struct localsymbol *, long));
|
||||
long claim_rrs_internal_gotslot __P((struct file_entry *, struct relocation_info *, struct localsymbol *, long));
|
||||
void claim_rrs_cpy_reloc __P((struct file_entry *, struct relocation_info *, symbol *));
|
||||
void claim_rrs_segment_reloc __P((struct file_entry *, struct relocation_info *));
|
||||
|
||||
/* In <md>.c */
|
||||
void md_init_header __P((struct exec *, int, int));
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: lib.c,v 1.5 1993/11/10 21:53:47 pk Exp $ - library routines
|
||||
* $Id: lib.c,v 1.6 1993/12/08 10:14:01 pk Exp $ - library routines
|
||||
*/
|
||||
|
||||
#include <sys/param.h>
|
||||
@ -78,7 +78,8 @@ decode_library_subfile(desc, library_entry, subfile_offset, length_loc)
|
||||
{
|
||||
int bytes_read;
|
||||
register int namelen;
|
||||
int member_length;
|
||||
int member_length, content_length;
|
||||
int starting_offset;
|
||||
register char *name;
|
||||
struct ar_hdr hdr1;
|
||||
register struct file_entry *subentry;
|
||||
@ -104,22 +105,49 @@ decode_library_subfile(desc, library_entry, subfile_offset, length_loc)
|
||||
&& hdr1.ar_name[namelen] != '/';
|
||||
namelen++);
|
||||
|
||||
name = (char *) xmalloc(namelen + 1);
|
||||
strncpy(name, hdr1.ar_name, namelen);
|
||||
name[namelen] = 0;
|
||||
starting_offset = subfile_offset + sizeof hdr1;
|
||||
content_length = member_length;
|
||||
|
||||
#ifdef AR_EFMT1
|
||||
/*
|
||||
* BSD 4.4 extended AR format: #1/<namelen>, with name as the
|
||||
* first <namelen> bytes of the file
|
||||
*/
|
||||
if ( (hdr1.ar_name[0] == '#') &&
|
||||
(hdr1.ar_name[1] == '1') &&
|
||||
(hdr1.ar_name[2] == '/') &&
|
||||
(isdigit(hdr1.ar_name[3]))) {
|
||||
|
||||
namelen = atoi(&hdr1.ar_name[3]);
|
||||
name = (char *)xmalloc(namelen + 1);
|
||||
if (read(desc, name, namelen) != namelen)
|
||||
fatal_with_file(
|
||||
"malformatted header of archive member in ",
|
||||
library_entry);
|
||||
name[namelen] = 0;
|
||||
content_length -= namelen;
|
||||
starting_offset += namelen;
|
||||
} else
|
||||
|
||||
#endif
|
||||
{
|
||||
name = (char *)xmalloc(namelen + 1);
|
||||
strncpy(name, hdr1.ar_name, namelen);
|
||||
name[namelen] = 0;
|
||||
}
|
||||
|
||||
subentry->filename = name;
|
||||
subentry->local_sym_name = name;
|
||||
subentry->symbols = 0;
|
||||
subentry->strings = 0;
|
||||
subentry->subfiles = 0;
|
||||
subentry->starting_offset = subfile_offset + sizeof hdr1;
|
||||
subentry->starting_offset = starting_offset;
|
||||
subentry->superfile = library_entry;
|
||||
subentry->library_flag = 0;
|
||||
subentry->header_read_flag = 0;
|
||||
subentry->just_syms_flag = 0;
|
||||
subentry->chain = 0;
|
||||
subentry->total_size = member_length;
|
||||
subentry->total_size = content_length;
|
||||
|
||||
(*length_loc) = member_length;
|
||||
|
||||
@ -573,6 +601,8 @@ read_shared_object (desc, entry)
|
||||
entry->symbols[i].next = NULL;
|
||||
entry->symbols[i].gotslot_offset = -1;
|
||||
entry->symbols[i].gotslot_claimed = 0;
|
||||
entry->symbols[i].write = 0;
|
||||
entry->symbols[i].is_L_symbol = 0;
|
||||
entry->symbols[i].rename = 0;
|
||||
}
|
||||
|
||||
@ -588,9 +618,110 @@ read_shared_object (desc, entry)
|
||||
enter_file_symbols (entry);
|
||||
entry->strings = 0;
|
||||
|
||||
/* TODO: examine needed shared objects */
|
||||
/*
|
||||
* Load any subsidiary shared objects.
|
||||
*/
|
||||
if (dyn2.ld_need) {
|
||||
struct link_object lobj;
|
||||
off_t offset;
|
||||
struct file_entry *subentry, *prev = NULL;
|
||||
|
||||
subentry = (struct file_entry *)
|
||||
xmalloc(sizeof(struct file_entry));
|
||||
bzero(subentry, sizeof(struct file_entry));
|
||||
|
||||
subentry->superfile = entry;
|
||||
|
||||
offset = (off_t)dyn2.ld_need;
|
||||
while (1) {
|
||||
char *libname, name[MAXPATHLEN]; /*XXX*/
|
||||
|
||||
lseek(desc, offset, L_SET);
|
||||
if (read(desc, &lobj, sizeof(lobj)) != sizeof(lobj)) {
|
||||
fatal_with_file(
|
||||
"premature eof while reading link objects ",
|
||||
entry);
|
||||
}
|
||||
md_swapin_link_object(&lobj, 1);
|
||||
(void)lseek(desc, (off_t)lobj.lo_name, L_SET);
|
||||
(void)read(desc, name, sizeof(name)); /*XXX*/
|
||||
if (lobj.lo_library) {
|
||||
int lo_major = lobj.lo_major;
|
||||
int lo_minor = lobj.lo_minor;
|
||||
|
||||
libname = findshlib(name,
|
||||
&lo_major, &lo_minor, 0);
|
||||
if (libname == NULL)
|
||||
fatal("no shared -l%s.%d.%d available",
|
||||
name, lobj.lo_major, lobj.lo_minor);
|
||||
subentry->filename = libname;
|
||||
subentry->local_sym_name = concat("-l", name, "");
|
||||
} else {
|
||||
subentry->filename = strdup(name);
|
||||
subentry->local_sym_name = strdup(name);
|
||||
}
|
||||
read_file_symbols(subentry);
|
||||
|
||||
if (prev)
|
||||
prev->chain = subentry;
|
||||
else
|
||||
entry->subfiles = subentry;
|
||||
prev = subentry;
|
||||
file_open(entry);
|
||||
if ((offset = (off_t)lobj.lo_next) == 0)
|
||||
break;
|
||||
}
|
||||
}
|
||||
#ifdef SUN_COMPAT
|
||||
if (link_mode & SILLYARCHIVE) {
|
||||
char *cp, *sa_name;
|
||||
char armag[SARMAG];
|
||||
int fd;
|
||||
struct file_entry *subentry;
|
||||
|
||||
sa_name = strdup(entry->filename);
|
||||
if (sa_name == NULL)
|
||||
goto out;
|
||||
cp = sa_name + strlen(sa_name) - 1;
|
||||
while (cp > sa_name) {
|
||||
if (!isdigit(*cp) && *cp != '.')
|
||||
break;
|
||||
--cp;
|
||||
}
|
||||
if (cp <= sa_name || *cp != 'o') {
|
||||
/* Not in `libxxx.so.n.m' form */
|
||||
free(sa_name);
|
||||
goto out;
|
||||
}
|
||||
|
||||
*cp = 'a';
|
||||
if ((fd = open(sa_name, O_RDONLY, 0)) < 0)
|
||||
goto out;
|
||||
|
||||
/* Read archive magic */
|
||||
bzero(armag, SARMAG);
|
||||
(void)read(fd, armag, SARMAG);
|
||||
(void)close(fd);
|
||||
if (strncmp(armag, ARMAG, SARMAG) != 0) {
|
||||
error("%s: malformed silly archive",
|
||||
get_file_name(entry));
|
||||
goto out;
|
||||
}
|
||||
|
||||
subentry = (struct file_entry *)
|
||||
xmalloc(sizeof(struct file_entry));
|
||||
bzero(subentry, sizeof(struct file_entry));
|
||||
|
||||
entry->silly_archive = subentry;
|
||||
subentry->superfile = entry;
|
||||
subentry->filename = sa_name;
|
||||
subentry->local_sym_name = sa_name;
|
||||
subentry->library_flag = 1;
|
||||
search_library(file_open(subentry), subentry);
|
||||
out:
|
||||
;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#undef major
|
||||
@ -609,7 +740,7 @@ struct file_entry *p;
|
||||
if (p->search_dynamic_flag == 0)
|
||||
goto dot_a;
|
||||
|
||||
fname = findshlib(p->filename, &major, &minor);
|
||||
fname = findshlib(p->filename, &major, &minor, 1);
|
||||
|
||||
if (fname && (desc = open (fname, O_RDONLY, 0)) > 0) {
|
||||
p->filename = fname;
|
||||
|
@ -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: rrs.c,v 1.6 1993/11/10 21:53:50 pk Exp $
|
||||
* $Id: rrs.c,v 1.7 1993/12/08 10:14:03 pk Exp $
|
||||
*/
|
||||
|
||||
#include <sys/param.h>
|
||||
@ -180,27 +180,31 @@ struct file_entry *entry;
|
||||
}
|
||||
|
||||
void
|
||||
alloc_rrs_reloc(sp)
|
||||
alloc_rrs_reloc(entry, sp)
|
||||
struct file_entry *entry;
|
||||
symbol *sp;
|
||||
{
|
||||
#ifdef DEBUG
|
||||
printf("alloc_rrs_reloc: %s\n", sp->name);
|
||||
printf("alloc_rrs_reloc: %s in %s\n", sp->name, get_file_name(entry));
|
||||
#endif
|
||||
reserved_rrs_relocs++;
|
||||
}
|
||||
|
||||
void
|
||||
alloc_rrs_segment_reloc(r)
|
||||
alloc_rrs_segment_reloc(entry, r)
|
||||
struct file_entry *entry;
|
||||
struct relocation_info *r;
|
||||
{
|
||||
#ifdef DEBUG
|
||||
printf("alloc_rrs_segment_reloc at %#x\n", r->r_address);
|
||||
printf("alloc_rrs_segment_reloc at %#x in %s\n",
|
||||
r->r_address, get_file_name(entry));
|
||||
#endif
|
||||
reserved_rrs_relocs++;
|
||||
}
|
||||
|
||||
void
|
||||
alloc_rrs_jmpslot(sp)
|
||||
alloc_rrs_jmpslot(entry, sp)
|
||||
struct file_entry *entry;
|
||||
symbol *sp;
|
||||
{
|
||||
if (sp->jmpslot_offset == -1) {
|
||||
@ -214,7 +218,8 @@ symbol *sp;
|
||||
}
|
||||
|
||||
void
|
||||
alloc_rrs_gotslot(r, lsp)
|
||||
alloc_rrs_gotslot(entry, r, lsp)
|
||||
struct file_entry *entry;
|
||||
struct relocation_info *r;
|
||||
struct localsymbol *lsp;
|
||||
{
|
||||
@ -222,8 +227,11 @@ struct localsymbol *lsp;
|
||||
|
||||
if (!RELOC_EXTERN_P(r)) {
|
||||
|
||||
if (sp != NULL)
|
||||
fatal("internal error: lsp->symbol not NULL");
|
||||
if (sp != NULL) {
|
||||
error("%s: relocation for internal symbol expected at %#x",
|
||||
get_file_name(entry), RELOC_ADDRESS(r));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!RELOC_STATICS_THROUGH_GOT_P(r))
|
||||
/* No need for a GOT slot */
|
||||
@ -242,11 +250,20 @@ struct localsymbol *lsp;
|
||||
reserved_rrs_relocs++;
|
||||
}
|
||||
|
||||
} else if (sp->gotslot_offset == -1) {
|
||||
} else {
|
||||
|
||||
if (sp == NULL) {
|
||||
error("%s: relocation must refer to global symbol at %#x",
|
||||
get_file_name(entry), RELOC_ADDRESS(r));
|
||||
return;
|
||||
}
|
||||
|
||||
if (sp->alias)
|
||||
sp = sp->alias;
|
||||
|
||||
if (sp->gotslot_offset != -1)
|
||||
return;
|
||||
|
||||
/*
|
||||
* External symbols always get a relocation entry
|
||||
*/
|
||||
@ -259,13 +276,14 @@ struct localsymbol *lsp;
|
||||
}
|
||||
|
||||
void
|
||||
alloc_rrs_cpy_reloc(sp)
|
||||
alloc_rrs_cpy_reloc(entry, sp)
|
||||
struct file_entry *entry;
|
||||
symbol *sp;
|
||||
{
|
||||
if (sp->cpyreloc_reserved)
|
||||
return;
|
||||
#ifdef DEBUG
|
||||
printf("alloc_rrs_copy: %s\n", sp->name);
|
||||
printf("alloc_rrs_copy: %s in %s\n", sp->name, get_file_name(entry));
|
||||
#endif
|
||||
sp->cpyreloc_reserved = 1;
|
||||
reserved_rrs_relocs++;
|
||||
@ -292,7 +310,8 @@ rrs_next_reloc()
|
||||
* written to a.out.
|
||||
*/
|
||||
int
|
||||
claim_rrs_reloc(rp, sp, relocation)
|
||||
claim_rrs_reloc(entry, rp, sp, relocation)
|
||||
struct file_entry *entry;
|
||||
struct relocation_info *rp;
|
||||
symbol *sp;
|
||||
long *relocation;
|
||||
@ -300,18 +319,19 @@ long *relocation;
|
||||
struct relocation_info *r = rrs_next_reloc();
|
||||
|
||||
if (rp->r_address < text_start + text_size)
|
||||
error("RRS text relocation at %#x (symbol %s)",
|
||||
rp->r_address, sp->name);
|
||||
error("%s: RRS text relocation at %#x for \"%s\"",
|
||||
get_file_name(entry), rp->r_address, sp->name);
|
||||
|
||||
#ifdef DEBUG
|
||||
printf("claim_rrs_reloc: %s\n", sp->name);
|
||||
printf("claim_rrs_reloc: %s in %s\n", sp->name, get_file_name(entry));
|
||||
#endif
|
||||
r->r_address = rp->r_address;
|
||||
r->r_symbolnum = sp->rrs_symbolnum;
|
||||
|
||||
if (link_mode & SYMBOLIC) {
|
||||
if (!sp->defined)
|
||||
error("Cannot reduce symbol %s", sp->name);
|
||||
error("Cannot reduce symbol \"%s\" in %s",
|
||||
sp->name, get_file_name(entry));
|
||||
RELOC_EXTERN_P(r) = 0;
|
||||
*relocation += sp->value;
|
||||
(void) md_make_reloc(rp, r, RELTYPE_RELATIVE);
|
||||
@ -326,7 +346,8 @@ printf("claim_rrs_reloc: %s\n", sp->name);
|
||||
* Claim a jmpslot. Setup RRS relocation if claimed for the first time.
|
||||
*/
|
||||
long
|
||||
claim_rrs_jmpslot(rp, sp, addend)
|
||||
claim_rrs_jmpslot(entry, rp, sp, addend)
|
||||
struct file_entry *entry;
|
||||
struct relocation_info *rp;
|
||||
symbol *sp;
|
||||
long addend;
|
||||
@ -337,18 +358,21 @@ long addend;
|
||||
return rrs_dyn2.ld_plt + sp->jmpslot_offset;
|
||||
|
||||
#ifdef DEBUG
|
||||
printf("claim_rrs_jmpslot: %s(%d) -> offset %x (textreloc %#x)\n",
|
||||
printf("claim_rrs_jmpslot: %s: %s(%d) -> offset %x (textreloc %#x)\n",
|
||||
get_file_name(entry),
|
||||
sp->name, sp->rrs_symbolnum, sp->jmpslot_offset, text_relocation);
|
||||
#endif
|
||||
|
||||
if (sp->jmpslot_offset == -1)
|
||||
fatal(
|
||||
"internal error: claim_rrs_jmpslot: %s: jmpslot_offset == -1\n",
|
||||
"internal error: %s: claim_rrs_jmpslot: %s: jmpslot_offset == -1\n",
|
||||
get_file_name(entry),
|
||||
sp->name);
|
||||
|
||||
if ((link_mode & SYMBOLIC) || rrs_section_type == RRS_PARTIAL) {
|
||||
if (!sp->defined)
|
||||
error("Cannot reduce symbol %s", sp->name);
|
||||
error("Cannot reduce symbol \"%s\" in %s",
|
||||
sp->name, get_file_name(entry));
|
||||
|
||||
md_fix_jmpslot( rrs_plt + sp->jmpslot_offset/sizeof(jmpslot_t),
|
||||
rrs_dyn2.ld_plt + sp->jmpslot_offset,
|
||||
@ -393,7 +417,8 @@ printf("claim_rrs_jmpslot: %s(%d) -> offset %x (textreloc %#x)\n",
|
||||
* Return offset into the GOT allocated to this symbol.
|
||||
*/
|
||||
long
|
||||
claim_rrs_gotslot(rp, lsp, addend)
|
||||
claim_rrs_gotslot(entry, rp, lsp, addend)
|
||||
struct file_entry *entry;
|
||||
struct relocation_info *rp;
|
||||
struct localsymbol *lsp;
|
||||
long addend;
|
||||
@ -402,6 +427,10 @@ long addend;
|
||||
symbol *sp = lsp->symbol;
|
||||
int reloc_type = 0;
|
||||
|
||||
if (sp == NULL) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (sp->alias)
|
||||
sp = sp->alias;
|
||||
|
||||
@ -411,8 +440,8 @@ printf("claim_rrs_gotslot: %s(%d) slot offset %#x, addend %#x\n",
|
||||
#endif
|
||||
if (sp->gotslot_offset == -1)
|
||||
fatal(
|
||||
"internal error: claim_rrs_gotslot: %s: gotslot_offset == -1\n",
|
||||
sp->name);
|
||||
"internal error: %s: claim_rrs_gotslot: %s: gotslot_offset == -1\n",
|
||||
get_file_name(entry), sp->name);
|
||||
|
||||
if (sp->gotslot_claimed)
|
||||
/* This symbol already passed here before. */
|
||||
@ -435,7 +464,8 @@ printf("claim_rrs_gotslot: %s(%d) slot offset %#x, addend %#x\n",
|
||||
* RRS_PARTIAL: we don't link against shared objects,
|
||||
* so again all symbols must be known.
|
||||
*/
|
||||
error("Cannot reduce symbol %s", sp->name);
|
||||
error("Cannot reduce symbol \"%s\" in %s",
|
||||
sp->name, get_file_name(entry));
|
||||
|
||||
} else {
|
||||
|
||||
@ -453,7 +483,8 @@ printf("claim_rrs_gotslot: %s(%d) slot offset %#x, addend %#x\n",
|
||||
* NOTE: RRS_PARTIAL implies !SHAREABLE.
|
||||
*/
|
||||
if (!sp->defined)
|
||||
error("Cannot reduce symbol %s", sp->name);
|
||||
error("Cannot reduce symbol \"%s\" in %s",
|
||||
sp->name, get_file_name(entry));
|
||||
return sp->gotslot_offset;
|
||||
}
|
||||
|
||||
@ -496,13 +527,14 @@ long addend;
|
||||
return addend - rrs_dyn2.ld_got;
|
||||
|
||||
#ifdef DEBUG
|
||||
printf("claim_rrsinternal__gotslot: slot offset %#x, addend = %#x\n",
|
||||
lsp->gotslot_offset, addend);
|
||||
printf("claim_rrs_internal_gotslot: %s: slot offset %#x, addend = %#x\n",
|
||||
get_file_name(entry), lsp->gotslot_offset, addend);
|
||||
#endif
|
||||
|
||||
if (lsp->gotslot_offset == -1)
|
||||
fatal(
|
||||
"internal error: claim_rrs_internal_gotslot: slot_offset == -1\n");
|
||||
"internal error: %s: claim_rrs_internal_gotslot at %#x: slot_offset == -1\n",
|
||||
get_file_name(entry), RELOC_ADDRESS(rp));
|
||||
|
||||
if (lsp->gotslot_claimed)
|
||||
/* Already done */
|
||||
@ -525,7 +557,8 @@ printf("claim_rrsinternal__gotslot: slot offset %#x, addend = %#x\n",
|
||||
}
|
||||
|
||||
void
|
||||
claim_rrs_cpy_reloc(rp, sp)
|
||||
claim_rrs_cpy_reloc(entry, rp, sp)
|
||||
struct file_entry *entry;
|
||||
struct relocation_info *rp;
|
||||
symbol *sp;
|
||||
{
|
||||
@ -535,11 +568,12 @@ symbol *sp;
|
||||
return;
|
||||
|
||||
if (!sp->cpyreloc_reserved)
|
||||
fatal("internal error: claim_cpy_reloc: %s: no reservation\n",
|
||||
sp->name);
|
||||
fatal("internal error: %s: claim_cpy_reloc: %s: no reservation\n",
|
||||
get_file_name(entry), sp->name);
|
||||
|
||||
#ifdef DEBUG
|
||||
printf("claim_rrs_copy: %s -> %x\n", sp->name, sp->so_defined);
|
||||
printf("claim_rrs_copy: %s: %s -> %x\n",
|
||||
get_file_name(entry), sp->name, sp->so_defined);
|
||||
#endif
|
||||
|
||||
r = rrs_next_reloc();
|
||||
@ -551,13 +585,15 @@ printf("claim_rrs_copy: %s -> %x\n", sp->name, sp->so_defined);
|
||||
}
|
||||
|
||||
void
|
||||
claim_rrs_segment_reloc(rp)
|
||||
claim_rrs_segment_reloc(entry, rp)
|
||||
struct file_entry *entry;
|
||||
struct relocation_info *rp;
|
||||
{
|
||||
struct relocation_info *r = rrs_next_reloc();
|
||||
|
||||
#ifdef DEBUG
|
||||
printf("claim_rrs_segment_reloc: %x\n", rp->r_address);
|
||||
printf("claim_rrs_segment_reloc: %s at %#x\n",
|
||||
get_file_name(entry), rp->r_address);
|
||||
#endif
|
||||
r->r_address = rp->r_address;
|
||||
RELOC_TYPE(r) = RELOC_TYPE(rp);
|
||||
@ -690,6 +726,16 @@ consider_rrs_section_lengths()
|
||||
rrs_strtab_size += 1 + strlen(sp->name);
|
||||
if (sp != dynamic_symbol)
|
||||
sp->rrs_symbolnum = number_of_rrs_symbols++;
|
||||
if (sp->alias) {
|
||||
/*
|
||||
* (sigh) Always allocate space to hold the
|
||||
* indirection. At this point there's not
|
||||
* enough information to decide whether it's
|
||||
* actually needed or not.
|
||||
*/
|
||||
number_of_rrs_symbols++;
|
||||
rrs_strtab_size += 1 + strlen(sp->alias->name);
|
||||
}
|
||||
}
|
||||
} END_EACH_SYMBOL;
|
||||
|
||||
@ -937,7 +983,17 @@ write_rrs_text()
|
||||
|
||||
if (sp->defined > 1) {
|
||||
/* defined with known type */
|
||||
if (sp->defined == N_SIZE) {
|
||||
if (!(link_mode & SHAREABLE) &&
|
||||
sp->alias && sp->alias->defined > 1) {
|
||||
/*
|
||||
* If the target of an indirect symbol has
|
||||
* been defined and we are outputting an
|
||||
* executable, resolve the indirection; it's
|
||||
* no longer needed.
|
||||
*/
|
||||
nlp->nz_type = sp->alias->defined;
|
||||
nlp->nz_value = sp->alias->value;
|
||||
} else if (sp->defined == N_SIZE) {
|
||||
/*
|
||||
* Make sure this symbol isn't going
|
||||
* to define anything.
|
||||
@ -965,7 +1021,6 @@ write_rrs_text()
|
||||
"internal error: %s defined in mysterious way",
|
||||
sp->name);
|
||||
|
||||
|
||||
/* Handle auxialiary type qualifiers */
|
||||
switch (sp->aux) {
|
||||
case 0:
|
||||
@ -984,7 +1039,7 @@ write_rrs_text()
|
||||
break;
|
||||
default:
|
||||
fatal(
|
||||
"internal error: %s: unsupported other value: %x",
|
||||
"internal error: %s: unsupported other value: %x",
|
||||
sp->name, sp->aux);
|
||||
break;
|
||||
}
|
||||
@ -994,14 +1049,32 @@ write_rrs_text()
|
||||
strcpy(rrs_strtab + offset, sp->name);
|
||||
offset += 1 + strlen(sp->name);
|
||||
|
||||
if (sp->alias) {
|
||||
/*
|
||||
* Write an extra symbol for indirections (possibly
|
||||
* just a dummy).
|
||||
*/
|
||||
int t = (nlp->nz_type == N_INDR + N_EXT);
|
||||
|
||||
INCR_NLP(nlp);
|
||||
nlp->nz_type = N_UNDF + t?N_EXT:0;
|
||||
nlp->nz_un.n_strx = offset;
|
||||
nlp->nz_value = 0;
|
||||
nlp->nz_other = 0;
|
||||
nlp->nz_desc = 0;
|
||||
nlp->nz_size = 0;
|
||||
strcpy(rrs_strtab + offset, sp->alias->name);
|
||||
offset += 1 + strlen(sp->alias->name);
|
||||
}
|
||||
|
||||
INCR_NLP(nlp);
|
||||
|
||||
} END_EACH_SYMBOL;
|
||||
|
||||
if (MALIGN(offset) != rrs_strtab_size)
|
||||
fatal(
|
||||
"internal error: inconsistent RRS string table length: %d",
|
||||
offset);
|
||||
"internal error: inconsistent RRS string table length: %d, expected %d",
|
||||
offset, rrs_strtab_size);
|
||||
|
||||
/* Write the symbol table */
|
||||
if (rrs_symbol_size == sizeof(struct nlist))
|
||||
@ -1023,8 +1096,9 @@ write_rrs_text()
|
||||
for (i = 0, shp = rrs_shobjs; shp; i++, shp = shp->next) {
|
||||
char *name = shp->entry->local_sym_name;
|
||||
|
||||
if (shp == NULL)
|
||||
fatal("internal error: shp == NULL");
|
||||
if (i >= number_of_shobjs)
|
||||
fatal("internal error: # of link objects exceeds %d",
|
||||
number_of_shobjs);
|
||||
|
||||
lo[i].lo_name = pos;
|
||||
lo[i].lo_major = shp->entry->lib_major;
|
||||
@ -1039,10 +1113,11 @@ write_rrs_text()
|
||||
pos += 1 + strlen(name);
|
||||
lo[i].lo_next = (i == number_of_shobjs - 1) ? 0 :
|
||||
(rrs_dyn2.ld_need + (i+1)*sizeof(struct link_object));
|
||||
|
||||
}
|
||||
if (shp != NULL)
|
||||
fatal("internal error: shp != NULL");
|
||||
|
||||
if (i < number_of_shobjs)
|
||||
fatal("internal error: # of link objects less then expected %d",
|
||||
number_of_shobjs);
|
||||
|
||||
md_swapout_link_object(lo, number_of_shobjs);
|
||||
mywrite(lo, number_of_shobjs, sizeof(struct link_object), outdesc);
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: symbol.c,v 1.4 1993/11/10 21:53:54 pk Exp $ - symbol table routines
|
||||
* $Id: symbol.c,v 1.5 1993/12/08 10:14:06 pk Exp $ - symbol table routines
|
||||
*/
|
||||
|
||||
/* Create the symbol table entries for `etext', `edata' and `end'. */
|
||||
|
@ -4,7 +4,7 @@
|
||||
* Foundation.
|
||||
*
|
||||
* from: @(#)symseg.h 5.4 (Berkeley) 4/30/91
|
||||
* $Id: symseg.h,v 1.2 1993/08/01 18:46:59 mycroft Exp $
|
||||
* $Id: symseg.h,v 1.3 1993/12/08 10:14:07 pk Exp $
|
||||
*/
|
||||
|
||||
/* GDB symbol table format definitions.
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: warnings.c,v 1.5 1993/12/07 01:44:26 mycroft Exp $
|
||||
* $Id: warnings.c,v 1.6 1993/12/08 10:14:09 pk Exp $
|
||||
*/
|
||||
|
||||
#include <sys/param.h>
|
||||
@ -162,19 +162,17 @@ print_symbols(outfile)
|
||||
for (i = 0; i < TABSIZE; i++) {
|
||||
register symbol *sp;
|
||||
for (sp = symtab[i]; sp; sp = sp->link) {
|
||||
if (sp->defined == 1)
|
||||
if (sp->defined == (N_UNDF|N_EXT))
|
||||
fprintf(outfile, " %s: common, length %#x\n",
|
||||
sp->name, sp->max_common_size);
|
||||
if ( sp->referenced) {
|
||||
if (sp->defined)
|
||||
fprintf(outfile, " %s: %#x %#x\n",
|
||||
sp->name, sp->value, sp->size);
|
||||
else
|
||||
fprintf(outfile, " %s: undefined\n",
|
||||
sp->name);
|
||||
} else
|
||||
if (!sp->referenced)
|
||||
fprintf(outfile, " %s: unreferenced\n",
|
||||
sp->name);
|
||||
sp->name);
|
||||
else if (!sp->defined)
|
||||
fprintf(outfile, " %s: undefined\n", sp->name);
|
||||
else
|
||||
fprintf(outfile, " %s: %#x, size %#x\n",
|
||||
sp->name, sp->value, sp->size);
|
||||
}
|
||||
}
|
||||
|
||||
@ -188,7 +186,7 @@ describe_file_sections(entry, outfile)
|
||||
{
|
||||
fprintf(outfile, " ");
|
||||
print_file_name(entry, outfile);
|
||||
if (entry->just_syms_flag)
|
||||
if (entry->just_syms_flag || entry->is_dynamic)
|
||||
fprintf(outfile, " symbols only\n", 0);
|
||||
else
|
||||
fprintf(outfile, " text %x(%x), data %x(%x), bss %x(%x) hex\n",
|
||||
@ -656,15 +654,17 @@ do_file_warnings (entry, outfile)
|
||||
if (list_multiple_defs && g->multiply_defined) {
|
||||
errfmt = "Definition of symbol %s (multiply defined)";
|
||||
switch (s->n_type) {
|
||||
|
||||
case N_TEXT | N_EXT:
|
||||
line_number = address_to_line (s->n_value, text_scan);
|
||||
file_name = text_scan[0].filename;
|
||||
break;
|
||||
|
||||
case N_DATA | N_EXT:
|
||||
line_number = address_to_line (s->n_value, data_scan);
|
||||
file_name = data_scan[0].filename;
|
||||
break;
|
||||
#if 0
|
||||
|
||||
case N_SETA | N_EXT:
|
||||
case N_SETT | N_EXT:
|
||||
case N_SETD | N_EXT:
|
||||
@ -673,10 +673,9 @@ do_file_warnings (entry, outfile)
|
||||
continue;
|
||||
errfmt = "First set element definition of symbol %s (multiply defined)";
|
||||
break;
|
||||
#endif
|
||||
|
||||
default:
|
||||
/* Don't print out multiple defs
|
||||
at references.*/
|
||||
/* Don't print out multiple defs at references.*/
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -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: xbits.c,v 1.1 1993/10/16 21:52:37 pk Exp $
|
||||
* $Id: xbits.c,v 1.2 1993/12/08 10:14:10 pk Exp $
|
||||
*/
|
||||
|
||||
/*
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: lib.c,v 1.5 1993/11/10 21:53:47 pk Exp $ - library routines
|
||||
* $Id: lib.c,v 1.6 1993/12/08 10:14:01 pk Exp $ - library routines
|
||||
*/
|
||||
|
||||
#include <sys/param.h>
|
||||
@ -78,7 +78,8 @@ decode_library_subfile(desc, library_entry, subfile_offset, length_loc)
|
||||
{
|
||||
int bytes_read;
|
||||
register int namelen;
|
||||
int member_length;
|
||||
int member_length, content_length;
|
||||
int starting_offset;
|
||||
register char *name;
|
||||
struct ar_hdr hdr1;
|
||||
register struct file_entry *subentry;
|
||||
@ -104,22 +105,49 @@ decode_library_subfile(desc, library_entry, subfile_offset, length_loc)
|
||||
&& hdr1.ar_name[namelen] != '/';
|
||||
namelen++);
|
||||
|
||||
name = (char *) xmalloc(namelen + 1);
|
||||
strncpy(name, hdr1.ar_name, namelen);
|
||||
name[namelen] = 0;
|
||||
starting_offset = subfile_offset + sizeof hdr1;
|
||||
content_length = member_length;
|
||||
|
||||
#ifdef AR_EFMT1
|
||||
/*
|
||||
* BSD 4.4 extended AR format: #1/<namelen>, with name as the
|
||||
* first <namelen> bytes of the file
|
||||
*/
|
||||
if ( (hdr1.ar_name[0] == '#') &&
|
||||
(hdr1.ar_name[1] == '1') &&
|
||||
(hdr1.ar_name[2] == '/') &&
|
||||
(isdigit(hdr1.ar_name[3]))) {
|
||||
|
||||
namelen = atoi(&hdr1.ar_name[3]);
|
||||
name = (char *)xmalloc(namelen + 1);
|
||||
if (read(desc, name, namelen) != namelen)
|
||||
fatal_with_file(
|
||||
"malformatted header of archive member in ",
|
||||
library_entry);
|
||||
name[namelen] = 0;
|
||||
content_length -= namelen;
|
||||
starting_offset += namelen;
|
||||
} else
|
||||
|
||||
#endif
|
||||
{
|
||||
name = (char *)xmalloc(namelen + 1);
|
||||
strncpy(name, hdr1.ar_name, namelen);
|
||||
name[namelen] = 0;
|
||||
}
|
||||
|
||||
subentry->filename = name;
|
||||
subentry->local_sym_name = name;
|
||||
subentry->symbols = 0;
|
||||
subentry->strings = 0;
|
||||
subentry->subfiles = 0;
|
||||
subentry->starting_offset = subfile_offset + sizeof hdr1;
|
||||
subentry->starting_offset = starting_offset;
|
||||
subentry->superfile = library_entry;
|
||||
subentry->library_flag = 0;
|
||||
subentry->header_read_flag = 0;
|
||||
subentry->just_syms_flag = 0;
|
||||
subentry->chain = 0;
|
||||
subentry->total_size = member_length;
|
||||
subentry->total_size = content_length;
|
||||
|
||||
(*length_loc) = member_length;
|
||||
|
||||
@ -573,6 +601,8 @@ read_shared_object (desc, entry)
|
||||
entry->symbols[i].next = NULL;
|
||||
entry->symbols[i].gotslot_offset = -1;
|
||||
entry->symbols[i].gotslot_claimed = 0;
|
||||
entry->symbols[i].write = 0;
|
||||
entry->symbols[i].is_L_symbol = 0;
|
||||
entry->symbols[i].rename = 0;
|
||||
}
|
||||
|
||||
@ -588,9 +618,110 @@ read_shared_object (desc, entry)
|
||||
enter_file_symbols (entry);
|
||||
entry->strings = 0;
|
||||
|
||||
/* TODO: examine needed shared objects */
|
||||
/*
|
||||
* Load any subsidiary shared objects.
|
||||
*/
|
||||
if (dyn2.ld_need) {
|
||||
struct link_object lobj;
|
||||
off_t offset;
|
||||
struct file_entry *subentry, *prev = NULL;
|
||||
|
||||
subentry = (struct file_entry *)
|
||||
xmalloc(sizeof(struct file_entry));
|
||||
bzero(subentry, sizeof(struct file_entry));
|
||||
|
||||
subentry->superfile = entry;
|
||||
|
||||
offset = (off_t)dyn2.ld_need;
|
||||
while (1) {
|
||||
char *libname, name[MAXPATHLEN]; /*XXX*/
|
||||
|
||||
lseek(desc, offset, L_SET);
|
||||
if (read(desc, &lobj, sizeof(lobj)) != sizeof(lobj)) {
|
||||
fatal_with_file(
|
||||
"premature eof while reading link objects ",
|
||||
entry);
|
||||
}
|
||||
md_swapin_link_object(&lobj, 1);
|
||||
(void)lseek(desc, (off_t)lobj.lo_name, L_SET);
|
||||
(void)read(desc, name, sizeof(name)); /*XXX*/
|
||||
if (lobj.lo_library) {
|
||||
int lo_major = lobj.lo_major;
|
||||
int lo_minor = lobj.lo_minor;
|
||||
|
||||
libname = findshlib(name,
|
||||
&lo_major, &lo_minor, 0);
|
||||
if (libname == NULL)
|
||||
fatal("no shared -l%s.%d.%d available",
|
||||
name, lobj.lo_major, lobj.lo_minor);
|
||||
subentry->filename = libname;
|
||||
subentry->local_sym_name = concat("-l", name, "");
|
||||
} else {
|
||||
subentry->filename = strdup(name);
|
||||
subentry->local_sym_name = strdup(name);
|
||||
}
|
||||
read_file_symbols(subentry);
|
||||
|
||||
if (prev)
|
||||
prev->chain = subentry;
|
||||
else
|
||||
entry->subfiles = subentry;
|
||||
prev = subentry;
|
||||
file_open(entry);
|
||||
if ((offset = (off_t)lobj.lo_next) == 0)
|
||||
break;
|
||||
}
|
||||
}
|
||||
#ifdef SUN_COMPAT
|
||||
if (link_mode & SILLYARCHIVE) {
|
||||
char *cp, *sa_name;
|
||||
char armag[SARMAG];
|
||||
int fd;
|
||||
struct file_entry *subentry;
|
||||
|
||||
sa_name = strdup(entry->filename);
|
||||
if (sa_name == NULL)
|
||||
goto out;
|
||||
cp = sa_name + strlen(sa_name) - 1;
|
||||
while (cp > sa_name) {
|
||||
if (!isdigit(*cp) && *cp != '.')
|
||||
break;
|
||||
--cp;
|
||||
}
|
||||
if (cp <= sa_name || *cp != 'o') {
|
||||
/* Not in `libxxx.so.n.m' form */
|
||||
free(sa_name);
|
||||
goto out;
|
||||
}
|
||||
|
||||
*cp = 'a';
|
||||
if ((fd = open(sa_name, O_RDONLY, 0)) < 0)
|
||||
goto out;
|
||||
|
||||
/* Read archive magic */
|
||||
bzero(armag, SARMAG);
|
||||
(void)read(fd, armag, SARMAG);
|
||||
(void)close(fd);
|
||||
if (strncmp(armag, ARMAG, SARMAG) != 0) {
|
||||
error("%s: malformed silly archive",
|
||||
get_file_name(entry));
|
||||
goto out;
|
||||
}
|
||||
|
||||
subentry = (struct file_entry *)
|
||||
xmalloc(sizeof(struct file_entry));
|
||||
bzero(subentry, sizeof(struct file_entry));
|
||||
|
||||
entry->silly_archive = subentry;
|
||||
subentry->superfile = entry;
|
||||
subentry->filename = sa_name;
|
||||
subentry->local_sym_name = sa_name;
|
||||
subentry->library_flag = 1;
|
||||
search_library(file_open(subentry), subentry);
|
||||
out:
|
||||
;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#undef major
|
||||
@ -609,7 +740,7 @@ struct file_entry *p;
|
||||
if (p->search_dynamic_flag == 0)
|
||||
goto dot_a;
|
||||
|
||||
fname = findshlib(p->filename, &major, &minor);
|
||||
fname = findshlib(p->filename, &major, &minor, 1);
|
||||
|
||||
if (fname && (desc = open (fname, O_RDONLY, 0)) > 0) {
|
||||
p->filename = fname;
|
||||
|
@ -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: rrs.c,v 1.6 1993/11/10 21:53:50 pk Exp $
|
||||
* $Id: rrs.c,v 1.7 1993/12/08 10:14:03 pk Exp $
|
||||
*/
|
||||
|
||||
#include <sys/param.h>
|
||||
@ -180,27 +180,31 @@ struct file_entry *entry;
|
||||
}
|
||||
|
||||
void
|
||||
alloc_rrs_reloc(sp)
|
||||
alloc_rrs_reloc(entry, sp)
|
||||
struct file_entry *entry;
|
||||
symbol *sp;
|
||||
{
|
||||
#ifdef DEBUG
|
||||
printf("alloc_rrs_reloc: %s\n", sp->name);
|
||||
printf("alloc_rrs_reloc: %s in %s\n", sp->name, get_file_name(entry));
|
||||
#endif
|
||||
reserved_rrs_relocs++;
|
||||
}
|
||||
|
||||
void
|
||||
alloc_rrs_segment_reloc(r)
|
||||
alloc_rrs_segment_reloc(entry, r)
|
||||
struct file_entry *entry;
|
||||
struct relocation_info *r;
|
||||
{
|
||||
#ifdef DEBUG
|
||||
printf("alloc_rrs_segment_reloc at %#x\n", r->r_address);
|
||||
printf("alloc_rrs_segment_reloc at %#x in %s\n",
|
||||
r->r_address, get_file_name(entry));
|
||||
#endif
|
||||
reserved_rrs_relocs++;
|
||||
}
|
||||
|
||||
void
|
||||
alloc_rrs_jmpslot(sp)
|
||||
alloc_rrs_jmpslot(entry, sp)
|
||||
struct file_entry *entry;
|
||||
symbol *sp;
|
||||
{
|
||||
if (sp->jmpslot_offset == -1) {
|
||||
@ -214,7 +218,8 @@ symbol *sp;
|
||||
}
|
||||
|
||||
void
|
||||
alloc_rrs_gotslot(r, lsp)
|
||||
alloc_rrs_gotslot(entry, r, lsp)
|
||||
struct file_entry *entry;
|
||||
struct relocation_info *r;
|
||||
struct localsymbol *lsp;
|
||||
{
|
||||
@ -222,8 +227,11 @@ struct localsymbol *lsp;
|
||||
|
||||
if (!RELOC_EXTERN_P(r)) {
|
||||
|
||||
if (sp != NULL)
|
||||
fatal("internal error: lsp->symbol not NULL");
|
||||
if (sp != NULL) {
|
||||
error("%s: relocation for internal symbol expected at %#x",
|
||||
get_file_name(entry), RELOC_ADDRESS(r));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!RELOC_STATICS_THROUGH_GOT_P(r))
|
||||
/* No need for a GOT slot */
|
||||
@ -242,11 +250,20 @@ struct localsymbol *lsp;
|
||||
reserved_rrs_relocs++;
|
||||
}
|
||||
|
||||
} else if (sp->gotslot_offset == -1) {
|
||||
} else {
|
||||
|
||||
if (sp == NULL) {
|
||||
error("%s: relocation must refer to global symbol at %#x",
|
||||
get_file_name(entry), RELOC_ADDRESS(r));
|
||||
return;
|
||||
}
|
||||
|
||||
if (sp->alias)
|
||||
sp = sp->alias;
|
||||
|
||||
if (sp->gotslot_offset != -1)
|
||||
return;
|
||||
|
||||
/*
|
||||
* External symbols always get a relocation entry
|
||||
*/
|
||||
@ -259,13 +276,14 @@ struct localsymbol *lsp;
|
||||
}
|
||||
|
||||
void
|
||||
alloc_rrs_cpy_reloc(sp)
|
||||
alloc_rrs_cpy_reloc(entry, sp)
|
||||
struct file_entry *entry;
|
||||
symbol *sp;
|
||||
{
|
||||
if (sp->cpyreloc_reserved)
|
||||
return;
|
||||
#ifdef DEBUG
|
||||
printf("alloc_rrs_copy: %s\n", sp->name);
|
||||
printf("alloc_rrs_copy: %s in %s\n", sp->name, get_file_name(entry));
|
||||
#endif
|
||||
sp->cpyreloc_reserved = 1;
|
||||
reserved_rrs_relocs++;
|
||||
@ -292,7 +310,8 @@ rrs_next_reloc()
|
||||
* written to a.out.
|
||||
*/
|
||||
int
|
||||
claim_rrs_reloc(rp, sp, relocation)
|
||||
claim_rrs_reloc(entry, rp, sp, relocation)
|
||||
struct file_entry *entry;
|
||||
struct relocation_info *rp;
|
||||
symbol *sp;
|
||||
long *relocation;
|
||||
@ -300,18 +319,19 @@ long *relocation;
|
||||
struct relocation_info *r = rrs_next_reloc();
|
||||
|
||||
if (rp->r_address < text_start + text_size)
|
||||
error("RRS text relocation at %#x (symbol %s)",
|
||||
rp->r_address, sp->name);
|
||||
error("%s: RRS text relocation at %#x for \"%s\"",
|
||||
get_file_name(entry), rp->r_address, sp->name);
|
||||
|
||||
#ifdef DEBUG
|
||||
printf("claim_rrs_reloc: %s\n", sp->name);
|
||||
printf("claim_rrs_reloc: %s in %s\n", sp->name, get_file_name(entry));
|
||||
#endif
|
||||
r->r_address = rp->r_address;
|
||||
r->r_symbolnum = sp->rrs_symbolnum;
|
||||
|
||||
if (link_mode & SYMBOLIC) {
|
||||
if (!sp->defined)
|
||||
error("Cannot reduce symbol %s", sp->name);
|
||||
error("Cannot reduce symbol \"%s\" in %s",
|
||||
sp->name, get_file_name(entry));
|
||||
RELOC_EXTERN_P(r) = 0;
|
||||
*relocation += sp->value;
|
||||
(void) md_make_reloc(rp, r, RELTYPE_RELATIVE);
|
||||
@ -326,7 +346,8 @@ printf("claim_rrs_reloc: %s\n", sp->name);
|
||||
* Claim a jmpslot. Setup RRS relocation if claimed for the first time.
|
||||
*/
|
||||
long
|
||||
claim_rrs_jmpslot(rp, sp, addend)
|
||||
claim_rrs_jmpslot(entry, rp, sp, addend)
|
||||
struct file_entry *entry;
|
||||
struct relocation_info *rp;
|
||||
symbol *sp;
|
||||
long addend;
|
||||
@ -337,18 +358,21 @@ long addend;
|
||||
return rrs_dyn2.ld_plt + sp->jmpslot_offset;
|
||||
|
||||
#ifdef DEBUG
|
||||
printf("claim_rrs_jmpslot: %s(%d) -> offset %x (textreloc %#x)\n",
|
||||
printf("claim_rrs_jmpslot: %s: %s(%d) -> offset %x (textreloc %#x)\n",
|
||||
get_file_name(entry),
|
||||
sp->name, sp->rrs_symbolnum, sp->jmpslot_offset, text_relocation);
|
||||
#endif
|
||||
|
||||
if (sp->jmpslot_offset == -1)
|
||||
fatal(
|
||||
"internal error: claim_rrs_jmpslot: %s: jmpslot_offset == -1\n",
|
||||
"internal error: %s: claim_rrs_jmpslot: %s: jmpslot_offset == -1\n",
|
||||
get_file_name(entry),
|
||||
sp->name);
|
||||
|
||||
if ((link_mode & SYMBOLIC) || rrs_section_type == RRS_PARTIAL) {
|
||||
if (!sp->defined)
|
||||
error("Cannot reduce symbol %s", sp->name);
|
||||
error("Cannot reduce symbol \"%s\" in %s",
|
||||
sp->name, get_file_name(entry));
|
||||
|
||||
md_fix_jmpslot( rrs_plt + sp->jmpslot_offset/sizeof(jmpslot_t),
|
||||
rrs_dyn2.ld_plt + sp->jmpslot_offset,
|
||||
@ -393,7 +417,8 @@ printf("claim_rrs_jmpslot: %s(%d) -> offset %x (textreloc %#x)\n",
|
||||
* Return offset into the GOT allocated to this symbol.
|
||||
*/
|
||||
long
|
||||
claim_rrs_gotslot(rp, lsp, addend)
|
||||
claim_rrs_gotslot(entry, rp, lsp, addend)
|
||||
struct file_entry *entry;
|
||||
struct relocation_info *rp;
|
||||
struct localsymbol *lsp;
|
||||
long addend;
|
||||
@ -402,6 +427,10 @@ long addend;
|
||||
symbol *sp = lsp->symbol;
|
||||
int reloc_type = 0;
|
||||
|
||||
if (sp == NULL) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (sp->alias)
|
||||
sp = sp->alias;
|
||||
|
||||
@ -411,8 +440,8 @@ printf("claim_rrs_gotslot: %s(%d) slot offset %#x, addend %#x\n",
|
||||
#endif
|
||||
if (sp->gotslot_offset == -1)
|
||||
fatal(
|
||||
"internal error: claim_rrs_gotslot: %s: gotslot_offset == -1\n",
|
||||
sp->name);
|
||||
"internal error: %s: claim_rrs_gotslot: %s: gotslot_offset == -1\n",
|
||||
get_file_name(entry), sp->name);
|
||||
|
||||
if (sp->gotslot_claimed)
|
||||
/* This symbol already passed here before. */
|
||||
@ -435,7 +464,8 @@ printf("claim_rrs_gotslot: %s(%d) slot offset %#x, addend %#x\n",
|
||||
* RRS_PARTIAL: we don't link against shared objects,
|
||||
* so again all symbols must be known.
|
||||
*/
|
||||
error("Cannot reduce symbol %s", sp->name);
|
||||
error("Cannot reduce symbol \"%s\" in %s",
|
||||
sp->name, get_file_name(entry));
|
||||
|
||||
} else {
|
||||
|
||||
@ -453,7 +483,8 @@ printf("claim_rrs_gotslot: %s(%d) slot offset %#x, addend %#x\n",
|
||||
* NOTE: RRS_PARTIAL implies !SHAREABLE.
|
||||
*/
|
||||
if (!sp->defined)
|
||||
error("Cannot reduce symbol %s", sp->name);
|
||||
error("Cannot reduce symbol \"%s\" in %s",
|
||||
sp->name, get_file_name(entry));
|
||||
return sp->gotslot_offset;
|
||||
}
|
||||
|
||||
@ -496,13 +527,14 @@ long addend;
|
||||
return addend - rrs_dyn2.ld_got;
|
||||
|
||||
#ifdef DEBUG
|
||||
printf("claim_rrsinternal__gotslot: slot offset %#x, addend = %#x\n",
|
||||
lsp->gotslot_offset, addend);
|
||||
printf("claim_rrs_internal_gotslot: %s: slot offset %#x, addend = %#x\n",
|
||||
get_file_name(entry), lsp->gotslot_offset, addend);
|
||||
#endif
|
||||
|
||||
if (lsp->gotslot_offset == -1)
|
||||
fatal(
|
||||
"internal error: claim_rrs_internal_gotslot: slot_offset == -1\n");
|
||||
"internal error: %s: claim_rrs_internal_gotslot at %#x: slot_offset == -1\n",
|
||||
get_file_name(entry), RELOC_ADDRESS(rp));
|
||||
|
||||
if (lsp->gotslot_claimed)
|
||||
/* Already done */
|
||||
@ -525,7 +557,8 @@ printf("claim_rrsinternal__gotslot: slot offset %#x, addend = %#x\n",
|
||||
}
|
||||
|
||||
void
|
||||
claim_rrs_cpy_reloc(rp, sp)
|
||||
claim_rrs_cpy_reloc(entry, rp, sp)
|
||||
struct file_entry *entry;
|
||||
struct relocation_info *rp;
|
||||
symbol *sp;
|
||||
{
|
||||
@ -535,11 +568,12 @@ symbol *sp;
|
||||
return;
|
||||
|
||||
if (!sp->cpyreloc_reserved)
|
||||
fatal("internal error: claim_cpy_reloc: %s: no reservation\n",
|
||||
sp->name);
|
||||
fatal("internal error: %s: claim_cpy_reloc: %s: no reservation\n",
|
||||
get_file_name(entry), sp->name);
|
||||
|
||||
#ifdef DEBUG
|
||||
printf("claim_rrs_copy: %s -> %x\n", sp->name, sp->so_defined);
|
||||
printf("claim_rrs_copy: %s: %s -> %x\n",
|
||||
get_file_name(entry), sp->name, sp->so_defined);
|
||||
#endif
|
||||
|
||||
r = rrs_next_reloc();
|
||||
@ -551,13 +585,15 @@ printf("claim_rrs_copy: %s -> %x\n", sp->name, sp->so_defined);
|
||||
}
|
||||
|
||||
void
|
||||
claim_rrs_segment_reloc(rp)
|
||||
claim_rrs_segment_reloc(entry, rp)
|
||||
struct file_entry *entry;
|
||||
struct relocation_info *rp;
|
||||
{
|
||||
struct relocation_info *r = rrs_next_reloc();
|
||||
|
||||
#ifdef DEBUG
|
||||
printf("claim_rrs_segment_reloc: %x\n", rp->r_address);
|
||||
printf("claim_rrs_segment_reloc: %s at %#x\n",
|
||||
get_file_name(entry), rp->r_address);
|
||||
#endif
|
||||
r->r_address = rp->r_address;
|
||||
RELOC_TYPE(r) = RELOC_TYPE(rp);
|
||||
@ -690,6 +726,16 @@ consider_rrs_section_lengths()
|
||||
rrs_strtab_size += 1 + strlen(sp->name);
|
||||
if (sp != dynamic_symbol)
|
||||
sp->rrs_symbolnum = number_of_rrs_symbols++;
|
||||
if (sp->alias) {
|
||||
/*
|
||||
* (sigh) Always allocate space to hold the
|
||||
* indirection. At this point there's not
|
||||
* enough information to decide whether it's
|
||||
* actually needed or not.
|
||||
*/
|
||||
number_of_rrs_symbols++;
|
||||
rrs_strtab_size += 1 + strlen(sp->alias->name);
|
||||
}
|
||||
}
|
||||
} END_EACH_SYMBOL;
|
||||
|
||||
@ -937,7 +983,17 @@ write_rrs_text()
|
||||
|
||||
if (sp->defined > 1) {
|
||||
/* defined with known type */
|
||||
if (sp->defined == N_SIZE) {
|
||||
if (!(link_mode & SHAREABLE) &&
|
||||
sp->alias && sp->alias->defined > 1) {
|
||||
/*
|
||||
* If the target of an indirect symbol has
|
||||
* been defined and we are outputting an
|
||||
* executable, resolve the indirection; it's
|
||||
* no longer needed.
|
||||
*/
|
||||
nlp->nz_type = sp->alias->defined;
|
||||
nlp->nz_value = sp->alias->value;
|
||||
} else if (sp->defined == N_SIZE) {
|
||||
/*
|
||||
* Make sure this symbol isn't going
|
||||
* to define anything.
|
||||
@ -965,7 +1021,6 @@ write_rrs_text()
|
||||
"internal error: %s defined in mysterious way",
|
||||
sp->name);
|
||||
|
||||
|
||||
/* Handle auxialiary type qualifiers */
|
||||
switch (sp->aux) {
|
||||
case 0:
|
||||
@ -984,7 +1039,7 @@ write_rrs_text()
|
||||
break;
|
||||
default:
|
||||
fatal(
|
||||
"internal error: %s: unsupported other value: %x",
|
||||
"internal error: %s: unsupported other value: %x",
|
||||
sp->name, sp->aux);
|
||||
break;
|
||||
}
|
||||
@ -994,14 +1049,32 @@ write_rrs_text()
|
||||
strcpy(rrs_strtab + offset, sp->name);
|
||||
offset += 1 + strlen(sp->name);
|
||||
|
||||
if (sp->alias) {
|
||||
/*
|
||||
* Write an extra symbol for indirections (possibly
|
||||
* just a dummy).
|
||||
*/
|
||||
int t = (nlp->nz_type == N_INDR + N_EXT);
|
||||
|
||||
INCR_NLP(nlp);
|
||||
nlp->nz_type = N_UNDF + t?N_EXT:0;
|
||||
nlp->nz_un.n_strx = offset;
|
||||
nlp->nz_value = 0;
|
||||
nlp->nz_other = 0;
|
||||
nlp->nz_desc = 0;
|
||||
nlp->nz_size = 0;
|
||||
strcpy(rrs_strtab + offset, sp->alias->name);
|
||||
offset += 1 + strlen(sp->alias->name);
|
||||
}
|
||||
|
||||
INCR_NLP(nlp);
|
||||
|
||||
} END_EACH_SYMBOL;
|
||||
|
||||
if (MALIGN(offset) != rrs_strtab_size)
|
||||
fatal(
|
||||
"internal error: inconsistent RRS string table length: %d",
|
||||
offset);
|
||||
"internal error: inconsistent RRS string table length: %d, expected %d",
|
||||
offset, rrs_strtab_size);
|
||||
|
||||
/* Write the symbol table */
|
||||
if (rrs_symbol_size == sizeof(struct nlist))
|
||||
@ -1023,8 +1096,9 @@ write_rrs_text()
|
||||
for (i = 0, shp = rrs_shobjs; shp; i++, shp = shp->next) {
|
||||
char *name = shp->entry->local_sym_name;
|
||||
|
||||
if (shp == NULL)
|
||||
fatal("internal error: shp == NULL");
|
||||
if (i >= number_of_shobjs)
|
||||
fatal("internal error: # of link objects exceeds %d",
|
||||
number_of_shobjs);
|
||||
|
||||
lo[i].lo_name = pos;
|
||||
lo[i].lo_major = shp->entry->lib_major;
|
||||
@ -1039,10 +1113,11 @@ write_rrs_text()
|
||||
pos += 1 + strlen(name);
|
||||
lo[i].lo_next = (i == number_of_shobjs - 1) ? 0 :
|
||||
(rrs_dyn2.ld_need + (i+1)*sizeof(struct link_object));
|
||||
|
||||
}
|
||||
if (shp != NULL)
|
||||
fatal("internal error: shp != NULL");
|
||||
|
||||
if (i < number_of_shobjs)
|
||||
fatal("internal error: # of link objects less then expected %d",
|
||||
number_of_shobjs);
|
||||
|
||||
md_swapout_link_object(lo, number_of_shobjs);
|
||||
mywrite(lo, number_of_shobjs, sizeof(struct link_object), outdesc);
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: shlib.c,v 1.6 1993/12/07 03:04:28 mycroft Exp $
|
||||
* $Id: shlib.c,v 1.7 1993/12/08 10:14:04 pk Exp $
|
||||
*/
|
||||
|
||||
#include <sys/param.h>
|
||||
@ -17,6 +17,10 @@
|
||||
|
||||
#include "ld.h"
|
||||
|
||||
#ifdef SUNOS4
|
||||
char *strsep();
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Standard directories to search for files specified by -l.
|
||||
*/
|
||||
@ -133,9 +137,10 @@ int n1, n2;
|
||||
#undef minor
|
||||
|
||||
char *
|
||||
findshlib(name, majorp, minorp)
|
||||
findshlib(name, majorp, minorp, do_dot_a)
|
||||
char *name;
|
||||
int *majorp, *minorp;
|
||||
int do_dot_a;
|
||||
{
|
||||
int dewey[MAXDEWEY];
|
||||
int ndewey;
|
||||
@ -155,6 +160,7 @@ int *majorp, *minorp;
|
||||
for (i = 0; i < n_search_dirs; i++) {
|
||||
DIR *dd = opendir(search_dirs[i]);
|
||||
struct dirent *dp;
|
||||
int found_dot_a = 0;
|
||||
|
||||
if (dd == NULL)
|
||||
continue;
|
||||
@ -162,6 +168,16 @@ int *majorp, *minorp;
|
||||
while ((dp = readdir(dd)) != NULL) {
|
||||
int n, j, might_take_it = 0;
|
||||
|
||||
if (do_dot_a && path == NULL &&
|
||||
dp->d_namlen == len + 2 &&
|
||||
strncmp(dp->d_name, lname, len) == 0 &&
|
||||
(dp->d_name+len)[0] == '.' &&
|
||||
(dp->d_name+len)[1] == 'a') {
|
||||
|
||||
path = concat(search_dirs[i], "/", dp->d_name);
|
||||
found_dot_a = 1;
|
||||
}
|
||||
|
||||
if (dp->d_namlen < len + 4)
|
||||
continue;
|
||||
if (strncmp(dp->d_name, lname, len) != 0)
|
||||
@ -172,6 +188,12 @@ int *majorp, *minorp;
|
||||
if ((n = getdewey(tmp, dp->d_name+len+4)) == 0)
|
||||
continue;
|
||||
|
||||
if (major != -1 && found_dot_a) { /* XXX */
|
||||
free(path);
|
||||
path = NULL;
|
||||
found_dot_a = 0;
|
||||
}
|
||||
|
||||
if (major == -1 && minor == -1) {
|
||||
might_take_it = 1;
|
||||
} else if (major != -1 && minor == -1) {
|
||||
@ -193,12 +215,19 @@ int *majorp, *minorp;
|
||||
if (path)
|
||||
free(path);
|
||||
path = concat(search_dirs[i], "/", dp->d_name);
|
||||
found_dot_a = 0;
|
||||
bcopy(tmp, dewey, sizeof(dewey));
|
||||
ndewey = n;
|
||||
*majorp = dewey[0];
|
||||
*minorp = dewey[1];
|
||||
}
|
||||
closedir(dd);
|
||||
|
||||
if (found_dot_a)
|
||||
/*
|
||||
* There's a .a archive here.
|
||||
*/
|
||||
return path;
|
||||
}
|
||||
|
||||
return path;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: symbol.c,v 1.4 1993/11/10 21:53:54 pk Exp $ - symbol table routines
|
||||
* $Id: symbol.c,v 1.5 1993/12/08 10:14:06 pk Exp $ - symbol table routines
|
||||
*/
|
||||
|
||||
/* Create the symbol table entries for `etext', `edata' and `end'. */
|
||||
|
@ -4,7 +4,7 @@
|
||||
* Foundation.
|
||||
*
|
||||
* from: @(#)symseg.h 5.4 (Berkeley) 4/30/91
|
||||
* $Id: symseg.h,v 1.2 1993/08/01 18:46:59 mycroft Exp $
|
||||
* $Id: symseg.h,v 1.3 1993/12/08 10:14:07 pk Exp $
|
||||
*/
|
||||
|
||||
/* GDB symbol table format definitions.
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: warnings.c,v 1.5 1993/12/07 01:44:26 mycroft Exp $
|
||||
* $Id: warnings.c,v 1.6 1993/12/08 10:14:09 pk Exp $
|
||||
*/
|
||||
|
||||
#include <sys/param.h>
|
||||
@ -162,19 +162,17 @@ print_symbols(outfile)
|
||||
for (i = 0; i < TABSIZE; i++) {
|
||||
register symbol *sp;
|
||||
for (sp = symtab[i]; sp; sp = sp->link) {
|
||||
if (sp->defined == 1)
|
||||
if (sp->defined == (N_UNDF|N_EXT))
|
||||
fprintf(outfile, " %s: common, length %#x\n",
|
||||
sp->name, sp->max_common_size);
|
||||
if ( sp->referenced) {
|
||||
if (sp->defined)
|
||||
fprintf(outfile, " %s: %#x %#x\n",
|
||||
sp->name, sp->value, sp->size);
|
||||
else
|
||||
fprintf(outfile, " %s: undefined\n",
|
||||
sp->name);
|
||||
} else
|
||||
if (!sp->referenced)
|
||||
fprintf(outfile, " %s: unreferenced\n",
|
||||
sp->name);
|
||||
sp->name);
|
||||
else if (!sp->defined)
|
||||
fprintf(outfile, " %s: undefined\n", sp->name);
|
||||
else
|
||||
fprintf(outfile, " %s: %#x, size %#x\n",
|
||||
sp->name, sp->value, sp->size);
|
||||
}
|
||||
}
|
||||
|
||||
@ -188,7 +186,7 @@ describe_file_sections(entry, outfile)
|
||||
{
|
||||
fprintf(outfile, " ");
|
||||
print_file_name(entry, outfile);
|
||||
if (entry->just_syms_flag)
|
||||
if (entry->just_syms_flag || entry->is_dynamic)
|
||||
fprintf(outfile, " symbols only\n", 0);
|
||||
else
|
||||
fprintf(outfile, " text %x(%x), data %x(%x), bss %x(%x) hex\n",
|
||||
@ -656,15 +654,17 @@ do_file_warnings (entry, outfile)
|
||||
if (list_multiple_defs && g->multiply_defined) {
|
||||
errfmt = "Definition of symbol %s (multiply defined)";
|
||||
switch (s->n_type) {
|
||||
|
||||
case N_TEXT | N_EXT:
|
||||
line_number = address_to_line (s->n_value, text_scan);
|
||||
file_name = text_scan[0].filename;
|
||||
break;
|
||||
|
||||
case N_DATA | N_EXT:
|
||||
line_number = address_to_line (s->n_value, data_scan);
|
||||
file_name = data_scan[0].filename;
|
||||
break;
|
||||
#if 0
|
||||
|
||||
case N_SETA | N_EXT:
|
||||
case N_SETT | N_EXT:
|
||||
case N_SETD | N_EXT:
|
||||
@ -673,10 +673,9 @@ do_file_warnings (entry, outfile)
|
||||
continue;
|
||||
errfmt = "First set element definition of symbol %s (multiply defined)";
|
||||
break;
|
||||
#endif
|
||||
|
||||
default:
|
||||
/* Don't print out multiple defs
|
||||
at references.*/
|
||||
/* Don't print out multiple defs at references.*/
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -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: xbits.c,v 1.1 1993/10/16 21:52:37 pk Exp $
|
||||
* $Id: xbits.c,v 1.2 1993/12/08 10:14:10 pk Exp $
|
||||
*/
|
||||
|
||||
/*
|
||||
|
@ -1,8 +1,10 @@
|
||||
|
||||
/*
|
||||
* $Id: md-static-funcs.c,v 1.2 1993/12/08 10:14:44 pk Exp $
|
||||
*
|
||||
* Called by ld.so when onanating.
|
||||
* This *must* be a static function, so it is not called through a jmpslot.
|
||||
*/
|
||||
|
||||
static void
|
||||
md_relocate_simple(r, relocation, addr)
|
||||
struct relocation_info *r;
|
||||
|
@ -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: md.c,v 1.5 1993/11/14 16:51:33 pk Exp $
|
||||
* $Id: md.c,v 1.6 1993/12/08 10:14:46 pk Exp $
|
||||
*/
|
||||
|
||||
#include <sys/param.h>
|
||||
@ -242,7 +242,7 @@ long where;
|
||||
long *savep;
|
||||
{
|
||||
*savep = *(long *)where;
|
||||
*(char *)where = BPT;
|
||||
*(char *)where = TRAP;
|
||||
}
|
||||
|
||||
#ifdef NEED_SWAP
|
||||
|
@ -1,5 +1,33 @@
|
||||
/*
|
||||
* $Id: md.h,v 1.4 1993/11/13 11:20:19 pk Exp $ - I386 dependent definitions
|
||||
* Copyright (c) 1993 Paul Kranenburg
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by Paul Kranenburg.
|
||||
* 4. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software withough specific prior written permission
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (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: md.h,v 1.5 1993/12/08 10:14:48 pk Exp $
|
||||
*/
|
||||
|
||||
|
||||
@ -50,7 +78,7 @@ typedef struct jmpslot {
|
||||
#define NOP 0x90
|
||||
#define CALL 0xe890 /* NOP + CALL opcode */
|
||||
#define JUMP 0xe990 /* NOP + JMP opcode */
|
||||
#define BPT 0xcc /* breakpoint: INT 3 */
|
||||
#define TRAP 0xcc /* INT 3 */
|
||||
|
||||
/*
|
||||
* Byte swap defs for cross linking
|
||||
|
@ -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: mdprologue.S,v 1.1 1993/10/16 21:53:16 pk Exp $
|
||||
* $Id: mdprologue.S,v 1.2 1993/12/08 10:14:50 pk Exp $
|
||||
*/
|
||||
|
||||
/*
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: shlib.c,v 1.6 1993/12/07 03:04:28 mycroft Exp $
|
||||
* $Id: shlib.c,v 1.7 1993/12/08 10:14:04 pk Exp $
|
||||
*/
|
||||
|
||||
#include <sys/param.h>
|
||||
@ -17,6 +17,10 @@
|
||||
|
||||
#include "ld.h"
|
||||
|
||||
#ifdef SUNOS4
|
||||
char *strsep();
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Standard directories to search for files specified by -l.
|
||||
*/
|
||||
@ -133,9 +137,10 @@ int n1, n2;
|
||||
#undef minor
|
||||
|
||||
char *
|
||||
findshlib(name, majorp, minorp)
|
||||
findshlib(name, majorp, minorp, do_dot_a)
|
||||
char *name;
|
||||
int *majorp, *minorp;
|
||||
int do_dot_a;
|
||||
{
|
||||
int dewey[MAXDEWEY];
|
||||
int ndewey;
|
||||
@ -155,6 +160,7 @@ int *majorp, *minorp;
|
||||
for (i = 0; i < n_search_dirs; i++) {
|
||||
DIR *dd = opendir(search_dirs[i]);
|
||||
struct dirent *dp;
|
||||
int found_dot_a = 0;
|
||||
|
||||
if (dd == NULL)
|
||||
continue;
|
||||
@ -162,6 +168,16 @@ int *majorp, *minorp;
|
||||
while ((dp = readdir(dd)) != NULL) {
|
||||
int n, j, might_take_it = 0;
|
||||
|
||||
if (do_dot_a && path == NULL &&
|
||||
dp->d_namlen == len + 2 &&
|
||||
strncmp(dp->d_name, lname, len) == 0 &&
|
||||
(dp->d_name+len)[0] == '.' &&
|
||||
(dp->d_name+len)[1] == 'a') {
|
||||
|
||||
path = concat(search_dirs[i], "/", dp->d_name);
|
||||
found_dot_a = 1;
|
||||
}
|
||||
|
||||
if (dp->d_namlen < len + 4)
|
||||
continue;
|
||||
if (strncmp(dp->d_name, lname, len) != 0)
|
||||
@ -172,6 +188,12 @@ int *majorp, *minorp;
|
||||
if ((n = getdewey(tmp, dp->d_name+len+4)) == 0)
|
||||
continue;
|
||||
|
||||
if (major != -1 && found_dot_a) { /* XXX */
|
||||
free(path);
|
||||
path = NULL;
|
||||
found_dot_a = 0;
|
||||
}
|
||||
|
||||
if (major == -1 && minor == -1) {
|
||||
might_take_it = 1;
|
||||
} else if (major != -1 && minor == -1) {
|
||||
@ -193,12 +215,19 @@ int *majorp, *minorp;
|
||||
if (path)
|
||||
free(path);
|
||||
path = concat(search_dirs[i], "/", dp->d_name);
|
||||
found_dot_a = 0;
|
||||
bcopy(tmp, dewey, sizeof(dewey));
|
||||
ndewey = n;
|
||||
*majorp = dewey[0];
|
||||
*minorp = dewey[1];
|
||||
}
|
||||
closedir(dd);
|
||||
|
||||
if (found_dot_a)
|
||||
/*
|
||||
* There's a .a archive here.
|
||||
*/
|
||||
return path;
|
||||
}
|
||||
|
||||
return path;
|
||||
|
Loading…
Reference in New Issue
Block a user