diff options
author | nate <nate@FreeBSD.org> | 1994-12-23 22:31:35 +0000 |
---|---|---|
committer | nate <nate@FreeBSD.org> | 1994-12-23 22:31:35 +0000 |
commit | 7f56eb7b93f7774321c3f5924447d96ffcb858b9 (patch) | |
tree | 44d4ecee16a0e6d497426a41a2bdd4542c4c3342 /libexec | |
parent | 92495f8331471c4b72fe0037463cdac16b87b02e (diff) | |
download | FreeBSD-src-7f56eb7b93f7774321c3f5924447d96ffcb858b9.zip FreeBSD-src-7f56eb7b93f7774321c3f5924447d96ffcb858b9.tar.gz |
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
Diffstat (limited to 'libexec')
-rw-r--r-- | libexec/rtld-aout/i386/md.c | 6 | ||||
-rw-r--r-- | libexec/rtld-aout/i386/md.h | 4 | ||||
-rw-r--r-- | libexec/rtld-aout/i386/mdprologue.S | 11 | ||||
-rw-r--r-- | libexec/rtld-aout/rtld.c | 65 | ||||
-rw-r--r-- | libexec/rtld-aout/shlib.c | 12 |
5 files changed, 52 insertions, 46 deletions
diff --git a/libexec/rtld-aout/i386/md.c b/libexec/rtld-aout/i386/md.c index ce61355..40d9916 100644 --- a/libexec/rtld-aout/i386/md.c +++ b/libexec/rtld-aout/i386/md.c @@ -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) diff --git a/libexec/rtld-aout/i386/md.h b/libexec/rtld-aout/i386/md.h index 1209aee..89c1213 100644 --- a/libexec/rtld-aout/i386/md.h +++ b/libexec/rtld-aout/i386/md.h @@ -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, \ diff --git a/libexec/rtld-aout/i386/mdprologue.S b/libexec/rtld-aout/i386/mdprologue.S index 6a582be..43640c6 100644 --- a/libexec/rtld-aout/i386/mdprologue.S +++ b/libexec/rtld-aout/i386/mdprologue.S @@ -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 diff --git a/libexec/rtld-aout/rtld.c b/libexec/rtld-aout/rtld.c index d1ab408..2c31434 100644 --- a/libexec/rtld-aout/rtld.c +++ b/libexec/rtld-aout/rtld.c @@ -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 = { diff --git a/libexec/rtld-aout/shlib.c b/libexec/rtld-aout/shlib.c index 2e8dfe9..4ea4b85 100644 --- a/libexec/rtld-aout/shlib.c +++ b/libexec/rtld-aout/shlib.c @@ -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 |