diff --git a/libexec/ld.elf_so/headers.c b/libexec/ld.elf_so/headers.c index 4b913cf3fd52..083f4a0d513a 100644 --- a/libexec/ld.elf_so/headers.c +++ b/libexec/ld.elf_so/headers.c @@ -1,4 +1,4 @@ -/* $NetBSD: headers.c,v 1.55 2014/08/25 20:40:52 joerg Exp $ */ +/* $NetBSD: headers.c,v 1.56 2014/08/26 07:54:27 christos Exp $ */ /* * Copyright 1996 John D. Polstra. @@ -40,7 +40,7 @@ #include #ifndef lint -__RCSID("$NetBSD: headers.c,v 1.55 2014/08/25 20:40:52 joerg Exp $"); +__RCSID("$NetBSD: headers.c,v 1.56 2014/08/26 07:54:27 christos Exp $"); #endif /* not lint */ #include @@ -345,9 +345,9 @@ _rtld_digest_dynamic(const char *execname, Obj_Entry *obj) } if (init != 0) - obj->init = (Elf_Addr)obj->relocbase + init; + obj->init = (Elf_Addr) RTLD_ELF32_CAST obj->relocbase + init; if (fini != 0) - obj->fini = (Elf_Addr)obj->relocbase + fini; + obj->fini = (Elf_Addr) RTLD_ELF32_CAST obj->relocbase + fini; if (dyn_rpath != NULL) { _rtld_add_paths(execname, &obj->rpaths, obj->strtab + diff --git a/libexec/ld.elf_so/rtld.h b/libexec/ld.elf_so/rtld.h index 3800fb36d140..a94b17f5e77d 100644 --- a/libexec/ld.elf_so/rtld.h +++ b/libexec/ld.elf_so/rtld.h @@ -1,4 +1,4 @@ -/* $NetBSD: rtld.h,v 1.120 2014/08/25 20:40:52 joerg Exp $ */ +/* $NetBSD: rtld.h,v 1.121 2014/08/26 07:54:27 christos Exp $ */ /* * Copyright 1996 John D. Polstra. @@ -475,6 +475,15 @@ Obj_Entry *_rtld_map_object(const char *, int, const struct stat *); void _rtld_obj_free(Obj_Entry *); Obj_Entry *_rtld_obj_new(void); +/* + * The following uintptr_t cast is for Elf32 emulation on _LP64 systems + */ +#if defined(_LP64) && ELFSIZE == 32 +#define RTLD_ELF32_CAST (uintptr_t) +#else +#define RTLD_ELF32_CAST +#endif + /* function descriptors */ #ifdef __HAVE_FUNCTION_DESCRIPTORS Elf_Addr _rtld_function_descriptor_alloc(const Obj_Entry *, @@ -487,12 +496,12 @@ Elf_Addr _rtld_call_function_addr(const Obj_Entry *, Elf_Addr); static inline void _rtld_call_function_void(const Obj_Entry *obj, Elf_Addr addr) { - ((void (*)(void))addr)(); + ((void (*)(void)) RTLD_ELF32_CAST addr)(); } static inline Elf_Addr _rtld_call_function_addr(const Obj_Entry *obj, Elf_Addr addr) { - return ((Elf_Addr(*)(void))addr)(); + return ((Elf_Addr(*)(void)) RTLD_ELF32_CAST addr)(); } #endif /* __HAVE_FUNCTION_DESCRIPTORS */