Rename from vdso_image_info to avoid a symbol clash. Define HAVE_VDSO_IMAGE_INFO to signal the external definition exists. Provide fallback versions for other targets.
Reviewed-by: Peter Maydell <peter.mayd...@linaro.org> Signed-off-by: Richard Henderson <richard.hender...@linaro.org> --- linux-user/arm/target_elf.h | 1 + linux-user/loader.h | 12 +++++++++++ linux-user/arm/elfload.c | 20 ++++++++++++++++++ linux-user/elfload.c | 41 ++++++++----------------------------- 4 files changed, 42 insertions(+), 32 deletions(-) diff --git a/linux-user/arm/target_elf.h b/linux-user/arm/target_elf.h index 5f81a43efb..19fdfa2f2c 100644 --- a/linux-user/arm/target_elf.h +++ b/linux-user/arm/target_elf.h @@ -14,6 +14,7 @@ #define HAVE_ELF_HWCAP2 1 #define HAVE_ELF_PLATFORM 1 #define HAVE_ELF_CORE_DUMP 1 +#define HAVE_VDSO_IMAGE_INFO 1 #define HI_COMMPAGE ((intptr_t)0xffff0f00u) diff --git a/linux-user/loader.h b/linux-user/loader.h index c3b8f92e23..2175dd4e0a 100644 --- a/linux-user/loader.h +++ b/linux-user/loader.h @@ -110,4 +110,16 @@ bool init_guest_commpage(void); struct target_elf_gregset_t; void elf_core_copy_regs(struct target_elf_gregset_t *, const CPUArchState *); +typedef struct { + const uint8_t *image; + const uint32_t *relocs; + unsigned image_size; + unsigned reloc_count; + unsigned sigreturn_ofs; + unsigned rt_sigreturn_ofs; +} VdsoImageInfo; + +/* Note that both Elf32_Word and Elf64_Word are uint32_t. */ +const VdsoImageInfo *get_vdso_image_info(uint32_t elf_flags); + #endif /* LINUX_USER_LOADER_H */ diff --git a/linux-user/arm/elfload.c b/linux-user/arm/elfload.c index a3f14af691..7e804d82a3 100644 --- a/linux-user/arm/elfload.c +++ b/linux-user/arm/elfload.c @@ -7,6 +7,7 @@ #include "target_elf.h" #include "target/arm/cpu-features.h" #include "target_elf.h" +#include "elf.h" const char *get_elf_cpu_model(uint32_t eflags) @@ -255,3 +256,22 @@ void elf_core_copy_regs(target_elf_gregset_t *r, const CPUARMState *env) r->pt.cpsr = tswapal(cpsr_read((CPUARMState *)env)); r->pt.orig_r0 = tswapal(env->regs[0]); } + +#if TARGET_BIG_ENDIAN +# include "vdso-be8.c.inc" +# include "vdso-be32.c.inc" +#else +# include "vdso-le.c.inc" +#endif + +const VdsoImageInfo *get_vdso_image_info(uint32_t elf_flags) +{ +#if TARGET_BIG_ENDIAN + return (EF_ARM_EABI_VERSION(elf_flags) >= EF_ARM_EABI_VER4 + && (elf_flags & EF_ARM_BE8) + ? &vdso_be8_image_info + : &vdso_be32_image_info); +#else + return &vdso_image_info; +#endif +} diff --git a/linux-user/elfload.c b/linux-user/elfload.c index 81bf05f581..aed390ebb3 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -40,15 +40,6 @@ #define TARGET_ARCH_HAS_SIGTRAMP_PAGE 0 #endif -typedef struct { - const uint8_t *image; - const uint32_t *relocs; - unsigned image_size; - unsigned reloc_count; - unsigned sigreturn_ofs; - unsigned rt_sigreturn_ofs; -} VdsoImageInfo; - #define ELF_OSABI ELFOSABI_SYSV /* from personality.h */ @@ -191,23 +182,6 @@ typedef abi_int target_pid_t; #define ELF_EXEC_PAGESIZE 4096 -#if TARGET_BIG_ENDIAN -#include "elf.h" -#include "vdso-be8.c.inc" -#include "vdso-be32.c.inc" - -static const VdsoImageInfo *vdso_image_info(uint32_t elf_flags) -{ - return (EF_ARM_EABI_VERSION(elf_flags) >= EF_ARM_EABI_VER4 - && (elf_flags & EF_ARM_BE8) - ? &vdso_be8_image_info - : &vdso_be32_image_info); -} -#define vdso_image_info vdso_image_info -#else -# define VDSO_HEADER "vdso-le.c.inc" -#endif - #else /* 64 bit ARM definitions */ @@ -1973,14 +1947,17 @@ static void load_elf_interp(const char *filename, struct image_info *info, load_elf_image(filename, &src, info, &ehdr, NULL); } -#ifndef vdso_image_info +#ifndef HAVE_VDSO_IMAGE_INFO +const VdsoImageInfo *get_vdso_image_info(uint32_t elf_flags) +{ #ifdef VDSO_HEADER #include VDSO_HEADER -#define vdso_image_info(flags) &vdso_image_info + return &vdso_image_info; #else -#define vdso_image_info(flags) NULL -#endif /* VDSO_HEADER */ -#endif /* vdso_image_info */ + return NULL; +#endif +} +#endif /* HAVE_VDSO_IMAGE_INFO */ static void load_elf_vdso(struct image_info *info, const VdsoImageInfo *vdso) { @@ -2311,7 +2288,7 @@ int load_elf_binary(struct linux_binprm *bprm, struct image_info *info) * Load a vdso if available, which will amongst other things contain the * signal trampolines. Otherwise, allocate a separate page for them. */ - const VdsoImageInfo *vdso = vdso_image_info(info->elf_flags); + const VdsoImageInfo *vdso = get_vdso_image_info(info->elf_flags); if (vdso) { load_elf_vdso(&vdso_info, vdso); info->vdso = vdso_info.load_bias; -- 2.43.0