public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* Problem creating PIC executable
@ 2011-02-21 15:26 Stefano Bonifazi
  2011-02-21 16:21 ` Ian Lance Taylor
  0 siblings, 1 reply; 10+ messages in thread
From: Stefano Bonifazi @ 2011-02-21 15:26 UTC (permalink / raw)
  To: gcc-help

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.

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2011-02-23  1:31 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-02-21 15:26 Problem creating PIC executable Stefano Bonifazi
2011-02-21 16:21 ` Ian Lance Taylor
2011-02-21 18:10   ` Stefano Bonifazi
2011-02-21 20:39     ` Ian Lance Taylor
2011-02-21 23:10       ` Stefano Bonifazi
2011-02-22  4:15         ` Ian Lance Taylor
2011-02-22 11:17           ` Stefano Bonifazi
2011-02-22 23:06             ` Ian Lance Taylor
2011-02-23  0:38               ` Stefano Bonifazi
2011-02-23  1:55                 ` Ian Lance Taylor

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).