From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by yocto-www.yoctoproject.org (Postfix, from userid 118) id 6099AE00CAB; Fri, 24 May 2019 18:58:19 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on yocto-www.yoctoproject.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,FREEMAIL_REPLY,HTML_MESSAGE, RCVD_IN_DNSWL_NONE autolearn=no version=3.3.1 X-Spam-HAM-Report: * -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% * [score: 0.0000] * 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider * (lookatyouhacker[at]gmail.com) * -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no * trust * [209.85.167.182 listed in list.dnswl.org] * 0.0 HTML_MESSAGE BODY: HTML included in message * -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's * domain * -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature * 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily * valid * 1.0 FREEMAIL_REPLY From and body contain different freemails Received: from mail-oi1-f182.google.com (mail-oi1-f182.google.com [209.85.167.182]) by yocto-www.yoctoproject.org (Postfix) with ESMTP id 1A2D3E008E3 for ; Fri, 24 May 2019 18:58:18 -0700 (PDT) Received: by mail-oi1-f182.google.com with SMTP id v2so8362758oie.6 for ; Fri, 24 May 2019 18:58:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=POFEcQdAoW2xcHyrRRtQyZnZEyp5g+Owj/CXaoptcWk=; b=B/jBLdxiee1LPIfUejclWSFCWBtQe98lkef5Xb2fKBzx1HI8BX36cynfrAOh2dilE4 9DUW3v4VIe0jtd9rucfzlg5JmA4TnbLVMWdaGCKMe6Q6idRrVZwy81EZ9eGdNV8RYzGP +2E+uA2IujuV24N1nYOOvitozKpY3zRivyyHEiSJWrL6pVoSikMcX8bjpNRgfMAMbp8Y 3tRNycXyrwm2gKF10WmAwm7UQOLz2urGdHL3T0WN6rkBzXYel8bwX6HFEYmq7A0RzuGC qnJJskmmJpemnOAUSo62CfM76TlaAhUZI5Vu7gdddxcogvq6QwMIO+EeJT2eESD89Ehb xg3g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=POFEcQdAoW2xcHyrRRtQyZnZEyp5g+Owj/CXaoptcWk=; b=YnHXssqCyfqzwOaL4jlhmH+xD8QvBF5GN6d2o1LX8PEP6vbb8ydqIGJvsg9ledRVZB sLh66s9e76qtY1g0CFseTy4fnwhWXWmawrLCXF59Jg2/jh+dK6UDREhHjAqsfWUNfCkF bvxpvuv/jyYGK8ZWoIhS3S7mX1VpGdqUkFkuIdN2LGXY6bhNCZxOQnvqPiGyMRTvtqwu REGd15shILQpzVHNqrAneBIWBaVw0yMz/YBojik2WFC9lqZHm4SZsdn1521kBtHuDKMT A7aNuLlhTpKDARGdkZVBgPCBohJ23P9YhnWybdnHk8KkyVmT0dCWy8vKW6obI2dNB0l5 Y3Vw== X-Gm-Message-State: APjAAAX1XA0k7GBsAqupU0L7BfqBgw3bKgct9eoKORhdxCPou+lMy/bs mAm4VdlcKmFg7PE9hyFXaQBSdWiYyYFuObisxro= X-Google-Smtp-Source: APXvYqyJ8hvz1s4U9atYVIyVgfQ5ZNcA4YMKZxyRlA07UyeZSDn11HsOpNn4gaxOXEXnMSxigG16Jvul7BTSVhsKSTI= X-Received: by 2002:aca:7549:: with SMTP id q70mr8495019oic.58.1558749497424; Fri, 24 May 2019 18:58:17 -0700 (PDT) MIME-Version: 1.0 References: <50b3ec46-1c13-f0cb-64eb-bde7809db99d@gmail.com> <74876fa3-2e5f-60a6-f5e7-2a4a6242bac1@gmail.com> In-Reply-To: <74876fa3-2e5f-60a6-f5e7-2a4a6242bac1@gmail.com> From: Shane Peelar Date: Fri, 24 May 2019 21:58:10 -0400 Message-ID: To: Khem Raj Cc: yocto@yoctoproject.org Subject: Re: prelink-cross with -fno-plt X-BeenThere: yocto@yoctoproject.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Discussion of all things Yocto Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 25 May 2019 01:58:19 -0000 Content-Type: multipart/alternative; boundary="00000000000016816e0589aca688" --00000000000016816e0589aca688 Content-Type: text/plain; charset="UTF-8" Great! Would you be willing to accept a patch that makes arch-x86_64.c handle that condition like the other arches? -Shane On Fri, May 24, 2019 at 12:27 PM Khem Raj wrote: > > > On 5/24/19 8:10 AM, Shane Peelar wrote: > > I did some reading into the sources in other architectures. The closest > > match, arch_i386.c, makes the write conditional as you say. > > So do other arches, including |arch_arm.c, |arch_sh.c, |arch-mips.c, > > |arch-s390.c, |arch-s390x.c, and |arch-ia64.c.|||||| > > |||||| > > |||||| > > Notably, |||||||arch-cris.c||||||| has the same assert as > > |||||||arch-x86_64.c||||||| instead of the conditional. > > > > The code roughly looks like follows:|||||||||||||| > > |||||||||||||| > > ||||||| > > ||||||| > > 1. Check for dso->info[DT_PLTGOT]. If it does not exist, return 0 > > 2. Call addr_to_sec on dso->info[DT_PLTGOT], return 1 if error > > 3. Look for the section named ".plt" in the ELF. > > 4. If the section cannot be found, return 0 > > 5. Otherwise, write the address of .plt + constant (dependent on arch) > > to got[1]|||||||||||||| > > |||||||||||||| > > ||||||| > > ||||||| > > In |||||||arch-x86_64.c and arch-cris.c|||||||, step (4) above is an > > assert:||||||| > > > > |||||||1. Check for dso->info[DT_PLTGOT]. If it does not exist, return 0 > > 2. Call addr_to_sec on dso->info[DT_PLTGOT], return 1 if error > > 3. Look for the section named ".plt" in the ELF. > > 4. Assert that the section was found > > 5. Write the address of .plt + constant (dependent on arch) to got[1] > > > > I tested out making the assert conditional and nothing seemed to break > > at least. > > ||||||| > > ||||||| > > It seems ok to me. > > > > > On Fri, May 24, 2019 at 12:08 AM Khem Raj > > wrote: > > > > > > > > On 5/23/19 7:53 PM, Shane Peelar wrote: > > > Any of them on the system pretty much, and yes they are also > > built with > > > -fno-plt. > > > > OK, I think its better to them conditionally check for .plt section, > > can you describe more of whats going on when sections are checked. > > > > > > > > On Thu, May 23, 2019 at 9:59 PM Khem Raj > > > > >> wrote: > > > > > > > > > > > > On 5/23/19 8:05 AM, Shane Peelar wrote: > > > > Hi Everyone @ the Yocto project, > > > > > > > > I'm Shane Peelar, a PhD Candidate at the University of > > Windsor. > > > > I'm writing to you about prelink-cross, as part of the > > Yocto project. > > > > Specifically, I'm looking at using it with executables > > built using > > > > `-fno-plt` under GCC. > > > > I wasn't quite sure where to send this email to, so I > > figured I'd > > > try > > > > here. If there's a better place to send this, please let > > me know. > > > > > > > > Right now, prelink-cross seems to fail an assertion in > > > arch-x86_64.c, > > > > line 421, when > > > > using it with an executable built with `-fno-plt`: > > > > > > > > ... > > > > assert (i < dso->ehdr.e_shnum) > > > > ... > > > > > > > > This snippet seems to be looking for the ".plt" section > and, > > > since it > > > > can't find it, the assertion fires. This makes sense > > because in > > > > `-fno-plt` executables, the `.plt` section is missing > > entirely. > > > > I'm not an expert on ELF stuff, although I am learning > > quickly. It > > > > looks like > > > > this code wants to write into GOT[1] the address of ".plt" > > + 0x16 -- > > > > since ".plt" doesn't > > > > exist, does it make sense to just change this assert to an > if > > > statement > > > > like so: > > > > > > > > ... > > > > if (i < dso->ehdr.e_shnum) > > > > { ... } > > > > ... > > > > > > > > and skip over that part? Or is this a real error > > condition for > > > > prelink-cross and it really should not continue? The > > executable in > > > > question is also non-PIE, if that makes a difference. > > > > > > > > > > what shared libs is this linking to ? are they also built with > > > -fno-plt ? > > > > > > > Thanks for your time, > > > > Shane > > > > > > > > > > --00000000000016816e0589aca688 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Great!=C2=A0 Would you be willing to accept a patch t= hat makes arch-x86_64.c handle that condition like the other arches?
<= div>
-Shane

