This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH v4 06/17] RISC-V: Startup and Dynamic Loading Code


On Mon, 22 Jan 2018 15:08:55 PST (-0800), joseph@codesourcery.com wrote:
On Mon, 22 Jan 2018, Palmer Dabbelt wrote:

Ah, OK -- when I was going through something else I was wondering how that got
enforced, I guess the answer is that it wasn't.  I think something like this
should do it

   diff --git a/sysdeps/riscv/dl-machine.h b/sysdeps/riscv/dl-machine.h
   index 7d4fcee79662..21e401dbf2fb 100644
   --- a/sysdeps/riscv/dl-machine.h
   +++ b/sysdeps/riscv/dl-machine.h
   @@ -57,7 +57,20 @@
    static inline int __attribute_used__
    elf_machine_matches_host (const ElfW (Ehdr) *ehdr)
    {
   -  return ehdr->e_machine == EM_RISCV;
   +  /* We can only run RISC-V binaries.  */
   +  if (ehdr->e_machine != EM_RISCV)
   +    return 1;

This looks like it's inverted (should return 0 for non-RISCV, not 1).

Thanks -- that's why I shouldn't try to squeeze this stuff in between meetings, I also left half of a comment in there. I think this should do it

   /* Return nonzero iff ELF header is compatible with the running host.  */
   static inline int __attribute_used__
   elf_machine_matches_host (const ElfW (Ehdr) *ehdr)
   {
     /* We can only run RISC-V binaries.  */
     if (ehdr->e_machine != EM_RISCV)
       return 0;
/* Ensure the library's floating-point ABI matches that of the running
        system.  For now we don't support mixing XLEN, so there's no need (or way)
        to check it matches.  */
   #ifdef __ricsv_float_abi_double
     if ((ehdr->e_flags & EF_RISCV_FLOAT_ABI) != EF_RISCV_FLOAT_ABI_DOUBLE)
       return 0;
   #else
     if ((ehdr->e_flags & EF_RISCV_FLOAT_ABI) != EF_RISCV_FLOAT_ABI_SOFT)
       return 0;
   #endif
return 1;
   }


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]