Patchwork riscv: fix elf parsing

login
register
mail settings
Submitter DJ Delorie
Date Feb. 9, 2018, 2:07 a.m.
Message ID <xnd11encfu.fsf@greed.delorie.com>
Download mbox | patch
Permalink /patch/25880/
State New
Headers show

Comments

DJ Delorie - Feb. 9, 2018, 2:07 a.m.
I think this one is obvious...  it was causing ldconfig to cache all
libraries with the wrong flags (soft float vs double), thus making the
cache useless.

	* sysdeps/unix/sysv/linux/riscv/readelflib.c
        (process_elf_file): Fix Elf64 flag parsing.
Florian Weimer - Feb. 9, 2018, 10:08 a.m.
* DJ Delorie:

> I think this one is obvious...  it was causing ldconfig to cache all
> libraries with the wrong flags (soft float vs double), thus making the
> cache useless.
>
> 	* sysdeps/unix/sysv/linux/riscv/readelflib.c
>         (process_elf_file): Fix Elf64 flag parsing.

Since the port was released with 2.27, this needs a bug in Bugzilla
(and an eventual backport).  Thanks.
Palmer Dabbelt - Feb. 13, 2018, 2:20 a.m.
On Thu, 08 Feb 2018 18:07:01 PST (-0800), dj@redhat.com wrote:
>
> I think this one is obvious...  it was causing ldconfig to cache all
> libraries with the wrong flags (soft float vs double), thus making the
> cache useless.
>
> 	* sysdeps/unix/sysv/linux/riscv/readelflib.c
>         (process_elf_file): Fix Elf64 flag parsing.
>
> diff --git a/sysdeps/unix/sysv/linux/riscv/readelflib.c b/sysdeps/unix/sysv/linux/riscv/readelflib.c
> index 6e249ff82f..7e27e0c1d6 100644
> --- a/sysdeps/unix/sysv/linux/riscv/readelflib.c
> +++ b/sysdeps/unix/sysv/linux/riscv/readelflib.c
> @@ -43,6 +43,7 @@ process_elf_file (const char *file_name, const char *lib, int *flag,
>  {
>    ElfW(Ehdr) *elf_header = (ElfW(Ehdr) *) file_contents;
>    Elf32_Ehdr *elf32_header = (Elf32_Ehdr *) elf_header;
> +  Elf64_Ehdr *elf64_header = (Elf64_Ehdr *) elf_header;
>    int ret;
>    long flags;
>
> @@ -59,7 +60,7 @@ process_elf_file (const char *file_name, const char *lib, int *flag,
>      {
>        ret = process_elf64_file (file_name, lib, flag, osversion, soname,
>  				file_contents, file_length);
> -      flags = elf32_header->e_flags;
> +      flags = elf64_header->e_flags;
>      }
>
>    /* RISC-V linkers encode the floating point ABI as part of the ELF headers.  */

Sorry about that.  I'm still a bit behind on my email from FOSDEM, but I 
noticed you committed this one.  Thanks!

Patch

diff --git a/sysdeps/unix/sysv/linux/riscv/readelflib.c b/sysdeps/unix/sysv/linux/riscv/readelflib.c
index 6e249ff82f..7e27e0c1d6 100644
--- a/sysdeps/unix/sysv/linux/riscv/readelflib.c
+++ b/sysdeps/unix/sysv/linux/riscv/readelflib.c
@@ -43,6 +43,7 @@  process_elf_file (const char *file_name, const char *lib, int *flag,
 {
   ElfW(Ehdr) *elf_header = (ElfW(Ehdr) *) file_contents;
   Elf32_Ehdr *elf32_header = (Elf32_Ehdr *) elf_header;
+  Elf64_Ehdr *elf64_header = (Elf64_Ehdr *) elf_header;
   int ret;
   long flags;
 
@@ -59,7 +60,7 @@  process_elf_file (const char *file_name, const char *lib, int *flag,
     {
       ret = process_elf64_file (file_name, lib, flag, osversion, soname,
 				file_contents, file_length);
-      flags = elf32_header->e_flags;
+      flags = elf64_header->e_flags;
     }
 
   /* RISC-V linkers encode the floating point ABI as part of the ELF headers.  */