summaryrefslogtreecommitdiff
path: root/ldso
diff options
context:
space:
mode:
authorEric Andersen <andersen@codepoet.org>2002-01-11 19:57:41 +0000
committerEric Andersen <andersen@codepoet.org>2002-01-11 19:57:41 +0000
commited865232d8289ade7587a74d9cf2c0ccb878887b (patch)
tree8e3e317beba7e54259b98be6628bc90dc8e8e6aa /ldso
parentf1429771e1b4d6a42fd06a315e1509d4a2e94e33 (diff)
Rework naming for shared lib loader to avoid potential
nameing conflicts with std header files. -Erik
Diffstat (limited to 'ldso')
-rw-r--r--ldso/ldso/.cvsignore2
-rw-r--r--ldso/ldso/Makefile24
-rw-r--r--ldso/ldso/arm/elfinterp.c9
-rw-r--r--ldso/ldso/arm/syscalls.h124
-rw-r--r--ldso/ldso/arm/sysdep.h120
-rw-r--r--ldso/ldso/dl-elf.c8
-rw-r--r--ldso/ldso/dl-hash.c8
-rw-r--r--ldso/ldso/hash.c8
-rw-r--r--ldso/ldso/hash.h141
-rw-r--r--ldso/ldso/i386/dl-syscalls.h2
-rw-r--r--ldso/ldso/i386/elfinterp.c11
-rw-r--r--ldso/ldso/i386/ld_syscalls.h2
-rw-r--r--ldso/ldso/i386/syscalls.h166
-rw-r--r--ldso/ldso/i386/sysdep.h76
-rw-r--r--ldso/ldso/ld_hash.h2
-rw-r--r--ldso/ldso/ld_syscall.h16
-rw-r--r--ldso/ldso/linuxelf.h5
-rw-r--r--ldso/ldso/m68k/elfinterp.c10
-rw-r--r--ldso/ldso/m68k/syscalls.h175
-rw-r--r--ldso/ldso/m68k/sysdep.h83
-rw-r--r--ldso/ldso/powerpc/elfinterp.c11
-rw-r--r--ldso/ldso/powerpc/syscalls.h243
-rw-r--r--ldso/ldso/powerpc/sysdep.h122
-rw-r--r--ldso/ldso/readelflib1.c8
-rw-r--r--ldso/ldso/sparc/elfinterp.c10
-rw-r--r--ldso/ldso/sparc/resolve.S2
-rw-r--r--ldso/ldso/sparc/syscalls.h156
-rw-r--r--ldso/ldso/sparc/sysdep.h125
-rw-r--r--ldso/ldso/string.h259
-rw-r--r--ldso/ldso/syscall.h118
30 files changed, 62 insertions, 1984 deletions
diff --git a/ldso/ldso/.cvsignore b/ldso/ldso/.cvsignore
index 9103d4aa9..962b65384 100644
--- a/ldso/ldso/.cvsignore
+++ b/ldso/ldso/.cvsignore
@@ -1,2 +1,2 @@
ld-uclibc.so*
-ld.so.h
+ld-uClibc.h
diff --git a/ldso/ldso/Makefile b/ldso/ldso/Makefile
index d85900fbb..c91e0b85e 100644
--- a/ldso/ldso/Makefile
+++ b/ldso/ldso/Makefile
@@ -23,17 +23,17 @@
TOPDIR=../../
+DOPIC=true
include $(TOPDIR)Rules.mak
-TARGET_CFLAGS += #-DDL_DEBUG #-funroll-loops
-
-
LDSO_FULLNAME=ld-uClibc-$(MAJOR_VERSION).$(MINOR_VERSION).so
-TARGET_CFLAGS+=-fPIC -D__PIC__ -DUCLIBC_TARGET_PREFIX=\"$(TARGET_PREFIX)\" \
+
+#XXFLAGS += #-DDL_DEBUG #-funroll-loops
+XXFLAGS+=-DUCLIBC_TARGET_PREFIX=\"$(TARGET_PREFIX)\" \
-DUCLIBC_DEVEL_PREFIX=\"$(DEVEL_PREFIX)\" \
-DUCLIBC_BUILD_DIR=\"$(shell cd $(TOPDIR) && pwd)\"
-CSRC= boot1.c hash.c readelflib1.c $(TARGET_ARCH)/elfinterp.c
+CSRC= ldso.c hash.c readelflib1.c $(TARGET_ARCH)/elfinterp.c
COBJS=$(patsubst %.c,%.o, $(CSRC))
ASRC=$(shell ls $(TARGET_ARCH)/*.S)
AOBJS=$(patsubst %.S,%.o, $(ASRC))
@@ -42,20 +42,20 @@ OBJS=$(AOBJS) $(COBJS)
all: lib
-lib:: ld.so.h $(OBJS) $(DLINK_OBJS)
- $(TARGET_CC) -e _dl_boot $(TARGET_LDFLAGS) -nostdlib -shared -o $(LDSO_FULLNAME) \
- -Wl,-soname,$(UCLIBC_LDSO) $(OBJS)
+lib:: ldso.h $(OBJS) $(DLINK_OBJS)
+ $(LD) -e _dl_boot $(LDFLAGS) -nostdlib -shared -o $(LDSO_FULLNAME) \
+ -soname=$(UCLIBC_LDSO) $(OBJS)
install -d $(TOPDIR)lib
install -m 755 $(LDSO_FULLNAME) $(TOPDIR)lib
(cd $(TOPDIR)lib && ln -sf $(LDSO_FULLNAME) $(UCLIBC_LDSO))
-ld.so.h: Makefile
- echo "#define _dl_static_progname \""$(UCLIBC_LDSO)"\"" > ld.so.h
+ldso.h: Makefile
+ echo "#define _dl_static_progname \""$(UCLIBC_LDSO)"\"" > ld-uClibc.h
$(COBJS): %.o : %.c
- $(TARGET_CC) $(TARGET_CFLAGS) -I. -I./$(TARGET_ARCH) -I../libdl -c $< -o $@
+ $(CC) $(CFLAGS) $(XXFLAGS) -I. -I./$(TARGET_ARCH) -I../libdl -c $< -o $@
$(STRIPTOOL) -x -R .note -R .comment $*.o
clean::
- $(RM) -f $(UCLIBC_LDSO)* $(OBJS) $(LDSO_FULLNAME)* core *.o *.a *.s *.i tmp_make foo *~
+ $(RM) -f $(UCLIBC_LDSO)* $(OBJS) $(LDSO_FULLNAME)* core *.o *.a *.s *.i ldso.h *~
diff --git a/ldso/ldso/arm/elfinterp.c b/ldso/ldso/arm/elfinterp.c
index f0c83a166..d1616c5bf 100644
--- a/ldso/ldso/arm/elfinterp.c
+++ b/ldso/ldso/arm/elfinterp.c
@@ -49,11 +49,10 @@ static char *_dl_reltypes[] =
#include <sys/types.h>
#include <errno.h>
-#include "elf.h"
-#include "hash.h"
-#include "syscall.h"
-#include "string.h"
-#include "sysdep.h"
+#include "linuxelf.h"
+#include "ld_hash.h"
+#include "ld_syscall.h"
+#include "ld_string.h"
extern char *_dl_progname;
diff --git a/ldso/ldso/arm/syscalls.h b/ldso/ldso/arm/syscalls.h
deleted file mode 100644
index aa08421a5..000000000
--- a/ldso/ldso/arm/syscalls.h
+++ /dev/null
@@ -1,124 +0,0 @@
-#include <sys/types.h>
-
-/*
- * This file contains the system call macros and syscall
- * numbers used by the shared library loader.
- */
-
-#define __NR_SYSCALL_BASE 0x900000
-
-#define __NR_exit (__NR_SYSCALL_BASE+ 1)
-#define __NR_read (__NR_SYSCALL_BASE+ 3)
-#define __NR_write (__NR_SYSCALL_BASE+ 4)
-#define __NR_open (__NR_SYSCALL_BASE+ 5)
-#define __NR_close (__NR_SYSCALL_BASE+ 6)
-#define __NR_getuid (__NR_SYSCALL_BASE+ 24)
-#define __NR_geteuid (__NR_SYSCALL_BASE+ 49)
-#define __NR_getgid (__NR_SYSCALL_BASE+ 47)
-#define __NR_getegid (__NR_SYSCALL_BASE+ 50)
-#define __NR_mmap (__NR_SYSCALL_BASE+ 90)
-#define __NR_munmap (__NR_SYSCALL_BASE+ 91)
-#define __NR_stat (__NR_SYSCALL_BASE+106)
-#define __NR_mprotect (__NR_SYSCALL_BASE+125)
-
-
-/* Here are the macros which define how this platform makes
- * system calls. This particular variant does _not_ set
- * errno (note how it is disabled in __syscall_return) since
- * these will get called before the errno symbol is dynamicly
- * linked. */
-
-/* These are Erik's versions of the syscall routines. His were
- * cleaner than mine, so I adopted them instead with some
- * reformating. Shane Nay.
- */
-
-#define __sys2(x) #x
-#define __sys1(x) __sys2(x)
-
-#ifndef __syscall
-#define __syscall(name) "swi\t" __sys1(__NR_##name) "\n\t"
-#endif
-
-#undef __syscall_return
-#define __syscall_return(type, res) \
-do { \
- if ((unsigned long)(res) >= (unsigned long)(-125)) { \
- /*errno = -(res);*/ \
- res = -1; \
- } \
- return (type) (res); \
-} while (0)
-
-#define _syscall0(type,name) \
-type name(void) { \
- long __res; \
- __asm__ __volatile__ ( \
- __syscall(name) \
- "mov %0,r0" \
- :"=r" (__res) : : "r0","lr"); \
- __syscall_return(type,__res); \
-}
-
-#define _syscall1(type,name,type1,arg1) \
-type name(type1 arg1) { \
- long __res; \
- __asm__ __volatile__ ( \
- "mov\tr0,%1\n\t" \
- __syscall(name) \
- "mov %0,r0" \
- : "=r" (__res) \
- : "r" ((long)(arg1)) \
- : "r0","lr"); \
- __syscall_return(type,__res); \
-}
-
-#define _syscall2(type,name,type1,arg1,type2,arg2) \
-type name(type1 arg1,type2 arg2) { \
- long __res; \
- __asm__ __volatile__ ( \
- "mov\tr0,%1\n\t" \
- "mov\tr1,%2\n\t" \
- __syscall(name) \
- "mov\t%0,r0" \
- : "=r" (__res) \
- : "r" ((long)(arg1)),"r" ((long)(arg2)) \
- : "r0","r1","lr"); \
- __syscall_return(type,__res); \
-}
-
-
-#define _syscall3(type,name,type1,arg1,type2,arg2,type3,arg3) \
-type name(type1 arg1,type2 arg2,type3 arg3) { \
- long __res; \
- __asm__ __volatile__ ( \
- "mov\tr0,%1\n\t" \
- "mov\tr1,%2\n\t" \
- "mov\tr2,%3\n\t" \
- __syscall(name) \
- "mov\t%0,r0" \
- : "=r" (__res) \
- : "r" ((long)(arg1)),"r" ((long)(arg2)),"r" ((long)(arg3)) \
- : "r0","r1","r2","lr"); \
- __syscall_return(type,__res); \
-}
-
-#undef _syscall4
-#define _syscall4(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4)\
-type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4) { \
- long __res; \
- __asm__ __volatile__ ( \
- "mov\tr0,%1\n\t" \
- "mov\tr1,%2\n\t" \
- "mov\tr2,%3\n\t" \
- "mov\tr3,%4\n\t" \
- __syscall(name) \
- "mov\t%0,r0" \
- : "=r" (__res) \
- : "r" ((long)(arg1)),"r" ((long)(arg2)), \
- "r" ((long)(arg3)),"r" ((long)(arg4)) \
- : "r0","r1","r2","r3","lr"); \
- __syscall_return(type,__res); \
-}
-
-
diff --git a/ldso/ldso/arm/sysdep.h b/ldso/ldso/arm/sysdep.h
deleted file mode 100644
index b3d430519..000000000
--- a/ldso/ldso/arm/sysdep.h
+++ /dev/null
@@ -1,120 +0,0 @@
-/*
- * Various assmbly language/system dependent hacks that are required
- * so that we can minimize the amount of platform specific code.
- */
-
-/*
- * Define this if the system uses RELOCA.
- */
-#undef ELF_USES_RELOCA
-
-/*
- * Get a pointer to the argv array. On many platforms this can be just
- * the address if the first argument, on other platforms we need to
- * do something a little more subtle here.
- */
-#define GET_ARGV(ARGVP, ARGS) ARGVP = ((unsigned long*) ARGS)
-
-/*
- * Initialization sequence for a GOT.
- */
-#define INIT_GOT(GOT_BASE,MODULE) \
-{ \
- GOT_BASE[2] = (unsigned long) _dl_linux_resolve; \
- GOT_BASE[1] = (unsigned long) MODULE; \
-}
-
-/*
- * Here is a macro to perform a relocation. This is only used when
- * bootstrapping the dynamic loader. RELP is the relocation that we
- * are performing, REL is the pointer to the address we are relocating.
- * SYMBOL is the symbol involved in the relocation, and LOAD is the
- * load address.
- */
-#define PERFORM_BOOTSTRAP_RELOC(RELP,REL,SYMBOL,LOAD) \
- switch(ELF32_R_TYPE((RELP)->r_info)){ \
- case R_ARM_ABS32: \
- *REL += SYMBOL; \
- break; \
- case R_ARM_PC24: \
- { \
- unsigned long newval, topbits; \
- long addend=*REL & 0x00ffffff; \
- if(addend & 0x00800000) \
- addend|=0xff000000; \
- newval=SYMBOL- ((unsigned long)REL) + (addend<<2); \
- topbits=newval & 0xfe000000; \
- if (topbits != 0xfe000000 && topbits != 0x00000000) {/* \
- newval=fix_bad_pc24(REL,value) - \
- ((unsigned long)REL) + (addend << 2); \
- topbits=newval & 0xfe000000; \
- if(topbits != 0xfe000000 && topbits != 0x00000000)*/ \
- _dl_exit(1); \
- } \
- newval>>=2; \
- SYMBOL= (*REL & 0xff000000)|(newval & 0x00ffffff); \
- *REL=SYMBOL; \
- } \
- break; \
- case R_ARM_GLOB_DAT: \
- case R_ARM_JUMP_SLOT: \
- *REL = SYMBOL; \
- break; \
- case R_ARM_RELATIVE: \
- *REL += (unsigned long) LOAD; \
- break; \
- case R_ARM_NONE: \
- break; \
- default: \
- _dl_exit(1); \
- }
-
-
-/*
- * Transfer control to the user's application, once the dynamic loader
- * is done. This routine has to exit the current function, then
- * call the _dl_elf_main function.
- */
-
-#define START() return _dl_elf_main;
-
-
-
-/* Here we define the magic numbers that this dynamic loader should accept */
-
-#define MAGIC1 EM_ARM
-#undef MAGIC2
-/* Used for error messages */
-#define ELF_TARGET "ARM"
-
-struct elf_resolve;
-extern unsigned long _dl_linux_resolver(struct elf_resolve * tpnt, int reloc_entry);
-
-static inline unsigned long arm_modulus(unsigned long m, unsigned long p) {
- unsigned long i,t,inc;
- i=p; t=0;
- while(!(i&(1<<31))) {
- i<<=1;
- t++;
- }
- t--;
- for(inc=t;inc>2;inc--) {
- i=p<<inc;
- if(i&(1<<31))
- break;
- while(m>=i) {
- m-=i;
- i<<=1;
- if(i&(1<<31))
- break;
- if(i<p)
- break;
- }
- }
- while(m>=p) {
- m-=p;
- }
- return m;
-}
-
-#define do_rem(result, n, base) result=arm_modulus(n,base);
diff --git a/ldso/ldso/dl-elf.c b/ldso/ldso/dl-elf.c
index eed74321d..335f6fc29 100644
--- a/ldso/ldso/dl-elf.c
+++ b/ldso/ldso/dl-elf.c
@@ -21,12 +21,10 @@
/* This file contains the helper routines to load an ELF sharable
library into memory and add the symbol table info to the chain. */
-#include <elf.h>
#include "linuxelf.h"
-#include "string.h"
-#include "hash.h"
-#include "sysdep.h"
-#include "syscall.h"
+#include "ld_hash.h"
+#include "ld_syscall.h"
+#include "ld_string.h"
#include <sys/mman.h>
#ifdef USE_CACHE
#include "../config.h"
diff --git a/ldso/ldso/dl-hash.c b/ldso/ldso/dl-hash.c
index 5639a9a69..40d29bb44 100644
--- a/ldso/ldso/dl-hash.c
+++ b/ldso/ldso/dl-hash.c
@@ -20,13 +20,11 @@
/* Various symbol table handling functions, including symbol lookup */
-#include "string.h"
#include "dlfcn.h"
-#include "hash.h"
#include "linuxelf.h"
-#include "syscall.h"
-#include "string.h"
-#include "sysdep.h"
+#include "ld_hash.h"
+#include "ld_syscall.h"
+#include "ld_string.h"
/*
* This is the start of the linked list that describes all of the files present
diff --git a/ldso/ldso/hash.c b/ldso/ldso/hash.c
index 5639a9a69..40d29bb44 100644
--- a/ldso/ldso/hash.c
+++ b/ldso/ldso/hash.c
@@ -20,13 +20,11 @@
/* Various symbol table handling functions, including symbol lookup */
-#include "string.h"
#include "dlfcn.h"
-#include "hash.h"
#include "linuxelf.h"
-#include "syscall.h"
-#include "string.h"
-#include "sysdep.h"
+#include "ld_hash.h"
+#include "ld_syscall.h"
+#include "ld_string.h"
/*
* This is the start of the linked list that describes all of the files present
diff --git a/ldso/ldso/hash.h b/ldso/ldso/hash.h
deleted file mode 100644
index bb1b51fdc..000000000
--- a/ldso/ldso/hash.h
+++ /dev/null
@@ -1,141 +0,0 @@
-#ifndef _HASH_H_
-#define _HASH_H_
-
-#include "elf.h"
-
-/* Header file that describes the internal data structures used by the
- * ELF dynamic linker. */
-
-struct link_map
-{
- /* These entries must be in this order to be compatible with the
- * interface used by gdb to obtain the list of symbols. */
- unsigned long l_addr; /* address at which object is mapped */
- char *l_name; /* full name of loaded object */
- Elf32_Dyn *l_ld; /* dynamic structure of object */
- struct link_map *l_next;
- struct link_map *l_prev;
-};
-
-/* The DT_DEBUG entry in the .dynamic section is given the address of
- * this structure. gdb can pick this up to obtain the correct list of
- * loaded modules. */
-struct r_debug
-{
- int r_version; /* debugging info version no */
- struct link_map *r_map; /* address of link_map */
- unsigned long r_brk; /* address of update routine */
- enum
- {
- RT_CONSISTENT,
- RT_ADD,
- RT_DELETE
- } r_state;
- unsigned long r_ldbase; /* base addr of ld.so */
-};
-
-#ifndef RTLD_NEXT
-#define RTLD_NEXT ((void*)-1)
-#endif
-
-struct dyn_elf{
- unsigned long flags;
- struct elf_resolve * dyn;
- struct dyn_elf * next_handle; /* Used by dlopen et al. */
- struct dyn_elf * next;
-};
-
-struct elf_resolve{
- /* These entries must be in this order to be compatible with the interface used
- by gdb to obtain the list of symbols. */
- char * loadaddr;
- char * libname;
- unsigned long dynamic_addr;
- struct elf_resolve * next;
- struct elf_resolve * prev;
- /* Nothing after this address is used by gdb. */
- enum {elf_lib, elf_executable,program_interpreter, loaded_file} libtype;
- struct dyn_elf * symbol_scope;
- unsigned short usage_count;
- unsigned short int init_flag;
- unsigned int nbucket;
- unsigned long * elf_buckets;
- /*
- * These are only used with ELF style shared libraries
- */
- unsigned long nchain;
- unsigned long * chains;
- unsigned long dynamic_info[24];
-
- unsigned long dynamic_size;
- unsigned long n_phent;
- Elf32_Phdr * ppnt;
-
-#ifdef __powerpc__
- /* this is used to store the address of relocation data words, so
- * we don't have to calculate it every time, which requires a divide */
- unsigned long data_words;
-#endif
-};
-
-#if 0
-/*
- * The DT_DEBUG entry in the .dynamic section is given the address of this structure.
- * gdb can pick this up to obtain the correct list of loaded modules.
- */
-
-struct r_debug{
- int r_version;
- struct elf_resolve * link_map;
- unsigned long brk_fun;
- enum {RT_CONSISTENT, RT_ADD, RT_DELETE};
- unsigned long ldbase;
-};
-#endif
-
-#define COPY_RELOCS_DONE 1
-#define RELOCS_DONE 2
-#define JMP_RELOCS_DONE 4
-#define INIT_FUNCS_CALLED 8
-
-extern struct dyn_elf * _dl_symbol_tables;
-extern struct elf_resolve * _dl_loaded_modules;
-extern struct dyn_elf * _dl_handles;
-
-extern struct elf_resolve * _dl_check_hashed_files(char * libname);
-extern struct elf_resolve * _dl_add_elf_hash_table(char * libname,
- char * loadaddr, unsigned long * dynamic_info,
- unsigned long dynamic_addr, unsigned long dynamic_size);
-extern char * _dl_find_hash(char * name, struct dyn_elf * rpnt1,
- unsigned long instr_addr, struct elf_resolve * f_tpnt,
- int copyrel);
-extern int _dl_linux_dynamic_link(void);
-
-extern char * _dl_library_path;
-extern char * _dl_not_lazy;
-extern unsigned long _dl_elf_hash(const char * name);
-
-static inline int _dl_symbol(char * name)
-{
- if(name[0] != '_' || name[1] != 'd' || name[2] != 'l' || name[3] != '_')
- return 0;
- return 1;
-}
-
-
-#define DL_ERROR_NOFILE 1
-#define DL_ERROR_NOZERO 2
-#define DL_ERROR_NOTELF 3
-#define DL_ERROR_NOTMAGIC 4
-#define DL_ERROR_NOTDYN 5
-#define DL_ERROR_MMAP_FAILED 6
-#define DL_ERROR_NODYNAMIC 7
-#define DL_WRONG_RELOCS 8
-#define DL_BAD_HANDLE 9
-#define DL_NO_SYMBOL 10
-
-
-
-#endif /* _HASH_H_ */
-
-
diff --git a/ldso/ldso/i386/dl-syscalls.h b/ldso/ldso/i386/dl-syscalls.h
index b06c3238d..dc9c6934b 100644
--- a/ldso/ldso/i386/dl-syscalls.h
+++ b/ldso/ldso/i386/dl-syscalls.h
@@ -1,5 +1,3 @@
-#include <sys/types.h>
-
/*
* This file contains the system call macros and syscall
* numbers used by the shared library loader.
diff --git a/ldso/ldso/i386/elfinterp.c b/ldso/ldso/i386/elfinterp.c
index 621272bee..7745b1405 100644
--- a/ldso/ldso/i386/elfinterp.c
+++ b/ldso/ldso/i386/elfinterp.c
@@ -39,13 +39,10 @@ static char *_dl_reltypes[] =
a more than adequate job of explaining everything required to get this
working. */
-#include <sys/types.h>
-#include <errno.h>
-#include "elf.h"
-#include "hash.h"
-#include "syscall.h"
-#include "string.h"
-#include "sysdep.h"
+#include "linuxelf.h"
+#include "ld_hash.h"
+#include "ld_syscall.h"
+#include "ld_string.h"
extern char *_dl_progname;
diff --git a/ldso/ldso/i386/ld_syscalls.h b/ldso/ldso/i386/ld_syscalls.h
index b06c3238d..dc9c6934b 100644
--- a/ldso/ldso/i386/ld_syscalls.h
+++ b/ldso/ldso/i386/ld_syscalls.h
@@ -1,5 +1,3 @@
-#include <sys/types.h>
-
/*
* This file contains the system call macros and syscall
* numbers used by the shared library loader.
diff --git a/ldso/ldso/i386/syscalls.h b/ldso/ldso/i386/syscalls.h
deleted file mode 100644
index b06c3238d..000000000
--- a/ldso/ldso/i386/syscalls.h
+++ /dev/null
@@ -1,166 +0,0 @@
-#include <sys/types.h>
-
-/*
- * This file contains the system call macros and syscall
- * numbers used by the shared library loader.
- */
-
-#define __NR_exit 1
-#define __NR_read 3
-#define __NR_write 4
-#define __NR_open 5
-#define __NR_close 6
-#define __NR_getuid 24
-#define __NR_geteuid 49
-#define __NR_getgid 47
-#define __NR_getegid 50
-#define __NR_mmap 90
-#define __NR_munmap 91
-#define __NR_stat 106
-#define __NR_mprotect 125
-
-/* Here are the macros which define how this platform makes
- * system calls. This particular variant does _not_ set
- * errno (note how it is disabled in __syscall_return) since
- * these will get called before the errno symbol is dynamicly
- * linked. */
-
-#define __syscall_return(type, res) \
-do { \
- if ((unsigned long)(res) >= (unsigned long)(-125)) { \
- /*errno = -(res); */ \
- res = -1; \
- } \
- return (type) (res); \
-} while (0)
-
-#define _syscall0(type,name) \
-type name(void) \
-{ \
-long __res; \
-__asm__ volatile ("int $0x80" \
- : "=a" (__res) \
- : "0" (__NR_##name)); \
-__syscall_return(type,__res); \
-}
-
-#if defined(__PIC__)
-
-/*
- * PIC uses %ebx, so we need to save it during system calls
- */
-
-#define _syscall1(type,name,type1,arg1) \
-type name(type1 arg1) \
-{ \
-long __res; \
-__asm__ volatile ("push %%ebx; movl %2,%%ebx; int $0x80; pop %%ebx" \
- : "=a" (__res) \
- : "0" (__NR_##name),"r" ((long)(arg1))); \
-__syscall_return(type,__res); \
-}
-
-#define _syscall2(type,name,type1,arg1,type2,arg2) \
-type name(type1 arg1,type2 arg2) \
-{ \
-long __res; \
-__asm__ volatile ("push %%ebx; movl %2,%%ebx; int $0x80; pop %%ebx" \
- : "=a" (__res) \
- : "0" (__NR_##name),"r" ((long)(arg1)),"c" ((long)(arg2))); \
-__syscall_return(type,__res); \
-}
-
-#define _syscall3(type,name,type1,arg1,type2,arg2,type3,arg3) \
-type name(type1 arg1,type2 arg2,type3 arg3) \
-{ \
-long __res; \
-__asm__ volatile ("push %%ebx; movl %2,%%ebx; int $0x80; pop %%ebx" \
- : "=a" (__res) \
- : "0" (__NR_##name),"r" ((long)(arg1)),"c" ((long)(arg2)), \
- "d" ((long)(arg3))); \
-__syscall_return(type,__res); \
-}
-
-#define _syscall4(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4) \
-type name (type1 arg1, type2 arg2, type3 arg3, type4 arg4) \
-{ \
-long __res; \
-__asm__ volatile ("push %%ebx; movl %2,%%ebx; int $0x80; pop %%ebx" \
- : "=a" (__res) \
- : "0" (__NR_##name),"r" ((long)(arg1)),"c" ((long)(arg2)), \
- "d" ((long)(arg3)),"S" ((long)(arg4))); \
-__syscall_return(type,__res); \
-}
-
-#define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \
- type5,arg5) \
-type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5) \
-{ \
-long __res; \
-__asm__ volatile ("push %%ebx; movl %2,%%ebx; int $0x80; pop %%ebx" \
- : "=a" (__res) \
- : "0" (__NR_##name),"m" ((long)(arg1)),"c" ((long)(arg2)), \
- "d" ((long)(arg3)),"S" ((long)(arg4)),"D" ((long)(arg5))); \
-__syscall_return(type,__res); \
-}
-
-#else /* not doing __PIC__ */
-
-#define _syscall1(type,name,type1,arg1) \
-type name(type1 arg1) \
-{ \
-long __res; \
-__asm__ volatile ("int $0x80" \
- : "=a" (__res) \
- : "0" (__NR_##name),"b" ((long)(arg1))); \
-__syscall_return(type,__res); \
-}
-
-#define _syscall2(type,name,type1,arg1,type2,arg2) \
-type name(type1 arg1,type2 arg2) \
-{ \
-long __res; \
-__asm__ volatile ("int $0x80" \
- : "=a" (__res) \
- : "0" (__NR_##name),"b" ((long)(arg1)),"c" ((long)(arg2))); \
-__syscall_return(type,__res); \
-}
-
-#define _syscall3(type,name,type1,arg1,type2,arg2,type3,arg3) \
-type name(type1 arg1,type2 arg2,type3 arg3) \
-{ \
-long __res; \
-__asm__ volatile ("int $0x80" \
- : "=a" (__res) \
- : "0" (__NR_##name),"b" ((long)(arg1)),"c" ((long)(arg2)), \
- "d" ((long)(arg3))); \
-__syscall_return(type,__res); \
-}
-
-#define _syscall4(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4) \
-type name (type1 arg1, type2 arg2, type3 arg3, type4 arg4) \
-{ \
-long __res; \
-__asm__ volatile ("int $0x80" \
- : "=a" (__res) \
- : "0" (__NR_##name),"b" ((long)(arg1)),"c" ((long)(arg2)), \
- "d" ((long)(arg3)),"S" ((long)(arg4))); \
-__syscall_return(type,__res); \
-}
-
-#define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \
- type5,arg5) \
-type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5) \
-{ \
-long __res; \
-__asm__ volatile ("int $0x80" \
- : "=a" (__res) \
- : "0" (__NR_##name),"b" ((long)(arg1)),"c" ((long)(arg2)), \
- "d" ((long)(arg3)),"S" ((long)(arg4)),"D" ((long)(arg5))); \
-__syscall_return(type,__res); \
-}
-
-
-#endif /* __PIC__ */
-
-
diff --git a/ldso/ldso/i386/sysdep.h b/ldso/ldso/i386/sysdep.h
deleted file mode 100644
index d44b020ee..000000000
--- a/ldso/ldso/i386/sysdep.h
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * Various assmbly language/system dependent hacks that are required
- * so that we can minimize the amount of platform specific code.
- */
-
-/*
- * Define this if the system uses RELOCA.
- */
-#undef ELF_USES_RELOCA
-
-/*
- * Get a pointer to the argv array. On many platforms this can be just
- * the address if the first argument, on other platforms we need to
- * do something a little more subtle here.
- */
-#define GET_ARGV(ARGVP, ARGS) ARGVP = ((unsigned long*) & ARGS)
-
-/*
- * Initialization sequence for a GOT.
- */
-#define INIT_GOT(GOT_BASE,MODULE) \
-{ \
- GOT_BASE[2] = (unsigned long) _dl_linux_resolve; \
- GOT_BASE[1] = (unsigned long) MODULE; \
-}
-
-/*
- * Here is a macro to perform a relocation. This is only used when
- * bootstrapping the dynamic loader. RELP is the relocation that we
- * are performing, REL is the pointer to the address we are relocating.
- * SYMBOL is the symbol involved in the relocation, and LOAD is the
- * load address.
- */
-#define PERFORM_BOOTSTRAP_RELOC(RELP,REL,SYMBOL,LOAD) \
- switch(ELF32_R_TYPE((RELP)->r_info)){ \
- case R_386_32: \
- *REL += SYMBOL; \
- break; \
- case R_386_PC32: \
- *REL += SYMBOL - (unsigned long) REL; \
- break; \
- case R_386_GLOB_DAT: \
- case R_386_JMP_SLOT: \
- *REL = SYMBOL; \
- break; \
- case R_386_RELATIVE: \
- *REL += (unsigned long) LOAD; \
- break; \
- default: \
- _dl_exit(1); \
- }
-
-
-/*
- * Transfer control to the user's application, once the dynamic loader
- * is done. This routine has to exit the current function, then
- * call the _dl_elf_main function.
- */
-#define START() \
- __asm__ volatile ("leave\n\t" \
- "jmp *%%eax\n\t" \
- : "=a" (status) : "a" (_dl_elf_main))
-
-
-
-/* Here we define the magic numbers that this dynamic loader should accept */
-
-#define MAGIC1 EM_386
-#undef MAGIC2
-/* Used for error messages */
-#define ELF_TARGET "386"
-
-struct elf_resolve;
-extern unsigned long _dl_linux_resolver(struct elf_resolve * tpnt, int reloc_entry);
-
-#define do_rem(result, n, base) result = (n % base)
diff --git a/ldso/ldso/ld_hash.h b/ldso/ldso/ld_hash.h
index bb1b51fdc..01b3a4c33 100644
--- a/ldso/ldso/ld_hash.h
+++ b/ldso/ldso/ld_hash.h
@@ -1,7 +1,7 @@
#ifndef _HASH_H_
#define _HASH_H_
-#include "elf.h"
+#include <elf.h>
/* Header file that describes the internal data structures used by the
* ELF dynamic linker. */
diff --git a/ldso/ldso/ld_syscall.h b/ldso/ldso/ld_syscall.h
index 322c618f6..2542bc3e5 100644
--- a/ldso/ldso/ld_syscall.h
+++ b/ldso/ldso/ld_syscall.h
@@ -1,4 +1,13 @@
-#include "syscalls.h"
+/* Pull in the arch specific type information */
+#include <