From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,HTML_MESSAGE,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL autolearn=ham autolearn_force=no version=3.4.2 Received: from mother.openwall.net (mother.openwall.net [195.42.179.200]) by inbox.vuxu.org (OpenSMTPD) with SMTP id 76fa2a2a for ; Wed, 29 Jan 2020 23:10:48 +0000 (UTC) Received: (qmail 27925 invoked by uid 550); 29 Jan 2020 23:10:46 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Reply-To: musl@lists.openwall.com Received: (qmail 27907 invoked from network); 29 Jan 2020 23:10:46 -0000 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; bh=Ny3YHZpVKSdasYPQEne5r+GiA5qRS8G9yWibjeWE3VA=; b=oENQ7fBx5YqN1IB6sOnS56QwAbqAlolqba3KnGeu4LIP6YHk+808lTEwtzrYy+rNOf /RyRR1ciqdix4wVyTrQn1BRY9cmI/jLb/wzaT2ndZtsZB32uHWebJ4foopSrxGNisgu/ UN85LYnfLFizTj7tsLynSnlbgJeU2x5e25d9PMGu5TzpotX0hg39LGhB9G/TrMtf3IsY 63X/XSQr1zP15JoDDFb7CHQfkMcV/vxgkBsGHyaGosJBxi397ZehrrxHknzFCmtUUKAS sbSV4E1hMOtS9YrYu+ejwCTGYmoui6kVxxkKky5rHK7xqmSEFfkFDR2hgvyihgnmN6Yj JTtg== 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; bh=Ny3YHZpVKSdasYPQEne5r+GiA5qRS8G9yWibjeWE3VA=; b=Xj1QLFYP4rFonELWz2ym/0KlZMxmt+EcPQkRjRw4XQOSP3LGiujLo/kVG4vqi9uL2S 4WU9F/80sCyq3yj/m1JmAcWlM+MArkmg+dcFc1Fi04+cCGgixO95PfwtxidfsL2ekbki 7b/Bgx8K0DnbLbjb6tgQqOYTKEWIsbXDrsgO6TmVmTzJELwLJ5bWxmBGQxDh/6pFP10m 2vP87B67hawvgwn7tJQKU5gEo8ncAVIKaEacb8r9tzrA7WQk8UocmgE8yhhZCGGiI9Y0 4bGDszpEHPrYYPXU5fIcZnwggL+0cmM2424UZ/QG1KiHga33E1cSZrbf0LDPaTj5kD+C OtVg== X-Gm-Message-State: APjAAAWktTllgIBX2u7O5Godid82bW4+s/5TcK9xJsxHyIZG0r0Yt/rA fAn0BFXoub7zdUmH/QNDHvPRL8s/dM7rZ0YuA3SFvogGLxI= X-Google-Smtp-Source: APXvYqxNGKt6x7oWtU7cXva1AtG2QyKc1GgIiC2SzQIkl22CejSTejgLaYhdL/3imQ3gBQ848Br0kqNp5OfSAT9ZSUY= X-Received: by 2002:a2e:89d4:: with SMTP id c20mr902939ljk.228.1580339435024; Wed, 29 Jan 2020 15:10:35 -0800 (PST) MIME-Version: 1.0 References: <20200129205330.GK30412@brightrain.aerifal.cx> <20200129211024.GY23985@port70.net> <20200129214641.GN30412@brightrain.aerifal.cx> In-Reply-To: <20200129214641.GN30412@brightrain.aerifal.cx> From: =?UTF-8?B?0JDQvdC00YDQtdC5INCQ0LvQsNC00YzQtdCy?= Date: Thu, 30 Jan 2020 02:10:24 +0300 Message-ID: To: musl@lists.openwall.com Content-Type: multipart/alternative; boundary="000000000000a636cf059d4f72a0" Subject: Re: [musl] Static linking is broken after creation of DT_TEXTREL segment --000000000000a636cf059d4f72a0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable I've tested and both "-fno-pie" and "-static" are not compatible with some gcc and clang sanitizers, so these solutions are bad. Found right solution in gmp source. It was hidden in configure: "--with-pic" option. I've enabled it and now both glibc and musl works perfect. Created gentoo bug https://bugs.gentoo.org/707332. For everyone who will read this thread - you need to enable "--with-pic" option for gmp. You don't need to disable assembly completely. So on this week I will try to create small user friendly patch for musl about readonly relocations. =D1=87=D1=82, 30 =D1=8F=D0=BD=D0=B2. 2020 =D0=B3. =D0=B2 00:46, Rich Felker= : > On Thu, Jan 30, 2020 at 12:35:52AM +0300, =D0=90=D0=BD=D0=B4=D1=80=D0=B5= =D0=B9 =D0=90=D0=BB=D0=B0=D0=B4=D1=8C=D0=B5=D0=B2 wrote: > > "readelf -d main | grep TEXTREL" returns the same text on both musl and > > glibc containers: > > > > 0x0000000000000016 (TEXTREL) 0x0 > > 0x000000000000001e (FLAGS) TEXTREL > > > > "gcc -no-pie" is another workaround for musl container like Rich said. > But > > I think that 'set(CMAKE_EXE_LINKER_FLAGS "-static")' will be best cross > > platform solution. As I know "-static" implies "no-pie". > > -static normally does not imply -no-pie with musl target. musl was the > first to introduce static pie, and it was not treated as something > special/weird you have to request, just what you get with -static + > -pie or -static and default-pie toolchain. > > When GCC upstreamed static pie with glibc support, they made it so > -static overrides -pie and so you need the new -static-pie to get > static pie. musl patches for gcc revert this change since it's a > regression to the original behavior, treats static-pie a second-class, > and does not work with environments where pie is mandatory (like nommu > targets) where default-pie *must* be honored. > > Rich > --000000000000a636cf059d4f72a0 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
I've tested and both "-fno-pie" and "-s= tatic" are not compatible with some gcc and clang sanitizers, so these= solutions are bad.

