public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Adhemerval Zanella <adhemerval.zanella@linaro.org>
To: "Lucas A. M. Magalhaes" <lamm@linux.ibm.com>, libc-alpha@sourceware.org
Cc: fweimer@redhat.com, tuliom@linux.ibm.com
Subject: Re: [PATCH] powerpc: Use FLAG_ELF_LIBC6 for 32-bit known libraries
Date: Fri, 3 Dec 2021 11:51:29 -0300	[thread overview]
Message-ID: <b223ba5a-a1a0-2f6d-2cce-1ed1254a3c69@linaro.org> (raw)
In-Reply-To: <20211104181039.97106-1-lamm@linux.ibm.com>



On 04/11/2021 15:10, Lucas A. M. Magalhaes via Libc-alpha wrote:
> In systems with more versions of the known libraries, i.e. on IBM
> Advance Toolchain, ldconfig will order them incorrectly on ld.cache.
> 
> The issue only occurs with 32-bit libraries that don't depend on libc or
> libm. That's because process_elf32_file check if the elf depends on one
> of the libraries at known_libs to select the elf flag. For example, as
> libc.so.6 don't depend on itself or on libm it will be flagged as
> FLAG_ELF instead of FLAG_ELF_LIBC6 as expected.

Wouldn't be simpler to check if the DT_SONAME matches any on 'known_libs' after
dynamic section parsing and set the appropriated flag on generic 'process_file'? 

(also powerpc SYSDEP_KNOWN_LIBRARY_NAMES seems redundant).

> 
> This commit fixes this by checking if a appropriate flag was set by
> process_elf32_file. If not it will search on known_libs and use the flag
> in there.
> ---
>  sysdeps/unix/sysv/linux/powerpc/readelflib.c | 21 +++++++++++++++++---
>  1 file changed, 18 insertions(+), 3 deletions(-)
> 
> diff --git a/sysdeps/unix/sysv/linux/powerpc/readelflib.c b/sysdeps/unix/sysv/linux/powerpc/readelflib.c
> index 51f8a9496a..94da21c407 100644
> --- a/sysdeps/unix/sysv/linux/powerpc/readelflib.c
> +++ b/sysdeps/unix/sysv/linux/powerpc/readelflib.c
> @@ -33,11 +33,26 @@ process_elf_file (const char *file_name, const char *lib, int *flag,
>  		  char **soname, void *file_contents, size_t file_length)
>  {
>    ElfW(Ehdr) *elf_header = (ElfW(Ehdr) *) file_contents;
> -  int ret;
> +  int ret, j;
>  
>    if (elf_header->e_ident [EI_CLASS] == ELFCLASS32)
> -    return process_elf32_file (file_name, lib, flag, osversion, isa_level,
> -			       soname, file_contents, file_length);
> +    {
> +      ret = process_elf32_file (file_name, lib, flag, osversion, isa_level,
> +                                soname, file_contents, file_length);
> +      /* Use the apropriate flag for known_libs instead of FLAG_ELF.  */
> +      if (*flag == FLAG_ELF)
> +        {
> +          for (j = 0;
> +               j < sizeof (known_libs) / sizeof (known_libs [0]);
> +               ++j)
> +            if (strcmp (lib, known_libs [j].soname) == 0)
> +              {
> +                *flag = known_libs [j].flag;
> +                break;
> +              }
> +        }
> +      return ret;
> +    }
>    else
>      {
>        ret = process_elf64_file (file_name, lib, flag, osversion, isa_level,
> 

  parent reply	other threads:[~2021-12-03 14:51 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-22 21:12 [PATCH] powerpc: Use the correct flag " Lucas A. M. Magalhaes
2021-10-25 18:22 ` Florian Weimer
2021-12-22 15:31   ` [RFC] Remove special flags of libc.5.so and libc.4.so Lucas A. M. Magalhaes
2022-01-10 19:21     ` Lucas A. M. Magalhaes
2022-01-11 19:22     ` Adhemerval Zanella
2022-03-02 19:37       ` Raoni Fassina Firmino
2022-03-04 18:38         ` Adhemerval Zanella
2022-02-23 22:17     ` Raoni Fassina Firmino
2021-11-04 18:10 ` [PATCH] powerpc: Use FLAG_ELF_LIBC6 for 32-bit known libraries Lucas A. M. Magalhaes
2021-12-03 12:40   ` Lucas A. M. Magalhaes
2021-12-03 14:17   ` Florian Weimer
2021-12-03 14:51   ` Adhemerval Zanella [this message]
2022-03-02 19:30     ` Raoni Fassina Firmino
2022-03-04 18:49       ` Adhemerval Zanella
2022-02-23 22:09   ` Raoni Fassina Firmino

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=b223ba5a-a1a0-2f6d-2cce-1ed1254a3c69@linaro.org \
    --to=adhemerval.zanella@linaro.org \
    --cc=fweimer@redhat.com \
    --cc=lamm@linux.ibm.com \
    --cc=libc-alpha@sourceware.org \
    --cc=tuliom@linux.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).