diff options
author | imp <imp@FreeBSD.org> | 2016-01-03 04:32:02 +0000 |
---|---|---|
committer | imp <imp@FreeBSD.org> | 2016-01-03 04:32:02 +0000 |
commit | 867e4a7989de6f2866668dd3e961827e3a16055b (patch) | |
tree | d37f7c112db034272afeef8e30196e6f2d582318 /libexec/rtld-elf | |
parent | 68e5953df5a63acbc4f32e9b2e828ebc2fe1ac1f (diff) | |
download | FreeBSD-src-867e4a7989de6f2866668dd3e961827e3a16055b.zip FreeBSD-src-867e4a7989de6f2866668dd3e961827e3a16055b.tar.gz |
Create a generalized exec hook that different architectures can hook
into if they need to, but default to no action.
Differential Review: https://reviews.freebsd.org/D2718
Diffstat (limited to 'libexec/rtld-elf')
-rw-r--r-- | libexec/rtld-elf/aarch64/rtld_machdep.h | 2 | ||||
-rw-r--r-- | libexec/rtld-elf/amd64/rtld_machdep.h | 2 | ||||
-rw-r--r-- | libexec/rtld-elf/arm/reloc.c | 35 | ||||
-rw-r--r-- | libexec/rtld-elf/arm/rtld_machdep.h | 5 | ||||
-rw-r--r-- | libexec/rtld-elf/i386/rtld_machdep.h | 2 | ||||
-rw-r--r-- | libexec/rtld-elf/mips/rtld_machdep.h | 2 | ||||
-rw-r--r-- | libexec/rtld-elf/paths.h | 10 | ||||
-rw-r--r-- | libexec/rtld-elf/powerpc/rtld_machdep.h | 2 | ||||
-rw-r--r-- | libexec/rtld-elf/powerpc64/rtld_machdep.h | 2 | ||||
-rw-r--r-- | libexec/rtld-elf/rtld.c | 2 | ||||
-rw-r--r-- | libexec/rtld-elf/sparc64/rtld_machdep.h | 2 |
11 files changed, 63 insertions, 3 deletions
diff --git a/libexec/rtld-elf/aarch64/rtld_machdep.h b/libexec/rtld-elf/aarch64/rtld_machdep.h index 943e3e6..a2fc74a 100644 --- a/libexec/rtld-elf/aarch64/rtld_machdep.h +++ b/libexec/rtld-elf/aarch64/rtld_machdep.h @@ -80,4 +80,6 @@ extern void *__tls_get_addr(tls_index *ti); #define RTLD_DEFAULT_STACK_PF_EXEC PF_X #define RTLD_DEFAULT_STACK_EXEC PROT_EXEC +#define md_abi_variant_hook(x) + #endif diff --git a/libexec/rtld-elf/amd64/rtld_machdep.h b/libexec/rtld-elf/amd64/rtld_machdep.h index cb5e9a1..a8696fe 100644 --- a/libexec/rtld-elf/amd64/rtld_machdep.h +++ b/libexec/rtld-elf/amd64/rtld_machdep.h @@ -79,4 +79,6 @@ void *__tls_get_addr(tls_index *ti) __exported; #define RTLD_DEFAULT_STACK_PF_EXEC PF_X #define RTLD_DEFAULT_STACK_EXEC PROT_EXEC +#define md_abi_variant_hook(x) + #endif diff --git a/libexec/rtld-elf/arm/reloc.c b/libexec/rtld-elf/arm/reloc.c index d0bf987..6bdda73 100644 --- a/libexec/rtld-elf/arm/reloc.c +++ b/libexec/rtld-elf/arm/reloc.c @@ -18,6 +18,41 @@ __FBSDID("$FreeBSD$"); #include "paths.h" void +arm_abi_variant_hook(Elf_Auxinfo **aux_info) +{ + Elf_Word ehdr; + + /* + * If we're running an old kernel that doesn't provide any data fail + * safe by doing nothing. + */ + if (aux_info[AT_EHDRFLAGS] == NULL) + return; + ehdr = aux_info[AT_EHDRFLAGS]->a_un.a_val; + + /* + * Hard float ABI binaries are the default, and use the default paths + * and such. + */ + if ((ehdr & EF_ARM_VFP_FLOAT) != 0) + return; + + /* + * This is a soft float ABI binary. We need to use the soft float + * settings. For the moment, the standard library path includes the hard + * float paths as well. When upgrading, we need to execute the wrong + * kind of binary until we've installed the new binaries. We could go + * off whether or not /libsoft exists, but the simplicity of having it + * in the path wins. + */ + ld_elf_hints_default = _PATH_SOFT_ELF_HINTS; + ld_path_libmap_conf = _PATH_SOFT_LIBMAP_CONF; + ld_path_rtld = _PATH_SOFT_RTLD; + ld_standard_library_path = SOFT_STANDARD_LIBRARY_PATH; + ld_env_prefix = LD_SOFT_; +} + +void init_pltgot(Obj_Entry *obj) { if (obj->pltgot != NULL) { diff --git a/libexec/rtld-elf/arm/rtld_machdep.h b/libexec/rtld-elf/arm/rtld_machdep.h index f980de0..c61bce0 100644 --- a/libexec/rtld-elf/arm/rtld_machdep.h +++ b/libexec/rtld-elf/arm/rtld_machdep.h @@ -75,4 +75,9 @@ extern void *__tls_get_addr(tls_index *ti); #define RTLD_DEFAULT_STACK_PF_EXEC PF_X #define RTLD_DEFAULT_STACK_EXEC PROT_EXEC +extern void arm_abi_variant_hook(Elf_Auxinfo **); + +#define md_abi_variant_hook(x) arm_abi_variant_hook(x) +#define RTLD_VARIANT_ENV_NAMES + #endif diff --git a/libexec/rtld-elf/i386/rtld_machdep.h b/libexec/rtld-elf/i386/rtld_machdep.h index 5c328da..5237d4f 100644 --- a/libexec/rtld-elf/i386/rtld_machdep.h +++ b/libexec/rtld-elf/i386/rtld_machdep.h @@ -80,4 +80,6 @@ void *__tls_get_addr(tls_index *ti) __exported; #define RTLD_DEFAULT_STACK_PF_EXEC PF_X #define RTLD_DEFAULT_STACK_EXEC PROT_EXEC +#define md_abi_variant_hook(x) + #endif diff --git a/libexec/rtld-elf/mips/rtld_machdep.h b/libexec/rtld-elf/mips/rtld_machdep.h index befbf13..34e8f3c 100644 --- a/libexec/rtld-elf/mips/rtld_machdep.h +++ b/libexec/rtld-elf/mips/rtld_machdep.h @@ -75,4 +75,6 @@ extern void *__tls_get_addr(tls_index *ti); #define RTLD_DEFAULT_STACK_PF_EXEC PF_X #define RTLD_DEFAULT_STACK_EXEC PROT_EXEC +#define md_abi_variant_hook(x) + #endif diff --git a/libexec/rtld-elf/paths.h b/libexec/rtld-elf/paths.h index 709e4d3..abfeb3f 100644 --- a/libexec/rtld-elf/paths.h +++ b/libexec/rtld-elf/paths.h @@ -1,8 +1,6 @@ /*- * Copyright 1996, 1997, 1998, 1999, 2000 John D. Polstra. * Copyright 2003 Alexander Kabaev <kan@FreeBSD.ORG>. - * Copyright 2009-2012 Konstantin Belousov <kib@FreeBSD.ORG>. - * Copyright 2012 John Marino <draco@marino.st>. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -61,7 +59,13 @@ #define LD_ "LD_" #endif -extern char *ld_path_elf_hints; +#define _PATH_SOFT_ELF_HINTS "/var/run/ld-elf-soft.so.hints" +#define _PATH_SOFT_LIBMAP_CONF "/etc/libmap-soft.conf" +#define _PATH_SOFT_RTLD "/libexec/ld-elf.so.1" +#define SOFT_STANDARD_LIBRARY_PATH "/libsoft:/usr/libsoft:/lib:/usr/lib" +#define LD_SOFT_ "LD_SOFT_" + +extern char *ld_elf_hints_default; extern char *ld_path_libmap_conf; extern char *ld_path_rtld; extern char *ld_standard_library_path; diff --git a/libexec/rtld-elf/powerpc/rtld_machdep.h b/libexec/rtld-elf/powerpc/rtld_machdep.h index 1ddf1bc..3e39c82 100644 --- a/libexec/rtld-elf/powerpc/rtld_machdep.h +++ b/libexec/rtld-elf/powerpc/rtld_machdep.h @@ -90,4 +90,6 @@ extern void *__tls_get_addr(tls_index* ti); #define RTLD_DEFAULT_STACK_PF_EXEC PF_X #define RTLD_DEFAULT_STACK_EXEC PROT_EXEC +#define md_abi_variant_hook(x) + #endif diff --git a/libexec/rtld-elf/powerpc64/rtld_machdep.h b/libexec/rtld-elf/powerpc64/rtld_machdep.h index b88ed9d..32c7d12 100644 --- a/libexec/rtld-elf/powerpc64/rtld_machdep.h +++ b/libexec/rtld-elf/powerpc64/rtld_machdep.h @@ -82,4 +82,6 @@ extern void *__tls_get_addr(tls_index* ti); #define RTLD_DEFAULT_STACK_PF_EXEC PF_X #define RTLD_DEFAULT_STACK_EXEC PROT_EXEC +#define md_abi_variant_hook(x) + #endif diff --git a/libexec/rtld-elf/rtld.c b/libexec/rtld-elf/rtld.c index 4eee6c5..b30249a 100644 --- a/libexec/rtld-elf/rtld.c +++ b/libexec/rtld-elf/rtld.c @@ -419,6 +419,8 @@ _rtld(Elf_Addr *sp, func_ptr_type *exit_proc, Obj_Entry **objp) trust = !issetugid(); + md_abi_variant_hook(aux_info); + ld_bind_now = getenv(_LD("BIND_NOW")); /* * If the process is tainted, then we un-set the dangerous environment diff --git a/libexec/rtld-elf/sparc64/rtld_machdep.h b/libexec/rtld-elf/sparc64/rtld_machdep.h index 44fe2cf..9df63b8 100644 --- a/libexec/rtld-elf/sparc64/rtld_machdep.h +++ b/libexec/rtld-elf/sparc64/rtld_machdep.h @@ -71,4 +71,6 @@ extern void *__tls_get_addr(tls_index *ti); #define RTLD_DEFAULT_STACK_PF_EXEC 0 #define RTLD_DEFAULT_STACK_EXEC 0 +#define md_abi_variant_hook(x) + #endif |