Found right solution in gmp source. = It was hidden in configure: "--with-pic" option. I've enabled= it and now both glibc and musl works perfect. Created gentoo bug=C2=A0https://bugs.gentoo.org/707332. = For everyone who will read this thread - you need to enable "--with-pi= c" option for gmp. You don't need to disable assembly completely.<= /div>

So on this week I will try to create small user fr= iendly patch for musl about readonly relocations.

=D1=87=D1=82, 30 =D1= =8F=D0=BD=D0=B2. 2020 =D0=B3. =D0=B2 00:46, Rich Felker <dalias@libc.org>:
On Thu, Jan 30, 2020 at 12:35:52AM +0300, =D0= =90=D0=BD=D0=B4=D1=80=D0=B5=D0=B9 =D0=90=D0=BB=D0=B0=D0=B4=D1=8C=D0=B5=D0= =B2 wrote:
> "readelf -d main | grep TEXTREL" returns the same text on bo= th musl and
> glibc containers:
>
> 0x0000000000000016 (TEXTREL) 0x0
> 0x000000000000001e (FLAGS)=C2=A0 =C2=A0 =C2=A0TEXTREL
>
> "gcc -no-pie" is another workaround for musl container like = Rich said. But
> I think that 'set(CMAKE_EXE_LINKER_FLAGS "-static")'= will be best cross
> platform solution. As I know "-static" implies "no-pie&= quot;.

-static normally does not imply -no-pie with musl target. musl was the
first to introduce static pie, and it was not treated as something
special/weird you have to request, just what you get with -static +
-pie or -static and default-pie toolchain.

When GCC upstreamed static pie with glibc support, they made it so
-static overrides -pie and so you need the new -static-pie to get
static pie. musl patches for gcc revert this change since it's a
regression to the original behavior, treats static-pie a second-class,
and does not work with environments where pie is mandatory (like nommu
targets) where default-pie *must* be honored.

Rich
--000000000000a636cf059d4f72a0--