From 70709408336e483de74947eb53e9ba01ef4ab140 Mon Sep 17 00:00:00 2001 From: Eric Andersen Date: Tue, 10 Feb 2004 09:26:57 +0000 Subject: Rework file naming, aiming for at least a vague level of consistancy --- ldso/Makefile | 6 +- ldso/include/dl-elf.h | 2 +- ldso/include/dl-string.h | 7 - ldso/include/dl-syscall.h | 2 +- ldso/include/ld_elf.h | 104 ----- ldso/include/ld_hash.h | 103 ----- ldso/include/ld_string.h | 281 ------------ ldso/include/ld_syscall.h | 132 ------ ldso/include/ldso.h | 8 +- ldso/ldso/.cvsignore | 2 +- ldso/ldso/Makefile | 12 +- ldso/ldso/arm/boot1_arch.h | 25 -- ldso/ldso/arm/ld_syscalls.h | 19 - ldso/ldso/arm/ld_sysdep.h | 124 ------ ldso/ldso/cris/boot1_arch.h | 16 - ldso/ldso/cris/dl-sysdep.h | 2 +- ldso/ldso/cris/ld_syscalls.h | 7 - ldso/ldso/cris/ld_sysdep.h | 112 ----- ldso/ldso/dl-startup.c | 4 +- ldso/ldso/hash.c | 262 ------------ ldso/ldso/i386/boot1_arch.h | 7 - ldso/ldso/i386/ld_syscalls.h | 7 - ldso/ldso/i386/ld_sysdep.h | 81 ---- ldso/ldso/ldso.c | 6 +- ldso/ldso/m68k/boot1_arch.h | 7 - ldso/ldso/m68k/ld_syscalls.h | 174 -------- ldso/ldso/m68k/ld_sysdep.h | 88 ---- ldso/ldso/mips/README | 4 +- ldso/ldso/mips/boot1_arch.h | 37 -- ldso/ldso/mips/ld_syscalls.h | 7 - ldso/ldso/mips/ld_sysdep.h | 136 ------ ldso/ldso/powerpc/boot1_arch.h | 20 - ldso/ldso/powerpc/ld_syscalls.h | 244 ----------- ldso/ldso/powerpc/ld_sysdep.h | 127 ------ ldso/ldso/readelflib1.c | 926 ---------------------------------------- ldso/ldso/sh/boot1_arch.h | 21 - ldso/ldso/sh/ld_syscalls.h | 7 - ldso/ldso/sh/ld_sysdep.h | 144 ------- ldso/ldso/sh64/boot1_arch.h | 25 -- ldso/ldso/sh64/ld_syscalls.h | 9 - ldso/ldso/sh64/ld_sysdep.h | 170 -------- ldso/ldso/sparc/boot1_arch.h | 7 - ldso/ldso/sparc/ld_syscalls.h | 156 ------- ldso/ldso/sparc/ld_sysdep.h | 112 ----- ldso/ldso/sparc/resolve.S | 2 +- ldso/ldso/startup.c | 583 ------------------------- ldso/libdl/Makefile | 14 +- ldso/libdl/dlib.c | 644 ---------------------------- ldso/libdl/libdl.c | 6 +- 49 files changed, 35 insertions(+), 4966 deletions(-) delete mode 100644 ldso/include/ld_elf.h delete mode 100644 ldso/include/ld_hash.h delete mode 100644 ldso/include/ld_string.h delete mode 100644 ldso/include/ld_syscall.h delete mode 100644 ldso/ldso/arm/boot1_arch.h delete mode 100644 ldso/ldso/arm/ld_syscalls.h delete mode 100644 ldso/ldso/arm/ld_sysdep.h delete mode 100644 ldso/ldso/cris/boot1_arch.h delete mode 100644 ldso/ldso/cris/ld_syscalls.h delete mode 100644 ldso/ldso/cris/ld_sysdep.h delete mode 100644 ldso/ldso/hash.c delete mode 100644 ldso/ldso/i386/boot1_arch.h delete mode 100644 ldso/ldso/i386/ld_syscalls.h delete mode 100644 ldso/ldso/i386/ld_sysdep.h delete mode 100644 ldso/ldso/m68k/boot1_arch.h delete mode 100644 ldso/ldso/m68k/ld_syscalls.h delete mode 100644 ldso/ldso/m68k/ld_sysdep.h delete mode 100644 ldso/ldso/mips/boot1_arch.h delete mode 100644 ldso/ldso/mips/ld_syscalls.h delete mode 100644 ldso/ldso/mips/ld_sysdep.h delete mode 100644 ldso/ldso/powerpc/boot1_arch.h delete mode 100644 ldso/ldso/powerpc/ld_syscalls.h delete mode 100644 ldso/ldso/powerpc/ld_sysdep.h delete mode 100644 ldso/ldso/readelflib1.c delete mode 100644 ldso/ldso/sh/boot1_arch.h delete mode 100644 ldso/ldso/sh/ld_syscalls.h delete mode 100644 ldso/ldso/sh/ld_sysdep.h delete mode 100644 ldso/ldso/sh64/boot1_arch.h delete mode 100644 ldso/ldso/sh64/ld_syscalls.h delete mode 100644 ldso/ldso/sh64/ld_sysdep.h delete mode 100644 ldso/ldso/sparc/boot1_arch.h delete mode 100644 ldso/ldso/sparc/ld_syscalls.h delete mode 100644 ldso/ldso/sparc/ld_sysdep.h delete mode 100644 ldso/ldso/startup.c delete mode 100644 ldso/libdl/dlib.c diff --git a/ldso/Makefile b/ldso/Makefile index 1c9fc8fef..3836a01d3 100644 --- a/ldso/Makefile +++ b/ldso/Makefile @@ -38,9 +38,9 @@ endif headers: $(LN) -fs $(TOPDIR)../include/elf.h include/ - $(LN) -fs ../ldso/$(TARGET_ARCH)/boot1_arch.h include/ - $(LN) -fs ../ldso/$(TARGET_ARCH)/ld_syscalls.h include/ - $(LN) -fs ../ldso/$(TARGET_ARCH)/ld_sysdep.h include/ + $(LN) -fs ../ldso/$(TARGET_ARCH)/dl-startup.h include/ + $(LN) -fs ../ldso/$(TARGET_ARCH)/dl-syscalls.h include/ + $(LN) -fs ../ldso/$(TARGET_ARCH)/dl-sysdep.h include/ clean: set -e ; for d in $(ALL_SUBDIRS) ; do $(MAKE) -C $$d $@ ; done diff --git a/ldso/include/dl-elf.h b/ldso/include/dl-elf.h index 04c450fc5..4cab5505f 100644 --- a/ldso/include/dl-elf.h +++ b/ldso/include/dl-elf.h @@ -1,7 +1,7 @@ #ifndef LINUXELF_H #define LINUXELF_H -#include /* before elf.h to get ELF_USES_RELOCA right */ +#include /* before elf.h to get ELF_USES_RELOCA right */ #include #include diff --git a/ldso/include/dl-string.h b/ldso/include/dl-string.h index 6fd266fc2..cbb867010 100644 --- a/ldso/include/dl-string.h +++ b/ldso/include/dl-string.h @@ -1,13 +1,6 @@ #ifndef _LINUX_STRING_H_ #define _LINUX_STRING_H_ -extern void *_dl_malloc(int size); -extern char *_dl_getenv(const char *symbol, char **envp); -extern void _dl_unsetenv(const char *symbol, char **envp); -extern char *_dl_strdup(const char *string); -extern void _dl_dprintf(int, const char *, ...); - - static size_t _dl_strlen(const char * str); static char *_dl_strcat(char *dst, const char *src); static char * _dl_strcpy(char * dst,const char *src); diff --git a/ldso/include/dl-syscall.h b/ldso/include/dl-syscall.h index 344a93039..0dd3f593d 100644 --- a/ldso/include/dl-syscall.h +++ b/ldso/include/dl-syscall.h @@ -2,7 +2,7 @@ #define _LD_SYSCALL_H_ /* Pull in the arch specific syscall implementation */ -#include +#include /* For MAP_ANONYMOUS -- differs between platforms */ #include /* Pull in whatever this particular arch's kernel thinks the kernel version of diff --git a/ldso/include/ld_elf.h b/ldso/include/ld_elf.h deleted file mode 100644 index 04c450fc5..000000000 --- a/ldso/include/ld_elf.h +++ /dev/null @@ -1,104 +0,0 @@ -#ifndef LINUXELF_H -#define LINUXELF_H - -#include /* before elf.h to get ELF_USES_RELOCA right */ -#include -#include - -#ifdef DEBUG -# define LDSO_CONF "../util/ld.so.conf" -# define LDSO_CACHE "../util/ld.so.cache" -# define LDSO_PRELOAD "../util/ld.so.preload" -#else -# define LDSO_CONF UCLIBC_RUNTIME_PREFIX "etc/ld.so.conf" -# define LDSO_CACHE UCLIBC_RUNTIME_PREFIX "etc/ld.so.cache" -# define LDSO_PRELOAD UCLIBC_RUNTIME_PREFIX "etc/ld.so.preload" -#endif - - -#define LIB_ANY -1 -#define LIB_DLL 0 -#define LIB_ELF 1 -#define LIB_ELF64 0x80 -#define LIB_ELF_LIBC5 2 -#define LIB_ELF_LIBC6 3 -#define LIB_ELF_LIBC0 4 - -/* Forward declarations for stuff defined in ld_hash.h */ -struct dyn_elf; -struct elf_resolve; - - -/* Definitions and prototypes for cache stuff */ -#ifdef USE_CACHE -extern int _dl_map_cache(void); -extern int _dl_unmap_cache(void); - -#define LDSO_CACHE_MAGIC "ld.so-" -#define LDSO_CACHE_MAGIC_LEN (sizeof LDSO_CACHE_MAGIC -1) -#define LDSO_CACHE_VER "1.7.0" -#define LDSO_CACHE_VER_LEN (sizeof LDSO_CACHE_VER -1) - -typedef struct { - char magic [LDSO_CACHE_MAGIC_LEN]; - char version [LDSO_CACHE_VER_LEN]; - int nlibs; -} header_t; - -typedef struct { - int flags; - int sooffset; - int liboffset; -} libentry_t; - -#else -static inline void _dl_map_cache(void) { } -static inline void _dl_unmap_cache(void) { } -#endif - - -/* Function prototypes for non-static stuff in readelflib1.c */ -extern int _dl_parse_copy_information(struct dyn_elf *rpnt, - unsigned long rel_addr, unsigned long rel_size, int type); -extern void _dl_parse_lazy_relocation_information(struct dyn_elf *rpnt, - unsigned long rel_addr, unsigned long rel_size, int type); -extern int _dl_parse_relocation_information(struct dyn_elf *rpnt, - unsigned long rel_addr, unsigned long rel_size, int type); -extern struct elf_resolve * _dl_load_shared_library(int secure, - struct dyn_elf **rpnt, struct elf_resolve *tpnt, char *full_libname, - int trace_loaded_objects); -extern struct elf_resolve * _dl_load_elf_shared_library(int secure, - struct dyn_elf **rpnt, char *libname); -extern struct elf_resolve *_dl_check_if_named_library_is_loaded(const char *full_libname, - int trace_loaded_objects); -extern int _dl_linux_resolve(void); -extern int _dl_fixup(struct dyn_elf *rpnt, int flag); - - -/* - * Datatype of a relocation on this platform - */ -#ifdef ELF_USES_RELOCA -# define ELF_RELOC ElfW(Rela) -# define DT_RELOC_TABLE_ADDR DT_RELA -# define DT_RELOC_TABLE_SIZE DT_RELASZ -# define UNSUPPORTED_RELOC_TYPE DT_REL -# define UNSUPPORTED_RELOC_STR "REL" -#else -# define ELF_RELOC ElfW(Rel) -# define DT_RELOC_TABLE_ADDR DT_REL -# define DT_RELOC_TABLE_SIZE DT_RELSZ -# define UNSUPPORTED_RELOC_TYPE DT_RELA -# define UNSUPPORTED_RELOC_STR "RELA" -#endif - - - -/* Convert between the Linux flags for page protections and the - ones specified in the ELF standard. */ -#define LXFLAGS(X) ( (((X) & PF_R) ? PROT_READ : 0) | \ - (((X) & PF_W) ? PROT_WRITE : 0) | \ - (((X) & PF_X) ? PROT_EXEC : 0)) - - -#endif /* LINUXELF_H */ diff --git a/ldso/include/ld_hash.h b/ldso/include/ld_hash.h deleted file mode 100644 index 246ed2608..000000000 --- a/ldso/include/ld_hash.h +++ /dev/null @@ -1,103 +0,0 @@ -#ifndef _LD_HASH_H_ -#define _LD_HASH_H_ - -#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 dyn_elf * prev; -}; - -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. */ - ElfW(Addr) loadaddr; /* Base address shared object is loaded at. */ - char *libname; /* Absolute file name object was found in. */ - ElfW(Dyn) *dynamic_addr; /* Dynamic section of the shared object. */ - 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; - -#if defined(__mips__) - /* Needed for MIPS relocation */ - unsigned long mips_gotsym; - unsigned long mips_local_gotno; - unsigned long mips_symtabno; -#endif - -#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 -}; - -#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(const char * libname); -extern struct elf_resolve * _dl_add_elf_hash_table(const char * libname, - char * loadaddr, unsigned long * dynamic_info, - unsigned long dynamic_addr, unsigned long dynamic_size); - -enum caller_type{symbolrel=0,copyrel=1,resolver=2}; -extern char * _dl_find_hash(const char * name, struct dyn_elf * rpnt1, - struct elf_resolve * f_tpnt, enum caller_type); - -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 LD_ERROR_NOFILE 1 -#define LD_ERROR_NOZERO 2 -#define LD_ERROR_NOTELF 3 -#define LD_ERROR_NOTMAGIC 4 -#define LD_ERROR_NOTDYN 5 -#define LD_ERROR_MMAP_FAILED 6 -#define LD_ERROR_NODYNAMIC 7 -#define LD_WRONG_RELOCS 8 -#define LD_BAD_HANDLE 9 -#define LD_NO_SYMBOL 10 - - - -#endif /* _LD_HASH_H_ */ - - diff --git a/ldso/include/ld_string.h b/ldso/include/ld_string.h deleted file mode 100644 index 6fd266fc2..000000000 --- a/ldso/include/ld_string.h +++ /dev/null @@ -1,281 +0,0 @@ -#ifndef _LINUX_STRING_H_ -#define _LINUX_STRING_H_ - -extern void *_dl_malloc(int size); -extern char *_dl_getenv(const char *symbol, char **envp); -extern void _dl_unsetenv(const char *symbol, char **envp); -extern char *_dl_strdup(const char *string); -extern void _dl_dprintf(int, const char *, ...); - - -static size_t _dl_strlen(const char * str); -static char *_dl_strcat(char *dst, const char *src); -static char * _dl_strcpy(char * dst,const char *src); -static int _dl_strcmp(const char * s1,const char * s2); -static int _dl_strncmp(const char * s1,const char * s2,size_t len); -static char * _dl_strchr(const char * str,int c); -static char *_dl_strrchr(const char *str, int c); -static char *_dl_strstr(const char *s1, const char *s2); -static void * _dl_memcpy(void * dst, const void * src, size_t len); -static int _dl_memcmp(const void * s1,const void * s2,size_t len); -static void *_dl_memset(void * str,int c,size_t len); -static char *_dl_get_last_path_component(char *path); -static char *_dl_simple_ltoa(char * local, unsigned long i); -static char *_dl_simple_ltoahex(char * local, unsigned long i); - -#ifndef NULL -#define NULL ((void *) 0) -#endif - -static inline size_t _dl_strlen(const char * str) -{ - register char *ptr = (char *) str; - - while (*ptr) - ptr++; - return (ptr - str); -} - -static inline char *_dl_strcat(char *dst, const char *src) -{ - register char *ptr = dst; - - while (*ptr) - ptr++; - - while (*src) - *ptr++ = *src++; - *ptr = '\0'; - - return dst; -} - -static inline char * _dl_strcpy(char * dst,const char *src) -{ - register char *ptr = dst; - - while (*src) - *dst++ = *src++; - *dst = '\0'; - - return ptr; -} - -static inline int _dl_strcmp(const char * s1,const char * s2) -{ - register unsigned char c1, c2; - - do { - c1 = (unsigned char) *s1++; - c2 = (unsigned char) *s2++; - if (c1 == '\0') - return c1 - c2; - } - while (c1 == c2); - - return c1 - c2; -} - -static inline int _dl_strncmp(const char * s1,const char * s2,size_t len) -{ - register unsigned char c1 = '\0'; - register unsigned char c2 = '\0'; - - while (len > 0) { - c1 = (unsigned char) *s1++; - c2 = (unsigned char) *s2++; - if (c1 == '\0' || c1 != c2) - return c1 - c2; - len--; - } - - return c1 - c2; -} - -static inline char * _dl_strchr(const char * str,int c) -{ - register char ch; - - do { - if ((ch = *str) == c) - return (char *) str; - str++; - } - while (ch); - - return 0; -} - -static inline char *_dl_strrchr(const char *str, int c) -{ - register char *prev = 0; - register char *ptr = (char *) str; - - while (*ptr != '\0') { - if (*ptr == c) - prev = ptr; - ptr++; - } - if (c == '\0') - return(ptr); - return(prev); -} - - -static inline char *_dl_strstr(const char *s1, const char *s2) -{ - register const char *s = s1; - register const char *p = s2; - - do { - if (!*p) { - return (char *) s1;; - } - if (*p == *s) { - ++p; - ++s; - } else { - p = s2; - if (!*s) { - return NULL; - } - s = ++s1; - } - } while (1); -} - -static inline void * _dl_memcpy(void * dst, const void * src, size_t len) -{ - register char *a = dst; - register const char *b = src; - - while (len--) - *a++ = *b++; - - return dst; -} - - -static inline int _dl_memcmp(const void * s1,const void * s2,size_t len) -{ - unsigned char *c1 = (unsigned char *)s1; - unsigned char *c2 = (unsigned char *)s2; - - while (len--) { - if (*c1 != *c2) - return *c1 - *c2; - c1++; - c2++; - } - return 0; -} - -static inline void * _dl_memset(void * str,int c,size_t len) -{ - register char *a = str; - - while (len--) - *a++ = c; - - return str; -} - -static inline char *_dl_get_last_path_component(char *path) -{ - char *s; - register char *ptr = path; - register char *prev = 0; - - while (*ptr) - ptr++; - s = ptr - 1; - - /* strip trailing slashes */ - while (s != path && *s == '/') { - *s-- = '\0'; - } - - /* find last component */ - ptr = path; - while (*ptr != '\0') { - if (*ptr == '/') - prev = ptr; - ptr++; - } - s = prev; - - if (s == NULL || s[1] == '\0') - return path; - else - return s+1; -} - -/* Early on, we can't call printf, so use this to print out - * numbers using the SEND_STDERR() macro */ -static inline char *_dl_simple_ltoa(char * local, unsigned long i) -{ - /* 21 digits plus null terminator, good for 64-bit or smaller ints */ - char *p = &local[22]; - *p-- = '\0'; - do { - *p-- = '0' + i % 10; - i /= 10; - } while (i > 0); - return p + 1; -} - -static inline char *_dl_simple_ltoahex(char * local, unsigned long i) -{ - /* 21 digits plus null terminator, good for 64-bit or smaller ints */ - char *p = &local[22]; - *p-- = '\0'; - do { - char temp = i % 0x10; - if (temp <= 0x09) - *p-- = '0' + temp; - else - *p-- = 'a' - 0x0a + temp; - i /= 0x10; - } while (i > 0); - *p-- = 'x'; - *p-- = '0'; - return p + 1; -} - - -#if defined(mc68000) || defined(__arm__) || defined(__mips__) || defined(__sh__) || defined(__powerpc__) -/* On some arches constant strings are referenced through the GOT. */ -/* XXX Requires load_addr to be defined. */ -#define SEND_STDERR(X) \ - { const char *__s = (X); \ - if (__s < (const char *) load_addr) __s += load_addr; \ - _dl_write (2, __s, _dl_strlen (__s)); \ - } -#else -#define SEND_STDERR(X) _dl_write(2, X, _dl_strlen(X)); -#endif - -#define SEND_ADDRESS_STDERR(X, add_a_newline) { \ - char tmp[22], *tmp1; \ - _dl_memset(tmp, 0, sizeof(tmp)); \ - tmp1=_dl_simple_ltoahex( tmp, (unsigned long)(X)); \ - _dl_write(2, tmp1, _dl_strlen(tmp1)); \ - if (add_a_newline) { \ - tmp[0]='\n'; \ - _dl_write(2, tmp, 1); \ - } \ -}; - -#define SEND_NUMBER_STDERR(X, add_a_newline) { \ - char tmp[22], *tmp1; \ - _dl_memset(tmp, 0, sizeof(tmp)); \ - tmp1=_dl_simple_ltoa( tmp, (unsigned long)(X)); \ - _dl_write(2, tmp1, _dl_strlen(tmp1)); \ - if (add_a_newline) { \ - tmp[0]='\n'; \ - _dl_write(2, tmp, 1); \ - } \ -}; - - -#endif diff --git a/ldso/include/ld_syscall.h b/ldso/include/ld_syscall.h deleted file mode 100644 index 344a93039..000000000 --- a/ldso/include/ld_syscall.h +++ /dev/null @@ -1,132 +0,0 @@ -#ifndef _LD_SYSCALL_H_ -#define _LD_SYSCALL_H_ - -/* Pull in the arch specific syscall implementation */ -#include -/* For MAP_ANONYMOUS -- differs between platforms */ -#include -/* Pull in whatever this particular arch's kernel thinks the kernel version of - * struct stat should look like. It turns out that each arch has a different - * opinion on the subject, and different kernel revs use different names... */ -#define kernel_stat stat -#include -#include - - -/* _dl_open() parameters */ -#define O_RDONLY 0x0000 -#define O_WRONLY 01 -#define O_RDWR 02 -#define O_CREAT 0100 - -/* Encoding of the file mode. */ -#define S_IFMT 0170000 /* These bits determine file type. */ - -/* File types. */ -#define S_IFDIR 0040000 /* Directory. */ -#define S_IFCHR 0020000 /* Character device. */ -#define S_IFBLK 0060000 /* Block device. */ -#define S_IFREG 0100000 /* Regular file. */ -#define S_IFIFO 0010000 /* FIFO. */ -#define S_IFLNK 0120000 /* Symbolic link. */ -#define S_IFSOCK 0140000 /* Socket. */ - -/* Protection bits. */ -#define S_ISUID 04000 /* Set user ID on execution. */ -#define S_ISGID 02000 /* Set group ID on execution. */ -#define S_ISVTX 01000 /* Save swapped text after use (sticky). */ -#define S_IREAD 0400 /* Read by owner. */ -#define S_IWRITE 0200 /* Write by owner. */ -#define S_IEXEC 0100 /* Execute by owner. */ - -/* Stuff for _dl_mmap */ -#if 0 -#define MAP_FAILED ((void *) -1) -#define _dl_mmap_check_error(X) (((void *)X) == MAP_FAILED) -#else -#ifndef _dl_MAX_ERRNO -#define _dl_MAX_ERRNO 4096 -#endif -#define _dl_mmap_check_error(__res) \ - (((int)__res) < 0 && ((int)__res) >= -_dl_MAX_ERRNO) -#endif - - - -/* Here are the definitions for some syscalls that are used - by the dynamic linker. The idea is that we want to be able - to call these before the errno symbol is dynamicly linked, so - we use our own version here. Note that we cannot assume any - dynamic linking at all, so we cannot return any error codes. - We just punt if there is an error. */ -#define __NR__dl_exit __NR_exit -static inline _syscall1(void, _dl_exit, int, status); - -#define __NR__dl_close __NR_close -static inline _syscall1(int, _dl_close, int, fd); - -#define __NR__dl_open __NR_open -static inline _syscall3(int, _dl_open, const char *, fn, int, flags, __kernel_mode_t, mode); - -#define __NR__dl_write __NR_write -static inline _syscall3(unsigned long, _dl_write, int, fd, - const void *, buf, unsigned long, count); - -#define __NR__dl_read __NR_read -static inline _syscall3(unsigned long, _dl_read, int, fd, - const void *, buf, unsigned long, count); - -#define __NR__dl_mprotect __NR_mprotect -static inline _syscall3(int, _dl_mprotect, const void *, addr, unsigned long, len, int, prot); - -#define __NR__dl_stat __NR_stat -static inline _syscall2(int, _dl_stat, const char *, file_name, struct stat *, buf); - -#define __NR__dl_munmap __NR_munmap -static inline _syscall2(int, _dl_munmap, void *, start, unsigned long, length); - -#define __NR__dl_getuid __NR_getuid -static inline _syscall0(uid_t, _dl_getuid); - -#define __NR__dl_geteuid __NR_geteuid -static inline _syscall0(uid_t, _dl_geteuid); - -#define __NR__dl_getgid __NR_getgid -static inline _syscall0(gid_t, _dl_getgid); - -#define __NR__dl_getegid __NR_getegid -static inline _syscall0(gid_t, _dl_getegid); - -#define __NR__dl_getpid __NR_getpid -static inline _syscall0(gid_t, _dl_getpid); - -#define __NR__dl_readlink __NR_readlink -static inline _syscall3(int, _dl_readlink, const char *, path, char *, buf, size_t, bufsiz); - -#if defined(__powerpc__) || defined(__mips__) || defined(__sh__) -/* PowerPC, MIPS and SuperH have a different calling convention for mmap(). */ -#define __NR__dl_mmap __NR_mmap -static inline _syscall6(void *, _dl_mmap, void *, start, size_t, length, - int, prot, int, flags, int, fd, off_t, offset); -#else -#define __NR__dl_mmap_real __NR_mmap -static inline _syscall1(void *, _dl_mmap_real, unsigned long *, buffer); - -static inline void * _dl_mmap(void * addr, unsigned long size, int prot, - int flags, int fd, unsigned long offset) -{ - unsigned long buffer[6]; - - buffer[0] = (unsigned long) addr; - buffer[1] = (unsigned long) size; - buffer[2] = (unsigned long) prot; - buffer[3] = (unsigned long) flags; - buffer[4] = (unsigned long) fd; - buffer[5] = (unsigned long) offset; - return (void *) _dl_mmap_real(buffer); -} -#endif - - -#endif /* _LD_SYSCALL_H_ */ - diff --git a/ldso/include/ldso.h b/ldso/include/ldso.h index 15f76ee80..a23e89355 100644 --- a/ldso/include/ldso.h +++ b/ldso/include/ldso.h @@ -8,10 +8,10 @@ /* Pull in the arch specific type information */ #include /* Now the ldso specific headers */ -#include -#include -#include -#include +#include +#include +#include +#include /* Pull in the arch specific page size */ #include #ifndef PAGE_SIZE diff --git a/ldso/ldso/.cvsignore b/ldso/ldso/.cvsignore index cc73e174c..5fe696107 100644 --- a/ldso/ldso/.cvsignore +++ b/ldso/ldso/.cvsignore @@ -1,2 +1,2 @@ ld-uclibc.so* -_dl_progname.h +dl-progname.h diff --git a/ldso/ldso/Makefile b/ldso/ldso/Makefile index 8b62961fb..bd924b142 100644 --- a/ldso/ldso/Makefile +++ b/ldso/ldso/Makefile @@ -41,7 +41,7 @@ XXFLAGS+=$(shell $(CC) -print-search-dirs | sed -ne "s/install: *\(.*\)/-I\1incl LDFLAGS=$(CPU_LDFLAGS-y) -shared --warn-common --export-dynamic --sort-common \ -z combreloc --discard-locals --discard-all --no-undefined -CSRC= ldso.c startup.c #hash.c readelflib1.c $(TARGET_ARCH)/elfinterp.c +CSRC= ldso.c dl-startup.c COBJS=$(patsubst %.c,%.o, $(CSRC)) ASRC=$(shell ls $(TARGET_ARCH)/*.S) AOBJS=$(patsubst %.S,%.o, $(ASRC)) @@ -68,16 +68,16 @@ XXFLAGS := $(XXFLAGS:-fomit-frame-pointer=) all: lib -lib:: _dl_progname.h $(OBJS) $(DLINK_OBJS) +lib:: dl-progname.h $(OBJS) $(DLINK_OBJS) $(LD) $(LDFLAGS) -e _dl_boot -soname=$(UCLIBC_LDSO) \ -o $(LDSO_FULLNAME) $(OBJS) $(LIBGCC); $(INSTALL) -d $(TOPDIR)lib $(INSTALL) -m 755 $(LDSO_FULLNAME) $(TOPDIR)lib $(LN) -sf $(LDSO_FULLNAME) $(TOPDIR)lib/$(UCLIBC_LDSO) -_dl_progname.h: Makefile - echo "const char *_dl_progname=\""$(UCLIBC_LDSO)"\";" > _dl_progname.h - echo "#include \"$(TARGET_ARCH)/elfinterp.c\"" >> _dl_progname.h +dl-progname.h: Makefile + echo "const char *_dl_progname=\""$(UCLIBC_LDSO)"\";" > dl-progname.h + echo "#include \"$(TARGET_ARCH)/elfinterp.c\"" >> dl-progname.h $(COBJS): %.o : %.c @@ -91,4 +91,4 @@ $(AOBJS): %.o : %.S ldso.o: $(CSRC) clean: - $(RM) $(UCLIBC_LDSO)* $(OBJS) $(LDSO_FULLNAME)* core *.o *.a *.s *.i _dl_progname.h ldso.h *~ + $(RM) $(UCLIBC_LDSO)* $(OBJS) $(LDSO_FULLNAME)* core *.o *.a *.s *.i dl-progname.h ldso.h *~ diff --git a/ldso/ldso/arm/boot1_arch.h b/ldso/ldso/arm/boot1_arch.h deleted file mode 100644 index 383fe4e1f..000000000 --- a/ldso/ldso/arm/boot1_arch.h +++ /dev/null @@ -1,25 +0,0 @@ -/* Any assmbly language/system dependent hacks needed to setup boot1.c so it - * will work as expected and cope with whatever platform specific wierdness is - * needed for this architecture. */ - -/* Overrive the default _dl_boot function, and replace it with a bit of asm. - * Then call the real _dl_boot function, which is now named _dl_boot2. */ - -asm("" \ -" .text\n" \ -" .globl _dl_boot\n" \ -"_dl_boot:\n" \ -" mov r7, sp\n" \ -" @ldr r0, [sp], #4\n" \ -" mov r0, sp\n" \ -" bl _dl_boot2\n" \ -" mov r6, r0\n" \ -" mov r0, r7\n" \ -" mov pc, r6\n" \ -); - - /* It seems ARM needs an offset here */ -#undef ELFMAGIC -#define ELFMAGIC ELFMAG+load_addr - -#define DL_BOOT(X) static void __attribute__ ((unused)) _dl_boot2 (X) diff --git a/ldso/ldso/arm/ld_syscalls.h b/ldso/ldso/arm/ld_syscalls.h deleted file mode 100644 index dbf1634e0..000000000 --- a/ldso/ldso/arm/ld_syscalls.h +++ /dev/null @@ -1,19 +0,0 @@ -/* Define the __set_errno macro as nothing so that INLINE_SYSCALL - * won't set errno, which is important since we make system calls - * before the errno symbol is dynamicly linked. */ - -#define __set_errno(X) {(void)(X);} - -/* Prepare for the case that `__builtin_expect' is not available. */ -#if __GNUC__ == 2 && __GNUC_MINOR__ < 96 -#define __builtin_expect(x, expected_value) (x) -#endif -#ifndef likely -# define likely(x) __builtin_expect((!!(x)),1) -#endif -#ifndef unlikely -# define unlikely(x) __builtin_expect((!!(x)),0) -#endif - -#include "sys/syscall.h" - diff --git a/ldso/ldso/arm/ld_sysdep.h b/ldso/ldso/arm/ld_sysdep.h deleted file mode 100644 index 04e504eda..000000000 --- a/ldso/ldso/arm/ld_sysdep.h +++ /dev/null @@ -1,124 +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,SYMTAB) \ - switch(ELF32_R_TYPE((RELP)->r_info)){ \ - case R_ARM_ABS32: \ - *REL += SYMBOL; \ - break; \ - case R_ARM_PC24: \ - { long newvalue, topbits; \ - unsigned long addend = *REL & 0x00ffffff; \ - if (addend & 0x00800000) addend |= 0xff000000; \ - newvalue=SYMBOL-(unsigned long)REL+(addend<<2); \ - topbits = newvalue & 0xfe000000; \ - if (topbits!=0xfe000000&&topbits!=0x00000000){ \ - newvalue = fix_bad_pc24(REL, SYMBOL) \ - -(unsigned long)REL+(addend<<2); \ - topbits = newvalue & 0xfe000000; \ - if (topbits!=0xfe000000&&topbits!=0x00000000){ \ - SEND_STDERR("R_ARM_PC24 relocation out of range\n");\ - _dl_exit(1); } } \ - newvalue>>=2; \ - SYMBOL=(*REL&0xff000000)|(newvalue & 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: \ - SEND_STDERR("Aiieeee!"); \ - _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; -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<=i) { - m-=i; - i<<=1; - if(i&(1<<31)) - break; - if(i=p) { - m-=p; - } - return m; -} - -#define do_rem(result, n, base) result=arm_modulus(n,base); - -/* 4096 bytes alignment */ -#define PAGE_ALIGN 0xfffff000 -#define ADDR_ALIGN 0xfff -#define OFFS_ALIGN 0x7ffff000 diff --git a/ldso/ldso/cris/boot1_arch.h b/ldso/ldso/cris/boot1_arch.h deleted file mode 100644 index bf7714539..000000000 --- a/ldso/ldso/cris/boot1_arch.h +++ /dev/null @@ -1,16 +0,0 @@ -/* - * This code fix the stack pointer so that the dynamic linker - * can find argc, argv and auxvt (Auxillary Vector Table). - */ -asm("" \ -" .text\n" \ -" .globl _dl_boot\n" \ -" .type _dl_boot,@function\n" \ -"_dl_boot:\n" \ -" move.d $sp,$r10\n" \ -" move.d $pc,$r9\n" \ -" add.d _dl_boot2 - ., $r9\n" \ -" jsr $r9\n" \ -); - -#define DL_BOOT(X) static void __attribute__ ((unused)) _dl_boot2 (X) diff --git a/ldso/ldso/cris/dl-sysdep.h b/ldso/ldso/cris/dl-sysdep.h index c127076ff..7066863f6 100644 --- a/ldso/ldso/cris/dl-sysdep.h +++ b/ldso/ldso/cris/dl-sysdep.h @@ -66,7 +66,7 @@ struct elf_resolve; extern unsigned long _dl_linux_resolver(struct elf_resolve *tpnt, int reloc_entry); -/* Cheap modulo implementation, taken from arm/ld_sysdep.h. */ +/* Cheap modulo implementation, taken from arm/dl-sysdep.h. */ static inline unsigned long cris_mod(unsigned long m, unsigned long p) { diff --git a/ldso/ldso/cris/ld_syscalls.h b/ldso/ldso/cris/ld_syscalls.h deleted file mode 100644 index 651280c18..000000000 --- a/ldso/ldso/cris/ld_syscalls.h +++ /dev/null @@ -1,7 +0,0 @@ -/* - * Define the __set_errno macro as nothing so that INLINE_SYSCALL - * won't set errno, which is important since we make system calls - * before the errno symbol is dynamicly linked. - */ -#define __set_errno(X) {(void)(X);} -#include "sys/syscall.h" diff --git a/ldso/ldso/cris/ld_sysdep.h b/ldso/ldso/cris/ld_sysdep.h deleted file mode 100644 index c127076ff..000000000 --- a/ldso/ldso/cris/ld_sysdep.h +++ /dev/null @@ -1,112 +0,0 @@ -/* CRIS can never use Elf32_Rel relocations. */ -#define 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[1] = (unsigned long) MODULE; \ - GOT_BASE[2] = (unsigned long) _dl_linux_resolve; \ -} - -/* - * 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, SYMTAB) \ - switch (ELF32_R_TYPE((RELP)->r_info)) { \ - case R_CRIS_GLOB_DAT: \ - case R_CRIS_JUMP_SLOT: \ - case R_CRIS_32: \ - *REL = SYMBOL; \ - break; \ - case R_CRIS_16_PCREL: \ - *(short *) *REL = SYMBOL + (RELP)->r_addend - *REL - 2; \ - break; \ - case R_CRIS_32_PCREL: \ - *REL = SYMBOL + (RELP)->r_addend - *REL - 4; \ - break; \ - case R_CRIS_NONE: \ - break; \ - case R_CRIS_RELATIVE: \ - *REL = (unsigned long) LOAD + (RELP)->r_addend; \ - break; \ - default: \ - _dl_exit(1); \ - break; \ - } - -/* - * Transfer control to the user's application once the dynamic loader - * is done. This routine has to exit the current function, then call - * _dl_elf_main. - */ -#define START() __asm__ volatile ("moveq 0,$r8\n\t" \ - "move $r8,$srp\n\t" \ - "move.d %1,$sp\n\t" \ - "jump %0\n\t" \ - : : "r" (_dl_elf_main), "r" (args)) - -/* Defined some magic numbers that this ld.so should accept. */ -#define MAGIC1 EM_CRIS -#undef MAGIC2 -#define ELF_TARGET "CRIS" - -struct elf_resolve; -extern unsigned long _dl_linux_resolver(struct elf_resolve *tpnt, int reloc_entry); - -/* Cheap modulo implementation, taken from arm/ld_sysdep.h. */ -static inline unsigned long -cris_mod(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 = cris_mod(n, base); - -/* 8192 bytes alignment */ -#define PAGE_ALIGN 0xffffe000 -#define ADDR_ALIGN 0x1fff -#define OFFS_ALIGN 0xffffe000 diff --git a/ldso/ldso/dl-startup.c b/ldso/ldso/dl-startup.c index 6a131633a..f40207996 100644 --- a/ldso/ldso/dl-startup.c +++ b/ldso/ldso/dl-startup.c @@ -90,7 +90,7 @@ #include "ldso.h" -/* Some arches may need to override this in boot1_arch.h */ +/* Some arches may need to override this in dl-startup.h */ #define ELFMAGIC ELFMAG /* This is a poor man's malloc, used prior to resolving our internal poor man's malloc */ @@ -102,7 +102,7 @@ #define REALIGN() malloc_buffer = (char *) (((unsigned long) malloc_buffer + 3) & ~(3)) /* Pull in all the arch specific stuff */ -#include "boot1_arch.h" +#include "dl-startup.h" /* Static declarations */ int (*_dl_elf_main) (int, char **, char **); diff --git a/ldso/ldso/hash.c b/ldso/ldso/hash.c deleted file mode 100644 index c33b329ec..000000000 --- a/ldso/ldso/hash.c +++ /dev/null @@ -1,262 +0,0 @@ -/* vi: set sw=4 ts=4: */ -/* - * Program to load an ELF binary on a linux system, and run it - * after resolving ELF shared library symbols - * - * Copyright (C) 2004 by Joakim Tjernlund - * Copyright (C) 2000-2004 by Erik Andersen - * Copyright (c) 1994-2000 Eric Youngdale, Peter MacDonald, - * David Engel, Hongjiu Lu and Mitch D'Souza - * - * 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. The name of the above contributors may not be - * used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS ``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 CONTRIBUTORS 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. - */ - - -/* Various symbol table handling functions, including symbol lookup */ - -/* - * This is the start of the linked list that describes all of the files present - * in the system with pointers to all of the symbol, string, and hash tables, - * as well as all of the other good stuff in the binary. - */ -struct elf_resolve *_dl_loaded_modules = NULL; - -/* - * This is the list of modules that are loaded when the image is first - * started. As we add more via dlopen, they get added into other - * chains. - */ -struct dyn_elf *_dl_symbol_tables = NULL; - -/* - * This is the list of modules that are loaded via dlopen. We may need - * to search these for RTLD_GLOBAL files. - */ -struct dyn_elf *_dl_handles = NULL; - - -/* This is the hash function that is used by the ELF linker to generate the - * hash table that each executable and library is required to have. We need - * it to decode the hash table. */ -unsigned long _dl_elf_hash(const char *name) -{ - unsigned long hash = 0; - unsigned long tmp; - - while (*name) { - hash = (hash << 4) + *name++; - if ((tmp = hash & 0xf0000000)) - hash ^= tmp >> 24; - hash &= ~tmp; - }; - return hash; -} - -/* Check to see if a library has already been added to the hash chain. */ -struct elf_resolve *_dl_check_hashed_files(const char *libname) -{ - struct elf_resolve *tpnt; - int len = _dl_strlen(libname); - - for (tpnt = _dl_loaded_modules; tpnt; tpnt = tpnt->next) { - if (_dl_strncmp(tpnt->libname, libname, len) == 0 && - (tpnt->libname[len] == '\0' || tpnt->libname[len] == '.')) - return tpnt; - } - - return NULL; -} - -/* - * We call this function when we have just read an ELF library or executable. - * We add the relevant info to the symbol chain, so that we can resolve all - * externals properly. - */ -struct elf_resolve *_dl_add_elf_hash_table(const char *libname, - char *loadaddr, unsigned long *dynamic_info, unsigned long dynamic_addr, - unsigned long dynamic_size) -{ - unsigned long *hash_addr; - struct elf_resolve *tpnt; - int i; - - if (!_dl_loaded_modules) { - tpnt = _dl_loaded_modules = (struct elf_resolve *) _dl_malloc(sizeof(struct elf_resolve)); - _dl_memset(tpnt, 0, sizeof(struct elf_resolve)); - } else { - tpnt = _dl_loaded_modules; - while (tpnt->next) - tpnt = tpnt->next; - tpnt->next = (struct elf_resolve *) _dl_malloc(sizeof(struct elf_resolve)); - _dl_memset(tpnt->next, 0, sizeof(struct elf_resolve)); - tpnt->next->prev = tpnt; - tpnt = tpnt->next; - }; - - tpnt->next = NULL; - tpnt->init_flag = 0; - tpnt->libname = _dl_strdup(libname); - tpnt->dynamic_addr = (ElfW(Dyn) *)dynamic_addr; - tpnt->dynamic_size = dynamic_size; - tpnt->libtype = loaded_file; - - if (dynamic_info[DT_HASH] != 0) { - hash_addr = (unsigned long *) (intptr_t)(dynamic_info[DT_HASH] + loadaddr); - tpnt->nbucket = *hash_addr++; - tpnt->nchain = *hash_addr++; - tpnt->elf_buckets = hash_addr; - hash_addr += tpnt->nbucket; - tpnt->chains = hash_addr; - } - tpnt->loadaddr = (ElfW(Addr))loadaddr; - for (i = 0; i < 24; i++) - tpnt->dynamic_info[i] = dynamic_info[i]; -#ifdef __mips__ - { - Elf32_Dyn *dpnt = (Elf32_Dyn *) dynamic_addr; - - while(dpnt->d_tag) { - if (dpnt->d_tag == DT_MIPS_GOTSYM) - tpnt->mips_gotsym = dpnt->d_un.d_val; - if (dpnt->d_tag == DT_MIPS_LOCAL_GOTNO) - tpnt->mips_local_gotno = dpnt->d_un.d_val; - if (dpnt->d_tag == DT_MIPS_SYMTABNO) - tpnt->mips_symtabno = dpnt->d_un.d_val; - dpnt++; - } - } -#endif - return tpnt; -} - - -/* - * This function resolves externals, and this is either called when we process - * relocations or when we call an entry in the PLT table for the first time. - */ -char *_dl_find_hash(const char *name, struct dyn_elf *rpnt1, - struct elf_resolve *f_tpnt, enum caller_type caller_type) -{ - struct elf_resolve *tpnt; - int si; - int pass; - char *strtab; - Elf32_Sym *symtab; - unsigned long elf_hash_number, hn; - char *weak_result; - struct dyn_elf *rpnt, first; - const ElfW(Sym) *sym; - - weak_result = 0; - elf_hash_number = _dl_elf_hash(name); - - /* A quick little hack to make sure that any symbol in the executable - will be preferred to one in a shared library. This is necessary so - that any shared library data symbols referenced in the executable - will be seen at the same address by the executable, shared libraries - and dynamically loaded code. -Rob Ryan (robr@cmu.edu) */ - if (_dl_symbol_tables && rpnt1) { - first = (*_dl_symbol_tables); - first.next = rpnt1; - rpnt1 = (&first); - } - - /* - * The passes are so that we can first search the regular symbols - * for whatever module was specified, and then search anything - * loaded with RTLD_GLOBAL. When pass is 1, it means we are just - * starting the first dlopened module, and anything above that - * is just the next one in the chain. - */ - for (pass = 0; (1 == 1); pass++) { - - /* - * If we are just starting to search for RTLD_GLOBAL, setup - * the pointer for the start of the search. - */ - if (pass == 1) { - rpnt1 = _dl_handles; - } - - /* - * Anything after this, we need to skip to the next module. - */ - else if (pass >= 2) { - rpnt1 = rpnt1->next_handle; - } - - /* - * Make sure we still have a module, and make sure that this - * module was loaded with RTLD_GLOBAL. - */ - if (pass != 0) { - if (rpnt1 == NULL) - break; - //if ((rpnt1->flags & RTLD_GLOBAL) == 0) - //continue; - } - - for (rpnt = (rpnt1 ? rpnt1 : _dl_symbol_tables); rpnt; rpnt = rpnt->next) { - tpnt = rpnt->dyn; - - /* Don't search the executable when resolving a copy reloc. */ - if (tpnt->libtype == elf_executable && caller_type == copyrel) - continue; - - /* - * Avoid calling .urem here. - */ - do_rem(hn, elf_hash_number, tpnt->nbucket); - symtab = (Elf32_Sym *) (intptr_t) (tpnt->dynamic_info[DT_SYMTAB] + tpnt->loadaddr); - strtab = (char *) (tpnt->dynamic_info[DT_STRTAB] + tpnt->loadaddr); - - for (si = tpnt->elf_buckets[hn]; si != STN_UNDEF; si = tpnt->chains[si]) { - sym = &symtab[si]; - - if (sym->st_value == 0) - continue; - if (ELF32_ST_TYPE(sym->st_info) > STT_FUNC) - continue; - if (sym->st_shndx == SHN_UNDEF && caller_type != copyrel) - continue; - if (_dl_strcmp(strtab + sym->st_name, name) != 0) - continue; - - switch (ELF32_ST_BIND(sym->st_info)) { - case STB_WEAK: -//Disable this to match current glibc behavior. Of course, -//this doesn't actually work yet and will cause segfaults... -#if 1 - if (!weak_result) - weak_result = (char *)tpnt->loadaddr + sym->st_value; - break; -#endif - case STB_GLOBAL: - return (char*)tpnt->loadaddr + sym->st_value; - default: /* Local symbols not handled here */ - break; - } - } - } - } - return weak_result; -} diff --git a/ldso/ldso/i386/boot1_arch.h b/ldso/ldso/i386/boot1_arch.h deleted file mode 100644 index 42c96a6f5..000000000 --- a/ldso/ldso/i386/boot1_arch.h +++ /dev/null @@ -1,7 +0,0 @@ -/* Any assmbly language/system dependent hacks needed to setup boot1.c so it - * will work as expected and cope with whatever platform specific wierdness is - * needed for this architecture. See arm/boot1_arch.h for an example of what - * can be done. - */ - -#define DL_BOOT(X) void __attribute__ ((unused)) _dl_boot (X) diff --git a/ldso/ldso/i386/ld_syscalls.h b/ldso/ldso/i386/ld_syscalls.h deleted file mode 100644 index c020832bb..000000000 --- a/ldso/ldso/i386/ld_syscalls.h +++ /dev/null @@ -1,7 +0,0 @@ -/* Define the __set_errno macro as nothing so that INLINE_SYSCALL - * won't set errno, which is important since we make system calls - * before the errno symbol is dynamicly linked. */ - -#define __set_errno(X) {(void)(X);} -#include "sys/syscall.h" - diff --git a/ldso/ldso/i386/ld_sysdep.h b/ldso/ldso/i386/ld_sysdep.h deleted file mode 100644 index f39a1966c..000000000 --- a/ldso/ldso/i386/ld_sysdep.h +++ /dev/null @@ -1,81 +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) \ -do { \ - GOT_BASE[2] = (unsigned long) _dl_linux_resolve; \ - GOT_BASE[1] = (unsigned long) MODULE; \ -} while(0) - -/* - * 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,SYMTAB) \ - 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) - -/* 4096 bytes alignment */ -#define PAGE_ALIGN 0xfffff000 -#define ADDR_ALIGN 0xfff -#define OFFS_ALIGN 0x7ffff000 diff --git a/ldso/ldso/ldso.c b/ldso/ldso/ldso.c index 064323bf7..0b0cb1389 100644 --- a/ldso/ldso/ldso.c +++ b/ldso/ldso/ldso.c @@ -35,7 +35,7 @@ #define ALLOW_ZERO_PLTGOT /* Pull in the value of _dl_progname */ -#include "_dl_progname.h" +#include "dl-progname.h" /* Global variables used within the shared library loader */ char *_dl_library_path = 0; /* Where we look for libraries */ @@ -767,5 +767,5 @@ static int _dl_suid_ok(void) return 0; } -#include "hash.c" -#include "readelflib1.c" +#include "dl-hash.c" +#include "dl-elf.c" diff --git a/ldso/ldso/m68k/boot1_arch.h b/ldso/ldso/m68k/boot1_arch.h deleted file mode 100644 index 42c96a6f5..000000000 --- a/ldso/ldso/m68k/boot1_arch.h +++ /dev/null @@ -1,7 +0,0 @@ -/* Any assmbly language/system dependent hacks needed to setup boot1.c so it - * will work as expected and cope with whatever platform specific wierdness is - * needed for this architecture. See arm/boot1_arch.h for an example of what - * can be done. - */ - -#define DL_BOOT(X) void __attribute__ ((unused)) _dl_boot (X) diff --git a/ldso/ldso/m68k/ld_syscalls.h b/ldso/ldso/m68k/ld_syscalls.h deleted file mode 100644 index 1fb2cccd2..000000000 --- a/ldso/ldso/m68k/ld_syscalls.h +++ /dev/null @@ -1,174 +0,0 @@ -/* - * 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_readlink 85 -#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)) { \ - /* avoid using res which is declared to be in register d0; \ - errno might expand to a function call and clobber it. */ \ - /* int __err = -(res); \ - errno = __err; */ \ - res = -1; \ - } \ - return (type) (res); \ -} while (0) - -#define _syscall0(type, name) \ -type name(void) \ -{ \ - long __res; \ - __asm__ __volatile__ ("movel %1, %%d0\n\t" \ - "trap #0\n\t" \ - "movel %%d0, %0" \ - : "=g" (__res) \ - : "i" (__NR_##name) \ - : "cc", "%d0"); \ - if ((unsigned long)(__res) >= (unsigned long)(-125)) { \ - /* errno = -__res; */ \ - __res = -1; \ - } \ - return (type)__res; \ -} - -#define _syscall1(type, name, atype, a) \ -type name(atype a) \ -{ \ - long __res; \ - __asm__ __volatile__ ("movel %2, %%d1\n\t" \ - "movel %1, %%d0\n\t" \ - "trap #0\n\t" \ - "movel %%d0, %0" \ - : "=g" (__res) \ - : "i" (__NR_##name), \ - "g" ((long)a) \ - : "cc", "%d0", "%d1"); \ - if ((unsigned long)(__res) >= (unsigned long)(-125)) { \ - /* errno = -__res; */ \ - __res = -1; \ - } \ - return (type)__res; \ -} - -#define _syscall2(type, name, atype, a, btype, b) \ -type name(atype a, btype b) \ -{ \ - long __res; \ - __asm__ __volatile__ ("movel %3, %%d2\n\t" \ - "movel %2, %%d1\n\t" \ - "movel %1, %%d0\n\t" \ - "trap #0\n\t" \ - "movel %%d0, %0" \ - : "=g" (__res) \ - : "i" (__NR_##name), \ - "a" ((long)a), \ - "g" ((long)b) \ - : "cc", "%d0", "%d1", "%d2"); \ - if ((unsigned long)(__res) >= (unsigned long)(-125)) { \ - /* errno = -__res; */ \ - __res = -1; \ - } \ - return (type)__res; \ -} - -#define _syscall3(type, name, atype, a, btype, b, ctype, c) \ -type name(atype a, btype b, ctype c) \ -{ \ - long __res; \ - __asm__ __volatile__ ("movel %4, %%d3\n\t" \ - "movel %3, %%d2\n\t" \ - "movel %2, %%d1\n\t" \ - "movel %1, %%d0\n\t" \ - "trap #0\n\t" \ - "movel %%d0, %0" \ - : "=g" (__res) \ - : "i" (__NR_##name), \ - "a" ((long)a), \ - "a" ((long)b), \ - "g" ((long)c) \ - : "cc", "%d0", "%d1", "%d2", "%d3"); \ - if ((unsigned long)(__res) >= (unsigned long)(-125)) { \ - /* errno = -__res; */ \ - __res = -1; \ - } \ - return (type)__res; \ -} - -#define _syscall4(type, name, atype, a, btype, b, ctype, c, dtype, d) \ -type name(atype a, btype b, ctype c, dtype d) \ -{ \ - long __res; \ - __asm__ __volatile__ ("movel %5, %%d4\n\t" \ - "movel %4, %%d3\n\t" \ - "movel %3, %%d2\n\t" \ - "movel %2, %%d1\n\t" \ - "movel %1, %%d0\n\t" \ - "trap #0\n\t" \ - "movel %%d0, %0" \ - : "=g" (__res) \ - : "i" (__NR_##name), \ - "a" ((long)a), \ - "a" ((long)b), \ - "a" ((long)c), \ - "g" ((long)d) \ - : "cc", "%d0", "%d1", "%d2", "%d3", \ - "%d4"); \ - if ((unsigned long)(__res) >= (unsigned long)(-125)) { \ - /* errno = -__res; */ \ - __res = -1; \ - } \ - return (type)__res; \ -} - -#define _syscall5(type, name, atype, a, btype, b, ctype, c, dtype, d, etype, e)\ -type name(atype a, btype b, ctype c, dtype d, etype e) \ -{ \ - long __res; \ - __asm__ __volatile__ ("movel %6, %%d5\n\t" \ - "movel %5, %%d4\n\t" \ - "movel %4, %%d3\n\t" \ - "movel %3, %%d2\n\t" \ - "movel %2, %%d1\n\t" \ - "movel %1, %%d0\n\t" \ - "trap #0\n\t" \ - "movel %%d0, %0" \ - : "=g" (__res) \ - : "i" (__NR_##name), \ - "a" ((long)a), \ - "a" ((long)b), \ - "a" ((long)c), \ - "a" ((long)d), \ - "g" ((long)e) \ - : "cc", "%d0", "%d1", "%d2", "%d3", \ - "%d4", "%d5"); \ - if ((unsigned long)(__res) >= (unsigned long)(-125)) { \ - /* errno = -__res; */ \ - __res = -1; \ - } \ - return (type)__res; \ -} - diff --git a/ldso/ldso/m68k/ld_sysdep.h b/ldso/ldso/m68k/ld_sysdep.h deleted file mode 100644 index 2cbc7d46b..000000000 --- a/ldso/ldso/m68k/ld_sysdep.h +++ /dev/null @@ -1,88 +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. */ -#define 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 int *) &(ARGS))) - -/* Initialization sequence for a GOT. */ -#define INIT_GOT(GOT_BASE,MODULE) \ -{ \ - GOT_BASE[2] = (int) _dl_linux_resolve; \ - GOT_BASE[1] = (int) (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,SYMTAB) \ - switch (ELF32_R_TYPE ((RELP)->r_info)) \ - { \ - case R_68K_8: \ - *(char *) (REL) = (SYMBOL) + (RELP)->r_addend; \ - break; \ - case R_68K_16: \ - *(short *) (REL) = (SYMBOL) + (RELP)->r_addend; \ - break; \ - case R_68K_32: \ - *(REL) = (SYMBOL) + (RELP)->r_addend; \ - break; \ - case R_68K_PC8: \ - *(char *) (REL) = ((SYMBOL) + (RELP)->r_addend \ - - (unsigned int) (REL)); \ - break; \ - case R_68K_PC16: \ - *(short *) (REL) = ((SYMBOL) + (RELP)->r_addend \ - - (unsigned int) (REL)); \ - break; \ - case R_68K_PC32: \ - *(REL) = ((SYMBOL) + (RELP)->r_addend \ - - (unsigned int) (REL)); \ - break; \ - case R_68K_GLOB_DAT: \ - case R_68K_JMP_SLOT: \ - *(REL) = (SYMBOL); \ - break; \ - case R_68K_RELATIVE: /* Compatibility kludge */ \ - *(REL) = ((unsigned int) (LOAD) + ((RELP)->r_addend ? : *(REL))); \ - break; \ - default: \ - _dl_exit (1); \ - } - - -/* Transfer control to the user's application, once the dynamic loader - is done. */ - -#define START() \ - __asm__ volatile ("unlk %%a6\n\t" \ - "jmp %0@" \ - : : "a" (_dl_elf_main)); - - - -/* Here we define the magic numbers that this dynamic loader should accept */ - -#define MAGIC1 EM_68K -#undef MAGIC2 -/* Used for error messages */ -#define ELF_TARGET "m68k" - -struct elf_resolve; -extern unsigned int _dl_linux_resolver (int, int, struct elf_resolve *, int); - -/* Define this because we do not want to call .udiv in the library. - Not needed for m68k. */ -#define do_rem(result, n, base) ((result) = (n) % (base)) - -/* 4096 bytes alignment */ -#define PAGE_ALIGN 0xfffff000 -#define ADDR_ALIGN 0xfff -#define OFFS_ALIGN 0x7ffff000 diff --git a/ldso/ldso/mips/README b/ldso/ldso/mips/README index 1cf6301e5..9ca6a869b 100644 --- a/ldso/ldso/mips/README +++ b/ldso/ldso/mips/README @@ -18,7 +18,7 @@ contains the function to perform relocations for objects other than the linker itself. The code was taken from the function 'elf_machine_rel' in 'sysdeps/mips/dl-machine.h'. -ld_syscalls.h +dl-syscalls.h ------------- Used to contain all the macro functions for the system calls as well as the list of system calls supported. We now include @@ -27,7 +27,7 @@ so we can use the same file for the linker as well as userspace. Original code was taken from the Linux kernel source 2.4.17 and can be found in the file 'include/asm-mips/unistd.h'. -ld_sysdep.h +dl-sysdep.h ----------- Contains bootstrap code for the dynamic linker, magic numbers for detecting MIPS target types and some macros. The macro diff --git a/ldso/ldso/mips/boot1_arch.h b/ldso/ldso/mips/boot1_arch.h deleted file mode 100644 index 886f8b8b8..000000000 --- a/ldso/ldso/mips/boot1_arch.h +++ /dev/null @@ -1,37 +0,0 @@ -/* Any assmbly language/system dependent hacks needed to setup boot1.c so it - * will work as expected and cope with whatever platform specific wierdness is - * needed for this architecture. - */ - -asm("" \ -" .text\n" \ -" .globl _dl_boot\n" \ -"_dl_boot:\n" \ -" .set noreorder\n" \ -" bltzal $0, 0f\n" \ -" nop\n" \ -"0: .cpload $31\n" \ -" .set reorder\n" \ -" la $4, _DYNAMIC\n" \ -" sw $4, -0x7ff0($28)\n" \ -" move $4, $29\n" \ -" la $8, coff\n" \ -" .set noreorder\n" \ -" bltzal $0, coff\n" \ -" nop\n" \ -"coff: subu $8, $31, $8\n" \ -" .set reorder\n" \ -" la $25, _dl_boot2\n" \ -" addu $25, $8\n" \ -" jalr $25\n" \ -" lw $4, 0($29)\n" \ -" la $5, 4($29)\n" \ -" sll $6, $4, 2\n" \ -" addu $6, $6, $5\n" \ -" addu $6, $6, 4\n" \ -" la $7, _dl_elf_main\n" \ -" lw $25, 0($7)\n" \ -" jr $25\n" \ -); - -#define DL_BOOT(X) static void __attribute__ ((unused)) _dl_boot2 (X) diff --git a/ldso/ldso/mips/ld_syscalls.h b/ldso/ldso/mips/ld_syscalls.h deleted file mode 100644 index e4a1ff9c4..000000000 --- a/ldso/ldso/mips/ld_syscalls.h +++ /dev/null @@ -1,7 +0,0 @@ -/* Define the __set_errno macro as nothing so that we don't bother - * setting errno, which is important since we make system calls - * before the errno symbol is dynamicly linked. */ - -#define __set_errno(X) {(void)(X);} -#include "sys/syscall.h" - diff --git a/ldso/ldso/mips/ld_sysdep.h b/ldso/ldso/mips/ld_sysdep.h deleted file mode 100644 index 17ce7cf71..000000000 --- a/ldso/ldso/mips/ld_sysdep.h +++ /dev/null @@ -1,136 +0,0 @@ -/* vi: set sw=4 ts=4: */ - -/* - * 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 the application/library GOT. - */ -#define INIT_GOT(GOT_BASE,MODULE) \ -do { \ - unsigned long i; \ - \ - /* Check if this is the dynamic linker itself */ \ - if (MODULE->libtype == program_interpreter) \ - continue; \ - \ - /* Fill in first two GOT entries according to the ABI */ \ - GOT_BASE[0] = (unsigned long) _dl_linux_resolve; \ - GOT_BASE[1] = (unsigned long) MODULE; \ - \ - /* Add load address displacement to all local GOT entries */ \ - i = 2; \ - while (i < MODULE->mips_local_gotno) \ - GOT_BASE[i++] += (unsigned long) MODULE->loadaddr; \ - \ -} while (0) - - -/* - * Here is a macro to perform the GOT relocation. This is only - * used when bootstrapping the dynamic loader. - */ -#define PERFORM_BOOTSTRAP_GOT(got) \ -do { \ - Elf32_Sym *sym; \ - unsigned long i; \ - \ - /* Add load address displacement to all local GOT entries */ \ - i = 2; \ - while (i < tpnt->mips_local_gotno) \ - got[i++] += load_addr; \ - \ - /* Handle global GOT entries */ \ - got += tpnt->mips_local_gotno; \ - sym = (Elf32_Sym *) (tpnt->dynamic_info[DT_SYMTAB] + \ - load_addr) + tpnt->mips_gotsym; \ - i = tpnt->mips_symtabno - tpnt->mips_gotsym; \ - \ - while (i--) { \ - if (sym->st_shndx == SHN_UNDEF || \ - sym->st_shndx == SHN_COMMON) \ - *got = load_addr + sym->st_value; \ - else if (ELF32_ST_TYPE(sym->st_info) == STT_FUNC && \ - *got != sym->st_value) \ - *got += load_addr; \ - else if (ELF32_ST_TYPE(sym->st_info) == STT_SECTION) { \ - if (sym->st_other == 0) \ - *got += load_addr; \ - } \ - else \ - *got = load_addr + sym->st_value; \ - \ - got++; \ - sym++; \ - } \ -} while (0) - - -/* - * Here is a macro to perform a relocation. This is only used when - * bootstrapping the dynamic loader. - */ -#define PERFORM_BOOTSTRAP_RELOC(RELP,REL,SYMBOL,LOAD,SYMTAB) \ - switch(ELF32_R_TYPE((RELP)->r_info)) { \ - case R_MIPS_REL32: \ - if (symtab_index) { \ - if (symtab_index < tpnt->mips_gotsym) \ - *REL += SYMBOL; \ - } \ - else { \ - *REL += LOAD; \ - } \ - break; \ - case R_MIPS_NONE: \ - break; \ - default: \ - SEND_STDERR("Aiieeee!"); \ - _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. For MIPS, we do it in assembly - * because the stack doesn't get properly restored otherwise. Got look - * at boot1_arch.h - */ -#define START() - - -/* Here we define the magic numbers that this dynamic loader should accept */ -#define MAGIC1 EM_MIPS -#define MAGIC2 EM_MIPS_RS3_LE - - -/* Used for error messages */ -#define ELF_TARGET "MIPS" - - -unsigned long _dl_linux_resolver(unsigned long sym_index, - unsigned long old_gpreg); - - -#define do_rem(result, n, base) result = (n % base) - -/* 4096 bytes alignment */ -#define PAGE_ALIGN 0xfffff000 -#define ADDR_ALIGN 0xfff -#define OFFS_ALIGN 0x7ffff000 diff --git a/ldso/ldso/powerpc/boot1_arch.h b/ldso/ldso/powerpc/boot1_arch.h deleted file mode 100644 index 70e494331..000000000 --- a/ldso/ldso/powerpc/boot1_arch.h +++ /dev/null @@ -1,20 +0,0 @@ -/* Any assmbly language/system dependent hacks needed to setup boot1.c so it - * w