From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18081 invoked by alias); 21 Feb 2011 14:42:04 -0000 Received: (qmail 18073 invoked by uid 22791); 21 Feb 2011 14:42:03 -0000 X-SWARE-Spam-Status: No, hits=-0.8 required=5.0 tests=AWL,BAYES_00,DKIM_ADSP_CUSTOM_MED,FREEMAIL_FROM,NML_ADSP_CUSTOM_MED,SPF_HELO_PASS,TW_QE,T_RP_MATCHES_RCVD,T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: sourceware.org Received: from lo.gmane.org (HELO lo.gmane.org) (80.91.229.12) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 21 Feb 2011 14:41:55 +0000 Received: from list by lo.gmane.org with local (Exim 4.69) (envelope-from ) id 1PrWxV-0000ie-2Q for gcc-help@gcc.gnu.org; Mon, 21 Feb 2011 15:41:53 +0100 Received: from 93-63-215-23.ip29.fastwebnet.it ([93.63.215.23]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 21 Feb 2011 15:41:52 +0100 Received: from stefboombastic by 93-63-215-23.ip29.fastwebnet.it with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 21 Feb 2011 15:41:52 +0100 To: gcc-help@gcc.gnu.org From: Stefano Bonifazi Subject: Problem creating PIC executable Date: Mon, 21 Feb 2011 15:26:00 -0000 Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.13) Gecko/20101208 Thunderbird/3.1.7 X-IsSubscribed: yes Mailing-List: contact gcc-help-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-help-owner@gcc.gnu.org X-SW-Source: 2011-02/txt/msg00326.txt.bz2 Hi all! I am reposting the previous problem, as after some investigation the problem is more clear:there is some error creating a PIC EXECUTABLE! Even when creating the simplest code: int main() {} compiling with "gcc -fPIC" and then linking with "gcc -Wl,-pie" produces non PIC code: checking all the linked object files (also those added by gcc) with "readelf -d myobjectfile | fgrep TEXT" all seem to be PIC as nothing is produced by the previous command. Oddly giving the command "readelf -d mypie_executable | fgrep TEXT" to my final 'PIC' output executable I get: "0x00000016 (TEXTREL) 0x0" Then if I try to load the file with QEMU-USER I get: "error while loading shared libraries: R_PPC_REL24 relocation at 0xb31f95a0 for symbol `__libc_start_main' out of range" !!! If I link with "-shared" all is fine and the library is PIC.. Also if I create a normal executable, or a normal executable relocated at linker time with "-Wl,-Ttext-segment=myaddress" all is fine.. I think the linker goes crazy as I want a PIC executable not a library! I am creating the binaries using Debian 6 kernel 2.6.32.5 powerpc running in a qemu VM, with gcc 4.4.5-8, binutils 2.20.1 eglibc 2.11.2-10 Please help!! I really dunno how to solve it! Thank you very much in advance! Stefano B.