gcc 64bit libc.a not compile with -fPIC

Bug #1132899 reported by tg123
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
gcc-4.7 (Ubuntu)
Invalid
Undecided
Unassigned

Bug Description

I have problem link libgcc into a static linked .so

it only happens when linking 64bit module with `-m64`

Ubuntu 64bit 12.10 gcc 4.7

also failed on Ubuntu 64bit 12.04 gcc 4.6

32bit no problem

    $gcc -fPIC -c -o hello.o hello.c -m32
    $gcc -shared -m32 hello.o -o libhello.so -static-libgcc -Wl,-Bstatic -lc
    $ ldd libhello.so
     statically linked

64bit failed

    $ make
    gcc -fPIC -c -o hello.o hello.c
    gcc -shared -m64 hello.o -o libhello.so -static-libgcc -Wl,-Bstatic -lc
    /usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/libc.a(iofclose.o): relocation R_X86_64_32 against `__gcc_personality_v0' can not be used when making a shared object; recompile with -fPIC
    /usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/libc.a: could not read symbols: Bad value
    collect2: error: ld returned 1 exit status
    make: *** [libhello.so] Error 1

hello.c

    #include <stdio.h>

    int f(){

    FILE *out = fopen("/tmp/x.log", "wb");
    fclose(out);

    return 1;
    }

Makefile

    all: libhello.so

    libhello.so: hello.o
     gcc -shared -m64 hello.o -o libhello.so -static-libgcc -Wl,-Bstatic -lc

    hello.o: hello.c
     gcc -fPIC -c -o hello.o hello.c

    clean:
     rm -f hello.o libhello.so

Tags: bot-comment
Revision history for this message
tg123 (farmer1992) wrote :

i first asked this on stackoverflow

http://stackoverflow.com/questions/15072196/why-cant-link-64bit-static-libgcc-on-ubuntu

but now i think it might be something wrong with libc.a on ubuntu

Revision history for this message
Ubuntu Foundations Team Bug Bot (crichton) wrote :

Thank you for taking the time to report this bug and helping to make Ubuntu better. It seems that your bug report is not filed about a specific source package though, rather it is just filed against Ubuntu in general. It is important that bug reports be filed about source packages so that people interested in the package can find the bugs about it. You can find some hints about determining what package your bug might be about at https://wiki.ubuntu.com/Bugs/FindRightPackage. You might also ask for help in the #ubuntu-bugs irc channel on Freenode.

To change the source package that this bug is filed about visit https://bugs.launchpad.net/ubuntu/+bug/1132899/+editstatus and add the package name in the text box next to the word Package.

[This is an automated message. I apologize if it reached you inappropriately; please just reply to this message indicating so.]

tags: added: bot-comment
tg123 (farmer1992)
affects: ubuntu → gcc-4.7 (Ubuntu)
Revision history for this message
Matthias Klose (doko) wrote :

invalid, i386 is one of the few archs where you can add non-pic code into a shared library, but that's not the case for every architecture.

Changed in gcc-4.7 (Ubuntu):
status: New → Invalid
Revision history for this message
tg123 (farmer1992) wrote : Re: [Bug 1132899] Re: gcc 64bit libc.a not compile with -fPIC

Hi

I got some problem run my .so on Ubuntu 10.10 64bit due to 10.10 does not
have gcc 2.14 compitiable symbol.
thus, I want make it static.

here is my question
http://stackoverflow.com/questions/15072196/why-cant-link-64bit-static-libgcc-on-ubuntu

On Tue, Feb 26, 2013 at 6:31 PM, Matthias Klose <email address hidden> wrote:

> invalid, i386 is one of the few archs where you can add non-pic code
>

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.