summaryrefslogtreecommitdiff
path: root/libexec/ld.so/powerpc
diff options
context:
space:
mode:
authorDale Rahn <drahn@cvs.openbsd.org>2002-07-12 20:18:31 +0000
committerDale Rahn <drahn@cvs.openbsd.org>2002-07-12 20:18:31 +0000
commit80402e9cf360236b13306bcaf6d797f76f687dba (patch)
treecd26d9d127539c446450d138a3b7dafe8da253f5 /libexec/ld.so/powerpc
parent5865d6a998391648e294e7a7d4670166fb810364 (diff)
Change ld.so search order/method to match the a.out ld.so.
run destructors on dlclose() Move more symbols into _dl_ private space, so that the proper (libc) version of the function will be used. Add readdir() functionality to perform the proper library searching. Support DL_PRELOAD Do not relocate symbols if ld.so is being traced (and will exit). Misc lint cleanup. ok art@
Diffstat (limited to 'libexec/ld.so/powerpc')
-rw-r--r--libexec/ld.so/powerpc/archdep.h3
-rw-r--r--libexec/ld.so/powerpc/rtld_machine.c9
-rw-r--r--libexec/ld.so/powerpc/syscall.h80
3 files changed, 82 insertions, 10 deletions
diff --git a/libexec/ld.so/powerpc/archdep.h b/libexec/ld.so/powerpc/archdep.h
index 15d1da02aed..fe20594845a 100644
--- a/libexec/ld.so/powerpc/archdep.h
+++ b/libexec/ld.so/powerpc/archdep.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: archdep.h,v 1.7 2002/05/24 04:17:01 deraadt Exp $ */
+/* $OpenBSD: archdep.h,v 1.8 2002/07/12 20:18:30 drahn Exp $ */
/*
* Copyright (c) 1998 Per Fogelstrom, Opsycon AB
@@ -57,6 +57,7 @@
* The following functions are declared inline so they can
* be used before bootstrap linking has been finished.
*/
+
static inline void
_dl_dcbf(Elf32_Addr *addr)
{
diff --git a/libexec/ld.so/powerpc/rtld_machine.c b/libexec/ld.so/powerpc/rtld_machine.c
index 999818782f4..fb88fcd70fc 100644
--- a/libexec/ld.so/powerpc/rtld_machine.c
+++ b/libexec/ld.so/powerpc/rtld_machine.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rtld_machine.c,v 1.11 2002/07/07 08:54:50 jufi Exp $ */
+/* $OpenBSD: rtld_machine.c,v 1.12 2002/07/12 20:18:30 drahn Exp $ */
/*
* Copyright (c) 1999 Dale Rahn
@@ -81,6 +81,9 @@ _dl_printf("object relocation size %x, numrela %x\n",
if (relas == NULL)
return(0);
+ pltcall = NULL;
+ plttable = NULL;
+
/* for plt relocation usage */
if (object->Dyn.info[DT_JMPREL] != 0) {
/* resolver stub not set up */
@@ -145,6 +148,8 @@ _dl_printf("object relocation size %x, numrela %x\n",
this = sym;
symn = object->dyn.strtab + sym->st_name;
+ ooff = 0;
+
if (ELF32_R_SYM(relas->r_info) &&
!(ELF32_ST_BIND(sym->st_info) == STB_LOCAL &&
ELF32_ST_TYPE (sym->st_info) == STT_NOTYPE)) {
@@ -344,6 +349,8 @@ _dl_dcbf(r_addr);
const Elf32_Sym *cpysrc = NULL;
Elf32_Addr src_loff;
int size;
+
+ src_loff = 0;
for (cobj = _dl_objects; cobj != NULL && cpysrc == NULL;
cobj = cobj->next) {
if (object != cobj) {
diff --git a/libexec/ld.so/powerpc/syscall.h b/libexec/ld.so/powerpc/syscall.h
index 5abbec8a737..fd5f5b2ae73 100644
--- a/libexec/ld.so/powerpc/syscall.h
+++ b/libexec/ld.so/powerpc/syscall.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: syscall.h,v 1.8 2002/07/07 08:54:50 jufi Exp $ */
+/* $OpenBSD: syscall.h,v 1.9 2002/07/12 20:18:30 drahn Exp $ */
/*
* Copyright (c) 1998 Per Fogelstrom, Opsycon AB
@@ -34,12 +34,13 @@
#ifndef __DL_SYSCALL_H__
#define __DL_SYSCALL_H__
-#ifdef USE_CACHE
#include <sys/stat.h>
-#endif
#include <sys/syscall.h>
+
+static off_t _dl_lseek(int, off_t, int);
+
#ifndef _dl_MAX_ERRNO
#define _dl_MAX_ERRNO 4096
#endif
@@ -145,7 +146,7 @@ _dl_read (int fd, const char* buf, int len)
#define STRINGIFY(x) #x
#define XSTRINGIFY(x) STRINGIFY(x)
-int _dl__syscall(quad_t val, ...);
+long _dl__syscall(quad_t val, ...);
__asm__(".align 2\n\t"
".type _dl__syscall,@function\n"
"_dl__syscall:\n\t"
@@ -157,7 +158,7 @@ __asm__(".align 2\n\t"
"1:\n\t"
"blr");
-static int
+static inline int
_dl_mmap (void *addr, unsigned int len, unsigned int prot,
unsigned int flags, int fd, off_t offset)
{
@@ -204,7 +205,6 @@ _dl_mprotect (const void *addr, int size, int prot)
return status;
}
-#ifdef USE_CACHE
static inline int
_dl_stat (const char *addr, struct stat *sb)
{
@@ -224,7 +224,66 @@ _dl_stat (const char *addr, struct stat *sb)
return status;
}
-#endif
+static inline int
+_dl_fstat (int fd, struct stat *sb)
+{
+ register int status __asm__ ("3");
+
+ __asm__ volatile ("mr 0,%1\n\t"
+ "mr 3,%2\n\t"
+ "mr 4,%3\n\t"
+ "sc\n\t"
+ "cmpwi 0, 0\n\t"
+ "beq 1f\n\t"
+ "li 3,-1\n\t"
+ "1:"
+ : "=r" (status)
+ : "r" (SYS_fstat), "r" (fd), "r" (sb)
+ : "0", "3", "4");
+ return status;
+}
+
+static inline int
+_dl_fcntl (int fd, int cmd, int flag)
+{
+ register int status __asm__ ("3");
+
+ __asm__ volatile ("mr 0,%1\n\t"
+ "mr 3,%2\n\t"
+ "mr 4,%3\n\t"
+ "mr 5,%4\n\t"
+ "sc\n\t"
+ "cmpwi 0, 0\n\t"
+ "beq 1f\n\t"
+ "li 3,-1\n\t"
+ "1:"
+ : "=r" (status)
+ : "r" (SYS_fcntl), "r" (fd), "r" (cmd), "r"(flag)
+ : "0", "3", "4", "5");
+ return status;
+}
+
+static inline int
+_dl_getdirentries(int fd, char *buf, int nbytes, long *basep)
+{
+ register int status __asm__ ("3");
+
+ __asm__ volatile ("mr 0,%1\n\t"
+ "mr 3,%2\n\t"
+ "mr 4,%3\n\t"
+ "mr 5,%4\n\t"
+ "mr 6,%5\n\t"
+ "sc\n\t"
+ "cmpwi 0, 0\n\t"
+ "beq 1f\n\t"
+ "li 3,-1\n\t"
+ "1:"
+ : "=r" (status)
+ : "r" (SYS_getdirentries), "r" (fd), "r" (buf), "r"(nbytes),
+ "r" (basep)
+ : "0", "3", "4", "5", "6");
+ return status;
+}
static inline int
_dl_issetugid()
@@ -242,5 +301,10 @@ _dl_issetugid()
: "0", "3");
return status;
}
-#include <elf_abi.h>
+
+static inline off_t
+_dl_lseek(int fildes, off_t offset, int whence)
+{
+ return _dl__syscall((quad_t)SYS_lseek, fildes, 0, offset, whence);
+}
#endif /*__DL_SYSCALL_H__*/