mirror of
https://github.com/freebsd/freebsd-src.git
synced 2024-11-28 04:43:32 +00:00
Updated to recent version of Paul K.'s shlib code. This code has better
warning handling and allows for link-time warnings with a modified version of gas. Note: Not all of the newer bits were updated such as some of the non-x86 machine-dependant code is relevant to FreeBSD right now. Obtained from: NetBSD
This commit is contained in:
parent
3ed375cb27
commit
61f9ce8d32
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=5205
@ -1,14 +1,14 @@
|
||||
# $Id: Makefile,v 1.14 1994/02/14 10:02:13 rgrimes Exp $
|
||||
# $Id: Makefile,v 1.15 1994/08/19 12:24:45 davidg Exp $
|
||||
#
|
||||
|
||||
PROG= ld
|
||||
SRCS= ld.c symbol.c lib.c shlib.c warnings.c etc.c rrs.c xbits.c md.c
|
||||
CFLAGS += -I$(.CURDIR) -I$(.CURDIR)/$(MACHINE)
|
||||
|
||||
LDADD+= -lgnumalloc
|
||||
DPADD+= /usr/lib/libgnumalloc.a
|
||||
LDFLAGS+= -Xlinker -Bstatic
|
||||
|
||||
DPADD+= $(LIBGNUMALLOC)
|
||||
LDADD+= -lgnumalloc
|
||||
|
||||
SUBDIR= ldconfig ldd
|
||||
.if !defined(NOPIC)
|
||||
SUBDIR+= rtld
|
||||
|
@ -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.9 1994/02/13 20:42:09 jkh Exp $
|
||||
* $Id: md.c,v 1.10 1994/06/15 22:40:44 rich Exp $
|
||||
*/
|
||||
|
||||
#include <sys/param.h>
|
||||
@ -228,7 +228,7 @@ long *savep;
|
||||
|
||||
#ifndef RTLD
|
||||
|
||||
#ifdef FreeBSD
|
||||
#ifdef __FreeBSD__
|
||||
int netzmagic;
|
||||
#endif
|
||||
|
||||
@ -247,7 +247,7 @@ int magic, flags;
|
||||
else
|
||||
N_SETMAGIC((*hp), magic, MID_I386, flags);
|
||||
#endif
|
||||
#ifdef FreeBSD
|
||||
#ifdef __FreeBSD__
|
||||
if (oldmagic)
|
||||
hp->a_midmag = magic;
|
||||
else if (netzmagic)
|
||||
|
@ -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.h,v 1.9 1994/02/13 20:42:11 jkh Exp $
|
||||
* $Id: md.h,v 1.10 1994/06/15 22:40:46 rich Exp $
|
||||
*/
|
||||
|
||||
|
||||
@ -63,7 +63,7 @@
|
||||
/*
|
||||
* FreeBSD does it differently
|
||||
*/
|
||||
#ifdef FreeBSD
|
||||
#ifdef __FreeBSD__
|
||||
#define N_SET_FLAG(ex,f) (oldmagic ? (0) : \
|
||||
(netzmagic == 0 ? \
|
||||
N_SETMAGIC(ex, \
|
||||
|
@ -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.3 1993/12/10 10:16:00 jkh Exp $
|
||||
* $Id: mdprologue.S,v 1.4 1994/06/15 22:40:49 rich Exp $
|
||||
*/
|
||||
|
||||
/*
|
||||
@ -43,13 +43,10 @@
|
||||
/*
|
||||
* _rtl(int version, struct crt_ldso *crtp)
|
||||
*/
|
||||
#define FRAME 12 /* Size of stack frame */
|
||||
|
||||
|
||||
_rtl: # crt0 calls us here
|
||||
pushl %ebp # Allocate stack frame
|
||||
movl %esp, %ebp
|
||||
subl $FRAME, %esp
|
||||
pushl %ebx
|
||||
call 1f # PIC function prologue
|
||||
1:
|
||||
@ -68,9 +65,9 @@ _rtl: # crt0 calls us here
|
||||
call %eax # _rtld(version, crtp, DYNAMIC)
|
||||
addl $12,%esp # pop arguments
|
||||
|
||||
movl (-FRAME-4)(%ebp), %ebx # restore %ebx
|
||||
movl -4(%ebp), %ebx # restore %ebx
|
||||
leave # remove stack frame,
|
||||
ret # lets rock
|
||||
ret # let's rock
|
||||
|
||||
# First call to a procedure generally comes through here for
|
||||
# binding.
|
||||
@ -96,7 +93,7 @@ _binder_entry:
|
||||
ret
|
||||
|
||||
# Special system call stubs which return real and effective user and group
|
||||
# ids. Saves overhead of making separate calls for each.
|
||||
# id's. Saves overhead of making separate calls for each.
|
||||
# !! Relies on compatability option in BSD 4.three-and-a-half
|
||||
|
||||
.globl _getreuid, _getregid
|
||||
|
@ -27,11 +27,11 @@
|
||||
.\" (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: ld.1,v 1.7 1994/06/15 22:39:35 rich Exp $
|
||||
.\" $Id: ld.1,v 1.8 1994/12/11 21:39:31 ats Exp $
|
||||
.\"
|
||||
.Dd October 14, 1993
|
||||
.Dt LD 1
|
||||
.Os FreeBSD 2.0
|
||||
.Os FreeBSD
|
||||
.Sh NAME
|
||||
.Nm ld
|
||||
.Nd link editor
|
||||
@ -48,6 +48,7 @@
|
||||
.Op Fl e Ar entry
|
||||
.Op Fl l Ar library-specifier
|
||||
.Op Fl L Ar library-search-path
|
||||
.Op Fl nostdlib
|
||||
.Op Fl o Ar filename
|
||||
.Op Fl T Ar address
|
||||
.Op Fl u Ar symbol
|
||||
@ -144,11 +145,20 @@ values assigned to (global) symbols in the output file.
|
||||
Produce a OMAGIC output file.
|
||||
.It Fl n
|
||||
Produce a NMAGIC output file.
|
||||
.It Fl nostdlib
|
||||
Do not search the built-in path
|
||||
.Po
|
||||
usually
|
||||
.Dq /usr/lib
|
||||
.Pc
|
||||
for
|
||||
.Ar -l
|
||||
specified libraries.
|
||||
.It Fl o Ar filename
|
||||
Specifies the name of the output file. Defaults to
|
||||
.Dq a.out.
|
||||
.It Fl Q
|
||||
Make a BSD/386 / FreeBSD 1.1 output file. This is the default.
|
||||
Produce a QMAGIC (FreeBSD/BSDi-i386) output file. This is the default.
|
||||
.It Fl r
|
||||
Produce relocatable object file, suitable for another pass through
|
||||
.Nm ld.
|
||||
@ -181,10 +191,10 @@ Trace the manipulations inflicted on
|
||||
.It Fl Z
|
||||
Make a 386BSD ZMAGIC output file.
|
||||
.It Fl z
|
||||
Make a NetBSD 0.9 ZMAGIC output file.
|
||||
Make a NetBSD ZMAGIC output file.
|
||||
.Sh FILES
|
||||
.Sh SEE ALSO
|
||||
.Xr ldconfig 1 ,
|
||||
.Xr ldconfig 8 ,
|
||||
.Xr link 5
|
||||
.Sh CAVEATS
|
||||
An entry point must now explicitly be given if the output is intended to be
|
||||
|
@ -27,11 +27,11 @@
|
||||
.\" (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: ld.1,v 1.7 1994/06/15 22:39:35 rich Exp $
|
||||
.\" $Id: ld.1,v 1.8 1994/12/11 21:39:31 ats Exp $
|
||||
.\"
|
||||
.Dd October 14, 1993
|
||||
.Dt LD 1
|
||||
.Os FreeBSD 2.0
|
||||
.Os FreeBSD
|
||||
.Sh NAME
|
||||
.Nm ld
|
||||
.Nd link editor
|
||||
@ -48,6 +48,7 @@
|
||||
.Op Fl e Ar entry
|
||||
.Op Fl l Ar library-specifier
|
||||
.Op Fl L Ar library-search-path
|
||||
.Op Fl nostdlib
|
||||
.Op Fl o Ar filename
|
||||
.Op Fl T Ar address
|
||||
.Op Fl u Ar symbol
|
||||
@ -144,11 +145,20 @@ values assigned to (global) symbols in the output file.
|
||||
Produce a OMAGIC output file.
|
||||
.It Fl n
|
||||
Produce a NMAGIC output file.
|
||||
.It Fl nostdlib
|
||||
Do not search the built-in path
|
||||
.Po
|
||||
usually
|
||||
.Dq /usr/lib
|
||||
.Pc
|
||||
for
|
||||
.Ar -l
|
||||
specified libraries.
|
||||
.It Fl o Ar filename
|
||||
Specifies the name of the output file. Defaults to
|
||||
.Dq a.out.
|
||||
.It Fl Q
|
||||
Make a BSD/386 / FreeBSD 1.1 output file. This is the default.
|
||||
Produce a QMAGIC (FreeBSD/BSDi-i386) output file. This is the default.
|
||||
.It Fl r
|
||||
Produce relocatable object file, suitable for another pass through
|
||||
.Nm ld.
|
||||
@ -181,10 +191,10 @@ Trace the manipulations inflicted on
|
||||
.It Fl Z
|
||||
Make a 386BSD ZMAGIC output file.
|
||||
.It Fl z
|
||||
Make a NetBSD 0.9 ZMAGIC output file.
|
||||
Make a NetBSD ZMAGIC output file.
|
||||
.Sh FILES
|
||||
.Sh SEE ALSO
|
||||
.Xr ldconfig 1 ,
|
||||
.Xr ldconfig 8 ,
|
||||
.Xr link 5
|
||||
.Sh CAVEATS
|
||||
An entry point must now explicitly be given if the output is intended to be
|
||||
|
@ -32,7 +32,7 @@ static char sccsid[] = "@(#)ld.c 6.10 (Berkeley) 5/22/91";
|
||||
Set, indirect, and warning symbol features added by Randy Smith. */
|
||||
|
||||
/*
|
||||
* $Id: ld.c,v 1.21 1994/02/17 03:57:00 davidg Exp $
|
||||
* $Id: ld.c,v 1.22 1994/06/15 22:39:40 rich Exp $
|
||||
*/
|
||||
|
||||
/* Define how to initialize system-dependent header fields. */
|
||||
@ -119,7 +119,7 @@ int rrs_data_start; /* Location of above */
|
||||
int set_sect_start; /* start of set element vectors */
|
||||
int set_sect_size; /* size of above */
|
||||
|
||||
int link_mode; /* Current link mode */
|
||||
int link_mode; /* Current link mode */
|
||||
|
||||
/*
|
||||
* When loading the text and data, we can avoid doing a close
|
||||
@ -191,7 +191,8 @@ int special_sym_count; /* # of linker defined symbols. */
|
||||
int global_alias_count; /* # of aliased symbols */
|
||||
int set_symbol_count; /* # of N_SET* symbols. */
|
||||
int set_vector_count; /* # of set vectors in output. */
|
||||
int warning_count; /* # of warning symbols encountered. */
|
||||
int warn_sym_count; /* # of warning symbols encountered. */
|
||||
int list_warning_symbols; /* 1 => warning symbols referenced */
|
||||
|
||||
struct string_list_element *set_element_prefixes;
|
||||
|
||||
@ -258,7 +259,7 @@ static int parse __P((char *, char *, char *));
|
||||
|
||||
int
|
||||
main(argc, argv)
|
||||
int argc;
|
||||
int argc;
|
||||
char *argv[];
|
||||
{
|
||||
|
||||
@ -272,7 +273,7 @@ main(argc, argv)
|
||||
if (getrlimit(RLIMIT_STACK, &rlim) != 0)
|
||||
warn("getrlimit");
|
||||
else {
|
||||
rlim.rlim_cur = rlim.rlim_max;
|
||||
rlim.rlim_cur = rlim.rlim_max;
|
||||
if (setrlimit(RLIMIT_STACK, &rlim) != 0)
|
||||
warn("setrlimit");
|
||||
}
|
||||
@ -321,7 +322,8 @@ main(argc, argv)
|
||||
non_L_local_sym_count = 0;
|
||||
debugger_sym_count = 0;
|
||||
undefined_global_sym_count = 0;
|
||||
warning_count = 0;
|
||||
warn_sym_count = 0;
|
||||
list_warning_symbols = 0;
|
||||
multiple_def_count = 0;
|
||||
common_defined_global_count = 0;
|
||||
|
||||
@ -490,7 +492,7 @@ decode_command(argc, argv)
|
||||
errx(1, "no input files");
|
||||
|
||||
p = file_table = (struct file_entry *)
|
||||
xmalloc(number_of_files * sizeof(struct file_entry));
|
||||
xmalloc(number_of_files * sizeof(struct file_entry));
|
||||
bzero(p, number_of_files * sizeof(struct file_entry));
|
||||
|
||||
/* Now scan again and fill in file_table. */
|
||||
@ -553,7 +555,7 @@ decode_command(argc, argv)
|
||||
|
||||
if (page_align_segments &&
|
||||
(text_start - text_start_alignment) & (page_size - 1))
|
||||
errx(1, "-T argument not multiple of page size, with sharable output");
|
||||
errx(1, "incorrect alignment of text start address");
|
||||
|
||||
/* Append the standard search directories to the user-specified ones. */
|
||||
add_search_path(getenv("LD_LIBRARY_PATH"));
|
||||
@ -782,7 +784,7 @@ decode_option(swt, arg)
|
||||
errx(1, "invalid command option `%s'", swt);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Convenient functions for operating on one or all files being loaded. */
|
||||
|
||||
/*
|
||||
@ -938,7 +940,7 @@ file_close()
|
||||
*/
|
||||
int
|
||||
file_open(entry)
|
||||
register struct file_entry *entry;
|
||||
register struct file_entry *entry;
|
||||
{
|
||||
register int fd;
|
||||
|
||||
@ -990,7 +992,7 @@ read_header(fd, entry)
|
||||
register int len;
|
||||
|
||||
if (lseek(fd, entry->starting_offset, L_SET) !=
|
||||
entry->starting_offset)
|
||||
entry->starting_offset)
|
||||
err(1, "%s: read_header: lseek", get_file_name(entry));
|
||||
|
||||
len = read(fd, &entry->header, sizeof(struct exec));
|
||||
@ -1000,7 +1002,7 @@ read_header(fd, entry)
|
||||
md_swapin_exec_hdr(&entry->header);
|
||||
|
||||
if (N_BADMAG (entry->header))
|
||||
errx(1, "%s: bad magic number", get_file_name(entry));
|
||||
errx(1, "%s: bad magic", get_file_name(entry));
|
||||
|
||||
if (N_BADMID(entry->header))
|
||||
errx(1, "%s: non-native input file", get_file_name(entry));
|
||||
@ -1016,7 +1018,7 @@ read_header(fd, entry)
|
||||
|
||||
void
|
||||
read_entry_symbols(fd, entry)
|
||||
struct file_entry *entry;
|
||||
struct file_entry *entry;
|
||||
int fd;
|
||||
{
|
||||
int str_size;
|
||||
@ -1035,8 +1037,8 @@ read_entry_symbols(fd, entry)
|
||||
xmalloc(entry->nsymbols * sizeof(struct localsymbol));
|
||||
|
||||
if (lseek(fd, N_SYMOFF(entry->header) + entry->starting_offset, L_SET)
|
||||
!= N_SYMOFF(entry->header) + entry->starting_offset)
|
||||
err(1, "%s: read_symbols: lseek(syms) failed", get_file_name(entry));
|
||||
!= N_SYMOFF(entry->header) + entry->starting_offset)
|
||||
err(1, "%s: read_symbols: lseek(syms)", get_file_name(entry));
|
||||
|
||||
if (entry->header.a_syms != read(fd, np, entry->header.a_syms))
|
||||
errx(1, "%s: read_symbols: premature end of file in symbols",
|
||||
@ -1055,9 +1057,9 @@ read_entry_symbols(fd, entry)
|
||||
}
|
||||
|
||||
entry->strings_offset = N_STROFF(entry->header) +
|
||||
entry->starting_offset;
|
||||
entry->starting_offset;
|
||||
if (lseek(fd, entry->strings_offset, 0) == (off_t)-1)
|
||||
err(1, "%s: read_symbols: lseek(strings) failed",
|
||||
err(1, "%s: read_symbols: lseek(strings)",
|
||||
get_file_name(entry));
|
||||
if (sizeof str_size != read(fd, &str_size, sizeof str_size))
|
||||
errx(1, "%s: read_symbols: cannot read string table size",
|
||||
@ -1071,7 +1073,7 @@ read_entry_symbols(fd, entry)
|
||||
*/
|
||||
void
|
||||
read_entry_strings(fd, entry)
|
||||
struct file_entry *entry;
|
||||
struct file_entry *entry;
|
||||
int fd;
|
||||
{
|
||||
|
||||
@ -1108,13 +1110,13 @@ read_entry_relocation(fd, entry)
|
||||
if (!entry->textrel) {
|
||||
|
||||
reloc = (struct relocation_info *)
|
||||
xmalloc(entry->header.a_trsize);
|
||||
xmalloc(entry->header.a_trsize);
|
||||
|
||||
pos = text_offset(entry) +
|
||||
entry->header.a_text + entry->header.a_data;
|
||||
entry->header.a_text + entry->header.a_data;
|
||||
|
||||
if (lseek(fd, pos, L_SET) != pos)
|
||||
err(1, "%s: read_reloc(text): lseek failed",
|
||||
err(1, "%s: read_reloc(text): lseek",
|
||||
get_file_name(entry));
|
||||
|
||||
if (read(fd, reloc, entry->header.a_trsize) !=
|
||||
@ -1131,13 +1133,13 @@ read_entry_relocation(fd, entry)
|
||||
if (!entry->datarel) {
|
||||
|
||||
reloc = (struct relocation_info *)
|
||||
xmalloc(entry->header.a_drsize);
|
||||
xmalloc(entry->header.a_drsize);
|
||||
|
||||
pos = text_offset(entry) + entry->header.a_text +
|
||||
entry->header.a_data + entry->header.a_trsize;
|
||||
entry->header.a_data + entry->header.a_trsize;
|
||||
|
||||
if (lseek(fd, pos, L_SET) != pos)
|
||||
err(1, "%s: read_reloc(data): lseek failed",
|
||||
err(1, "%s: read_reloc(data): lseek",
|
||||
get_file_name(entry));
|
||||
|
||||
if (read(fd, reloc, entry->header.a_drsize) !=
|
||||
@ -1180,11 +1182,11 @@ load_symbols()
|
||||
|
||||
void
|
||||
read_file_symbols(entry)
|
||||
register struct file_entry *entry;
|
||||
register struct file_entry *entry;
|
||||
{
|
||||
register int fd;
|
||||
register int len;
|
||||
struct exec hdr;
|
||||
register int len;
|
||||
struct exec hdr;
|
||||
|
||||
fd = file_open(entry);
|
||||
|
||||
@ -1199,18 +1201,25 @@ read_file_symbols(entry)
|
||||
if (N_IS_DYNAMIC(hdr) && !(entry->flags & E_JUST_SYMS)) {
|
||||
if (relocatable_output) {
|
||||
errx(1,
|
||||
"%s: -r and shared objects currently not supported ",
|
||||
"%s: -r and shared objects currently not supported",
|
||||
get_file_name(entry));
|
||||
return;
|
||||
}
|
||||
#if notyet /* Compatibility */
|
||||
if (!(N_GETFLAG(hdr) & EX_PIC))
|
||||
warnx("%s: EX_PIC not set",
|
||||
get_file_name(entry));
|
||||
#endif
|
||||
entry->flags |= E_DYNAMIC;
|
||||
if (entry->superfile || rrs_add_shobj(entry))
|
||||
read_shared_object(fd, entry);
|
||||
else
|
||||
entry->flags |= E_SCRAPPED;
|
||||
} else {
|
||||
if (N_GETFLAG(hdr) & EX_PIC)
|
||||
pic_code_seen = 1;
|
||||
read_entry_symbols(fd, entry);
|
||||
entry->strings = (char *)alloca (entry->string_size);
|
||||
entry->strings = (char *)alloca(entry->string_size);
|
||||
read_entry_strings(fd, entry);
|
||||
read_entry_relocation(fd, entry);
|
||||
enter_file_symbols(entry);
|
||||
@ -1221,7 +1230,7 @@ read_file_symbols(entry)
|
||||
|
||||
lseek (fd, 0, 0);
|
||||
if (SARMAG != read(fd, armag, SARMAG) ||
|
||||
strncmp (armag, ARMAG, SARMAG))
|
||||
strncmp (armag, ARMAG, SARMAG))
|
||||
errx(1,
|
||||
"%s: malformed input file (not rel or archive)",
|
||||
get_file_name(entry));
|
||||
@ -1268,26 +1277,33 @@ enter_file_symbols(entry)
|
||||
enter_global_ref(lsp,
|
||||
p->n_un.n_strx + entry->strings, entry);
|
||||
} else if (p->n_type == N_WARNING) {
|
||||
char *name = p->n_un.n_strx + entry->strings;
|
||||
char *msg = p->n_un.n_strx + entry->strings;
|
||||
|
||||
/* Grab the next entry. */
|
||||
p++;
|
||||
lsp++;
|
||||
p = &lsp->nzlist.nlist;
|
||||
if (p->n_type != (N_UNDF | N_EXT)) {
|
||||
warnx(
|
||||
"%s: Warning symbol without external reference following.",
|
||||
get_file_name(entry));
|
||||
make_executable = 0;
|
||||
p--; /* Process normally. */
|
||||
lsp--; /* Process normally. */
|
||||
} else {
|
||||
symbol *sp;
|
||||
char *sname = p->n_un.n_strx + entry->strings;
|
||||
char *name = p->n_un.n_strx + entry->strings;
|
||||
/* Deal with the warning symbol. */
|
||||
enter_global_ref(lsp,
|
||||
p->n_un.n_strx + entry->strings, entry);
|
||||
sp = getsym (sname);
|
||||
sp->warning = (char *)xmalloc(strlen(name)+1);
|
||||
strcpy (sp->warning, name);
|
||||
warning_count++;
|
||||
lsp->flags |= LS_WARNING;
|
||||
enter_global_ref(lsp, name, entry);
|
||||
sp = getsym(name);
|
||||
if (sp->warning == NULL) {
|
||||
sp->warning = (char *)
|
||||
xmalloc(strlen(msg)+1);
|
||||
strcpy(sp->warning, msg);
|
||||
warn_sym_count++;
|
||||
} else if (strcmp(sp->warning, msg))
|
||||
warnx(
|
||||
"%s: multiple definitions for warning symbol `%s'",
|
||||
get_file_name(entry), sp->name);
|
||||
}
|
||||
} else if (p->n_type & N_EXT) {
|
||||
enter_global_ref(lsp,
|
||||
@ -1332,7 +1348,7 @@ enter_global_ref(lsp, name, entry)
|
||||
sp->alias = getsym(entry->strings + (lsp + 1)->nzlist.nz_strx);
|
||||
if (sp == sp->alias) {
|
||||
warnx("%s: %s is alias for itself",
|
||||
get_file_name(entry), name);
|
||||
get_file_name(entry), name);
|
||||
/* Rewrite symbol as global text symbol with value 0 */
|
||||
lsp->nzlist.nz_type = N_TEXT|N_EXT;
|
||||
lsp->nzlist.nz_value = 0;
|
||||
@ -1345,6 +1361,7 @@ enter_global_ref(lsp, name, entry)
|
||||
if (entry->flags & E_DYNAMIC) {
|
||||
lsp->next = sp->sorefs;
|
||||
sp->sorefs = lsp;
|
||||
lsp->symbol = sp;
|
||||
|
||||
/*
|
||||
* Handle commons from shared objects:
|
||||
@ -1376,7 +1393,12 @@ enter_global_ref(lsp, name, entry)
|
||||
if (nzp->nz_size > sp->size)
|
||||
sp->size = nzp->nz_size;
|
||||
|
||||
lsp->symbol = sp;
|
||||
if ((lsp->flags & LS_WARNING) && (sp->flags & GS_REFERENCED))
|
||||
/*
|
||||
* Prevent warning symbols from getting
|
||||
* gratuitously referenced.
|
||||
*/
|
||||
list_warning_symbols = 1;
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1384,12 +1406,25 @@ enter_global_ref(lsp, name, entry)
|
||||
sp->refs = lsp;
|
||||
lsp->symbol = sp;
|
||||
|
||||
if (lsp->flags & LS_WARNING) {
|
||||
/*
|
||||
* Prevent warning symbols from getting
|
||||
* gratuitously referenced.
|
||||
*/
|
||||
if (sp->flags & GS_REFERENCED)
|
||||
list_warning_symbols = 1;
|
||||
return;
|
||||
}
|
||||
|
||||
if (sp->warning)
|
||||
list_warning_symbols = 1;
|
||||
|
||||
sp->flags |= GS_REFERENCED;
|
||||
|
||||
if (sp == dynamic_symbol || sp == got_symbol) {
|
||||
if (type != (N_UNDF | N_EXT) && !(entry->flags & E_JUST_SYMS))
|
||||
errx(1,"Linker reserved symbol %s defined as type %x ",
|
||||
name, type);
|
||||
name, type);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1433,8 +1468,8 @@ enter_global_ref(lsp, name, entry)
|
||||
*/
|
||||
common_defined_global_count--;
|
||||
sp->common_size = 0;
|
||||
} else if (com && type == (N_UNDF | N_EXT)
|
||||
&& sp->common_size < nzp->nz_value)
|
||||
} else if (com && type == (N_UNDF | N_EXT) &&
|
||||
sp->common_size < nzp->nz_value)
|
||||
/*
|
||||
* It used to be common and this is a new common entry
|
||||
* to which we need to pay attention.
|
||||
@ -1453,7 +1488,7 @@ enter_global_ref(lsp, name, entry)
|
||||
|
||||
|
||||
if (sp == end_symbol && (entry->flags & E_JUST_SYMS) &&
|
||||
!T_flag_specified)
|
||||
!T_flag_specified)
|
||||
text_start = nzp->nz_value;
|
||||
|
||||
if (sp->flags & GS_TRACE) {
|
||||
@ -1656,7 +1691,7 @@ printf("set_sect_start = %#x, set_sect_size = %#x\n",
|
||||
* the output symbol table (barring DISCARD_* settings).
|
||||
*/
|
||||
global_sym_count = defined_global_sym_count +
|
||||
undefined_global_sym_count;
|
||||
undefined_global_sym_count;
|
||||
|
||||
if (dynamic_symbol->flags & GS_REFERENCED)
|
||||
global_sym_count++;
|
||||
@ -1664,19 +1699,24 @@ printf("set_sect_start = %#x, set_sect_size = %#x\n",
|
||||
if (got_symbol->flags & GS_REFERENCED)
|
||||
global_sym_count++;
|
||||
|
||||
if (relocatable_output || building_shared_object)
|
||||
if (relocatable_output || building_shared_object) {
|
||||
/* For each alias we write out two struct nlists */
|
||||
global_sym_count += global_alias_count;
|
||||
/* Propagate warning symbols; costs two extra struct nlists */
|
||||
global_sym_count += 2 * warn_sym_count;
|
||||
}
|
||||
|
||||
if (relocatable_output)
|
||||
/* We write out the original N_SET* symbols */
|
||||
global_sym_count += size_sym_count;
|
||||
|
||||
#ifdef DEBUG
|
||||
printf("global symbols %d (defined %d, undefined %d, aliases %d), locals: %d, \
|
||||
debug symbols: %d, set_symbols %d\n",
|
||||
printf(
|
||||
"global symbols %d (defined %d, undefined %d, aliases %d, warnings 2 * %d), \
|
||||
locals: %d, debug symbols: %d, set_symbols %d\n",
|
||||
global_sym_count,
|
||||
defined_global_sym_count, undefined_global_sym_count, global_alias_count,
|
||||
defined_global_sym_count, undefined_global_sym_count,
|
||||
global_alias_count, warn_sym_count,
|
||||
local_sym_count, debugger_sym_count, set_symbol_count);
|
||||
#endif
|
||||
}
|
||||
@ -1766,7 +1806,7 @@ digest_pass1()
|
||||
sp->mult_defs = 1;
|
||||
multiple_def_count++;
|
||||
}
|
||||
sp->def_nlist = p;
|
||||
sp->def_lsp = lsp;
|
||||
lsp->entry->flags |= E_SYMBOLS_USED;
|
||||
sp->defined = type;
|
||||
sp->aux = N_AUX(p);
|
||||
@ -1814,10 +1854,12 @@ digest_pass1()
|
||||
if ((type & N_EXT) && type != (N_UNDF | N_EXT) &&
|
||||
(type & N_TYPE) != N_FN) {
|
||||
/* non-common definition */
|
||||
sp->def_nlist = p;
|
||||
lsp->entry->flags |= E_SYMBOLS_USED;
|
||||
sp->def_lsp = lsp;
|
||||
sp->so_defined = type;
|
||||
sp->aux = N_AUX(p);
|
||||
if (lsp->entry->flags & E_SECONDCLASS)
|
||||
continue;
|
||||
lsp->entry->flags |= E_SYMBOLS_USED;
|
||||
if (sp->flags & GS_REFERENCED)
|
||||
undefined_global_sym_count--;
|
||||
else
|
||||
@ -1873,7 +1915,7 @@ consider_relocation(entry, dataseg)
|
||||
if (relocatable_output) {
|
||||
lsp = &entry->symbols[reloc->r_symbolnum];
|
||||
if (RELOC_BASEREL_P(reloc)) {
|
||||
pic_code_seen = 1;
|
||||
pic_code_seen = 1; /* Compatibility */
|
||||
if (!RELOC_EXTERN_P(reloc))
|
||||
lsp->flags |= LS_RENAME;
|
||||
}
|
||||
@ -1977,13 +2019,13 @@ consider_relocation(entry, dataseg)
|
||||
}
|
||||
|
||||
if (force_alias_definition && sp->so_defined &&
|
||||
sp->aux == AUX_FUNC) {
|
||||
sp->aux == AUX_FUNC) {
|
||||
|
||||
/* Call to shared library procedure */
|
||||
alloc_rrs_jmpslot(entry, sp);
|
||||
|
||||
} else if (sp->size && sp->so_defined &&
|
||||
sp->aux == AUX_OBJECT) {
|
||||
sp->aux == AUX_OBJECT) {
|
||||
|
||||
/* Reference to shared library data */
|
||||
alloc_rrs_cpy_reloc(entry, sp);
|
||||
@ -2146,7 +2188,7 @@ printf("%s: datastart: %#x, bss %#x\n", get_file_name(entry),
|
||||
* file's text.
|
||||
*/
|
||||
p->n_value += entry->data_start_address -
|
||||
entry->header.a_text;
|
||||
entry->header.a_text;
|
||||
break;
|
||||
case N_BSS:
|
||||
case N_SETB:
|
||||
@ -2237,10 +2279,13 @@ digest_pass2()
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
if (sp->defined && sp->def_nlist &&
|
||||
((sp->defined & ~N_EXT) != N_SETV))
|
||||
sp->value = sp->def_nlist->n_value;
|
||||
if (sp->def_lsp) {
|
||||
if (sp->defined && (sp->defined & ~N_EXT) != N_SETV)
|
||||
sp->value = sp->def_lsp->nzlist.nz_value;
|
||||
if (sp->so_defined &&
|
||||
(sp->def_lsp->entry->flags & E_SECONDCLASS))
|
||||
undefined_global_sym_count++;
|
||||
}
|
||||
|
||||
/*
|
||||
* If not -r'ing, allocate common symbols in the BSS section.
|
||||
@ -2371,9 +2416,18 @@ static int nsyms;
|
||||
void
|
||||
write_header()
|
||||
{
|
||||
int flags = (rrs_section_type == RRS_FULL) ? EX_DYNAMIC : 0;
|
||||
int flags;
|
||||
|
||||
if (oldmagic && (flags & EX_DYNAMIC))
|
||||
if (link_mode & SHAREABLE)
|
||||
flags = EX_DYNAMIC | EX_PIC;
|
||||
else if (pic_code_seen)
|
||||
flags = EX_PIC;
|
||||
else if (rrs_section_type == RRS_FULL)
|
||||
flags = EX_DYNAMIC;
|
||||
else
|
||||
flags = 0;
|
||||
|
||||
if (oldmagic && (flags & EX_DPMASK))
|
||||
warnx("Cannot set flag in old magic headers\n");
|
||||
|
||||
N_SET_FLAG (outheader, flags);
|
||||
@ -2382,7 +2436,7 @@ write_header()
|
||||
outheader.a_data = data_size;
|
||||
outheader.a_bss = bss_size;
|
||||
outheader.a_entry = (entry_symbol ? entry_symbol->value
|
||||
: text_start + entry_offset);
|
||||
: text_start + entry_offset);
|
||||
|
||||
if (strip_symbols == STRIP_ALL)
|
||||
nsyms = 0;
|
||||
@ -2415,7 +2469,7 @@ write_header()
|
||||
padfile(N_TXTOFF(outheader) - sizeof outheader, outdesc);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Relocate the text segment of each input file
|
||||
* and write to the output file.
|
||||
@ -2443,9 +2497,9 @@ write_text()
|
||||
*/
|
||||
void
|
||||
copy_text(entry)
|
||||
struct file_entry *entry;
|
||||
struct file_entry *entry;
|
||||
{
|
||||
register char *bytes;
|
||||
register char *bytes;
|
||||
register int fd;
|
||||
|
||||
if (trace_files)
|
||||
@ -2464,16 +2518,16 @@ copy_text(entry)
|
||||
if (lseek(fd, text_offset(entry), L_SET) == (off_t)-1)
|
||||
err(1, "%s: copy_text: lseek", get_file_name(entry));
|
||||
if (entry->header.a_text != read(fd, bytes, entry->header.a_text))
|
||||
errx(1, "%s: copy_text: premature EOF in text section", get_file_name(entry));
|
||||
errx(1, "%s: copy_text: premature EOF", get_file_name(entry));
|
||||
|
||||
/* Relocate the text according to the text relocation. */
|
||||
perform_relocation (bytes, entry->header.a_text,
|
||||
entry->textrel, entry->ntextrel, entry, 0);
|
||||
entry->textrel, entry->ntextrel, entry, 0);
|
||||
|
||||
/* Write the relocated text to the output file. */
|
||||
mywrite(bytes, 1, entry->header.a_text, outdesc);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Relocate the data segment of each input file
|
||||
* and write to the output file.
|
||||
@ -2489,7 +2543,7 @@ write_data()
|
||||
|
||||
pos = N_DATOFF(outheader) + data_start - rrs_data_start;
|
||||
if (lseek(outdesc, pos, L_SET) != pos)
|
||||
errx(1, "write_data: failed to lseek to data offset");
|
||||
errx(1, "write_data: lseek");
|
||||
|
||||
each_full_file(copy_data, 0);
|
||||
file_close();
|
||||
@ -2518,9 +2572,9 @@ write_data()
|
||||
*/
|
||||
void
|
||||
copy_data(entry)
|
||||
struct file_entry *entry;
|
||||
struct file_entry *entry;
|
||||
{
|
||||
register char *bytes;
|
||||
register char *bytes;
|
||||
register int fd;
|
||||
|
||||
if (trace_files)
|
||||
@ -2537,10 +2591,10 @@ copy_data(entry)
|
||||
(off_t)-1)
|
||||
err(1, "%s: copy_data: lseek", get_file_name(entry));
|
||||
if (entry->header.a_data != read(fd, bytes, entry->header.a_data))
|
||||
errx(1, "%s: copy_data: premature EOF in data section", get_file_name(entry));
|
||||
errx(1, "%s: copy_data: premature EOF", get_file_name(entry));
|
||||
|
||||
perform_relocation(bytes, entry->header.a_data,
|
||||
entry->datarel, entry->ndatarel, entry, 1);
|
||||
entry->datarel, entry->ndatarel, entry, 1);
|
||||
|
||||
mywrite(bytes, 1, entry->header.a_data, outdesc);
|
||||
}
|
||||
@ -2664,7 +2718,7 @@ perform_relocation(data, data_size, reloc, nreloc, entry, dataseg)
|
||||
if (sp == got_symbol) {
|
||||
/* Handle _GOT_ refs */
|
||||
relocation = addend + sp->value
|
||||
+ md_got_reloc(r);
|
||||
+ md_got_reloc(r);
|
||||
} else if (building_shared_object) {
|
||||
/*
|
||||
* Normal (non-PIC) relocation needs
|
||||
@ -2796,12 +2850,12 @@ perform_relocation(data, data_size, reloc, nreloc, entry, dataseg)
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* For relocatable_output only: write out the relocation,
|
||||
* relocating the addresses-to-be-relocated.
|
||||
*/
|
||||
|
||||
void
|
||||
write_rel()
|
||||
{
|
||||
@ -2822,13 +2876,17 @@ write_rel()
|
||||
if (dynamic_symbol->flags & GS_REFERENCED)
|
||||
dynamic_symbol->symbolnum = count++;
|
||||
FOR_EACH_SYMBOL(i, sp) {
|
||||
if (sp != dynamic_symbol && (sp->flags & GS_REFERENCED)) {
|
||||
sp->symbolnum = count++;
|
||||
if (sp->size)
|
||||
count++;
|
||||
if (sp->alias)
|
||||
count++;
|
||||
}
|
||||
if (sp == dynamic_symbol)
|
||||
continue;
|
||||
if (sp->warning)
|
||||
count += 2;
|
||||
if (!(sp->flags & GS_REFERENCED))
|
||||
continue;
|
||||
sp->symbolnum = count++;
|
||||
if (sp->size)
|
||||
count++;
|
||||
if (sp->alias)
|
||||
count++;
|
||||
} END_EACH_SYMBOL;
|
||||
|
||||
if (count != global_sym_count)
|
||||
@ -2947,7 +3005,7 @@ coptxtrel(entry)
|
||||
}
|
||||
md_swapout_reloc(entry->textrel, entry->ntextrel);
|
||||
mywrite(entry->textrel, entry->ntextrel,
|
||||
sizeof(struct relocation_info), outdesc);
|
||||
sizeof(struct relocation_info), outdesc);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -3012,9 +3070,9 @@ copdatrel(entry)
|
||||
}
|
||||
md_swapout_reloc(entry->datarel, entry->ndatarel);
|
||||
mywrite(entry->datarel, entry->ndatarel,
|
||||
sizeof(struct relocation_info), outdesc);
|
||||
sizeof(struct relocation_info), outdesc);
|
||||
}
|
||||
|
||||
|
||||
void write_file_syms __P((struct file_entry *, int *));
|
||||
void write_string_table __P((void));
|
||||
|
||||
@ -3023,24 +3081,24 @@ void write_string_table __P((void));
|
||||
static int symbol_table_offset;
|
||||
static int symbol_table_len;
|
||||
|
||||
/* Address in output file where string table starts. */
|
||||
/* Address in output file where string table starts. */
|
||||
static int string_table_offset;
|
||||
|
||||
/* Offset within string table
|
||||
where the strings in `strtab_vector' should be written. */
|
||||
where the strings in `strtab_vector' should be written. */
|
||||
static int string_table_len;
|
||||
|
||||
/* Total size of string table strings allocated so far,
|
||||
including strings in `strtab_vector'. */
|
||||
including strings in `strtab_vector'. */
|
||||
static int strtab_size;
|
||||
|
||||
/* Vector whose elements are strings to be added to the string table. */
|
||||
/* Vector whose elements are strings to be added to the string table. */
|
||||
static char **strtab_vector;
|
||||
|
||||
/* Vector whose elements are the lengths of those strings. */
|
||||
/* Vector whose elements are the lengths of those strings. */
|
||||
static int *strtab_lens;
|
||||
|
||||
/* Index in `strtab_vector' at which the next string will be stored. */
|
||||
/* Index in `strtab_vector' at which the next string will be stored. */
|
||||
static int strtab_index;
|
||||
|
||||
/*
|
||||
@ -3093,8 +3151,8 @@ write_string_table()
|
||||
if (ferror(outstream))
|
||||
err(1, "write_string_table: %s", output_filename);
|
||||
}
|
||||
|
||||
/* Write the symbol table and string table of the output file. */
|
||||
|
||||
/* Write the symbol table and string table of the output file. */
|
||||
|
||||
void
|
||||
write_syms()
|
||||
@ -3166,6 +3224,28 @@ write_syms()
|
||||
/* Already dealt with above */
|
||||
continue;
|
||||
|
||||
/*
|
||||
* Propagate N_WARNING symbols.
|
||||
*/
|
||||
if ((relocatable_output || building_shared_object)
|
||||
&& sp->warning) {
|
||||
nl.n_type = N_WARNING;
|
||||
nl.n_un.n_strx = assign_string_table_index(sp->warning);
|
||||
nl.n_value = 0;
|
||||
nl.n_other = 0;
|
||||
nl.n_desc = 0;
|
||||
*bufp++ = nl;
|
||||
syms_written++;
|
||||
|
||||
nl.n_type = N_UNDF + N_EXT;
|
||||
nl.n_un.n_strx = assign_string_table_index(sp->name);
|
||||
nl.n_value = 0;
|
||||
nl.n_other = 0;
|
||||
nl.n_desc = 0;
|
||||
*bufp++ = nl;
|
||||
syms_written++;
|
||||
}
|
||||
|
||||
if (!(sp->flags & GS_REFERENCED))
|
||||
/* Came from shared object but was not used */
|
||||
continue;
|
||||
@ -3342,8 +3422,8 @@ wrong number of symbols (%d) written into output file, should be %d",
|
||||
*/
|
||||
void
|
||||
write_file_syms(entry, syms_written_addr)
|
||||
struct file_entry *entry;
|
||||
int *syms_written_addr;
|
||||
struct file_entry *entry;
|
||||
int *syms_written_addr;
|
||||
{
|
||||
struct localsymbol *lsp, *lspend;
|
||||
|
||||
@ -3463,9 +3543,9 @@ parse(arg, format, error)
|
||||
*/
|
||||
void
|
||||
mywrite(buf, count, eltsize, fd)
|
||||
void *buf;
|
||||
int count;
|
||||
int eltsize;
|
||||
void *buf;
|
||||
int count;
|
||||
int eltsize;
|
||||
int fd;
|
||||
{
|
||||
register int val;
|
||||
@ -3500,7 +3580,7 @@ cleanup()
|
||||
*/
|
||||
void
|
||||
padfile(padding, fd)
|
||||
int padding;
|
||||
int padding;
|
||||
int fd;
|
||||
{
|
||||
register char *buf;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: ld.h,v 1.10 1994/02/13 20:41:34 jkh Exp $
|
||||
* $Id: ld.h,v 1.11 1994/06/15 22:39:46 rich Exp $
|
||||
*/
|
||||
/*-
|
||||
* This code is derived from software copyrighted by the Free Software
|
||||
@ -31,10 +31,6 @@
|
||||
#define alloca __builtin_alloca
|
||||
#endif
|
||||
|
||||
#ifdef __FreeBSD__
|
||||
#define FreeBSD
|
||||
#endif
|
||||
|
||||
#include "md.h"
|
||||
#include "link.h"
|
||||
|
||||
@ -49,7 +45,7 @@
|
||||
|
||||
/* Define this to specify the default executable format. */
|
||||
#ifndef DEFAULT_MAGIC
|
||||
#ifdef FreeBSD
|
||||
#ifdef __FreeBSD__
|
||||
#define DEFAULT_MAGIC QMAGIC
|
||||
extern int netzmagic;
|
||||
#else
|
||||
@ -342,6 +338,7 @@ typedef struct localsymbol {
|
||||
#define LS_WRITE 2 /* Symbol goes in output symtable */
|
||||
#define LS_RENAME 4 /* xlat name to `<file>.<name>' */
|
||||
#define LS_GOTSLOTCLAIMED 8 /* This symbol has a GOT entry */
|
||||
#define LS_WARNING 16 /* Second part of a N_WARNING duo */
|
||||
} localsymbol_t;
|
||||
|
||||
/* Symbol table */
|
||||
@ -368,7 +365,7 @@ typedef struct glosym {
|
||||
int symbolnum; /* Symbol index in output symbol table */
|
||||
int rrs_symbolnum; /* Symbol index in RRS symbol table */
|
||||
|
||||
struct nlist *def_nlist; /* The local symbol that gave this
|
||||
localsymbol_t *def_lsp; /* The local symbol that gave this
|
||||
global symbol its definition */
|
||||
|
||||
char defined; /* Definition of this symbol */
|
||||
@ -428,7 +425,8 @@ extern int multiple_def_count;
|
||||
extern int common_defined_global_count;
|
||||
|
||||
/* # of warning symbols encountered. */
|
||||
extern int warning_count;
|
||||
extern int warn_sym_count;
|
||||
extern int list_warning_symbols;
|
||||
|
||||
/*
|
||||
* Define a linked list of strings which define symbols which should be
|
||||
@ -523,6 +521,7 @@ struct file_entry {
|
||||
#define E_DYNAMIC 0x20 /* File is a shared object */
|
||||
#define E_SCRAPPED 0x40 /* Ignore this file */
|
||||
#define E_SYMBOLS_USED 0x80 /* Symbols from this entry were used */
|
||||
#define E_SECONDCLASS 0x100 /* Shared object is a subsidiary */
|
||||
};
|
||||
|
||||
/*
|
||||
|
@ -1,6 +1,37 @@
|
||||
.\"
|
||||
.\" 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.
|
||||
.\" 3. The name of the author may not be used to endorse or promote products
|
||||
.\" derived from this software without 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$
|
||||
.\"
|
||||
.Dd October 3, 1993
|
||||
.Dt LDCONFIG 8
|
||||
.Os FreeBSD 1.1
|
||||
.Os FreeBSD
|
||||
.Sh NAME
|
||||
.Nm ldconfig
|
||||
.Nd configure the shared library cache
|
||||
@ -20,7 +51,7 @@ directories. It scans a set of built-in system directories and any
|
||||
specified on the command line (in the given order) looking for shared
|
||||
libraries and stores the results in the file
|
||||
.Xr /var/run/ld.so.hints
|
||||
to forstall the overhead that would otherwise result from the
|
||||
to forestall the overhead that would otherwise result from the
|
||||
directory search operations
|
||||
.Xr ld.so
|
||||
would have to perform to load the required shared libraries.
|
||||
@ -56,16 +87,8 @@ Lists the current contents of
|
||||
.Xr ld.so.hints
|
||||
on the standard output. The hints file will not be modified.
|
||||
.It Fl s
|
||||
Do not scan
|
||||
.Nm ldconfig
|
||||
\'s builtin system directories
|
||||
.Sq /usr/lib
|
||||
,
|
||||
.Sq /usr/X386/lib
|
||||
,
|
||||
.Sq /usr/X11R6/lib
|
||||
and
|
||||
.Sq /usr/local/lib
|
||||
Do not scan the built-in system directory
|
||||
.Pq Dq /usr/lib
|
||||
for shared libraries.
|
||||
.It Fl v
|
||||
Switch on verbose mode.
|
||||
|
@ -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: ldconfig.c,v 1.6 1994/06/05 19:04:11 ats Exp $
|
||||
* $Id: ldconfig.c,v 1.7 1994/06/15 22:40:56 rich Exp $
|
||||
*/
|
||||
|
||||
#include <sys/param.h>
|
||||
@ -54,7 +54,8 @@
|
||||
#undef major
|
||||
#undef minor
|
||||
|
||||
char *progname;
|
||||
extern char *__progname;
|
||||
|
||||
static int verbose;
|
||||
static int nostd;
|
||||
static int justread;
|
||||
@ -84,12 +85,6 @@ char *argv[];
|
||||
{
|
||||
int i, c;
|
||||
int rval = 0;
|
||||
extern int optind;
|
||||
|
||||
if ((progname = strrchr(argv[0], '/')) == NULL)
|
||||
progname = argv[0];
|
||||
else
|
||||
progname++;
|
||||
|
||||
while ((c = getopt(argc, argv, "rsv")) != EOF) {
|
||||
switch (c) {
|
||||
@ -103,7 +98,8 @@ char *argv[];
|
||||
justread = 1;
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr, "Usage: %s [-r] [-s] [-v] [dir ...]\n", progname);
|
||||
fprintf(stderr, "Usage: %s [-r][-s][-v][dir ...]\n",
|
||||
__progname);
|
||||
exit(1);
|
||||
break;
|
||||
}
|
||||
@ -368,7 +364,7 @@ listhints()
|
||||
}
|
||||
|
||||
msize = PAGSIZ;
|
||||
addr = mmap(0, msize, PROT_READ, MAP_FILE|MAP_COPY, fd, 0);
|
||||
addr = mmap(0, msize, PROT_READ, MAP_COPY, fd, 0);
|
||||
|
||||
if (addr == (caddr_t)-1) {
|
||||
perror(_PATH_LD_HINTS);
|
||||
@ -389,7 +385,7 @@ listhints()
|
||||
|
||||
if (hdr->hh_ehints > msize) {
|
||||
if (mmap(addr+msize, hdr->hh_ehints - msize,
|
||||
PROT_READ, MAP_FILE|MAP_COPY|MAP_FIXED,
|
||||
PROT_READ, MAP_COPY|MAP_FIXED,
|
||||
fd, msize) != (caddr_t)(addr+msize)) {
|
||||
|
||||
perror(_PATH_LD_HINTS);
|
||||
|
@ -1,6 +1,6 @@
|
||||
.Dd October 22, 1993
|
||||
.Dt LDD 1
|
||||
.Os FreeBSD 1.1
|
||||
.Os FreeBSD
|
||||
.Sh NAME
|
||||
.Nm ldd
|
||||
.Nd list dynamic object dependencies
|
||||
@ -16,6 +16,7 @@ depedencies that are the result of needed shared objects which themselves
|
||||
depend on yet other shared objects.
|
||||
.Sh SEE ALSO
|
||||
.Xr ld 1 ,
|
||||
.Xr ld.so 1 ,
|
||||
.Xr nm 1
|
||||
.Sh HISTORY
|
||||
A
|
||||
|
@ -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: ldd.c,v 1.3 1994/02/13 20:42:43 jkh Exp $
|
||||
* $Id: ldd.c,v 1.4 1994/06/15 22:41:03 rich Exp $
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
@ -91,9 +91,12 @@ char *argv[];
|
||||
argv++;
|
||||
continue;
|
||||
}
|
||||
if (read(fd, &hdr, sizeof hdr) != sizeof hdr ||
|
||||
!(N_GETFLAG(hdr) & EX_DYNAMIC) ||
|
||||
hdr.a_entry < __LDPGSZ) {
|
||||
if (read(fd, &hdr, sizeof hdr) != sizeof hdr
|
||||
|| (N_GETFLAG(hdr) & EX_DPMASK) != EX_DYNAMIC
|
||||
#if 1 /* Compatibility */
|
||||
|| hdr.a_entry < __LDPGSZ
|
||||
#endif
|
||||
) {
|
||||
|
||||
warnx("%s: not a dynamic executable", *argv);
|
||||
(void)close(fd);
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: lib.c,v 1.9 1994/02/13 20:41:37 jkh Exp $ - library routines
|
||||
* $Id: lib.c,v 1.10 1994/06/15 22:39:49 rich Exp $ - library routines
|
||||
*/
|
||||
|
||||
#include <sys/param.h>
|
||||
@ -302,7 +302,7 @@ symdef_library(fd, entry, member_length)
|
||||
if (!(link_mode & FORCEARCHIVE) &&
|
||||
!subfile_wanted_p(subentry)) {
|
||||
if (subentry->symbols)
|
||||
free(subentry->symbols);
|
||||
free(subentry->symbols);
|
||||
free(subentry);
|
||||
} else {
|
||||
/*
|
||||
@ -334,14 +334,14 @@ symdef_library(fd, entry, member_length)
|
||||
symdef_base[j].ran_un.ran_strx = -1;
|
||||
}
|
||||
|
||||
/*
|
||||
/*
|
||||
* We'll read the strings again
|
||||
* if we need them.
|
||||
*/
|
||||
subentry->strings = 0;
|
||||
*/
|
||||
subentry->strings = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
free(symdef_data);
|
||||
}
|
||||
@ -378,7 +378,7 @@ linear_library(fd, entry)
|
||||
if (!(link_mode & FORCEARCHIVE) &&
|
||||
!subfile_wanted_p(subentry)) {
|
||||
if (subentry->symbols)
|
||||
free(subentry->symbols);
|
||||
free(subentry->symbols);
|
||||
free(subentry);
|
||||
} else {
|
||||
read_entry_relocation(fd, subentry);
|
||||
@ -581,7 +581,7 @@ subfile_wanted_p(entry)
|
||||
*/
|
||||
void
|
||||
read_shared_object(fd, entry)
|
||||
struct file_entry *entry;
|
||||
struct file_entry *entry;
|
||||
int fd;
|
||||
{
|
||||
struct _dynamic dyn;
|
||||
@ -618,8 +618,8 @@ read_shared_object(fd, entry)
|
||||
|
||||
/* Read Section Dispatch Table (from data segment) */
|
||||
if (lseek(fd,
|
||||
text_offset(entry) + (long)dyn.d_un.d_sdt -
|
||||
(DATA_START(entry->header) - N_DATOFF(entry->header)),
|
||||
text_offset(entry) + (long)dyn.d_un.d_sdt -
|
||||
(DATA_START(entry->header) - N_DATOFF(entry->header)),
|
||||
L_SET) == (off_t)-1)
|
||||
err(1, "%s: lseek", get_file_name(entry));
|
||||
if (read(fd, &sdt, sizeof sdt) != sizeof sdt)
|
||||
@ -633,11 +633,11 @@ read_shared_object(fd, entry)
|
||||
(has_nz ? sizeof(struct nzlist) : sizeof(struct nlist));
|
||||
nzp = (struct nzlist *)(np = (struct nlist *)alloca (n));
|
||||
entry->symbols = (struct localsymbol *)
|
||||
xmalloc(entry->nsymbols * sizeof(struct localsymbol));
|
||||
xmalloc(entry->nsymbols * sizeof(struct localsymbol));
|
||||
|
||||
if (lseek(fd,
|
||||
text_offset(entry) + (long)sdt.sdt_nzlist -
|
||||
(TEXT_START(entry->header) - N_TXTOFF(entry->header)),
|
||||
(TEXT_START(entry->header) - N_TXTOFF(entry->header)),
|
||||
L_SET) == (off_t)-1)
|
||||
err(1, "%s: lseek", get_file_name(entry));
|
||||
if (read(fd, (char *)nzp, n) != n)
|
||||
@ -670,7 +670,7 @@ read_shared_object(fd, entry)
|
||||
entry->strings_offset = text_offset(entry) + sdt.sdt_strings;
|
||||
if (lseek(fd,
|
||||
entry->strings_offset -
|
||||
(TEXT_START(entry->header) - N_TXTOFF(entry->header)),
|
||||
(TEXT_START(entry->header) - N_TXTOFF(entry->header)),
|
||||
L_SET) == (off_t)-1)
|
||||
err(1, "%s: lseek", get_file_name(entry));
|
||||
if (read(fd, entry->strings, n) != n)
|
||||
@ -696,6 +696,7 @@ read_shared_object(fd, entry)
|
||||
xmalloc(sizeof(struct file_entry));
|
||||
bzero(subentry, sizeof(struct file_entry));
|
||||
subentry->superfile = entry;
|
||||
subentry->flags = E_SECONDCLASS;
|
||||
|
||||
if (lseek(fd,
|
||||
offset - (TEXT_START(entry->header) -
|
||||
|
@ -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.11 1994/02/13 20:41:40 jkh Exp $
|
||||
* $Id: rrs.c,v 1.12 1994/06/15 22:39:52 rich Exp $
|
||||
*/
|
||||
|
||||
#include <sys/param.h>
|
||||
@ -62,6 +62,7 @@ static struct shobj *rrs_shobjs;
|
||||
|
||||
static int reserved_rrs_relocs;
|
||||
static int claimed_rrs_relocs;
|
||||
static int discarded_rrs_relocs;
|
||||
|
||||
static int number_of_gotslots;
|
||||
static int number_of_jmpslots;
|
||||
@ -144,6 +145,7 @@ init_rrs()
|
||||
{
|
||||
reserved_rrs_relocs = 0;
|
||||
claimed_rrs_relocs = 0;
|
||||
discarded_rrs_relocs = 0;
|
||||
|
||||
number_of_rrs_symbols = 0;
|
||||
rrs_strtab_size = 0;
|
||||
@ -212,9 +214,7 @@ symbol *sp;
|
||||
sp->jmpslot_offset = current_jmpslot_offset;
|
||||
current_jmpslot_offset += sizeof(jmpslot_t);
|
||||
number_of_jmpslots++;
|
||||
if (!(link_mode & SYMBOLIC) || JMPSLOT_NEEDS_RELOC) {
|
||||
reserved_rrs_relocs++;
|
||||
}
|
||||
reserved_rrs_relocs++;
|
||||
}
|
||||
}
|
||||
|
||||
@ -242,13 +242,7 @@ struct localsymbol *lsp;
|
||||
lsp->gotslot_offset = current_got_offset;
|
||||
current_got_offset += sizeof(got_t);
|
||||
number_of_gotslots++;
|
||||
/*
|
||||
* Now, see if slot needs run-time fixing
|
||||
* If the load address is known (entry_symbol), this
|
||||
* slot will have its final value set by `claim_got'
|
||||
*/
|
||||
if ((link_mode & SHAREABLE) || (link_mode & SYMBOLIC))
|
||||
reserved_rrs_relocs++;
|
||||
reserved_rrs_relocs++;
|
||||
}
|
||||
|
||||
} else {
|
||||
@ -262,16 +256,12 @@ struct localsymbol *lsp;
|
||||
if (sp->alias)
|
||||
sp = sp->alias;
|
||||
|
||||
if (sp->gotslot_offset != -1)
|
||||
return;
|
||||
|
||||
/*
|
||||
* External symbols always get a relocation entry
|
||||
*/
|
||||
sp->gotslot_offset = current_got_offset;
|
||||
reserved_rrs_relocs++;
|
||||
current_got_offset += sizeof(got_t);
|
||||
number_of_gotslots++;
|
||||
if (sp->gotslot_offset == -1) {
|
||||
sp->gotslot_offset = current_got_offset;
|
||||
current_got_offset += sizeof(got_t);
|
||||
number_of_gotslots++;
|
||||
reserved_rrs_relocs++;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -378,7 +368,10 @@ printf("claim_rrs_jmpslot: %s: %s(%d) -> offset %x\n",
|
||||
md_fix_jmpslot( rrs_plt + sp->jmpslot_offset/sizeof(jmpslot_t),
|
||||
rrs_sdt.sdt_plt + sp->jmpslot_offset,
|
||||
sp->value);
|
||||
if (!JMPSLOT_NEEDS_RELOC) {
|
||||
if (rrs_section_type == RRS_PARTIAL || !JMPSLOT_NEEDS_RELOC) {
|
||||
/* PLT is self-contained */
|
||||
sp->flags |= GS_JMPSLOTCLAIMED;
|
||||
discarded_rrs_relocs++;
|
||||
return rrs_sdt.sdt_plt + sp->jmpslot_offset;
|
||||
}
|
||||
} else {
|
||||
@ -387,10 +380,6 @@ printf("claim_rrs_jmpslot: %s: %s(%d) -> offset %x\n",
|
||||
claimed_rrs_relocs);
|
||||
}
|
||||
|
||||
if (rrs_section_type == RRS_PARTIAL)
|
||||
/* PLT is self-contained */
|
||||
return rrs_sdt.sdt_plt + sp->jmpslot_offset;
|
||||
|
||||
/*
|
||||
* Install a run-time relocation for this PLT entry.
|
||||
*/
|
||||
@ -436,20 +425,29 @@ long addend;
|
||||
sp = sp->alias;
|
||||
|
||||
#ifdef DEBUG
|
||||
printf("claim_rrs_gotslot: %s(%d) slot offset %#x, addend %#x\n",
|
||||
sp->name, sp->rrs_symbolnum, sp->gotslot_offset, addend);
|
||||
printf("claim_rrs_gotslot: %s(%d,%#x) slot offset %#x, addend %#x\n",
|
||||
sp->name, sp->rrs_symbolnum, sp->value, sp->gotslot_offset, addend);
|
||||
#endif
|
||||
if (sp->gotslot_offset == -1)
|
||||
errx(1,
|
||||
"internal error: %s: claim_rrs_gotslot: %s: gotslot_offset == -1\n",
|
||||
get_file_name(entry), sp->name);
|
||||
|
||||
if (sp->flags & GS_GOTSLOTCLAIMED)
|
||||
if (sp->flags & GS_GOTSLOTCLAIMED) {
|
||||
#ifdef DEBUG
|
||||
if (*(long *)((long)rrs_got + sp->gotslot_offset) != addend +
|
||||
(!(link_mode & SHAREABLE) || (link_mode & SYMBOLIC))
|
||||
?sp->value:0)
|
||||
errx(1, "%s: %s: gotslot at %#x is multiple valued\n",
|
||||
get_file_name(entry), sp->name,
|
||||
sp->gotslot_offset);
|
||||
#endif
|
||||
/* This symbol already passed here before. */
|
||||
return sp->gotslot_offset;
|
||||
}
|
||||
|
||||
if (sp->defined &&
|
||||
(!(link_mode & SHAREABLE) || (link_mode & SYMBOLIC))) {
|
||||
(!(link_mode & SHAREABLE) || (link_mode & SYMBOLIC))) {
|
||||
|
||||
/*
|
||||
* Reduce to just a base-relative translation.
|
||||
@ -471,7 +469,7 @@ printf("claim_rrs_gotslot: %s(%d) slot offset %#x, addend %#x\n",
|
||||
} else {
|
||||
|
||||
/*
|
||||
* This gotslot will be updated with symbol value at run-rime.
|
||||
* This gotslot will be updated with symbol value at run-time.
|
||||
*/
|
||||
|
||||
*(got_t *)((long)rrs_got + sp->gotslot_offset) = addend;
|
||||
@ -486,6 +484,8 @@ printf("claim_rrs_gotslot: %s(%d) slot offset %#x, addend %#x\n",
|
||||
if (!sp->defined)
|
||||
warnx("Cannot reduce symbol \"%s\" in %s",
|
||||
sp->name, get_file_name(entry));
|
||||
discarded_rrs_relocs++;
|
||||
sp->flags |= GS_GOTSLOTCLAIMED;
|
||||
return sp->gotslot_offset;
|
||||
}
|
||||
|
||||
@ -509,7 +509,7 @@ printf("claim_rrs_gotslot: %s(%d) slot offset %#x, addend %#x\n",
|
||||
|
||||
/*
|
||||
* Claim a GOT entry for a static symbol. Return offset of the
|
||||
* allocated GOT entry. If RELOC_STATICS_THROUGH_GOT_P is in effect
|
||||
* allocated GOT entry. If RELOC_STATICS_THROUGH_GOT_P is in effect,
|
||||
* return the offset of the symbol with respect to the *location* of
|
||||
* the GOT.
|
||||
*/
|
||||
@ -537,14 +537,21 @@ printf("claim_rrs_internal_gotslot: %s: slot offset %#x, addend = %#x\n",
|
||||
"internal error: %s: claim_rrs_internal_gotslot at %#x: slot_offset == -1\n",
|
||||
get_file_name(entry), RELOC_ADDRESS(rp));
|
||||
|
||||
if (lsp->flags & LS_GOTSLOTCLAIMED)
|
||||
if (lsp->flags & LS_GOTSLOTCLAIMED) {
|
||||
/* Already done */
|
||||
if (addend != *(long *)((long)rrs_got + lsp->gotslot_offset))
|
||||
errx(1, "%s: gotslot at %#x is multiple valued\n",
|
||||
get_file_name(entry), lsp->gotslot_offset);
|
||||
return lsp->gotslot_offset;
|
||||
}
|
||||
|
||||
*(long *)((long)rrs_got + lsp->gotslot_offset) = addend;
|
||||
|
||||
if (!(link_mode & SHAREABLE))
|
||||
if (rrs_section_type == RRS_PARTIAL) {
|
||||
lsp->flags |= LS_GOTSLOTCLAIMED;
|
||||
discarded_rrs_relocs++;
|
||||
return lsp->gotslot_offset;
|
||||
}
|
||||
|
||||
/*
|
||||
* Relocation entry needed for this static GOT entry.
|
||||
@ -597,6 +604,7 @@ struct relocation_info *rp;
|
||||
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);
|
||||
RELOC_EXTERN_P(r) = 0;
|
||||
@ -702,8 +710,7 @@ consider_rrs_section_lengths()
|
||||
* from crt0), as this is the method used to determine whether the
|
||||
* run-time linker must be called.
|
||||
*/
|
||||
if (!(link_mode & SHAREABLE) &&
|
||||
!(dynamic_symbol->flags & GS_REFERENCED))
|
||||
if (!(link_mode & SHAREABLE) && !(dynamic_symbol->flags & GS_REFERENCED))
|
||||
errx(1, "No reference to __DYNAMIC");
|
||||
|
||||
dynamic_symbol->flags |= GS_REFERENCED;
|
||||
@ -736,24 +743,33 @@ consider_rrs_section_lengths()
|
||||
|
||||
/*
|
||||
* Walk the symbol table, assign RRS symbol numbers
|
||||
* and calculate string space.
|
||||
* Assign number 0 to __DYNAMIC (!! Sun compatibility)
|
||||
*/
|
||||
dynamic_symbol->rrs_symbolnum = number_of_rrs_symbols++;
|
||||
FOR_EACH_SYMBOL(i ,sp) {
|
||||
if (sp->flags & GS_REFERENCED) {
|
||||
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);
|
||||
}
|
||||
if ((link_mode & SHAREABLE) && sp->warning) {
|
||||
/* Allocate N_WARNING & co */
|
||||
rrs_strtab_size +=
|
||||
2 + strlen(sp->name) + strlen(sp->warning);
|
||||
number_of_rrs_symbols += 2;
|
||||
}
|
||||
|
||||
if (!(sp->flags & GS_REFERENCED))
|
||||
continue;
|
||||
|
||||
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;
|
||||
|
||||
@ -828,7 +844,7 @@ relocate_rrs_addresses()
|
||||
if (rrs_section_type == RRS_PARTIAL) {
|
||||
got_symbol->value = rrs_sdt.sdt_got = rrs_data_start;
|
||||
rrs_sdt.sdt_plt = rrs_sdt.sdt_got +
|
||||
number_of_gotslots * sizeof(got_t);
|
||||
number_of_gotslots * sizeof(got_t);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -837,12 +853,12 @@ relocate_rrs_addresses()
|
||||
*/
|
||||
rrs_dyn.d_version = soversion;
|
||||
rrs_dyn.d_debug = (struct so_debug *)
|
||||
(rrs_data_start + sizeof(struct _dynamic));
|
||||
(rrs_data_start + sizeof(struct _dynamic));
|
||||
rrs_dyn.d_un.d_sdt = (struct section_dispatch_table *)
|
||||
((long)rrs_dyn.d_debug + sizeof(struct so_debug));
|
||||
((long)rrs_dyn.d_debug + sizeof(struct so_debug));
|
||||
|
||||
rrs_sdt.sdt_got = (long)rrs_dyn.d_un.d_sdt +
|
||||
sizeof(struct section_dispatch_table);
|
||||
sizeof(struct section_dispatch_table);
|
||||
rrs_sdt.sdt_plt = rrs_sdt.sdt_got + number_of_gotslots*sizeof(got_t);
|
||||
|
||||
/*
|
||||
@ -898,19 +914,12 @@ write_rrs_data()
|
||||
/*
|
||||
* Only a GOT and PLT are needed.
|
||||
*/
|
||||
if (number_of_gotslots <= 1)
|
||||
errx(1, "write_rrs_data: # gotslots <= 1");
|
||||
|
||||
md_swapout_got(rrs_got, number_of_gotslots);
|
||||
mywrite(rrs_got, number_of_gotslots,
|
||||
sizeof(got_t), outdesc);
|
||||
|
||||
if (number_of_jmpslots <= 1)
|
||||
errx(1, "write_rrs_data: # jmpslots <= 1");
|
||||
mywrite(rrs_got, number_of_gotslots, sizeof(got_t), outdesc);
|
||||
|
||||
md_swapout_jmpslot(rrs_plt, number_of_jmpslots);
|
||||
mywrite(rrs_plt, number_of_jmpslots,
|
||||
sizeof(jmpslot_t), outdesc);
|
||||
mywrite(rrs_plt, number_of_jmpslots, sizeof(jmpslot_t), outdesc);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@ -951,11 +960,12 @@ write_rrs_text()
|
||||
/* Write relocation records */
|
||||
md_swapout_reloc(rrs_reloc, reserved_rrs_relocs);
|
||||
mywrite(rrs_reloc, reserved_rrs_relocs,
|
||||
sizeof(struct relocation_info), outdesc);
|
||||
sizeof(struct relocation_info), outdesc);
|
||||
|
||||
/* Write the RRS symbol hash tables */
|
||||
md_swapout_rrs_hash(rrs_hashtab, number_of_rrs_hash_entries);
|
||||
mywrite(rrs_hashtab, number_of_rrs_hash_entries, sizeof(struct rrs_hash), outdesc);
|
||||
mywrite(rrs_hashtab, number_of_rrs_hash_entries,
|
||||
sizeof(struct rrs_hash), outdesc);
|
||||
|
||||
/*
|
||||
* Determine size of an RRS symbol entry, allocate space
|
||||
@ -985,11 +995,39 @@ write_rrs_text()
|
||||
*/
|
||||
FOR_EACH_SYMBOL(i, sp) {
|
||||
|
||||
if (!(sp->flags & GS_REFERENCED) || sp == dynamic_symbol)
|
||||
if (sp == dynamic_symbol)
|
||||
continue;
|
||||
|
||||
if ((link_mode & SHAREABLE) && sp->warning) {
|
||||
/*
|
||||
* Write a N_WARNING duo.
|
||||
*/
|
||||
nlp->nz_type = N_WARNING;
|
||||
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->warning);
|
||||
offset += 1 + strlen(sp->warning);
|
||||
INCR_NLP(nlp);
|
||||
|
||||
nlp->nz_type = N_UNDF + N_EXT;
|
||||
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->name);
|
||||
offset += 1 + strlen(sp->name);
|
||||
INCR_NLP(nlp);
|
||||
}
|
||||
|
||||
if (!(sp->flags & GS_REFERENCED))
|
||||
continue;
|
||||
|
||||
if ((long)nlp - (long)rrs_symbols >=
|
||||
number_of_rrs_symbols * rrs_symbol_size)
|
||||
number_of_rrs_symbols * rrs_symbol_size)
|
||||
errx(1,
|
||||
"internal error: rrs symbols exceed allocation %d ",
|
||||
number_of_rrs_symbols);
|
||||
@ -1002,7 +1040,7 @@ write_rrs_text()
|
||||
if (sp->defined > 1) {
|
||||
/* defined with known type */
|
||||
if (!(link_mode & SHAREABLE) &&
|
||||
sp->alias && sp->alias->defined > 1) {
|
||||
sp->alias && sp->alias->defined > 1) {
|
||||
/*
|
||||
* If the target of an indirect symbol has
|
||||
* been defined and we are outputting an
|
||||
@ -1125,7 +1163,7 @@ write_rrs_text()
|
||||
if (i < number_of_shobjs)
|
||||
errx(1,
|
||||
"internal error: # of link objects less then expected %d",
|
||||
number_of_shobjs);
|
||||
number_of_shobjs);
|
||||
|
||||
md_swapout_sod(sodp, number_of_shobjs);
|
||||
mywrite(sodp, number_of_shobjs, sizeof(struct sod), outdesc);
|
||||
@ -1157,21 +1195,19 @@ write_rrs()
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
printf("rrs_relocs %d, gotslots %d, jmpslots %d\n",
|
||||
reserved_rrs_relocs, number_of_gotslots-1, number_of_jmpslots-1);
|
||||
printf("rrs_relocs: reserved %d claimed %d discarded %d, gotslots %d jmpslots %d\n",
|
||||
reserved_rrs_relocs, claimed_rrs_relocs, discarded_rrs_relocs,
|
||||
number_of_gotslots-1, number_of_jmpslots-1);
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
/* Must fix this check: misses out when linking PIC code but no
|
||||
shared object involved: reserved relocs are never claimed!
|
||||
*/
|
||||
if (claimed_rrs_relocs != reserved_rrs_relocs) {
|
||||
errx(1, "internal error: reserved relocs(%d) != claimed(%d)",
|
||||
reserved_rrs_relocs, claimed_rrs_relocs);
|
||||
printf("FIX:internal error: reserved relocs(%d) != claimed(%d)\n",
|
||||
reserved_rrs_relocs, claimed_rrs_relocs);
|
||||
/* Final consistency check */
|
||||
if (claimed_rrs_relocs + discarded_rrs_relocs != reserved_rrs_relocs) {
|
||||
errx(1,
|
||||
"internal error: reserved relocs(%d) != claimed(%d) + discarded(%d)",
|
||||
reserved_rrs_relocs,
|
||||
claimed_rrs_relocs,
|
||||
discarded_rrs_relocs);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Write the RRS segments. */
|
||||
write_rrs_text ();
|
||||
|
@ -27,7 +27,7 @@
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* $Id: rtld.c,v 1.17 1994/06/15 22:41:15 rich Exp $
|
||||
* $Id: rtld.c,v 1.18 1994/09/15 20:48:55 bde Exp $
|
||||
*/
|
||||
|
||||
#include <sys/param.h>
|
||||
@ -403,7 +403,7 @@ alloc_link_map(path, sodp, parent, addr, dp)
|
||||
link_map_tail = &smp->som_next;
|
||||
|
||||
smp->som_addr = addr;
|
||||
smp->som_path = strdup(path);
|
||||
smp->som_path = path?strdup(path):NULL;
|
||||
smp->som_sod = sodp;
|
||||
smp->som_dynamic = dp;
|
||||
smp->som_spd = (caddr_t)smpp;
|
||||
@ -442,7 +442,7 @@ map_object(sodp, smp)
|
||||
usehints = 1;
|
||||
again:
|
||||
path = rtfindlib(name, sodp->sod_major,
|
||||
sodp->sod_minor, &usehints);
|
||||
sodp->sod_minor, &usehints);
|
||||
if (path == NULL) {
|
||||
errno = ENOENT;
|
||||
return NULL;
|
||||
@ -484,17 +484,17 @@ again:
|
||||
}
|
||||
|
||||
if ((addr = mmap(0, hdr.a_text + hdr.a_data,
|
||||
PROT_READ|PROT_EXEC,
|
||||
MAP_FILE|MAP_COPY, fd, 0)) == (caddr_t)-1) {
|
||||
PROT_READ|PROT_EXEC,
|
||||
MAP_COPY, fd, 0)) == (caddr_t)-1) {
|
||||
(void)close(fd);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#if 0
|
||||
if (mmap(addr + hdr.a_text, hdr.a_data,
|
||||
PROT_READ|PROT_WRITE|PROT_EXEC,
|
||||
MAP_FILE|MAP_FIXED|MAP_COPY,
|
||||
fd, hdr.a_text) == (caddr_t)-1) {
|
||||
PROT_READ|PROT_WRITE|PROT_EXEC,
|
||||
MAP_FIXED|MAP_COPY,
|
||||
fd, hdr.a_text) == (caddr_t)-1) {
|
||||
(void)close(fd);
|
||||
return NULL;
|
||||
}
|
||||
@ -548,9 +548,9 @@ caddr_t addr;
|
||||
else
|
||||
sym = "";
|
||||
|
||||
if (getenv("LD_WARN_NON_PURE_CODE") != NULL)
|
||||
fprintf(stderr,
|
||||
"ld.so: warning: non pure code in %s at %x (%s)\n",
|
||||
if (getenv("LD_SUPPRESS_WARNINGS") == NULL &&
|
||||
getenv("LD_WARN_NON_PURE_CODE") != NULL)
|
||||
warnx("ld.so: warning: non pure code in %s at %x (%s)\n",
|
||||
smp->som_path, r->r_address, sym);
|
||||
|
||||
if (smp->som_write == 0 &&
|
||||
@ -972,7 +972,7 @@ maphints()
|
||||
}
|
||||
|
||||
msize = PAGSIZ;
|
||||
addr = mmap(0, msize, PROT_READ, MAP_FILE|MAP_COPY, fd, 0);
|
||||
addr = mmap(0, msize, PROT_READ, MAP_COPY, fd, 0);
|
||||
|
||||
if (addr == (caddr_t)-1) {
|
||||
close(fd);
|
||||
@ -999,7 +999,7 @@ maphints()
|
||||
if (hheader->hh_ehints > msize) {
|
||||
hmsize = hheader->hh_ehints;
|
||||
if (mmap(addr+msize, hheader->hh_ehints - msize,
|
||||
PROT_READ, MAP_FILE|MAP_COPY|MAP_FIXED,
|
||||
PROT_READ, MAP_COPY|MAP_FIXED,
|
||||
fd, msize) != (caddr_t)(addr+msize)) {
|
||||
|
||||
munmap((caddr_t)hheader, msize);
|
||||
@ -1092,41 +1092,50 @@ rtfindlib(name, major, minor, usehints)
|
||||
int major, minor;
|
||||
int *usehints;
|
||||
{
|
||||
char *hint;
|
||||
char *cp, *ld_path = getenv("LD_LIBRARY_PATH");
|
||||
int realminor;
|
||||
|
||||
if (hheader == NULL)
|
||||
maphints();
|
||||
|
||||
if (!HINTS_VALID || !(*usehints)) {
|
||||
*usehints = 0;
|
||||
return (char *)findshlib(name, &major, &minor, 0);
|
||||
}
|
||||
if (!HINTS_VALID || !(*usehints))
|
||||
goto lose;
|
||||
|
||||
if (ld_path != NULL) {
|
||||
/* Prefer paths from LD_LIBRARY_PATH */
|
||||
while ((cp = strsep(&ld_path, ":")) != NULL) {
|
||||
|
||||
hint = findhint(name, major, minor, cp);
|
||||
cp = findhint(name, major, minor, cp);
|
||||
if (ld_path)
|
||||
*(ld_path-1) = ':';
|
||||
if (hint)
|
||||
return hint;
|
||||
if (cp)
|
||||
return cp;
|
||||
}
|
||||
/* Not found in hints, try directory search */
|
||||
hint = (char *)findshlib(name, &major, &minor, 0);
|
||||
if (hint)
|
||||
return hint;
|
||||
realminor = -1;
|
||||
cp = (char *)findshlib(name, &major, &realminor, 0);
|
||||
if (cp && realminor >= minor)
|
||||
return cp;
|
||||
}
|
||||
|
||||
/* No LD_LIBRARY_PATH or lib not found in there; check default */
|
||||
hint = findhint(name, major, minor, NULL);
|
||||
if (hint)
|
||||
return hint;
|
||||
cp = findhint(name, major, minor, NULL);
|
||||
if (cp)
|
||||
return cp;
|
||||
|
||||
lose:
|
||||
/* No hints available for name */
|
||||
*usehints = 0;
|
||||
return (char *)findshlib(name, &major, &minor, 0);
|
||||
realminor = -1;
|
||||
cp = (char *)findshlib(name, &major, &realminor, 0);
|
||||
if (cp) {
|
||||
if (realminor < minor && getenv("LD_SUPPRESS_WARNINGS") == NULL)
|
||||
warnx("warning: lib%s.so.%d.%d: "
|
||||
"minor version >= %d expected, using it anyway",
|
||||
name, major, realminor, minor);
|
||||
return cp;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static struct somap_private dlmap_private = {
|
||||
|
@ -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: shlib.c,v 1.8 1994/02/13 20:41:43 jkh Exp $
|
||||
* $Id: shlib.c,v 1.9 1994/06/15 22:39:54 rich Exp $
|
||||
*/
|
||||
|
||||
#include <sys/param.h>
|
||||
@ -54,7 +54,7 @@ char *strsep();
|
||||
* Standard directories to search for files specified by -l.
|
||||
*/
|
||||
#ifndef STANDARD_SEARCH_DIRS
|
||||
#define STANDARD_SEARCH_DIRS "/usr/lib", "/usr/X11R6/lib", "/usr/X386/lib", "/usr/local/lib"
|
||||
#define STANDARD_SEARCH_DIRS "/usr/lib"
|
||||
#endif
|
||||
|
||||
/*
|
||||
@ -64,7 +64,7 @@ char *strsep();
|
||||
char **search_dirs;
|
||||
int n_search_dirs;
|
||||
|
||||
char *standard_search_dirs[] = {
|
||||
char *standard_search_dirs[] = {
|
||||
STANDARD_SEARCH_DIRS
|
||||
};
|
||||
|
||||
@ -88,12 +88,12 @@ char *path;
|
||||
if (path == NULL)
|
||||
return;
|
||||
|
||||
/* Add search directories from `paths' */
|
||||
/* Add search directories from `paths' */
|
||||
while ((cp = strsep(&path, ":")) != NULL) {
|
||||
add_search_dir(cp);
|
||||
add_search_dir(cp);
|
||||
if (path)
|
||||
*(path-1) = ':';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: symbol.c,v 1.4 1994/02/13 20:41:46 jkh Exp $ - symbol table routines
|
||||
* $Id: symbol.c,v 1.5 1994/06/15 22:39:56 rich Exp $ - symbol table routines
|
||||
*/
|
||||
|
||||
/* Create the symbol table entries for `etext', `edata' and `end'. */
|
||||
@ -126,7 +126,7 @@ getsym(key)
|
||||
bp->aux = 0;
|
||||
bp->sorefs = 0;
|
||||
bp->so_defined = 0;
|
||||
bp->def_nlist = 0;
|
||||
bp->def_lsp = 0;
|
||||
bp->jmpslot_offset = -1;
|
||||
bp->gotslot_offset = -1;
|
||||
bp->flags = 0;
|
||||
@ -144,15 +144,15 @@ getsym(key)
|
||||
|
||||
symbol *
|
||||
getsym_soft (key)
|
||||
char *key;
|
||||
char *key;
|
||||
{
|
||||
register int hashval;
|
||||
register symbol *bp;
|
||||
|
||||
/* Determine which bucket. */
|
||||
/* Determine which bucket. */
|
||||
hashval = hash_string(key) % SYMTABSIZE;
|
||||
|
||||
/* Search the bucket. */
|
||||
/* Search the bucket. */
|
||||
for (bp = symtab[hashval]; bp; bp = bp->link)
|
||||
if (strcmp(key, bp->name) == 0)
|
||||
return bp;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: warnings.c,v 1.7 1994/06/14 12:45:41 csgr Exp $
|
||||
* $Id: warnings.c,v 1.8 1994/06/15 22:40:00 rich Exp $
|
||||
*/
|
||||
|
||||
#include <sys/param.h>
|
||||
@ -141,8 +141,8 @@ list_file_locals (entry, outfile)
|
||||
{
|
||||
struct localsymbol *lsp, *lspend;
|
||||
|
||||
entry->strings = (char *) alloca (entry->string_size);
|
||||
read_entry_strings (file_open (entry), entry);
|
||||
entry->strings = (char *)alloca(entry->string_size);
|
||||
read_entry_strings (file_open(entry), entry);
|
||||
|
||||
fprintf (outfile, "\nLocal symbols of ");
|
||||
print_file_name (entry, outfile);
|
||||
@ -163,14 +163,13 @@ list_file_locals (entry, outfile)
|
||||
entry->strings = 0; /* All done with them. */
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Static vars for do_warnings and subroutines of it */
|
||||
static int list_unresolved_refs; /* List unresolved refs */
|
||||
static int list_warning_symbols; /* List warning syms */
|
||||
static int list_multiple_defs; /* List multiple definitions */
|
||||
|
||||
static struct line_debug_entry *init_debug_scan __P((int, struct file_entry *));
|
||||
static int next_debug_entry __P((int, struct line_debug_entry *));
|
||||
static int next_debug_entry __P((int, struct line_debug_entry *));
|
||||
|
||||
/*
|
||||
* Structure for communication between do_file_warnings and it's
|
||||
@ -188,28 +187,32 @@ struct line_debug_entry
|
||||
* Helper routines for do_file_warnings.
|
||||
*/
|
||||
|
||||
/* Return an integer less than, equal to, or greater than 0 as per the
|
||||
relation between the two relocation entries. Used by qsort. */
|
||||
/*
|
||||
* Return an integer less than, equal to, or greater than 0 as per the
|
||||
* relation between the two relocation entries. Used by qsort.
|
||||
*/
|
||||
|
||||
static int
|
||||
relocation_entries_relation(rel1, rel2)
|
||||
struct relocation_info *rel1, *rel2;
|
||||
reloc_cmp(rel1, rel2)
|
||||
struct relocation_info *rel1, *rel2;
|
||||
{
|
||||
return RELOC_ADDRESS(rel1) - RELOC_ADDRESS(rel2);
|
||||
}
|
||||
|
||||
/* Moves to the next debugging symbol in the file. USE_DATA_SYMBOLS
|
||||
determines the type of the debugging symbol to look for (DSLINE or
|
||||
SLINE). STATE_POINTER keeps track of the old and new locatiosn in
|
||||
the file. It assumes that state_pointer[1] is valid; ie
|
||||
that it.sym points into some entry in the symbol table. If
|
||||
state_pointer[1].sym == 0, this routine should not be called. */
|
||||
/*
|
||||
* Moves to the next debugging symbol in the file. USE_DATA_SYMBOLS
|
||||
* determines the type of the debugging symbol to look for (DSLINE or
|
||||
* SLINE). STATE_POINTER keeps track of the old and new locatiosn in
|
||||
* the file. It assumes that state_pointer[1] is valid; ie
|
||||
* that it.sym points into some entry in the symbol table. If
|
||||
* state_pointer[1].sym == 0, this routine should not be called.
|
||||
*/
|
||||
|
||||
static int
|
||||
next_debug_entry(use_data_symbols, state_pointer)
|
||||
register int use_data_symbols;
|
||||
/* Next must be passed by reference! */
|
||||
struct line_debug_entry state_pointer[3];
|
||||
register int use_data_symbols;
|
||||
/* Next must be passed by reference! */
|
||||
struct line_debug_entry state_pointer[3];
|
||||
{
|
||||
register struct line_debug_entry
|
||||
*current = state_pointer,
|
||||
@ -217,15 +220,15 @@ next_debug_entry(use_data_symbols, state_pointer)
|
||||
/* Used to store source file */
|
||||
*source = state_pointer + 2;
|
||||
|
||||
struct file_entry *entry = (struct file_entry *) source->sym;
|
||||
struct localsymbol *endp = entry->symbols + entry->nsymbols;
|
||||
struct file_entry *entry = (struct file_entry *)source->sym;
|
||||
struct localsymbol *lspend = entry->symbols + entry->nsymbols;
|
||||
|
||||
|
||||
current->sym = next->sym;
|
||||
current->line = next->line;
|
||||
current->filename = next->filename;
|
||||
|
||||
while (++(next->sym) < endp) {
|
||||
while (++(next->sym) < lspend) {
|
||||
|
||||
struct nlist *np = &next->sym->nzlist.nlist;
|
||||
|
||||
@ -235,11 +238,13 @@ next_debug_entry(use_data_symbols, state_pointer)
|
||||
*/
|
||||
switch (np->n_type & 0xff) {
|
||||
case N_SLINE:
|
||||
if (use_data_symbols) continue;
|
||||
if (use_data_symbols)
|
||||
continue;
|
||||
next->line = np->n_desc;
|
||||
return 1;
|
||||
case N_DSLINE:
|
||||
if (!use_data_symbols) continue;
|
||||
if (!use_data_symbols)
|
||||
continue;
|
||||
next->line = np->n_desc;
|
||||
return 1;
|
||||
#ifdef HAVE_SUN_STABS
|
||||
@ -266,39 +271,41 @@ next_debug_entry(use_data_symbols, state_pointer)
|
||||
/*
|
||||
* Create a structure to save the state of a scan through the debug symbols.
|
||||
* USE_DATA_SYMBOLS is set if we should be scanning for DSLINE's instead of
|
||||
* SLINE's. entry is the file entry which points at the symbols to use.
|
||||
* SLINE's. ENTRY is the file entry which points at the symbols to use.
|
||||
*/
|
||||
|
||||
static struct line_debug_entry *
|
||||
init_debug_scan(use_data_symbols, entry)
|
||||
int use_data_symbols;
|
||||
struct file_entry *entry;
|
||||
int use_data_symbols;
|
||||
struct file_entry *entry;
|
||||
{
|
||||
struct localsymbol *lsp;
|
||||
struct line_debug_entry *state_pointer = (struct line_debug_entry *)
|
||||
xmalloc(3 * sizeof(struct line_debug_entry));
|
||||
register struct localsymbol *lsp, *lspend;
|
||||
struct line_debug_entry *state_pointer, *current, *next, *source;
|
||||
|
||||
register struct line_debug_entry
|
||||
*current = state_pointer,
|
||||
*next = state_pointer + 1,
|
||||
*source = state_pointer + 2; /* Used to store source file */
|
||||
state_pointer = (struct line_debug_entry *)
|
||||
xmalloc(3 * sizeof(*state_pointer));
|
||||
|
||||
current = state_pointer,
|
||||
next = state_pointer + 1,
|
||||
source = state_pointer + 2; /* Used to store source file */
|
||||
|
||||
for (lsp = entry->symbols; lsp < entry->symbols+entry->nsymbols; lsp++)
|
||||
lspend = entry->symbols+entry->nsymbols;
|
||||
|
||||
for (lsp = entry->symbols; lsp < lspend; lsp++)
|
||||
if (lsp->nzlist.nlist.n_type == N_SO)
|
||||
break;
|
||||
|
||||
if (lsp >= entry->symbols + entry->nsymbols) {
|
||||
if (lsp >= lspend) {
|
||||
/* I believe this translates to "We lose" */
|
||||
current->filename = next->filename = entry->filename;
|
||||
current->line = next->line = -1;
|
||||
current->sym = next->sym = (struct localsymbol *) 0;
|
||||
current->sym = next->sym = (struct localsymbol *)0;
|
||||
return state_pointer;
|
||||
}
|
||||
next->line = source->line = 0;
|
||||
next->filename = source->filename
|
||||
= (lsp->nzlist.nlist.n_un.n_strx + entry->strings);
|
||||
source->sym = (struct localsymbol *) entry;
|
||||
source->sym = (struct localsymbol *)entry;
|
||||
next->sym = lsp;
|
||||
|
||||
/* To setup next */
|
||||
@ -335,7 +342,7 @@ address_to_line(address, state_pointer)
|
||||
struct line_debug_entry state_pointer[3];
|
||||
{
|
||||
struct line_debug_entry *current, *next, *tmp_pointer;
|
||||
int use_data_symbols;
|
||||
int use_data_symbols;
|
||||
|
||||
current = state_pointer;
|
||||
next = state_pointer + 1;
|
||||
@ -346,7 +353,7 @@ address_to_line(address, state_pointer)
|
||||
else
|
||||
return current->line;
|
||||
|
||||
/* Go back to the beginning if we've already passed it. */
|
||||
/* Go back to the beginning if we've already passed it. */
|
||||
if (current->sym->nzlist.nlist.n_value > address) {
|
||||
tmp_pointer = init_debug_scan(use_data_symbols,
|
||||
(struct file_entry *)
|
||||
@ -357,7 +364,7 @@ address_to_line(address, state_pointer)
|
||||
free(tmp_pointer);
|
||||
}
|
||||
|
||||
/* If we're still in a bad way, return -1, meaning invalid line. */
|
||||
/* If we're still in a bad way, return -1, meaning invalid line. */
|
||||
if (current->sym->nzlist.nlist.n_value > address)
|
||||
return -1;
|
||||
|
||||
@ -391,22 +398,12 @@ do_relocation_warnings(entry, data_segment, outfile, nlist_bitvector)
|
||||
FILE *outfile;
|
||||
unsigned char *nlist_bitvector;
|
||||
{
|
||||
struct relocation_info *reloc, *reloc_start =
|
||||
data_segment ? entry->datarel : entry->textrel;
|
||||
|
||||
int reloc_size = (data_segment ? entry->ndatarel : entry->ntextrel);
|
||||
int start_of_segment = (data_segment ?
|
||||
entry->data_start_address :
|
||||
entry->text_start_address);
|
||||
struct localsymbol *start_of_syms = entry->symbols;
|
||||
struct line_debug_entry *state_pointer =
|
||||
init_debug_scan(data_segment != 0, entry);
|
||||
|
||||
register struct line_debug_entry *current = state_pointer;
|
||||
|
||||
struct relocation_info *rp, *erp;
|
||||
int start_of_segment;
|
||||
struct localsymbol *start_of_syms;
|
||||
struct line_debug_entry *state_pointer, *current;
|
||||
/* Assigned to generally static values; should not be written into. */
|
||||
char *errfmt;
|
||||
|
||||
/*
|
||||
* Assigned to alloca'd values cand copied into; should be freed when
|
||||
* done.
|
||||
@ -414,28 +411,32 @@ do_relocation_warnings(entry, data_segment, outfile, nlist_bitvector)
|
||||
char *errmsg;
|
||||
int invalidate_line_number;
|
||||
|
||||
rp = data_segment ? entry->datarel : entry->textrel;
|
||||
erp = data_segment ? (rp + entry->ndatarel) : (rp + entry->ntextrel);
|
||||
start_of_syms = entry->symbols;
|
||||
start_of_segment = (data_segment ?
|
||||
entry->data_start_address :
|
||||
entry->text_start_address);
|
||||
state_pointer = init_debug_scan(data_segment != 0, entry);
|
||||
current = state_pointer;
|
||||
|
||||
/*
|
||||
* We need to sort the relocation info here. Sheesh, so much effort
|
||||
* for one lousy error optimization.
|
||||
*/
|
||||
qsort(rp, erp - rp, sizeof(rp[0]), reloc_cmp);
|
||||
|
||||
qsort(reloc_start, reloc_size, sizeof(struct relocation_info),
|
||||
relocation_entries_relation);
|
||||
|
||||
for (reloc = reloc_start;
|
||||
reloc < (reloc_start + reloc_size);
|
||||
reloc++) {
|
||||
for (; rp < erp; rp++) {
|
||||
register struct localsymbol *lsp;
|
||||
register symbol *g;
|
||||
|
||||
/*
|
||||
* If the relocation isn't resolved through a symbol,
|
||||
* continue
|
||||
* If the relocation isn't resolved through a symbol, continue.
|
||||
*/
|
||||
if (!RELOC_EXTERN_P(reloc))
|
||||
if (!RELOC_EXTERN_P(rp))
|
||||
continue;
|
||||
|
||||
lsp = &entry->symbols[RELOC_SYMBOL(reloc)];
|
||||
lsp = &entry->symbols[RELOC_SYMBOL(rp)];
|
||||
|
||||
/*
|
||||
* Local symbols shouldn't ever be used by relocation info,
|
||||
@ -459,7 +460,7 @@ do_relocation_warnings(entry, data_segment, outfile, nlist_bitvector)
|
||||
errmsg = 0;
|
||||
|
||||
if (!g->defined && !g->so_defined && list_unresolved_refs) {
|
||||
/* Mark as being noted by relocation warning pass. */
|
||||
/* Mark as being noted by relocation warning pass. */
|
||||
SET_BIT(nlist_bitvector, lsp - start_of_syms);
|
||||
|
||||
if (g->undef_refs >= MAX_UREFS_PRINTED)
|
||||
@ -481,6 +482,9 @@ do_relocation_warnings(entry, data_segment, outfile, nlist_bitvector)
|
||||
if (!g->warning)
|
||||
continue;
|
||||
|
||||
if (BIT_SET_P(nlist_bitvector, lsp - start_of_syms))
|
||||
continue;
|
||||
|
||||
/* Mark as being noted by relocation warning pass. */
|
||||
SET_BIT(nlist_bitvector, lsp - start_of_syms);
|
||||
|
||||
@ -501,12 +505,14 @@ do_relocation_warnings(entry, data_segment, outfile, nlist_bitvector)
|
||||
if (nm != g->name)
|
||||
free(nm);
|
||||
}
|
||||
address_to_line(RELOC_ADDRESS(reloc) + start_of_segment,
|
||||
address_to_line(RELOC_ADDRESS(rp) + start_of_segment,
|
||||
state_pointer);
|
||||
|
||||
if (current->line >= 0)
|
||||
fprintf(outfile, "%s:%d: %s\n", current->filename,
|
||||
invalidate_line_number ? 0 : current->line, errmsg);
|
||||
fprintf(outfile, "%s:%d: %s\n",
|
||||
current->filename,
|
||||
invalidate_line_number ? 0 : current->line,
|
||||
errmsg);
|
||||
else
|
||||
fprintf(outfile, "%s: %s\n", current->filename, errmsg);
|
||||
|
||||
@ -525,28 +531,24 @@ do_relocation_warnings(entry, data_segment, outfile, nlist_bitvector)
|
||||
|
||||
void
|
||||
do_file_warnings (entry, outfile)
|
||||
struct file_entry *entry;
|
||||
FILE *outfile;
|
||||
struct file_entry *entry;
|
||||
FILE *outfile;
|
||||
{
|
||||
int number_of_syms = entry->nsymbols;
|
||||
unsigned char *nlist_bitvector = (unsigned char *)
|
||||
alloca ((number_of_syms >> 3) + 1);
|
||||
struct line_debug_entry *text_scan, *data_scan;
|
||||
int nsym;
|
||||
int i;
|
||||
char *errfmt, *file_name;
|
||||
int line_number;
|
||||
int dont_allow_symbol_name;
|
||||
u_char *nlist_bitvector;
|
||||
struct line_debug_entry *text_scan, *data_scan;
|
||||
|
||||
bzero (nlist_bitvector, (number_of_syms >> 3) + 1);
|
||||
nsym = entry->nsymbols;
|
||||
nlist_bitvector = (u_char *)alloca((nsym >> 3) + 1);
|
||||
bzero(nlist_bitvector, (nsym >> 3) + 1);
|
||||
|
||||
/* Read in the files strings if they aren't available */
|
||||
if (!entry->strings) {
|
||||
int desc;
|
||||
|
||||
entry->strings = (char *)alloca(entry->string_size);
|
||||
desc = file_open(entry);
|
||||
read_entry_strings(desc, entry);
|
||||
}
|
||||
/* Read in the strings */
|
||||
entry->strings = (char *)alloca(entry->string_size);
|
||||
read_entry_strings(file_open(entry), entry);
|
||||
|
||||
if (!(entry->flags & E_DYNAMIC)) {
|
||||
/* Do text warnings based on a scan through the reloc info. */
|
||||
@ -563,26 +565,17 @@ do_file_warnings (entry, outfile)
|
||||
text_scan = init_debug_scan(0, entry);
|
||||
data_scan = init_debug_scan(1, entry);
|
||||
|
||||
for (i = 0; i < number_of_syms; i++) {
|
||||
struct nlist *s;
|
||||
for (i = 0; i < nsym; i++) {
|
||||
struct nlist *np;
|
||||
symbol *g;
|
||||
|
||||
g = entry->symbols[i].symbol;
|
||||
s = &entry->symbols[i].nzlist.nlist;
|
||||
|
||||
/*
|
||||
* XXX This is a temporary fence to correct an
|
||||
* incorrect assumption made in the case of symbols
|
||||
* which do not have entries in the (global)
|
||||
* symbol table.
|
||||
*/
|
||||
if(g == NULL)
|
||||
continue;
|
||||
np = &entry->symbols[i].nzlist.nlist;
|
||||
|
||||
if (g == NULL)
|
||||
continue;
|
||||
|
||||
if (!(s->n_type & N_EXT) && !SET_ELEMENT_P(s->n_type)) {
|
||||
if (!(np->n_type & N_EXT) && !SET_ELEMENT_P(np->n_type)) {
|
||||
warnx("internal error: `%s' N_EXT not set", g->name);
|
||||
continue;
|
||||
}
|
||||
@ -613,18 +606,18 @@ do_file_warnings (entry, outfile)
|
||||
dont_allow_symbol_name = 0;
|
||||
|
||||
if (list_multiple_defs && g->mult_defs) {
|
||||
errfmt = "Definition of symbol `%s' (multiply defined)";
|
||||
switch (s->n_type) {
|
||||
|
||||
errfmt = "Definition of symbol `%s' (multiply defined)";
|
||||
switch (np->n_type) {
|
||||
case N_TEXT | N_EXT:
|
||||
line_number =
|
||||
address_to_line(s->n_value, text_scan);
|
||||
address_to_line(np->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);
|
||||
address_to_line(np->n_value, data_scan);
|
||||
file_name = data_scan[0].filename;
|
||||
break;
|
||||
|
||||
@ -635,12 +628,12 @@ do_file_warnings (entry, outfile)
|
||||
if (g->mult_defs == 2)
|
||||
continue;
|
||||
errfmt =
|
||||
"First set element definition of symbol %s (multiply defined)";
|
||||
"First set element definition of symbol `%s' (multiply defined)";
|
||||
line_number = -1;
|
||||
break;
|
||||
|
||||
default:
|
||||
printf("multiply defined: %s, type %#x\n", g->name, s->n_type);
|
||||
warnx("Unexpected multiple definitions of symbol `%s', type %#x\n", g->name, np->n_type);
|
||||
/* Don't print out multiple defs at references.*/
|
||||
continue;
|
||||
}
|
||||
@ -654,19 +647,28 @@ printf("multiply defined: %s, type %#x\n", g->name, s->n_type);
|
||||
continue;
|
||||
|
||||
if (++(g->undef_refs) == MAX_UREFS_PRINTED)
|
||||
errfmt = "More undefined \"%s\" refs follow";
|
||||
errfmt = "More undefined `%s' refs follow";
|
||||
else
|
||||
errfmt = "Undefined symbol \"%s\" referenced";
|
||||
errfmt = "Undefined symbol `%s' referenced";
|
||||
line_number = -1;
|
||||
} else if (g->def_lsp && g->def_lsp->entry != entry &&
|
||||
!(entry->flags & E_DYNAMIC) &&
|
||||
g->def_lsp->entry->flags & E_SECONDCLASS) {
|
||||
fprintf(outfile,
|
||||
"%s: Undefined symbol `%s' referenced (use %s ?)\n",
|
||||
entry->filename,
|
||||
g->name,
|
||||
g->def_lsp->entry->local_sym_name);
|
||||
continue;
|
||||
} else if (g->warning) {
|
||||
/*
|
||||
* There are two cases in which we don't want to do
|
||||
* this. The first is if this is a definition instead
|
||||
* do a reference. The second is if it's the reference
|
||||
* of a reference. The second is if it's the reference
|
||||
* used by the warning stabs itself.
|
||||
*/
|
||||
if (s->n_type != (N_EXT | N_UNDF) ||
|
||||
(i && (s-1)->n_type == N_WARNING))
|
||||
if (np->n_type != (N_EXT | N_UNDF) ||
|
||||
(entry->symbols[i].flags & LS_WARNING))
|
||||
continue;
|
||||
|
||||
errfmt = g->warning;
|
||||
@ -689,7 +691,7 @@ printf("multiply defined: %s, type %#x\n", g->name, s->n_type);
|
||||
}
|
||||
free(text_scan);
|
||||
free(data_scan);
|
||||
entry->strings = 0; /* Since it will dissapear anyway. */
|
||||
entry->strings = 0; /* Since it will disappear anyway. */
|
||||
}
|
||||
|
||||
int
|
||||
@ -698,17 +700,18 @@ do_warnings(outfile)
|
||||
{
|
||||
list_unresolved_refs = !relocatable_output &&
|
||||
(undefined_global_sym_count || undefined_shobj_sym_count);
|
||||
list_warning_symbols = warning_count;
|
||||
list_multiple_defs = multiple_def_count != 0;
|
||||
|
||||
if (!(list_unresolved_refs ||
|
||||
list_warning_symbols || list_multiple_defs))
|
||||
list_warning_symbols ||
|
||||
list_multiple_defs))
|
||||
/* No need to run this routine */
|
||||
return 1;
|
||||
|
||||
if (entry_symbol && !entry_symbol->defined)
|
||||
fprintf(outfile, "Undefined entry symbol %s\n",
|
||||
entry_symbol->name);
|
||||
fprintf(outfile, "Undefined entry symbol `%s'\n",
|
||||
entry_symbol->name);
|
||||
|
||||
each_file(do_file_warnings, (void *)outfile);
|
||||
|
||||
if (list_unresolved_refs || list_multiple_defs)
|
||||
|
@ -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.9 1994/02/13 20:42:09 jkh Exp $
|
||||
* $Id: md.c,v 1.10 1994/06/15 22:40:44 rich Exp $
|
||||
*/
|
||||
|
||||
#include <sys/param.h>
|
||||
@ -228,7 +228,7 @@ long *savep;
|
||||
|
||||
#ifndef RTLD
|
||||
|
||||
#ifdef FreeBSD
|
||||
#ifdef __FreeBSD__
|
||||
int netzmagic;
|
||||
#endif
|
||||
|
||||
@ -247,7 +247,7 @@ int magic, flags;
|
||||
else
|
||||
N_SETMAGIC((*hp), magic, MID_I386, flags);
|
||||
#endif
|
||||
#ifdef FreeBSD
|
||||
#ifdef __FreeBSD__
|
||||
if (oldmagic)
|
||||
hp->a_midmag = magic;
|
||||
else if (netzmagic)
|
||||
|
@ -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.h,v 1.9 1994/02/13 20:42:11 jkh Exp $
|
||||
* $Id: md.h,v 1.10 1994/06/15 22:40:46 rich Exp $
|
||||
*/
|
||||
|
||||
|
||||
@ -63,7 +63,7 @@
|
||||
/*
|
||||
* FreeBSD does it differently
|
||||
*/
|
||||
#ifdef FreeBSD
|
||||
#ifdef __FreeBSD__
|
||||
#define N_SET_FLAG(ex,f) (oldmagic ? (0) : \
|
||||
(netzmagic == 0 ? \
|
||||
N_SETMAGIC(ex, \
|
||||
|
@ -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.3 1993/12/10 10:16:00 jkh Exp $
|
||||
* $Id: mdprologue.S,v 1.4 1994/06/15 22:40:49 rich Exp $
|
||||
*/
|
||||
|
||||
/*
|
||||
@ -43,13 +43,10 @@
|
||||
/*
|
||||
* _rtl(int version, struct crt_ldso *crtp)
|
||||
*/
|
||||
#define FRAME 12 /* Size of stack frame */
|
||||
|
||||
|
||||
_rtl: # crt0 calls us here
|
||||
pushl %ebp # Allocate stack frame
|
||||
movl %esp, %ebp
|
||||
subl $FRAME, %esp
|
||||
pushl %ebx
|
||||
call 1f # PIC function prologue
|
||||
1:
|
||||
@ -68,9 +65,9 @@ _rtl: # crt0 calls us here
|
||||
call %eax # _rtld(version, crtp, DYNAMIC)
|
||||
addl $12,%esp # pop arguments
|
||||
|
||||
movl (-FRAME-4)(%ebp), %ebx # restore %ebx
|
||||
movl -4(%ebp), %ebx # restore %ebx
|
||||
leave # remove stack frame,
|
||||
ret # lets rock
|
||||
ret # let's rock
|
||||
|
||||
# First call to a procedure generally comes through here for
|
||||
# binding.
|
||||
@ -96,7 +93,7 @@ _binder_entry:
|
||||
ret
|
||||
|
||||
# Special system call stubs which return real and effective user and group
|
||||
# ids. Saves overhead of making separate calls for each.
|
||||
# id's. Saves overhead of making separate calls for each.
|
||||
# !! Relies on compatability option in BSD 4.three-and-a-half
|
||||
|
||||
.globl _getreuid, _getregid
|
||||
|
@ -27,7 +27,7 @@
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* $Id: rtld.c,v 1.17 1994/06/15 22:41:15 rich Exp $
|
||||
* $Id: rtld.c,v 1.18 1994/09/15 20:48:55 bde Exp $
|
||||
*/
|
||||
|
||||
#include <sys/param.h>
|
||||
@ -403,7 +403,7 @@ alloc_link_map(path, sodp, parent, addr, dp)
|
||||
link_map_tail = &smp->som_next;
|
||||
|
||||
smp->som_addr = addr;
|
||||
smp->som_path = strdup(path);
|
||||
smp->som_path = path?strdup(path):NULL;
|
||||
smp->som_sod = sodp;
|
||||
smp->som_dynamic = dp;
|
||||
smp->som_spd = (caddr_t)smpp;
|
||||
@ -442,7 +442,7 @@ map_object(sodp, smp)
|
||||
usehints = 1;
|
||||
again:
|
||||
path = rtfindlib(name, sodp->sod_major,
|
||||
sodp->sod_minor, &usehints);
|
||||
sodp->sod_minor, &usehints);
|
||||
if (path == NULL) {
|
||||
errno = ENOENT;
|
||||
return NULL;
|
||||
@ -484,17 +484,17 @@ again:
|
||||
}
|
||||
|
||||
if ((addr = mmap(0, hdr.a_text + hdr.a_data,
|
||||
PROT_READ|PROT_EXEC,
|
||||
MAP_FILE|MAP_COPY, fd, 0)) == (caddr_t)-1) {
|
||||
PROT_READ|PROT_EXEC,
|
||||
MAP_COPY, fd, 0)) == (caddr_t)-1) {
|
||||
(void)close(fd);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#if 0
|
||||
if (mmap(addr + hdr.a_text, hdr.a_data,
|
||||
PROT_READ|PROT_WRITE|PROT_EXEC,
|
||||
MAP_FILE|MAP_FIXED|MAP_COPY,
|
||||
fd, hdr.a_text) == (caddr_t)-1) {
|
||||
PROT_READ|PROT_WRITE|PROT_EXEC,
|
||||
MAP_FIXED|MAP_COPY,
|
||||
fd, hdr.a_text) == (caddr_t)-1) {
|
||||
(void)close(fd);
|
||||
return NULL;
|
||||
}
|
||||
@ -548,9 +548,9 @@ caddr_t addr;
|
||||
else
|
||||
sym = "";
|
||||
|
||||
if (getenv("LD_WARN_NON_PURE_CODE") != NULL)
|
||||
fprintf(stderr,
|
||||
"ld.so: warning: non pure code in %s at %x (%s)\n",
|
||||
if (getenv("LD_SUPPRESS_WARNINGS") == NULL &&
|
||||
getenv("LD_WARN_NON_PURE_CODE") != NULL)
|
||||
warnx("ld.so: warning: non pure code in %s at %x (%s)\n",
|
||||
smp->som_path, r->r_address, sym);
|
||||
|
||||
if (smp->som_write == 0 &&
|
||||
@ -972,7 +972,7 @@ maphints()
|
||||
}
|
||||
|
||||
msize = PAGSIZ;
|
||||
addr = mmap(0, msize, PROT_READ, MAP_FILE|MAP_COPY, fd, 0);
|
||||
addr = mmap(0, msize, PROT_READ, MAP_COPY, fd, 0);
|
||||
|
||||
if (addr == (caddr_t)-1) {
|
||||
close(fd);
|
||||
@ -999,7 +999,7 @@ maphints()
|
||||
if (hheader->hh_ehints > msize) {
|
||||
hmsize = hheader->hh_ehints;
|
||||
if (mmap(addr+msize, hheader->hh_ehints - msize,
|
||||
PROT_READ, MAP_FILE|MAP_COPY|MAP_FIXED,
|
||||
PROT_READ, MAP_COPY|MAP_FIXED,
|
||||
fd, msize) != (caddr_t)(addr+msize)) {
|
||||
|
||||
munmap((caddr_t)hheader, msize);
|
||||
@ -1092,41 +1092,50 @@ rtfindlib(name, major, minor, usehints)
|
||||
int major, minor;
|
||||
int *usehints;
|
||||
{
|
||||
char *hint;
|
||||
char *cp, *ld_path = getenv("LD_LIBRARY_PATH");
|
||||
int realminor;
|
||||
|
||||
if (hheader == NULL)
|
||||
maphints();
|
||||
|
||||
if (!HINTS_VALID || !(*usehints)) {
|
||||
*usehints = 0;
|
||||
return (char *)findshlib(name, &major, &minor, 0);
|
||||
}
|
||||
if (!HINTS_VALID || !(*usehints))
|
||||
goto lose;
|
||||
|
||||
if (ld_path != NULL) {
|
||||
/* Prefer paths from LD_LIBRARY_PATH */
|
||||
while ((cp = strsep(&ld_path, ":")) != NULL) {
|
||||
|
||||
hint = findhint(name, major, minor, cp);
|
||||
cp = findhint(name, major, minor, cp);
|
||||
if (ld_path)
|
||||
*(ld_path-1) = ':';
|
||||
if (hint)
|
||||
return hint;
|
||||
if (cp)
|
||||
return cp;
|
||||
}
|
||||
/* Not found in hints, try directory search */
|
||||
hint = (char *)findshlib(name, &major, &minor, 0);
|
||||
if (hint)
|
||||
return hint;
|
||||
realminor = -1;
|
||||
cp = (char *)findshlib(name, &major, &realminor, 0);
|
||||
if (cp && realminor >= minor)
|
||||
return cp;
|
||||
}
|
||||
|
||||
/* No LD_LIBRARY_PATH or lib not found in there; check default */
|
||||
hint = findhint(name, major, minor, NULL);
|
||||
if (hint)
|
||||
return hint;
|
||||
cp = findhint(name, major, minor, NULL);
|
||||
if (cp)
|
||||
return cp;
|
||||
|
||||
lose:
|
||||
/* No hints available for name */
|
||||
*usehints = 0;
|
||||
return (char *)findshlib(name, &major, &minor, 0);
|
||||
realminor = -1;
|
||||
cp = (char *)findshlib(name, &major, &realminor, 0);
|
||||
if (cp) {
|
||||
if (realminor < minor && getenv("LD_SUPPRESS_WARNINGS") == NULL)
|
||||
warnx("warning: lib%s.so.%d.%d: "
|
||||
"minor version >= %d expected, using it anyway",
|
||||
name, major, realminor, minor);
|
||||
return cp;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static struct somap_private dlmap_private = {
|
||||
|
@ -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: shlib.c,v 1.8 1994/02/13 20:41:43 jkh Exp $
|
||||
* $Id: shlib.c,v 1.9 1994/06/15 22:39:54 rich Exp $
|
||||
*/
|
||||
|
||||
#include <sys/param.h>
|
||||
@ -54,7 +54,7 @@ char *strsep();
|
||||
* Standard directories to search for files specified by -l.
|
||||
*/
|
||||
#ifndef STANDARD_SEARCH_DIRS
|
||||
#define STANDARD_SEARCH_DIRS "/usr/lib", "/usr/X11R6/lib", "/usr/X386/lib", "/usr/local/lib"
|
||||
#define STANDARD_SEARCH_DIRS "/usr/lib"
|
||||
#endif
|
||||
|
||||
/*
|
||||
@ -64,7 +64,7 @@ char *strsep();
|
||||
char **search_dirs;
|
||||
int n_search_dirs;
|
||||
|
||||
char *standard_search_dirs[] = {
|
||||
char *standard_search_dirs[] = {
|
||||
STANDARD_SEARCH_DIRS
|
||||
};
|
||||
|
||||
@ -88,12 +88,12 @@ char *path;
|
||||
if (path == NULL)
|
||||
return;
|
||||
|
||||
/* Add search directories from `paths' */
|
||||
/* Add search directories from `paths' */
|
||||
while ((cp = strsep(&path, ":")) != NULL) {
|
||||
add_search_dir(cp);
|
||||
add_search_dir(cp);
|
||||
if (path)
|
||||
*(path-1) = ':';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -1,6 +1,37 @@
|
||||
.\"
|
||||
.\" 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.
|
||||
.\" 3. The name of the author may not be used to endorse or promote products
|
||||
.\" derived from this software without 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$
|
||||
.\"
|
||||
.Dd October 3, 1993
|
||||
.Dt LDCONFIG 8
|
||||
.Os FreeBSD 1.1
|
||||
.Os FreeBSD
|
||||
.Sh NAME
|
||||
.Nm ldconfig
|
||||
.Nd configure the shared library cache
|
||||
@ -20,7 +51,7 @@ directories. It scans a set of built-in system directories and any
|
||||
specified on the command line (in the given order) looking for shared
|
||||
libraries and stores the results in the file
|
||||
.Xr /var/run/ld.so.hints
|
||||
to forstall the overhead that would otherwise result from the
|
||||
to forestall the overhead that would otherwise result from the
|
||||
directory search operations
|
||||
.Xr ld.so
|
||||
would have to perform to load the required shared libraries.
|
||||
@ -56,16 +87,8 @@ Lists the current contents of
|
||||
.Xr ld.so.hints
|
||||
on the standard output. The hints file will not be modified.
|
||||
.It Fl s
|
||||
Do not scan
|
||||
.Nm ldconfig
|
||||
\'s builtin system directories
|
||||
.Sq /usr/lib
|
||||
,
|
||||
.Sq /usr/X386/lib
|
||||
,
|
||||
.Sq /usr/X11R6/lib
|
||||
and
|
||||
.Sq /usr/local/lib
|
||||
Do not scan the built-in system directory
|
||||
.Pq Dq /usr/lib
|
||||
for shared libraries.
|
||||
.It Fl v
|
||||
Switch on verbose mode.
|
||||
|
@ -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: ldconfig.c,v 1.6 1994/06/05 19:04:11 ats Exp $
|
||||
* $Id: ldconfig.c,v 1.7 1994/06/15 22:40:56 rich Exp $
|
||||
*/
|
||||
|
||||
#include <sys/param.h>
|
||||
@ -54,7 +54,8 @@
|
||||
#undef major
|
||||
#undef minor
|
||||
|
||||
char *progname;
|
||||
extern char *__progname;
|
||||
|
||||
static int verbose;
|
||||
static int nostd;
|
||||
static int justread;
|
||||
@ -84,12 +85,6 @@ char *argv[];
|
||||
{
|
||||
int i, c;
|
||||
int rval = 0;
|
||||
extern int optind;
|
||||
|
||||
if ((progname = strrchr(argv[0], '/')) == NULL)
|
||||
progname = argv[0];
|
||||
else
|
||||
progname++;
|
||||
|
||||
while ((c = getopt(argc, argv, "rsv")) != EOF) {
|
||||
switch (c) {
|
||||
@ -103,7 +98,8 @@ char *argv[];
|
||||
justread = 1;
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr, "Usage: %s [-r] [-s] [-v] [dir ...]\n", progname);
|
||||
fprintf(stderr, "Usage: %s [-r][-s][-v][dir ...]\n",
|
||||
__progname);
|
||||
exit(1);
|
||||
break;
|
||||
}
|
||||
@ -368,7 +364,7 @@ listhints()
|
||||
}
|
||||
|
||||
msize = PAGSIZ;
|
||||
addr = mmap(0, msize, PROT_READ, MAP_FILE|MAP_COPY, fd, 0);
|
||||
addr = mmap(0, msize, PROT_READ, MAP_COPY, fd, 0);
|
||||
|
||||
if (addr == (caddr_t)-1) {
|
||||
perror(_PATH_LD_HINTS);
|
||||
@ -389,7 +385,7 @@ listhints()
|
||||
|
||||
if (hdr->hh_ehints > msize) {
|
||||
if (mmap(addr+msize, hdr->hh_ehints - msize,
|
||||
PROT_READ, MAP_FILE|MAP_COPY|MAP_FIXED,
|
||||
PROT_READ, MAP_COPY|MAP_FIXED,
|
||||
fd, msize) != (caddr_t)(addr+msize)) {
|
||||
|
||||
perror(_PATH_LD_HINTS);
|
||||
|
@ -1,6 +1,6 @@
|
||||
.Dd October 22, 1993
|
||||
.Dt LDD 1
|
||||
.Os FreeBSD 1.1
|
||||
.Os FreeBSD
|
||||
.Sh NAME
|
||||
.Nm ldd
|
||||
.Nd list dynamic object dependencies
|
||||
@ -16,6 +16,7 @@ depedencies that are the result of needed shared objects which themselves
|
||||
depend on yet other shared objects.
|
||||
.Sh SEE ALSO
|
||||
.Xr ld 1 ,
|
||||
.Xr ld.so 1 ,
|
||||
.Xr nm 1
|
||||
.Sh HISTORY
|
||||
A
|
||||
|
@ -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: ldd.c,v 1.3 1994/02/13 20:42:43 jkh Exp $
|
||||
* $Id: ldd.c,v 1.4 1994/06/15 22:41:03 rich Exp $
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
@ -91,9 +91,12 @@ char *argv[];
|
||||
argv++;
|
||||
continue;
|
||||
}
|
||||
if (read(fd, &hdr, sizeof hdr) != sizeof hdr ||
|
||||
!(N_GETFLAG(hdr) & EX_DYNAMIC) ||
|
||||
hdr.a_entry < __LDPGSZ) {
|
||||
if (read(fd, &hdr, sizeof hdr) != sizeof hdr
|
||||
|| (N_GETFLAG(hdr) & EX_DPMASK) != EX_DYNAMIC
|
||||
#if 1 /* Compatibility */
|
||||
|| hdr.a_entry < __LDPGSZ
|
||||
#endif
|
||||
) {
|
||||
|
||||
warnx("%s: not a dynamic executable", *argv);
|
||||
(void)close(fd);
|
||||
|
Loading…
Reference in New Issue
Block a user