aboutsummaryrefslogtreecommitdiff
path: root/libexec
diff options
context:
space:
mode:
authorJordan K. Hubbard <jkh@FreeBSD.org>1993-11-30 20:47:54 +0000
committerJordan K. Hubbard <jkh@FreeBSD.org>1993-11-30 20:47:54 +0000
commit52c4ca7af3f8ff112cb52086909057047ce5df91 (patch)
tree9392aab4f81d6be4eb1228cfb19ddc38026587ce /libexec
parent0da22b8b69bc472f4ef12bd918f6c2a6ff4d6021 (diff)
downloadsrc-52c4ca7af3f8ff112cb52086909057047ce5df91.tar.gz
src-52c4ca7af3f8ff112cb52086909057047ce5df91.zip
Many recent fixes from Paul K, add support for chaining of shared lib deps.
Notes
Notes: svn path=/head/; revision=811
Diffstat (limited to 'libexec')
-rw-r--r--libexec/rtld-aout/i386/md.c4
-rw-r--r--libexec/rtld-aout/i386/md.h4
-rw-r--r--libexec/rtld-aout/rtld.c62
-rw-r--r--libexec/rtld-aout/shlib.c29
4 files changed, 92 insertions, 7 deletions
diff --git a/libexec/rtld-aout/i386/md.c b/libexec/rtld-aout/i386/md.c
index 2344565ceba7..40766df1fd92 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.3 1993/11/15 20:58:20 paul Exp $
+ * $Id: md.c,v 1.4 1993/11/22 19:05:23 jkh Exp $
*/
#include <sys/param.h>
@@ -242,7 +242,7 @@ long where;
long *savep;
{
*savep = *(long *)where;
- *(char *)where = BPT;
+ *(char *)where = TRAP;
}
#ifdef NEED_SWAP
diff --git a/libexec/rtld-aout/i386/md.h b/libexec/rtld-aout/i386/md.h
index ca46e81f6c36..714073bbbbd5 100644
--- a/libexec/rtld-aout/i386/md.h
+++ b/libexec/rtld-aout/i386/md.h
@@ -1,5 +1,5 @@
/*
- * $Id: md.h,v 1.2 1993/11/09 04:19:17 paul Exp $ - I386 dependent definitions
+ * $Id: md.h,v 1.3 1993/11/22 19:05:24 jkh Exp $ - I386 dependent definitions
*/
@@ -50,7 +50,7 @@ typedef struct jmpslot {
#define NOP 0x90
#define CALL 0xe890 /* NOP + CALL opcode */
#define JUMP 0xe990 /* NOP + JMP opcode */
-#define BPT 0xcc /* breakpoint: INT 3 */
+#define TRAP 0xcc /* INT 3 */
/*
* Byte swap defs for cross linking
diff --git a/libexec/rtld-aout/rtld.c b/libexec/rtld-aout/rtld.c
index 0cccd23d12c0..2f9e361fa638 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.3 1993/11/09 04:44:30 paul Exp $
+ * $Id: rtld.c,v 1.4 1993/11/22 19:05:27 jkh Exp $
*/
#include <machine/vmparam.h>
@@ -240,6 +240,9 @@ struct link_dynamic *dp;
if (link_map_head)
ldp->ldd_sym_loaded = 1;
}
+
+ /* Close our file descriptor */
+ (void)close(crtp->crt_ldfd);
}
@@ -1055,6 +1058,63 @@ xprintf("sbrk: incr = %#x, curbrk = %#x\n", incr, curbrk);
if (mmap(curbrk, incr,
PROT_READ|PROT_WRITE,
MAP_ANON|MAP_FIXED|MAP_COPY, fd, 0) == (caddr_t)-1) {
+ xprintf("Cannot map anonymous memory");
+ _exit(1);
+ }
+
+#ifdef NEED_DEV_ZERO
+ close(fd);
+#endif
+
+ oldbrk = curbrk;
+#if TRY_THIS_FOR_A_CHANGE
+ curbrk -= incr;
+#else
+ curbrk += incr;
+#endif
+
+ return oldbrk;
+}
+#else
+
+caddr_t
+sbrk(incr)
+int incr;
+{
+ int fd = -1;
+ caddr_t oldbrk;
+
+xprintf("sbrk: incr = %#x, curbrk = %#x\n", incr, curbrk);
+#if DEBUG
+xprintf("sbrk: incr = %#x, curbrk = %#x\n", incr, curbrk);
+#endif
+ if (curbrk == 0 && (curbrk = mmap(0, PAGSIZ,
+ PROT_READ|PROT_WRITE,
+ MAP_ANON|MAP_COPY, fd, 0)) == (caddr_t)-1) {
+ xprintf("Cannot map anonymous memory");
+ _exit(1);
+ }
+
+ /* There's valid memory from `curbrk' to next page boundary */
+ if ((long)curbrk + incr <= (((long)curbrk + PAGSIZ) & ~(PAGSIZ - 1))) {
+ oldbrk = curbrk;
+ curbrk += incr;
+ return oldbrk;
+ }
+ /*
+ * If asking for than currently left in this chunk,
+ * go somewhere completely different.
+ */
+
+#ifdef NEED_DEV_ZERO
+ fd = open("/dev/zero", O_RDWR, 0);
+ if (fd == -1)
+ perror("/dev/zero");
+#endif
+
+ if ((curbrk = mmap(0, incr,
+ PROT_READ|PROT_WRITE,
+ MAP_ANON|MAP_COPY, fd, 0)) == (caddr_t)-1) {
perror("Cannot map anonymous memory");
}
diff --git a/libexec/rtld-aout/shlib.c b/libexec/rtld-aout/shlib.c
index 55cd8c387c5a..64e2efc88846 100644
--- a/libexec/rtld-aout/shlib.c
+++ b/libexec/rtld-aout/shlib.c
@@ -1,5 +1,5 @@
/*
- * $Id: shlib.c,v 1.4 1993/11/08 13:21:23 pk Exp $
+ * $Id: shlib.c,v 1.2 1993/11/09 04:19:03 paul Exp $
*/
#include <sys/param.h>
@@ -132,9 +132,10 @@ int n1, n2;
#undef minor
char *
-findshlib(name, majorp, minorp)
+findshlib(name, majorp, minorp, do_dot_a)
char *name;
int *majorp, *minorp;
+int do_dot_a;
{
int dewey[MAXDEWEY];
int ndewey;
@@ -154,6 +155,7 @@ int *majorp, *minorp;
for (i = 0; i < n_search_dirs; i++) {
DIR *dd = opendir(search_dirs[i]);
struct dirent *dp;
+ int found_dot_a = 0;
if (dd == NULL)
continue;
@@ -161,6 +163,16 @@ int *majorp, *minorp;
while ((dp = readdir(dd)) != NULL) {
int n, j, might_take_it = 0;
+ if (do_dot_a && path == NULL &&
+ dp->d_namlen == len + 2 &&
+ strncmp(dp->d_name, lname, len) == 0 &&
+ (dp->d_name+len)[0] == '.' &&
+ (dp->d_name+len)[1] == 'a') {
+
+ path = concat(search_dirs[i], "/", dp->d_name);
+ found_dot_a = 1;
+ }
+
if (dp->d_namlen < len + 4)
continue;
if (strncmp(dp->d_name, lname, len) != 0)
@@ -171,6 +183,12 @@ int *majorp, *minorp;
if ((n = getdewey(tmp, dp->d_name+len+4)) == 0)
continue;
+ if (major != -1 && found_dot_a) { /* XXX */
+ free(path);
+ path = NULL;
+ found_dot_a = 0;
+ }
+
if (major == -1 && minor == -1) {
might_take_it = 1;
} else if (major != -1 && minor == -1) {
@@ -192,12 +210,19 @@ int *majorp, *minorp;
if (path)
free(path);
path = concat(search_dirs[i], "/", dp->d_name);
+ found_dot_a = 0;
bcopy(tmp, dewey, sizeof(dewey));
ndewey = n;
*majorp = dewey[0];
*minorp = dewey[1];
}
closedir(dd);
+
+ if (found_dot_a)
+ /*
+ * There's a .a archive here.
+ */
+ return path;
}
return path;