[PATCH V2] ctf: make libabigail::ctf_reader::read_corpus reentrant

Jose E. Marchesi jose.marchesi@oracle.com
Wed Nov 10 12:08:50 GMT 2021


> "Jose E. Marchesi via Libabigail" <libabigail@sourceware.org> a écrit:
>
>> [Changes from V1:
>> - Make sure that the string table passed to libctf is the one related
>>   to the symbol table.]
>
>
> Pffft.
>
> I mistakenly applied the V1 patch to master, sorry about that.

Nah it is my fault.  I should have sent the right version straight away
:)

> So I am providing below a "differential" patch that would bring master
> to the level of this V2 patch.
>
> Would you mind reviewing it, please, (and sign it off) so that I can
> apply it master as well?

LGTM.

>
> Thanks, and sorry again.
>
> Cheers,
>
> From b3e9ff53879939a3e0d4092ecd23cbd39393c268 Mon Sep 17 00:00:00 2001
> From: Dodji Seketeli <dodji@redhat.com>
> Date: Tue, 9 Nov 2021 11:24:16 +0100
> Subject: [PATCH] ctf-reader: Use the string table related to the symtab
>
> There can be several string tables in the ELF file.  The one we want
> to use is the one related to the symbol table, referred to by its
> sh_link property.
>
> This patch ensures that.
>
> 	* src/abg-ctf-reader.cc (slurp_elf_info): Use the string table
> 	related to the symbol table.
>
> Signed-off-by: Dodji Seketeli <dodji@redhat.com>

Signed-off-by: Jose E. Marchesi <jose.marchesi@oracle.com>

> ---
>  src/abg-ctf-reader.cc | 14 +++++++++++---
>  1 file changed, 11 insertions(+), 3 deletions(-)
>
> diff --git a/src/abg-ctf-reader.cc b/src/abg-ctf-reader.cc
> index 51fb2ed9..33642821 100644
> --- a/src/abg-ctf-reader.cc
> +++ b/src/abg-ctf-reader.cc
> @@ -1037,12 +1037,20 @@ slurp_elf_info(read_context *ctxt, corpus_sptr corp)
>                                  0 /* No suppressions.  */);
>    corp->set_symtab(ctxt->symtab);
>  
> -  /* Get the raw ELF section contents for libctf.  */
> +  /* Get the raw ELF section contents for libctf.  The .ctf section
> +     and the symtab are straightforward enough.  */
>    Elf_Scn *ctf_scn = elf_helpers::find_section(ctxt->elf_handler, ".ctf", SHT_PROGBITS);
>    Elf_Scn *symtab_scn = elf_helpers::find_symbol_table_section(ctxt->elf_handler);
> -  Elf_Scn *strtab_scn = elf_helpers::find_section(ctxt->elf_handler, SHT_STRTAB);
>  
> -  if (ctf_scn == NULL || symtab_scn == NULL || strtab_scn == NULL)
> +  if (ctf_scn == NULL || symtab_scn == NULL)
> +    return 0;
> +
> +  /* The string table that libctf expects is the one related to the
> +     symbol table by virtue of sh_link.  */
> +  GElf_Shdr symtab_shdr_mem, *symtab_shdr = gelf_getshdr(symtab_scn, &symtab_shdr_mem);
> +  Elf_Scn *strtab_scn = elf_getscn(ctxt->elf_handler, symtab_shdr->sh_link);
> +
> +  if (strtab_scn == NULL)
>      return 0;
>  
>    fill_ctf_section(ctxt, ctf_scn, &ctxt->ctf_sect);
> -- 
>
> 2.32.0


More information about the Libabigail mailing list