On Fri, May 24, 2019 at 12:27 PM Khem Ra= j <raj.khem@gmail.com> wrot= e:


On 5/24/19 8:10 AM, Shane Peelar wrote:
> I did some reading into the sources in other architectures.=C2=A0 The = closest
> match, arch_i386.c, makes the write conditional as you say.
> So do other arches, including |arch_arm.c, |arch_sh.c, |arch-mips.c, <= br> > |arch-s390.c, |arch-s390x.c, and |arch-ia64.c.||||||
> ||||||
> ||||||
> Notably, |||||||arch-cris.c||||||| has the same assert as
> |||||||arch-x86_64.c||||||| instead of the conditional.
>
> The code roughly looks like follows:||||||||||||||
> ||||||||||||||
> |||||||
> |||||||
> 1. Check for dso->info[DT_PLTGOT].=C2=A0 If it does not exist, retu= rn 0
> 2. Call addr_to_sec on dso->info[DT_PLTGOT], return 1 if error
> 3. Look for the section named ".plt" in the ELF.
> 4. If the section cannot be found, return 0
> 5. Otherwise, write the address of .plt + constant (dependent on arch)=
> to got[1]||||||||||||||
> ||||||||||||||
> |||||||
> |||||||
> In |||||||arch-x86_64.c and arch-cris.c|||||||, step (4) above is an <= br> > assert:|||||||
>
> |||||||1. Check for dso->info[DT_PLTGOT].=C2=A0 If it does not exis= t, return 0
> 2. Call addr_to_sec on dso->info[DT_PLTGOT], return 1 if error
> 3. Look for the section named ".plt" in the ELF.
> 4. Assert that the section was found
> 5. Write the address of .plt + constant (dependent on arch) to got[1]<= br> >
> I tested out making the assert conditional and nothing seemed to break=
> at least.
> |||||||
> |||||||

