GNU bug report logs - #23531
C++ shared library breaks with "-pie -fpie" and libtool

Previous Next

Package: libtool;

Reported by: manuel.bachmann <at> iot.bzh

Date: Fri, 13 May 2016 16:14:02 UTC

Severity: normal

To reply to this bug, email your comments to 23531 AT debbugs.gnu.org.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-libtool <at> gnu.org:
bug#23531; Package libtool. (Fri, 13 May 2016 16:14:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to manuel.bachmann <at> iot.bzh:
New bug report received and forwarded. Copy sent to bug-libtool <at> gnu.org. (Fri, 13 May 2016 16:14:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Manuel Bachmann <manuel.bachmann <at> iot.bzh>
To: bug-libtool <at> gnu.org
Subject: C++ shared library breaks with "-pie -fpie" and libtool
Date: Fri, 13 May 2016 14:04:00 +0200
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




Information forwarded to bug-libtool <at> gnu.org:
bug#23531; Package libtool. (Fri, 13 May 2016 18:31:01 GMT) Full text and rfc822 format available.

Message #8 received at 23531 <at> debbugs.gnu.org (full text, mbox):

From: Mike Frysinger <vapier <at> gentoo.org>
To: Manuel Bachmann <manuel.bachmann <at> iot.bzh>
Cc: 23531 <at> debbugs.gnu.org
Subject: Re: bug#23531: C++ shared library breaks with "-pie -fpie" and libtool
Date: Fri, 13 May 2016 14:30:23 -0400
[Message part 1 (text/plain, inline)]
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
[signature.asc (application/pgp-signature, inline)]

Information forwarded to bug-libtool <at> gnu.org:
bug#23531; Package libtool. (Sat, 14 May 2016 15:28:01 GMT) Full text and rfc822 format available.

Message #11 received at 23531 <at> debbugs.gnu.org (full text, mbox):

From: Manuel Bachmann <manuel.bachmann <at> iot.bzh>
To: Manuel Bachmann <manuel.bachmann <at> iot.bzh>, 23531 <at> debbugs.gnu.org
Subject: Re: bug#23531: C++ shared library breaks with "-pie -fpie" and libtool
Date: Sat, 14 May 2016 17:27:31 +0200
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 <vapier <at> gentoo.org>:
> 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




This bug report was last modified 9 years and 121 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.