From unknown Thu Sep 11 03:25:21 2025 X-Loop: help-debbugs@gnu.org Subject: bug#23531: C++ shared library breaks with "-pie -fpie" and libtool Resent-From: Manuel Bachmann Original-Sender: "Debbugs-submit" Resent-CC: bug-libtool@gnu.org Resent-Date: Fri, 13 May 2016 16:14:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 23531 X-GNU-PR-Package: libtool X-GNU-PR-Keywords: To: 23531@debbugs.gnu.org X-Debbugs-Original-To: bug-libtool@gnu.org Reply-To: manuel.bachmann@iot.bzh Received: via spool by submit@debbugs.gnu.org id=B.146315603626517 (code B ref -1); Fri, 13 May 2016 16:14:02 +0000 Received: (at submit) by debbugs.gnu.org; 13 May 2016 16:13:56 +0000 Received: from localhost ([127.0.0.1]:50134 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1b1Fit-0006tc-9L for submit@debbugs.gnu.org; Fri, 13 May 2016 12:13:56 -0400 Received: from eggs.gnu.org ([208.118.235.92]:42388) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1b1BpP-0000ps-HR for submit@debbugs.gnu.org; Fri, 13 May 2016 08:04:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b1BpF-00089e-Ov for submit@debbugs.gnu.org; Fri, 13 May 2016 08:04:18 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50,T_DKIM_INVALID autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:46430) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b1BpF-00089M-LU for submit@debbugs.gnu.org; Fri, 13 May 2016 08:04:13 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33341) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b1Bp8-0004V4-Ol for bug-libtool@gnu.org; Fri, 13 May 2016 08:04:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b1Bp3-00088C-TX for bug-libtool@gnu.org; Fri, 13 May 2016 08:04:05 -0400 Received: from mail-yw0-x243.google.com ([2607:f8b0:4002:c05::243]:33728) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b1Bp3-000885-L0 for bug-libtool@gnu.org; Fri, 13 May 2016 08:04:01 -0400 Received: by mail-yw0-x243.google.com with SMTP id y6so10895420ywe.0 for ; Fri, 13 May 2016 05:04:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=koumoul.net; s=dkim; h=mime-version:reply-to:sender:date:message-id:subject:from:to; bh=PuQ0JQlcpLqp4QzrrJJeljjlUAHnp57yxkTGm6ph5DM=; b=kxm/xuhXWY/aezYnlFmgGQtgd3Kedu35fUQbN4I9waXRdIkwmMIhYrT8zivYUZAa+Y 9HLr66tSvj5BWwClgt+5hahC/yp22P05E/dX/thy4j/okE51aUISO7Yh/1Fi2NDhxF3V 5Gpl/IyOjiqse2v0AW+5y9sZilI6GDiI0yTW8= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=iot-bzh.20150623.gappssmtp.com; s=20150623; h=mime-version:reply-to:sender:date:message-id:subject:from:to; bh=PuQ0JQlcpLqp4QzrrJJeljjlUAHnp57yxkTGm6ph5DM=; b=A2U8gJOERmH5xsQlOFJwvSwm1sXzkTmGL9iSkrAKNjc+OYBToRbFEiSXKET2+HogPZ R3KIM+xaBSMg2O053p0KNv66Rnfx0aTu5fuz8CN24nxzR98HGnNXAk1+h6g1Vn/Sw2+p NPEhCgjpv/aoV9nuL4KFlgH/sG6kqRtXjh9RK2OOOi8fVAfMoRfoVzrXuQokBjEgzasO L0in7D1pEZcfIHft/hpQP9AQgpAVcUQFjU+HClPewtl5ktgdyJHnTKqvbIkdYTequdG1 32hVXJbckUlMfDjTmj6bfr4D/XWvQFqOayD7a/GvgGYuUg2Tdka/ewb5zXKXSG/rkhw9 QrnQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:reply-to:sender:date:message-id :subject:from:to; bh=PuQ0JQlcpLqp4QzrrJJeljjlUAHnp57yxkTGm6ph5DM=; b=XFCBezDeHtYbLlwrzcaex8uWPsJineV+TkK2ehLk162AJi7XVC4BR68v6tYyucyeWe 8X37oBfdN5QUOOFhQsWw3HGd9rI5/i/1zIK8VBuYvjU6fJ+nznh1gbMbLwuBePMht4KI 7WBlTdSAp1AkSKe5V1UnihRkjk30Y6HMz7QUwRvWr/XfgWFIXpX9z/+510zZeM2v9Kl3 AV5QnI+jsh9+07Mv+64avb8vjuXNtczN4eFH9LTsGQ6CpqfaVvNS64iCmThJWIUbQ5SZ hjZJpA2y4y4QgWKb2xFHbB9al0YiRuNW1onKWDGBUOqdbxDX63dwncnEg2/kAZOrdLYg qf9Q== X-Gm-Message-State: AOPr4FXxZc6BhVphxBmuX/2Il8XNG/0ZEF3U9PWrWbU6Z92f9a33vJtj70VcR/ve7Tr450l/nJw8ITne8TlXnA== MIME-Version: 1.0 X-Received: by 10.129.138.199 with SMTP id a190mr6983199ywg.21.1463141040679; Fri, 13 May 2016 05:04:00 -0700 (PDT) Received: by 10.13.217.149 with HTTP; Fri, 13 May 2016 05:04:00 -0700 (PDT) X-Originating-IP: [86.253.108.95] Date: Fri, 13 May 2016 14:04:00 +0200 X-Google-Sender-Auth: mcMpG4qprf8KWnPweDLbJwD1Rcg Message-ID: From: Manuel Bachmann Content-Type: text/plain; charset=UTF-8 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -4.0 (----) X-Mailman-Approved-At: Fri, 13 May 2016 12:13:54 -0400 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -4.0 (----) Hi folks, I am building a C++ project [1] with libtool ; this project contains a shared library. Since recently, and as I am building with the Yocto project, I am required to build with GCC security enforcement options ([2], see SECURITY_FLAGS line). It basically adds the following flags in CFLAGS and CXXFLAGS : "-pie -fpie" This makes the build break on x86_64 with the following message (ARM has a similar one) : /usr/lib64/libc_nonshared.a(elf-init.oS): In function `__libc_csu_init': (.text+0x14): undefined reference to `__init_array_start' /bin/ld: /usr/lib64/libc_nonshared.a(elf-init.oS): relocation R_X86_64_PC32 against undefined hidden symbol `__init_array_start' can not be used when making a shared object Removing the "-pie" flag, alone, makes the build succeed. I was told that "-pie" flag is reserved for executables, not shared libraries or modules. But build logs [3] show that libtool is propagating both "-pie -fpie" flags in all steps, but the final linker step. Is this a libtool bug, not removing "-pie" in this case ? Or should we not include "-pie" in our CFLAGS in the first place ? Thanks for any advice ! [1] : https://github.com/iotbzh/qml_radio_plugin [2] : https://git.yoctoproject.org/cgit/cgit.cgi/poky/tree/meta/conf/distro/include/security_flags.inc [3] : http://hastebin.com/onerixofop.md [4]: https://github.com/iotbzh/qml_radio_plugin/blob/master/Makefile.am Regards, Manuel Bachmann, Graphics & Multimedia Engineer www.iot.bzh From unknown Thu Sep 11 03:25:21 2025 X-Loop: help-debbugs@gnu.org Subject: bug#23531: C++ shared library breaks with "-pie -fpie" and libtool Resent-From: Mike Frysinger Original-Sender: "Debbugs-submit" Resent-CC: bug-libtool@gnu.org Resent-Date: Fri, 13 May 2016 18:31:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 23531 X-GNU-PR-Package: libtool X-GNU-PR-Keywords: To: Manuel Bachmann Cc: 23531@debbugs.gnu.org Received: via spool by 23531-submit@debbugs.gnu.org id=B23531.146316423314449 (code B ref 23531); Fri, 13 May 2016 18:31:01 +0000 Received: (at 23531) by debbugs.gnu.org; 13 May 2016 18:30:33 +0000 Received: from localhost ([127.0.0.1]:50218 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1b1Hr6-0003kz-Rf for submit@debbugs.gnu.org; Fri, 13 May 2016 14:30:33 -0400 Received: from smtp.gentoo.org ([140.211.166.183]:43498) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1b1Hr4-0003kh-P5 for 23531@debbugs.gnu.org; Fri, 13 May 2016 14:30:31 -0400 Received: from vapier.lan (localhost [127.0.0.1]) by smtp.gentoo.org (Postfix) with SMTP id 015A13407B8; Fri, 13 May 2016 18:30:23 +0000 (UTC) Date: Fri, 13 May 2016 14:30:23 -0400 From: Mike Frysinger Message-ID: <20160513183023.GU26300@vapier.lan> Mail-Followup-To: Manuel Bachmann , 23531@debbugs.gnu.org References: MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="MO4t1VgQTCtsHhID" Content-Disposition: inline In-Reply-To: X-Spam-Score: -6.4 (------) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -6.4 (------) --MO4t1VgQTCtsHhID Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On 13 May 2016 14:04, Manuel Bachmann wrote: > I am building a C++ project [1] with libtool ; this project contains a > shared library. >=20 > Since recently, and as I am building with the Yocto project, I am > required to build with GCC security enforcement options ([2], see > SECURITY_FLAGS line). > It basically adds the following flags in CFLAGS and CXXFLAGS : "-pie -fpi= e" >=20 > This makes the build break on x86_64 with the following message (ARM > has a similar one) : >=20 > /usr/lib64/libc_nonshared.a(elf-init.oS): In function `__libc_csu_init': > (.text+0x14): undefined reference to `__init_array_start' > /bin/ld: /usr/lib64/libc_nonshared.a(elf-init.oS): relocation > R_X86_64_PC32 against undefined hidden symbol `__init_array_start' can > not be used when making a shared object >=20 > Removing the "-pie" flag, alone, makes the build succeed. >=20 > I was told that "-pie" flag is reserved for executables, not shared > libraries or modules. But build logs [3] show that libtool is > propagating both "-pie -fpie" flags in all steps, but the final linker > step. > Is this a libtool bug, not removing "-pie" in this case ? Or should we > not include "-pie" in our CFLAGS in the first place ? currently, i'd say it's a bug in your build to add -pie/-fPIE when trying to produce shared libs. however, i think it's worthwhile to expand libtool to produce PIE objects like it does with PIC/non-PIC. then it should be able to gather inputs correctly to produce shared libs (PIC/non-PIE) the same time as programs (PIE). whether that'll happen any time soon though ... :) -mike --MO4t1VgQTCtsHhID Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQIcBAEBCAAGBQJXNh0/AAoJEEFjO5/oN/WB4loQAIHvGzcNVdgD2bIUUDHXM+nf CX2ftnw65f94cMaBMsCvnMtG9G88Bi7UAJm9Xw2lckSjzQibCB/JTUV+WVmKxmoU 3EQyKOKymrtTlwIy1jPtOuujKAxrMtO90xGMZWFMrJ07eLQHGfoNeJp0zmGEK0LD 4lV/M1G6TmopJUZFNYqyxisigNt0QZx1Iz1AefXJOYhT2P7AjFf+mRvWR4RZI17g /p2y293tgG5zHYgA8Kjjrk1PLqK7G0oA0ZXC3MEiNIPgqG3myg2snkYtYi/B4cZ1 BavWHBj97nAPBy7fEDQhoVDe1zAyGMOlryBUisdxwLzFReSyOi0RzJ0Uf8qMSsQH UAwKQEPmPm6O67NolbN0XERq8Ajk12yj/9xS3RE9NwPqhzuc+WsJwYxvf1QMfBJI FtaUi5UAzar0G/AHdGymC3SE3qyNjgXjRCks23DVlor91cBjrwPvOR0bb7Uz+bvV TQdlCqNJeOog/1LWNGzccTb0M22tqzykHl+4WhNEBMvnAz/A2Hz9VGBwC7yrtv0Z ebqzftH8RIQRE7lhEwXSO9vYzIRiFtyNSc+vKWZsOST/UjLJYdLpzgSr6XVCi2Ie HmsoS1aZ/Xr8vPrnJsHB54RxNE4PPpdbCwRxSU4Lrw+ptuOsIb2ttpSfdxbT5oP/ ZYGGdph31N3vPyuTgm9/ =S9sm -----END PGP SIGNATURE----- --MO4t1VgQTCtsHhID-- From unknown Thu Sep 11 03:25:21 2025 X-Loop: help-debbugs@gnu.org Subject: bug#23531: C++ shared library breaks with "-pie -fpie" and libtool Resent-From: Manuel Bachmann Original-Sender: "Debbugs-submit" Resent-CC: bug-libtool@gnu.org Resent-Date: Sat, 14 May 2016 15:28:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 23531 X-GNU-PR-Package: libtool X-GNU-PR-Keywords: To: Manuel Bachmann , 23531@debbugs.gnu.org Reply-To: manuel.bachmann@iot.bzh Received: via spool by 23531-submit@debbugs.gnu.org id=B23531.146323965929525 (code B ref 23531); Sat, 14 May 2016 15:28:01 +0000 Received: (at 23531) by debbugs.gnu.org; 14 May 2016 15:27:39 +0000 Received: from localhost ([127.0.0.1]:51567 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1b1bTf-0007g9-4R for submit@debbugs.gnu.org; Sat, 14 May 2016 11:27:39 -0400 Received: from mail-yw0-f196.google.com ([209.85.161.196]:36629) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1b1bTd-0007fw-0l for 23531@debbugs.gnu.org; Sat, 14 May 2016 11:27:37 -0400 Received: by mail-yw0-f196.google.com with SMTP id u62so14392527ywe.3 for <23531@debbugs.gnu.org>; Sat, 14 May 2016 08:27:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=koumoul.net; s=dkim; h=mime-version:reply-to:sender:in-reply-to:references:date:message-id :subject:from:to; bh=Sw1M3Nb2STr3eA9fPFe1haRVw7HMCdqoVCphJioBHv0=; b=G7U+/g3/ves9fRVJyIcktt7zNR8007MAwl8/2Hm6vRS787oK52MjNYARHibI9s9k07 Q4qWSjGpqZ7SS/NYTx2DkPxpsrptxyg2xUw4xnBWnn/eJnYxtc5OjcEWKd3cb1KxCfDu un0ToAjI2Efgf5cny6DOrWmIthc9rGKpiKedU= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=iot-bzh.20150623.gappssmtp.com; s=20150623; h=mime-version:reply-to:sender:in-reply-to:references:date:message-id :subject:from:to; bh=Sw1M3Nb2STr3eA9fPFe1haRVw7HMCdqoVCphJioBHv0=; b=X5/8ZROlBkeFvc8LTR4Jl1bjXbe2YfqC9JhxT7zLH34Kxcfe0g+1EtDvL2gVVjQW+H KIKuQ5wVcXb+5HOp3fm3zRqol7ge9ArGuD6mXt76DyG6Zd7djsKh+txlcNvTMqBjdCo9 vDpfzZnQXAruE8tUdwHaQ9IlU2zGQJ/zD9z6qOCQz6NYuCFhp3VgWxo9qlRp42czpRog nns7mRbNlt41cJZVqtJzCkJUCrzA0277ycSCYXO+JHPZ5/xk6KTPGkvRwsRDs5KLmaMk FjbA0MxqDzaBUYVu24eH18wUyxNWazIFa2z/SjVMwVqAlNQCVWW+59NOlUe/86QGXMAt fgQA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:reply-to:sender:in-reply-to :references:date:message-id:subject:from:to; bh=Sw1M3Nb2STr3eA9fPFe1haRVw7HMCdqoVCphJioBHv0=; b=fZgyBRcuNBXUAdbAE1+KH7XY0AT/MMmTubXI+Y8nipFEMbZrWIZYM8E9SRdRJHSIW4 NfoIkS0aKGO0oSk3jKGC4QY7hWRf8tJfD+1rN/McGlhnb5NNpN1rfjh6kOkYo4Eo/aEl HO9SkIfIOKXoctZn2GfoRL5TMmqOGYZ6kJ3MGFrmVzm5I6Z92qYeZDoR4uMcuQT88HFQ x9V7S8xjji2sSumYJeepcy3Ci4WTFUaUaZgd7xug2IKx/+apDrWyNwo460A6m10UVd/y +Qdb1RLezQ53S/UzUR6R7+WDVO6iumFKiAGXapZGxiczKjYt/Gqr7v1IGuZ91p+VM+y3 BGHg== X-Gm-Message-State: AOPr4FV1yGRTXuEKsSGLXLYgqxYa0d3YQPDOmLCANMoBTPANjTdq35BCyrLUHK03l9DjjVhAAmE2/Zye9e5RyA== MIME-Version: 1.0 X-Received: by 10.37.114.3 with SMTP id n3mr10122124ybc.158.1463239651244; Sat, 14 May 2016 08:27:31 -0700 (PDT) Received: by 10.13.217.149 with HTTP; Sat, 14 May 2016 08:27:31 -0700 (PDT) X-Originating-IP: [89.81.60.108] In-Reply-To: <20160513183023.GU26300@vapier.lan> References: <20160513183023.GU26300@vapier.lan> Date: Sat, 14 May 2016 17:27:31 +0200 X-Google-Sender-Auth: WGdrR7F0sIMTQ4keOXR30EHlBYk Message-ID: From: Manuel Bachmann Content-Type: text/plain; charset=UTF-8 X-Spam-Score: -0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.0 (/) Hi Mike, Thanks a lot for the feedback ! So I better fix the build system (in this case, the Yocto one) first. Will take a look at libtool itself, but later. Regards, Manuel Bachmann, Graphics & Multimedia Engineer www.iot.bzh 2016-05-13 20:30 GMT+02:00 Mike Frysinger : > On 13 May 2016 14:04, Manuel Bachmann wrote: >> I am building a C++ project [1] with libtool ; this project contains a >> shared library. >> >> Since recently, and as I am building with the Yocto project, I am >> required to build with GCC security enforcement options ([2], see >> SECURITY_FLAGS line). >> It basically adds the following flags in CFLAGS and CXXFLAGS : "-pie -fpie" >> >> This makes the build break on x86_64 with the following message (ARM >> has a similar one) : >> >> /usr/lib64/libc_nonshared.a(elf-init.oS): In function `__libc_csu_init': >> (.text+0x14): undefined reference to `__init_array_start' >> /bin/ld: /usr/lib64/libc_nonshared.a(elf-init.oS): relocation >> R_X86_64_PC32 against undefined hidden symbol `__init_array_start' can >> not be used when making a shared object >> >> Removing the "-pie" flag, alone, makes the build succeed. >> >> I was told that "-pie" flag is reserved for executables, not shared >> libraries or modules. But build logs [3] show that libtool is >> propagating both "-pie -fpie" flags in all steps, but the final linker >> step. >> Is this a libtool bug, not removing "-pie" in this case ? Or should we >> not include "-pie" in our CFLAGS in the first place ? > > currently, i'd say it's a bug in your build to add -pie/-fPIE when trying > to produce shared libs. > > however, i think it's worthwhile to expand libtool to produce PIE objects > like it does with PIC/non-PIC. then it should be able to gather inputs > correctly to produce shared libs (PIC/non-PIE) the same time as programs > (PIE). whether that'll happen any time soon though ... :) > -mike