From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 74480 invoked by alias); 26 Mar 2017 18:35:59 -0000 Mailing-List: contact elfutils-devel-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Post: List-Help: List-Subscribe: Sender: elfutils-devel-owner@sourceware.org Received: (qmail 74345 invoked by uid 89); 26 Mar 2017 18:35:57 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Checked: by ClamAV 0.99.2 on sourceware.org X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.7 required=5.0 tests=AWL,BAYES_50,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 spammy=Hx-languages-length:258, H*r:212.227.17, H*m:gmx, H*c:HpplH X-Spam-Status: No, score=-0.7 required=5.0 tests=AWL,BAYES_50,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on sourceware.org X-Spam-Level: X-HELO: mout.gmx.net From: Torsten Polle Content-Type: multipart/mixed; boundary="Apple-Mail=_0FB71B17-865C-4CBA-8EFC-13CAF592FF1A" Mime-Version: 1.0 (Mac OS X Mail 10.2 \(3259\)) Subject: [RFC] libdw: prepend current directory in read_srclines Message-Id: Date: Sun, 26 Mar 2017 18:35:00 -0000 To: elfutils-devel@sourceware.org X-Mailer: Apple Mail (2.3259) X-Provags-ID: V03:K0:I40eQY9tRTCBgwfz80H13OJNb8c21rjGG3c855NI+z8L0rVVa2A /mSL+BL/ujFPmHqz0vHnhGfW+t4wJztxJZLHyDynM9xTfF6hnRba0UlV5Q1BbFoCeSslOdo oz5OLVyaR9ID2LfHAxt9Xr0Ha9uKVcXfAkItoVAlYxF5Q3YD1Ra9qcT4T6zx62MNohDVF4p ZKITx903AFR8gqZQlWyzw== X-UI-Out-Filterresults: notjunk:1;V01:K0:PBfNTPd67B0=:3FpAjDN9lTn3hcVWhBeSpM qiYP7hgyCPsoQGbQWqGMGmY/9MDkt40qDMOy9BV3cD/c9G/kFvuIoPe4lPQt+bUrofl5Z7GBF dVDuohhxf3wWnUYkWTBYh5wQkoJ6jXpNOdIqgipiDNTQqnA88esfHfGamm1fYLZagb8hu3rZn FAKrM6wXbOGyZJL4WdB6s58DJ9MxC0koJ8whyqBJsTXlplIf3bhLqipj5HoJtf0PaRUfUflde tGF5HjuJR+0ptAzKBv3gG+7Qxovcsa+BbsSzk0XYDlWSWvAJX7nBeqnyvjDa1Ze7Z9EecEDUx FGko0MKoCJMCLbftFSdOdw/8/syvwVyLYA0HYumGOpp+KcrKFiwXXMc77t9upKTdV/X07Q7Md XuOvb3Dywj6C/lKFEtxPYDsPFxz/VLd/Ho5jTOKq1tY5LqK+4YgmywSnqPdZKvNgcjwqGcqpM eYIQ1pzj1/jwd8kn9H65dmWG+o1Q6TR5JaauJf6Grqo07QlKz3lt9u0dr52X5XZHBv5W2M9Ht zY9Ur0QoqvPSbQkrHrkrqgsydRFS68bcIOPKv4hbT4mEnjUitXX5kqigsaMVlPQvNUjF+mogk GH6VMow1PKoRbsrAv5hBhageWxXpHnSYVfQG51xHhaMTUR1nTX9A9EpWcX/umJVwM+Pgt0jc2 qw/NcHQCoZ0ehgg/UI+OOMC62kTXMoOSr/Oq33IF+W2sbnkceHamoCFBOutfadtCpjbMkliqt KneegqNpVaxo5Phot87pOybxbrO6Q2gUYKEavqcXL4KdrnReErkhX6d0veQ= X-SW-Source: 2017-q1/txt/msg00117.txt.bz2 --Apple-Mail=_0FB71B17-865C-4CBA-8EFC-13CAF592FF1A Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 Content-length: 212 Hi, I observed that readelf and elfutils sometimes report different results. PF= A a patch that corrects this. I=E2=80=99m not sure whether the way I tackle= d the problem is acceptable. Kind Regards, Torsten --Apple-Mail=_0FB71B17-865C-4CBA-8EFC-13CAF592FF1A Content-Disposition: attachment; filename=0001-libdw-prepend-current-directory-in-read_srclines.patch Content-Type: application/octet-stream; x-unix-mode=0644; name="0001-libdw-prepend-current-directory-in-read_srclines.patch" Content-Transfer-Encoding: quoted-printable Content-length: 2459 >From dfd639e4e7377ce63d4e7296c0c139b7bf37167e Mon Sep 17 00:00:00 2001=0A= From: Torsten Polle =0A= Date: Sat, 18 Mar 2017 07:32:39 +0100=0A= Subject: [PATCH] libdw: prepend current directory in read_srclines=0A= =0A= read_srclines retrieves sometimes only relative paths for a source=0A= file. The file entry in the line number program header refers to an=0A= entry in the field "include_directories" that is a relative path. We=0A= prepend the current directory of the compilation to make this an=0A= absolute path.=0A= =0A= Signed-off-by: Torsten Polle =0A= ---=0A= libdw/dwarf_getsrclines.c | 26 +++++++++++++++++++++-----=0A= 1 file changed, 21 insertions(+), 5 deletions(-)=0A= =0A= diff --git a/libdw/dwarf_getsrclines.c b/libdw/dwarf_getsrclines.c=0A= index d02c38d..83a511e 100644=0A= --- a/libdw/dwarf_getsrclines.c=0A= +++ b/libdw/dwarf_getsrclines.c=0A= @@ -369,11 +369,28 @@ read_srclines (Dwarf *dbg,=0A= new_file->info.name =3D fname;=0A= else=0A= {=0A= - new_file->info.name =3D libdw_alloc (dbg, char, 1,=0A= - dirarray[diridx].len + 1=0A= - + fnamelen + 1);=0A= + size_t len =3D dirarray[diridx].len + 1 + fnamelen + 1;=0A= + if (dirarray[diridx].dir !=3D NULL=0A= + && *dirarray[diridx].dir !=3D '/'=0A= + && dirarray[0].dir !=3D NULL)=0A= + {=0A= + /* If the directory is a relative path, we need to make=0A= + room for the compile directory. */=0A= + len +=3D dirarray[0].len + 1;=0A= + }=0A= + new_file->info.name =3D libdw_alloc (dbg, char, 1, len);=0A= char *cp =3D new_file->info.name;=0A= =20=0A= + if (dirarray[diridx].dir !=3D NULL=0A= + && *dirarray[diridx].dir !=3D '/'=0A= + && dirarray[0].dir !=3D NULL)=0A= + {=0A= + /* If the directory is a relative path, we prepend the=0A= + compile directory. */=0A= + cp =3D stpcpy (cp, dirarray[0].dir);=0A= + *cp++ =3D '/';=0A= + }=0A= +=0A= if (dirarray[diridx].dir !=3D NULL)=0A= {=0A= /* This value could be NULL in case the DW_AT_comp_dir=0A= @@ -384,8 +401,7 @@ read_srclines (Dwarf *dbg,=0A= }=0A= *cp++ =3D '/';=0A= strcpy (cp, fname);=0A= - assert (strlen (new_file->info.name)=0A= - < dirarray[diridx].len + 1 + fnamelen + 1);=0A= + assert (strlen (new_file->info.name) < len);=0A= }=0A= =20=0A= /* Next comes the modification time. */=0A= --=20=0A= 2.7.4=0A= =0A= --Apple-Mail=_0FB71B17-865C-4CBA-8EFC-13CAF592FF1A--