From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from out0.migadu.com (out0.migadu.com [IPv6:2001:41d0:2:267::]) by sourceware.org (Postfix) with ESMTPS id B0E203938C03 for ; Sat, 11 Jul 2020 07:50:11 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org B0E203938C03 Date: Sat, 11 Jul 2020 09:50:10 +0200 In-Reply-To: References: MIME-Version: 1.0 Subject: Re: Compiling gcc fails while trying to link libgcc To: Jim Wilson CC: gcc-help X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Peter Lamby Message-ID: <2DC9FA62-4556-48A5-A97D-0FF67A268489@peterlamby.de> X-Spam-Score: -0.10 X-Spam-Status: No, score=2.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FOREIGN_BODY, HTML_MESSAGE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=no autolearn_force=no version=3.4.2 X-Spam-Level: ** X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Content-Filtered-By: Mailman/MimeDel 2.1.29 X-BeenThere: gcc-help@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-help mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 11 Jul 2020 07:50:13 -0000 Hi Jim, removing both pie flags did the trick=2E I removed the fno-plt too=2E Thanks for your help=2E I like the default flag for pie=2E This way I don't have to set them via CFLAGS and have them break my library builds :) Best Peter Am 11=2E Juli 2020 03:35:38 MESZ schrieb Jim Wilson : >On Thu, Jul 9, 2020 at 1:51 AM Peter Lamby via Gcc-help > wrote: >> export CFLAGS=3D-pipe -march=3Dnative -fstack-protector-strong -fno-plt= \ >> -pie -fpie > >You can't use -pie when linking a shared library=2E So this isn't going >to work=2E Also the -fno-plt is suspicious=2E Can you compile a shared >library without plts? The -fpie is clearly wrong too=2E You need to do >this a different way=2E Note that gcc has a configure option >--enable-default-pie which will produce pie output by default, but >won't pass -pie to the linker with -static, -shared, or -r=2E And won't >add -fpie if -fpic was specified=2E > >rohan:2242$ gcc -shared -fpic -o tmp=2Eso tmp=2Ec >rohan:2243$ gcc -shared -fpic -o tmp=2Eso tmp=2Ec -pie >/usr/lib/gcc/x86_64-linux-gnu/7/=2E=2E/=2E=2E/=2E=2E/x86_64-linux-gnu/Scr= t1=2Eo: In >function `_start': >(=2Etext+0x20): undefined reference to `main' >collect2: error: ld returned 1 exit status >rohan:2244$ > >Jim --=20 Diese Nachricht wurde von meinem Android-Ger=C3=A4t mit K-9 Mail gesendet= =2E