This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug target/67400] -fno-plt doesn't work with function pointers


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67400

--- Comment #5 from hjl at gcc dot gnu.org <hjl at gcc dot gnu.org> ---
Author: hjl
Date: Thu Jun 23 16:30:43 2016
New Revision: 237736

URL: https://gcc.gnu.org/viewcvs?rev=237736&root=gcc&view=rev
Log:
i386: Access external function via GOT slot for -fno-plt

i386 psABI has been updated to clarify that R_386_GOT32X and R_386_GOT32
relocations can be used to access GOT without base register when PIC is
disabled:

https://groups.google.com/forum/#!topic/ia32-abi/awsRSvJOJfs

32-bit x86 assembler and linker from binutils 2.26.1 and 2.27 support

call/jmp *_start@GOT
cmpl $0, bar@GOT

for both normal and IFUNC functions.  We check if 32-bit x86 assembler
and linker have the fix for:

https://sourceware.org/bugzilla/show_bug.cgi?id=20244

before accessing external function via GOT slot for -fno-plt in both PIC
and non-PIC modes.

        PR target/66232
        PR target/67400
        * configure.ac (as_ix86_tls_ldm_opt): Renamed to ...
        (as_ix86_gas_32_opt): This.
        (ld_ix86_tls_ldm_opt): Renamed to ...
        (ld_ix86_gld_32_opt): This.
        (R_386_TLS_LDM reloc): Updated.
        (R_386_GOT32X reloc): New assembler/linker check.
        (HAVE_AS_IX86_GOT32X): New.  Defined to 1 if 32-bit assembler and
        linker support "jmp *_start@GOT" and "cmpl $0, bar@GOT".  Otherise,
        defined to 0.
        * config.in: Regenerated.
        * configure: Likewise.
        * config/i386/i386.c (ix86_force_load_from_GOT_p): Return
        true if HAVE_AS_IX86_GOT32X is 1 in 32-bit mode.
        (ix86_legitimate_address_p): Allow UNSPEC_GOT for -fno-plt
        if ix86_force_load_from_GOT_p returns true.
        (ix86_print_operand_address_as): Also support UNSPEC_GOT if
        ix86_force_load_from_GOT_p returns true.
        (ix86_expand_move): Generate UNSPEC_GOT in 32-bit mode to load
        the external function address via the GOT slot.
        (ix86_nopic_noplt_attribute_p): Check both TARGET_64BIT and
        HAVE_AS_IX86_GOT32X before returning false.
        (ix86_output_call_insn): Generate "%!jmp/call\t*%p0@GOT" in
        32-bit mode if ix86_nopic_noplt_attribute_p returns true.

gcc/testsuite/

        PR target/66232
        PR target/67400
        * gcc.target/i386/pr66232-14.c: New file.
        * gcc.target/i386/pr66232-15.c: Likewise.
        * gcc.target/i386/pr66232-16.c: Likewise.
        * gcc.target/i386/pr66232-17.c: Likewise.
        * gcc.target/i386/pr67400-1.c: Don't disable for ia32.  Scan for
        ia32 if R_386_GOT32X relocation is supported.
        * gcc.target/i386/pr67400-2.c: Likewise.
        * gcc.target/i386/pr67400-3.c: Likewise.
        * gcc.target/i386/pr67400-4.c: Likewise.
        * gcc.target/i386/pr67400-6.c: Likewise.
        * gcc.target/i386/pr67400-7.c: Likewise.
        * lib/target-supports.exp (check_effective_target_got32x_reloc):
        New.

Added:
    trunk/gcc/testsuite/gcc.target/i386/pr66232-14.c
    trunk/gcc/testsuite/gcc.target/i386/pr66232-15.c
    trunk/gcc/testsuite/gcc.target/i386/pr66232-16.c
    trunk/gcc/testsuite/gcc.target/i386/pr66232-17.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/config.in
    trunk/gcc/config/i386/i386.c
    trunk/gcc/configure
    trunk/gcc/configure.ac
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/testsuite/gcc.target/i386/pr67400-1.c
    trunk/gcc/testsuite/gcc.target/i386/pr67400-2.c
    trunk/gcc/testsuite/gcc.target/i386/pr67400-3.c
    trunk/gcc/testsuite/gcc.target/i386/pr67400-4.c
    trunk/gcc/testsuite/gcc.target/i386/pr67400-6.c
    trunk/gcc/testsuite/gcc.target/i386/pr67400-7.c
    trunk/gcc/testsuite/lib/target-supports.exp

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]