7799a85590
Add -mindirect-branch= option to convert indirect call and jump to call and return thunks. The default is 'keep', which keeps indirect call and jump unmodified. 'thunk' converts indirect call and jump to call and return thunk. 'thunk-inline' converts indirect call and jump to inlined call and return thunk. 'thunk-extern' converts indirect call and jump to external call and return thunk provided in a separate object file. You can control this behavior for a specific function by using the function attribute indirect_branch. 2 kinds of thunks are geneated. Memory thunk where the function address is at the top of the stack: __x86_indirect_thunk: call L2 L1: pause lfence jmp L1 L2: lea 8(%rsp), %rsp|lea 4(%esp), %esp ret Indirect jmp via memory, "jmp mem", is converted to push memory jmp __x86_indirect_thunk Indirect call via memory, "call mem", is converted to jmp L2 L1: push [mem] jmp __x86_indirect_thunk L2: call L1 Register thunk where the function address is in a register, reg: __x86_indirect_thunk_reg: call L2 L1: pause lfence jmp L1 L2: movq %reg, (%rsp)|movl %reg, (%esp) ret where reg is one of (r|e)ax, (r|e)dx, (r|e)cx, (r|e)bx, (r|e)si, (r|e)di, (r|e)bp, r8, r9, r10, r11, r12, r13, r14 and r15. Indirect jmp via register, "jmp reg", is converted to jmp __x86_indirect_thunk_reg Indirect call via register, "call reg", is converted to call __x86_indirect_thunk_reg gcc/ Backport from mainline * config/i386/i386-opts.h (indirect_branch): New. * config/i386/i386-protos.h (ix86_output_indirect_jmp): Likewise. * config/i386/i386.c (ix86_using_red_zone): Disallow red-zone with local indirect jump when converting indirect call and jump. (ix86_set_indirect_branch_type): New. (ix86_set_current_function): Call ix86_set_indirect_branch_type. (indirectlabelno): New. (indirect_thunk_needed): Likewise. (indirect_thunk_bnd_needed): Likewise. (indirect_thunks_used): Likewise. (indirect_thunks_bnd_used): Likewise. (INDIRECT_LABEL): Likewise. (indirect_thunk_name): Likewise. (output_indirect_thunk): Likewise. (output_indirect_thunk_function): Likewise. (ix86_output_indirect_branch_via_reg): Likewise. (ix86_output_indirect_branch_via_push): Likewise. (ix86_output_indirect_branch): Likewise. (ix86_output_indirect_jmp): Likewise. (ix86_code_end): Call output_indirect_thunk_function if needed. (ix86_output_call_insn): Call ix86_output_indirect_branch if needed. (ix86_handle_fndecl_attribute): Handle indirect_branch. (ix86_attribute_table): Add indirect_branch. * config/i386/i386.h (machine_function): Add indirect_branch_type and has_local_indirect_jump. * config/i386/i386.md (indirect_jump): Set has_local_indirect_jump to true. (tablejump): Likewise. (*indirect_jump): Use ix86_output_indirect_jmp. (*tablejump_1): Likewise. (simple_return_indirect_internal): Likewise. * config/i386/i386.opt (mindirect-branch=): New option. (indirect_branch): New. (keep): Likewise. (thunk): Likewise. (thunk-inline): Likewise. (thunk-extern): Likewise. * doc/extend.texi: Document indirect_branch function attribute. * doc/invoke.texi: Document -mindirect-branch= option. gcc/testsuite/ Backport from mainline * gcc.target/i386/indirect-thunk-1.c: New test. * gcc.target/i386/indirect-thunk-2.c: Likewise. * gcc.target/i386/indirect-thunk-3.c: Likewise. * gcc.target/i386/indirect-thunk-4.c: Likewise. * gcc.target/i386/indirect-thunk-5.c: Likewise. * gcc.target/i386/indirect-thunk-6.c: Likewise. * gcc.target/i386/indirect-thunk-7.c: Likewise. * gcc.target/i386/indirect-thunk-attr-1.c: Likewise. * gcc.target/i386/indirect-thunk-attr-2.c: Likewise. * gcc.target/i386/indirect-thunk-attr-3.c: Likewise. * gcc.target/i386/indirect-thunk-attr-4.c: Likewise. * gcc.target/i386/indirect-thunk-attr-5.c: Likewise. * gcc.target/i386/indirect-thunk-attr-6.c: Likewise. * gcc.target/i386/indirect-thunk-attr-7.c: Likewise. * gcc.target/i386/indirect-thunk-attr-8.c: Likewise. * gcc.target/i386/indirect-thunk-bnd-1.c: Likewise. * gcc.target/i386/indirect-thunk-bnd-2.c: Likewise. * gcc.target/i386/indirect-thunk-bnd-3.c: Likewise. * gcc.target/i386/indirect-thunk-bnd-4.c: Likewise. * gcc.target/i386/indirect-thunk-extern-1.c: Likewise. * gcc.target/i386/indirect-thunk-extern-2.c: Likewise. * gcc.target/i386/indirect-thunk-extern-3.c: Likewise. * gcc.target/i386/indirect-thunk-extern-4.c: Likewise. * gcc.target/i386/indirect-thunk-extern-5.c: Likewise. * gcc.target/i386/indirect-thunk-extern-6.c: Likewise. * gcc.target/i386/indirect-thunk-extern-7.c: Likewise. * gcc.target/i386/indirect-thunk-inline-1.c: Likewise. * gcc.target/i386/indirect-thunk-inline-2.c: Likewise. * gcc.target/i386/indirect-thunk-inline-3.c: Likewise. * gcc.target/i386/indirect-thunk-inline-4.c: Likewise. * gcc.target/i386/indirect-thunk-inline-5.c: Likewise. * gcc.target/i386/indirect-thunk-inline-6.c: Likewise. * gcc.target/i386/indirect-thunk-inline-7.c: Likewise. From-SVN: r256732 |
||
---|---|---|
.. | ||
ada | ||
brig.dg | ||
c-c++-common | ||
config | ||
g++.dg | ||
g++.old-deja | ||
gcc.c-torture | ||
gcc.dg | ||
gcc.misc-tests | ||
gcc.target | ||
gcc.test-framework | ||
gfortran.dg | ||
gfortran.fortran-torture | ||
gnat.dg | ||
go.dg | ||
go.go-torture/execute | ||
go.test | ||
jit.dg | ||
lib | ||
obj-c++.dg | ||
objc | ||
objc-obj-c++-shared | ||
objc.dg | ||
selftests | ||
.gitattributes | ||
ChangeLog | ||
ChangeLog-1993-2007 | ||
ChangeLog-2008 | ||
ChangeLog-2009 | ||
ChangeLog-2010 | ||
ChangeLog-2011 | ||
ChangeLog-2012 | ||
ChangeLog-2013 | ||
ChangeLog-2014 | ||
ChangeLog-2015 | ||
ChangeLog-2016 | ||
ChangeLog.graphite | ||
ChangeLog.jit | ||
ChangeLog.ptr | ||
ChangeLog.tree-ssa | ||
README | ||
README.compat | ||
README.gcc |
README
This is a collection of tests for GCC. For further information about
the C testsuite, see README.gcc.
The driver that runs this testsuite is called DejaGnu and you will
need a current DejaGnu snapshot, which is available from
ftp://gcc.gnu.org/pub/gcc/infrastructure, for example.
These tests are included "as is". If any of them fails, do not report
a bug. Bug reports for DejaGnu can go to bug-dejagnu@gnu.org.
Discussion and comments about this testsuite should be sent to
gcc@gcc.gnu.org; additions and changes to should go to sent to
gcc-patches@gcc.gnu.org.
The entire testsuite is invoked by `make check` at the top level of
the GCC tree. `make check-g++` runs the C++ testsuite only.
STRUCTURE OF THE G++ TESTSUITE
g++.dg tests:
All new tests should be placed in an appropriate subdirectory of g++.dg.
g++.old-deja tests:
g++.benjamin Tests by Benjamin Koz
g++.bob
g++.brendan Tests by Brendan Kehoe
g++.bugs
g++.eh Tests for exception handling
g++.ext Tests for g++ extensions
g++.gb Tests by Gerald Baumgartner
g++.jason Tests by Jason Merill
g++.jeff Tests by Jeffrey A Law
g++.martin Tests by Martin v. Löwis
g++.mike Tests by Mike Stump
g++.niklas Tests by Niklas Hallqvist
g++.ns Tests for namespaces
g++.other
g++.pt Tests for templates
g++.rfg
g++.robertl Tests from gcc-bugs@gcc.gnu.org, gathered by Robert Lipe
Finally, some random last minute notes by Mike Stump <mrs@cygnus.com>, on
how to run tests (in the GCC 2.7 era):
runtest --tool g++ --srcdir ./testsuite
where
runtest Is the name used to invoke DejaGnu. If DejaGnu is not
install this will be the relative path name for runtest.
--tool This tells DejaGnu which tool you are testing. It is
mainly used to find the testsuite directories for a
particular tool when several testsuites are in the
same directory. (like the gcc and g++ testsuites)
--srcdir This points to the top level of the directory
containing the sources of the testsuite. This is
./testsuite if you are in the directory that has the
testsuite directory.
Copyright (C) 1998-2017 Free Software Foundation, Inc.
Copying and distribution of this file, with or without modification,
are permitted in any medium without royalty provided the copyright
notice and this notice are preserved.