This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH v4 06/17] RISC-V: Startup and Dynamic Loading Code
- From: Joseph Myers <joseph at codesourcery dot com>
- To: Palmer Dabbelt <palmer at dabbelt dot com>
- Cc: <libc-alpha at sourceware dot org>, <patches at groups dot riscv dot org>
- Date: Mon, 15 Jan 2018 16:54:55 +0000
- Subject: Re: [PATCH v4 06/17] RISC-V: Startup and Dynamic Loading Code
- Authentication-results: sourceware.org; auth=none
- References: <20180113103816.4861-1-palmer@dabbelt.com> <20180113103816.4861-7-palmer@dabbelt.com>
On Sat, 13 Jan 2018, Palmer Dabbelt wrote:
> diff --git a/sysdeps/riscv/dl-machine.h b/sysdeps/riscv/dl-machine.h
> +/* Return nonzero iff ELF header is compatible with the running host. */
> +static inline int __attribute_used__
> +elf_machine_matches_host (const ElfW (Ehdr) *ehdr)
> +{
> + return ehdr->e_machine == EM_RISCV;
> +}
I don't think this is sufficient. You should also check that the
floating-point ABI matches so you don't load shared libraries for the
wrong ABI. (See e.g. MIPS for a more complicated elf_machine_matches_host
example.) If in future you have RV64I ILP32, you'll also need to check
that only the right ILP32 libraries for the current instruction set are
loaded (not RV32I into an RV64I ILP32 process or vice versa). (Generic
code in dl-load.c deals with only loading whichever is appropriate of
32-bit or 64-bit ELF.)
--
Joseph S. Myers
joseph@codesourcery.com