From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from relay8-d.mail.gandi.net (relay8-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::228]) by sourceware.org (Postfix) with ESMTPS id 4EA6B3AA842D for ; Thu, 17 Nov 2022 14:33:09 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 4EA6B3AA842D Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=seketeli.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=seketeli.org Received: (Authenticated sender: dodji@seketeli.org) by mail.gandi.net (Postfix) with ESMTPSA id 94D5C1BF216; Thu, 17 Nov 2022 14:33:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=seketeli.org; s=gm1; t=1668695588; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=AOZ/Rv5fUy51tta1emfZ0bN53aRIHeucbDYrm+KyxiE=; b=K6aOyK8SRnPkGUVmXv8s60zIMWJWVKhSIgq6me0s/lQAC9ihAlorUFoWBI8Tn+olY7GMHt Gxos9oIEJLIOGWeo2Yn7OPdnAh7qPpfMuPsWfQPYW8pSRla3pOloj7IxpCRvuoLt8YIL7/ 3w+BiBeDvsR+3qvfw0RWi1NHkXmAK8TFSr26UN62arv2Ks9Jav0MPDTMcYJQODoiE3f05C P7kLnFlEQaomoUcNSwZWoM02M8XV9IezQC1rXaE/2GZmQ0RDl9tAF2MVrCeSlbBhspuDVm 9EtY1LtEXgbUWwt5l6YBfcqfj9AiYQNTIsFGxJQu9c6NFiILYPB/xMxcX/fHpQ== Received: by localhost (Postfix, from userid 1000) id F0E37581C59; Thu, 17 Nov 2022 15:33:06 +0100 (CET) From: Dodji Seketeli To: "Guillermo E. Martinez via Libabigail" Cc: "Guillermo E. Martinez" Subject: Re: [PATCH] ctf-reader: Fix symbols alias report in ABI representation. Organization: Me, myself and I References: <20220908044814.1783610-1-guillermo.e.martinez@oracle.com> X-Operating-System: Fedora 38 X-URL: http://www.seketeli.net/~dodji Date: Thu, 17 Nov 2022 15:33:06 +0100 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") Message-ID: <87zgcpmz19.fsf@seketeli.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-9.5 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,JMQ_SPF_NEUTRAL,RCVD_IN_DNSWL_LOW,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Hello Guillermo, "Guillermo E. Martinez via Libabigail" a =C3=A9crit: [...] > @@ -1396,6 +1396,41 @@ open_elf_handler(read_context *ctxt) > return 0; > } >=20=20 > + /* 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 =3D ctxt->elf_handler; > + GElf_Ehdr ehdr_mem, *ehdr =3D gelf_getehdr(elf, &ehdr_mem); > + if (ehdr =3D=3D NULL) > + return 0; > + > + GElf_Addr end =3D 0; > + Elf_Scn *scn =3D NULL; > + > + if (ehdr->e_type =3D=3D ET_REL) > + while ((scn =3D elf_nextscn(elf, scn)) !=3D NULL) > + { > + GElf_Shdr shdr_mem; > + GElf_Shdr *shdr =3D gelf_getshdr(scn, &shdr_mem); > + > + if (shdr =3D=3D NULL) > + return 0; > + > + if (shdr->sh_flags & SHF_ALLOC) > + { > + if (shdr->sh_addr =3D=3D 0) > + { > + shdr->sh_addr =3D end; > + end =3D shdr->sh_addr + shdr->sh_size; > + if ((shdr->sh_addr !=3D 0) && !gelf_update_shdr(scn, shd= r)) > + return 0; > + } > + else > + end =3D 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=3Dlibabigail.git;a=3Dshortlog;h=3Drefs/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=3Dlibabigail.git;a=3Dblob;f=3Dsrc/abg-elf-rea= der.cc;h=3Deedeaf8ece3e7cfb99a0ef392962d777630ae66b;hb=3D9b4a6e9e304bf8a4f2= 1e44a497a4379826b4b1ae#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, --=20 Dodji