1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-23 03:02:36 +01:00
llvm-mirror/bindings/ocaml
Nick Desaulniers e95a065d26 [IR] add fn attr for no_stack_protector; prevent inlining on mismatch
It's currently ambiguous in IR whether the source language explicitly
did not want a stack a stack protector (in C, via function attribute
no_stack_protector) or doesn't care for any given function.

It's common for code that manipulates the stack via inline assembly or
that has to set up its own stack canary (such as the Linux kernel) would
like to avoid stack protectors in certain functions. In this case, we've
been bitten by numerous bugs where a callee with a stack protector is
inlined into an __attribute__((__no_stack_protector__)) caller, which
generally breaks the caller's assumptions about not having a stack
protector. LTO exacerbates the issue.

While developers can avoid this by putting all no_stack_protector
functions in one translation unit together and compiling those with
-fno-stack-protector, it's generally not very ergonomic or as
ergonomic as a function attribute, and still doesn't work for LTO. See also:
https://lore.kernel.org/linux-pm/20200915172658.1432732-1-rkir@google.com/
https://lore.kernel.org/lkml/20200918201436.2932360-30-samitolvanen@google.com/T/#u

Typically, when inlining a callee into a caller, the caller will be
upgraded in its level of stack protection (see adjustCallerSSPLevel()).
By adding an explicit attribute in the IR when the function attribute is
used in the source language, we can now identify such cases and prevent
inlining.  Block inlining when the callee and caller differ in the case that one
contains `nossp` when the other has `ssp`, `sspstrong`, or `sspreq`.

Fixes pr/47479.

Reviewed By: void

Differential Revision: https://reviews.llvm.org/D87956
2020-10-23 11:55:39 -07:00
..
all_backends Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
analysis Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
backends Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
bitreader Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
bitwriter Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
executionengine Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
irreader Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
linker Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
llvm [IR] add fn attr for no_stack_protector; prevent inlining on mismatch 2020-10-23 11:55:39 -07:00
target Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
transforms [OCaml] Remove add_constant_propagation 2020-08-27 09:30:21 -07:00
CMakeLists.txt
README.txt

This directory contains LLVM bindings for the OCaml programming language
(http://ocaml.org).

Prerequisites
-------------

* OCaml 4.00.0+.
* ctypes 0.4+.
* oUnit 2+ (only required for tests).
* CMake (to build LLVM).

Building the bindings
---------------------

If all dependencies are present, the bindings will be built and installed
as a part of the default CMake configuration, with no further action.
They will only work with the specific OCaml compiler detected during the build.

The bindings can also be built out-of-tree, i.e. targeting a preinstalled
LLVM. To do this, configure the LLVM build tree as follows:

    $ cmake -DLLVM_OCAML_OUT_OF_TREE=TRUE \
            -DCMAKE_INSTALL_PREFIX=[OCaml install prefix] \
            [... any other options]

then build and install it as:

    $ make ocaml_all
    $ cmake -P bindings/ocaml/cmake_install.cmake