http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54626

             Bug #: 54626
           Summary: Unexpected consequences of
                    __attribute__((optimize("-fno-PIC")))
    Classification: Unclassified
           Product: gcc
           Version: 4.8.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
        AssignedTo: unassig...@gcc.gnu.org
        ReportedBy: jep...@unpythonic.net


(I doubt I've selected the right component; please correct)

I ran across bug 54232 and it occurred to me to wonder whether it was possible
to manually mark a single function that uses no global data (and thus does not
need to use ebx as the GOT register) as "no PIC".

This has the unexpected side-effect of making the entire translation unit "no
PIC".

Source code:
extern int o();

int f() __attribute__((optimize("-fno-PIC")));
int f() { return o(); }
 g() { return o(); }

Compiler commandline:
gcc -m32 -fPIC -c ff.c

Expected behavior: when examined with 'objdump -d ff.o', function f contains no
call to get_pc_thunk.bx while g does.  Alternately, the __attribute__
declaration results in an error if this is totally nonsensical.

Actual behavior: both f and g are compiled without call to get_pc_thunk.bx

Tested on svn trunk r19144:
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/local/jepler/gcc-dev/libexec/gcc/i686-pc-linux-gnu/4.8.0/lto-wrapper
Target: i686-pc-linux-gnu
Configured with: ../gcc/configure --prefix=/usr/local/jepler/gcc-dev
--with-gmp=/usr/local/jepler/gcc-dev --with-mpc=/usr/local/jepler/gcc-dev
--with-mpfr=/usr/local/jepler/gcc-dev
Thread model: posix
gcc version 4.8.0 20120918 (experimental) (GCC)

Reply via email to