It seems ok to me.

>
> On Fri, May 24, 2019 at 12:08 AM Khem Raj <raj.khem@gmail.com
> <mailto:raj= .khem@gmail.com>> wrote:
>
>
>
>=C2=A0 =C2=A0 =C2=A0On 5/23/19 7:53 PM, Shane Peelar wrote:
>=C2=A0 =C2=A0 =C2=A0 > Any of them on the system pretty much, and ye= s they are also
>=C2=A0 =C2=A0 =C2=A0built with
>=C2=A0 =C2=A0 =C2=A0 > -fno-plt.
>
>=C2=A0 =C2=A0 =C2=A0OK, I think its better to them conditionally check = for .plt section,
>=C2=A0 =C2=A0 =C2=A0can you describe more of whats going on when sectio= ns are checked.
>
>=C2=A0 =C2=A0 =C2=A0 >
>=C2=A0 =C2=A0 =C2=A0 > On Thu, May 23, 2019 at 9:59 PM Khem Raj <= raj.khem@gmail.com<= /a>
>=C2=A0 =C2=A0 =C2=A0<mailto:
raj.khem@gmail.com>
>=C2=A0 =C2=A0 =C2=A0 > <mailto:raj.khem@gmail.com <mailto:raj.khem@gmail.com>>> wro= te:
>=C2=A0 =C2=A0 =C2=A0 >
>=C2=A0 =C2=A0 =C2=A0 >
>=C2=A0 =C2=A0 =C2=A0 >
>=C2=A0 =C2=A0 =C2=A0 >=C2=A0 =C2=A0 =C2=A0On 5/23/19 8:05 AM, Shane = Peelar wrote:
>=C2=A0 =C2=A0 =C2=A0 >=C2=A0 =C2=A0 =C2=A0 > Hi Everyone @ the Yo= cto project,
>=C2=A0 =C2=A0 =C2=A0 >=C2=A0 =C2=A0 =C2=A0 >
>=C2=A0 =C2=A0 =C2=A0 >=C2=A0 =C2=A0 =C2=A0 > I'm Shane Peelar= , a PhD Candidate at the University of
>=C2=A0 =C2=A0 =C2=A0Windsor.
>=C2=A0 =C2=A0 =C2=A0 >=C2=A0 =C2=A0 =C2=A0 > I'm writing to y= ou about prelink-cross, as part of the
>=C2=A0 =C2=A0 =C2=A0Yocto project.
>=C2=A0 =C2=A0 =C2=A0 >=C2=A0 =C2=A0 =C2=A0 > Specifically, I'= m looking at using it with executables
>=C2=A0 =C2=A0 =C2=A0built using
>=C2=A0 =C2=A0 =C2=A0 >=C2=A0 =C2=A0 =C2=A0 > `-fno-plt` under GCC= .
>=C2=A0 =C2=A0 =C2=A0 >=C2=A0 =C2=A0 =C2=A0 > I wasn't quite s= ure where to send this email to, so I
>=C2=A0 =C2=A0 =C2=A0figured I'd
>=C2=A0 =C2=A0 =C2=A0 >=C2=A0 =C2=A0 =C2=A0try
>=C2=A0 =C2=A0 =C2=A0 >=C2=A0 =C2=A0 =C2=A0 > here.=C2=A0 If there= 's a better place to send this, please let
>=C2=A0 =C2=A0 =C2=A0me know.
>=C2=A0 =C2=A0 =C2=A0 >=C2=A0 =C2=A0 =C2=A0 >
>=C2=A0 =C2=A0 =C2=A0 >=C2=A0 =C2=A0 =C2=A0 > Right now, prelink-c= ross seems to fail an assertion in
>=C2=A0 =C2=A0 =C2=A0 >=C2=A0 =C2=A0 =C2=A0arch-x86_64.c,
>=C2=A0 =C2=A0 =C2=A0 >=C2=A0 =C2=A0 =C2=A0 > line 421, when
>=C2=A0 =C2=A0 =C2=A0 >=C2=A0 =C2=A0 =C2=A0 > using it with an exe= cutable built with `-fno-plt`:
>=C2=A0 =C2=A0 =C2=A0 >=C2=A0 =C2=A0 =C2=A0 >
>=C2=A0 =C2=A0 =C2=A0 >=C2=A0 =C2=A0 =C2=A0 > ...
>=C2=A0 =C2=A0 =C2=A0 >=C2=A0 =C2=A0 =C2=A0 > assert (i < dso-&= gt;ehdr.e_shnum)
>=C2=A0 =C2=A0 =C2=A0 >=C2=A0 =C2=A0 =C2=A0 > ...
>=C2=A0 =C2=A0 =C2=A0 >=C2=A0 =C2=A0 =C2=A0 >
>=C2=A0 =C2=A0 =C2=A0 >=C2=A0 =C2=A0 =C2=A0 > This snippet seems t= o be looking for the ".plt" section and,
>=C2=A0 =C2=A0 =C2=A0 >=C2=A0 =C2=A0 =C2=A0since it
>=C2=A0 =C2=A0 =C2=A0 >=C2=A0 =C2=A0 =C2=A0 > can't find it, t= he assertion fires.=C2=A0 This makes sense
>=C2=A0 =C2=A0 =C2=A0because in
>=C2=A0 =C2=A0 =C2=A0 >=C2=A0 =C2=A0 =C2=A0 > `-fno-plt` executabl= es, the `.plt` section is missing
>=C2=A0 =C2=A0 =C2=A0entirely.
>=C2=A0 =C2=A0 =C2=A0 >=C2=A0 =C2=A0 =C2=A0 > I'm not an exper= t on ELF stuff, although I am learning
>=C2=A0 =C2=A0 =C2=A0quickly.=C2=A0 It
>=C2=A0 =C2=A0 =C2=A0 >=C2=A0 =C2=A0 =C2=A0 > looks like
>=C2=A0 =C2=A0 =C2=A0 >=C2=A0 =C2=A0 =C2=A0 > this code wants to w= rite into GOT[1] the address of ".plt"
>=C2=A0 =C2=A0 =C2=A0+ 0x16 --
>=C2=A0 =C2=A0 =C2=A0 >=C2=A0 =C2=A0 =C2=A0 > since ".plt&quo= t; doesn't
>=C2=A0 =C2=A0 =C2=A0 >=C2=A0 =C2=A0 =C2=A0 > exist, does it make = sense to just change this assert to an if
>=C2=A0 =C2=A0 =C2=A0 >=C2=A0 =C2=A0 =C2=A0statement
>=C2=A0 =C2=A0 =C2=A0 >=C2=A0 =C2=A0 =C2=A0 > like so:
>=C2=A0 =C2=A0 =C2=A0 >=C2=A0 =C2=A0 =C2=A0 >
>=C2=A0 =C2=A0 =C2=A0 >=C2=A0 =C2=A0 =C2=A0 > ...
>=C2=A0 =C2=A0 =C2=A0 >=C2=A0 =C2=A0 =C2=A0 >=C2=A0 =C2=A0 =C2=A0 = =C2=A0 if (i < dso->ehdr.e_shnum)
>=C2=A0 =C2=A0 =C2=A0 >=C2=A0 =C2=A0 =C2=A0 >=C2=A0 =C2=A0 =C2=A0 = =C2=A0 { ... }
>=C2=A0 =C2=A0 =C2=A0 >=C2=A0 =C2=A0 =C2=A0 > ...
>=C2=A0 =C2=A0 =C2=A0 >=C2=A0 =C2=A0 =C2=A0 >
>=C2=A0 =C2=A0 =C2=A0 >=C2=A0 =C2=A0 =C2=A0 > and skip over that p= art?=C2=A0 Or is this a real error
>=C2=A0 =C2=A0 =C2=A0condition for
>=C2=A0 =C2=A0 =C2=A0 >=C2=A0 =C2=A0 =C2=A0 > prelink-cross and it= really should not continue?=C2=A0 The
>=C2=A0 =C2=A0 =C2=A0executable in
>=C2=A0 =C2=A0 =C2=A0 >=C2=A0 =C2=A0 =C2=A0 > question is also non= -PIE, if that makes a difference.
>=C2=A0 =C2=A0 =C2=A0 >=C2=A0 =C2=A0 =C2=A0 >
>=C2=A0 =C2=A0 =C2=A0 >
>=C2=A0 =C2=A0 =C2=A0 >=C2=A0 =C2=A0 =C2=A0what shared libs is this l= inking to ? are they also built with
>=C2=A0 =C2=A0 =C2=A0 >=C2=A0 =C2=A0 =C2=A0-fno-plt ?
>=C2=A0 =C2=A0 =C2=A0 >
>=C2=A0 =C2=A0 =C2=A0 >=C2=A0 =C2=A0 =C2=A0 > Thanks for your time= ,
>=C2=A0 =C2=A0 =C2=A0 >=C2=A0 =C2=A0 =C2=A0 > Shane
>=C2=A0 =C2=A0 =C2=A0 >=C2=A0 =C2=A0 =C2=A0 >
>=C2=A0 =C2=A0 =C2=A0 >
>
--00000000000016816e0589aca688--