Changeset View
Changeset View
Standalone View
Standalone View
libexec/rtld-elf/rtld.c
Show First 20 Lines • Show All 377 Lines • ▼ Show 20 Lines | _rtld(Elf_Addr *sp, func_ptr_type *exit_proc, Obj_Entry **objp) | ||||
RtldLockState lockstate; | RtldLockState lockstate; | ||||
struct stat st; | struct stat st; | ||||
Elf_Addr *argcp; | Elf_Addr *argcp; | ||||
char **argv, **env, **envp, *kexecpath, *library_path_rpath; | char **argv, **env, **envp, *kexecpath, *library_path_rpath; | ||||
const char *argv0; | const char *argv0; | ||||
caddr_t imgentry; | caddr_t imgentry; | ||||
char buf[MAXPATHLEN]; | char buf[MAXPATHLEN]; | ||||
int argc, fd, i, phnum, rtld_argc; | int argc, fd, i, phnum, rtld_argc; | ||||
#ifdef __powerpc__ | |||||
int old_auxv_format = 1; | |||||
#endif | |||||
bool dir_enable, explicit_fd, search_in_path; | bool dir_enable, explicit_fd, search_in_path; | ||||
/* | /* | ||||
* On entry, the dynamic linker itself has not been relocated yet. | * On entry, the dynamic linker itself has not been relocated yet. | ||||
* Be very careful not to reference any global data until after | * Be very careful not to reference any global data until after | ||||
* init_rtld has returned. It is OK to reference file-scope statics | * init_rtld has returned. It is OK to reference file-scope statics | ||||
* and string constants, and to call static and global functions. | * and string constants, and to call static and global functions. | ||||
*/ | */ | ||||
Show All 9 Lines | ; | ||||
aux = (Elf_Auxinfo *) sp; | aux = (Elf_Auxinfo *) sp; | ||||
/* Digest the auxiliary vector. */ | /* Digest the auxiliary vector. */ | ||||
for (i = 0; i < AT_COUNT; i++) | for (i = 0; i < AT_COUNT; i++) | ||||
aux_info[i] = NULL; | aux_info[i] = NULL; | ||||
for (auxp = aux; auxp->a_type != AT_NULL; auxp++) { | for (auxp = aux; auxp->a_type != AT_NULL; auxp++) { | ||||
if (auxp->a_type < AT_COUNT) | if (auxp->a_type < AT_COUNT) | ||||
aux_info[auxp->a_type] = auxp; | aux_info[auxp->a_type] = auxp; | ||||
#ifdef __powerpc__ | |||||
if (auxp->a_type == 23) /* AT_STACKPROT */ | |||||
old_auxv_format = 0; | |||||
#endif | |||||
} | } | ||||
#ifdef __powerpc__ | |||||
if (old_auxv_format) { | |||||
/* Remap from old-style auxv numbers. */ | |||||
aux_info[23] = aux_info[21]; /* AT_STACKPROT */ | |||||
aux_info[21] = aux_info[19]; /* AT_PAGESIZESLEN */ | |||||
aux_info[19] = aux_info[17]; /* AT_NCPUS */ | |||||
aux_info[17] = aux_info[15]; /* AT_CANARYLEN */ | |||||
aux_info[15] = aux_info[13]; /* AT_EXECPATH */ | |||||
aux_info[13] = NULL; /* AT_GID */ | |||||
aux_info[20] = aux_info[18]; /* AT_PAGESIZES */ | |||||
aux_info[18] = aux_info[16]; /* AT_OSRELDATE */ | |||||
aux_info[16] = aux_info[14]; /* AT_CANARY */ | |||||
aux_info[14] = NULL; /* AT_EGID */ | |||||
} | |||||
#endif | |||||
/* Initialize and relocate ourselves. */ | /* Initialize and relocate ourselves. */ | ||||
assert(aux_info[AT_BASE] != NULL); | assert(aux_info[AT_BASE] != NULL); | ||||
init_rtld((caddr_t) aux_info[AT_BASE]->a_un.a_ptr, aux_info); | init_rtld((caddr_t) aux_info[AT_BASE]->a_un.a_ptr, aux_info); | ||||
__progname = obj_rtld.path; | __progname = obj_rtld.path; | ||||
argv0 = argv[0] != NULL ? argv[0] : "(null)"; | argv0 = argv[0] != NULL ? argv[0] : "(null)"; | ||||
environ = env; | environ = env; | ||||
▲ Show 20 Lines • Show All 5,309 Lines • Show Last 20 Lines |