From: Dodji Seketeli <dodji@seketeli.org>
To: "Guillermo E. Martinez via Libabigail" <libabigail@sourceware.org>
Cc: "Guillermo E. Martinez" <guillermo.e.martinez@oracle.com>
Subject: Re: [PATCH] ctf-reader: Fix symbols alias report in ABI representation.
Date: Thu, 17 Nov 2022 15:33:06 +0100 [thread overview]
Message-ID: <87zgcpmz19.fsf@seketeli.org> (raw)
In-Reply-To: <20220908044814.1783610-1-guillermo.e.martinez@oracle.com> (Guillermo E. Martinez via Libabigail's message of "Wed, 7 Sep 2022 23:48:14 -0500")
Hello Guillermo,
"Guillermo E. Martinez via Libabigail" <libabigail@sourceware.org> a
écrit:
[...]
> @@ -1396,6 +1396,41 @@ open_elf_handler(read_context *ctxt)
> return 0;
> }
>
> + /* It Elf type is ET_REL it updates SHF_ALLOC sections in
> + its virtual addr field, it is done by adding the previous
> + section size and assigning this value to sh_addr field,
> + otherwise alias symbols (if the symbol has one) is mix up */
> + Elf *elf = ctxt->elf_handler;
> + GElf_Ehdr ehdr_mem, *ehdr = gelf_getehdr(elf, &ehdr_mem);
> + if (ehdr == NULL)
> + return 0;
> +
> + GElf_Addr end = 0;
> + Elf_Scn *scn = NULL;
> +
> + if (ehdr->e_type == ET_REL)
> + while ((scn = elf_nextscn(elf, scn)) != NULL)
> + {
> + GElf_Shdr shdr_mem;
> + GElf_Shdr *shdr = gelf_getshdr(scn, &shdr_mem);
> +
> + if (shdr == NULL)
> + return 0;
> +
> + if (shdr->sh_flags & SHF_ALLOC)
> + {
> + if (shdr->sh_addr == 0)
> + {
> + shdr->sh_addr = end;
> + end = shdr->sh_addr + shdr->sh_size;
> + if ((shdr->sh_addr != 0) && !gelf_update_shdr(scn, shdr))
> + return 0;
> + }
> + else
> + end = shdr->sh_addr + shdr->sh_size;
> + }
> + }
> +
Hmmh, doing this amounts to doing what the DWARF Front End Library, aka
dwfl, from elfutils does for us. The DWARF front-end of libabigail uses
dwfl exactly for this kinds of tricks.
I think that in the new front-end branch at
https://sourceware.org/git/?p=libabigail.git;a=shortlog;h=refs/heads/users/dodji/front-end,
the CTF front end is implicitly uses dwfl as well, just like the DWARF
front end. This is because they both derive from the
abigail::elf::reader which used the dwfl. You can see that at
https://sourceware.org/git/?p=libabigail.git;a=blob;f=src/abg-elf-reader.cc;h=eedeaf8ece3e7cfb99a0ef392962d777630ae66b;hb=9b4a6e9e304bf8a4f21e44a497a4379826b4b1ae#l304.
> return 1;
> }
So I think you should maybe just check that this functionality work on
that "front-end" branch.
If it does, maybe you can just add the tests below to that branch, to
make sure we don't regress on this functionality in the future.
What do you think?
>
> diff --git a/tests/data/Makefile.am b/tests/data/Makefile.am
> index 782dd7f3..793a0e89 100644
> --- a/tests/data/Makefile.am
> +++ b/tests/data/Makefile.am
> @@ -632,6 +632,7 @@ test-read-ctf/test9.c \
> test-read-ctf/test9.o \
> test-read-ctf/test9.o.abi \
> test-read-ctf/test-alias.c \
> +test-read-ctf/test-alias.o \
[...]
Cheers,
--
Dodji
next prev parent reply other threads:[~2022-11-17 14:33 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-08 4:48 Guillermo E. Martinez
2022-10-31 18:10 ` Guillermo Martinez
2022-11-17 14:33 ` Dodji Seketeli [this message]
2022-11-18 21:48 ` Guillermo E. Martinez
2022-11-18 21:55 ` [PATCH] ctf-front-end: Add test for alias symbols Guillermo E. Martinez
2022-11-21 3:46 ` [PATCHv2] " Guillermo E. Martinez
2022-12-20 18:59 ` Guillermo E. Martinez
2022-12-21 13:22 ` [PATCH] " Dodji Seketeli
2022-12-21 20:12 ` Guillermo E. Martinez
2022-12-22 10:00 ` Dodji Seketeli
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=87zgcpmz19.fsf@seketeli.org \
--to=dodji@seketeli.org \
--cc=guillermo.e.martinez@oracle.com \
--cc=libabigail@sourceware.org \
/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).