mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-25 04:02:41 +01:00
e95a065d26
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 |
||
---|---|---|
.. | ||
llvm | ||
build.sh | ||
conftest.go | ||
README.txt |
This directory contains LLVM bindings for the Go programming language (http://golang.org). Prerequisites ------------- * Go 1.2+. * CMake (to build LLVM). Using the bindings ------------------ The package path "llvm.org/llvm/bindings/go/llvm" can be used to import the latest development version of LLVM from SVN. Paths such as "llvm.org/llvm.v36/bindings/go/llvm" refer to released versions of LLVM. It is recommended to use the "-d" flag with "go get" to download the package or a dependency, as an additional step is required to build LLVM (see "Building LLVM" below). Building LLVM ------------- The script "build.sh" in this directory can be used to build LLVM and prepare it to be used by the bindings. If you receive an error message from "go build" like this: ./analysis.go:4:84: fatal error: llvm-c/Analysis.h: No such file or directory #include <llvm-c/Analysis.h> // If you are getting an error here read bindings/go/README.txt or like this: ./llvm_dep.go:5: undefined: run_build_sh it means that LLVM needs to be built or updated by running the script. $ $GOPATH/src/llvm.org/llvm/bindings/go/build.sh Any command line arguments supplied to the script are passed to LLVM's CMake build system. A good set of arguments to use during development are: $ $GOPATH/src/llvm.org/llvm/bindings/go/build.sh -DCMAKE_BUILD_TYPE=Debug -DLLVM_TARGETS_TO_BUILD=host -DBUILD_SHARED_LIBS=ON Note that CMake keeps a cache of build settings so once you have built LLVM there is no need to pass these arguments again after updating. Alternatively, you can build LLVM yourself, but you must then set the CGO_CPPFLAGS, CGO_CXXFLAGS and CGO_LDFLAGS environment variables: $ export CGO_CPPFLAGS="`/path/to/llvm-build/bin/llvm-config --cppflags`" $ export CGO_CXXFLAGS=-std=c++14 $ export CGO_LDFLAGS="`/path/to/llvm-build/bin/llvm-config --ldflags --libs --system-libs all`" $ go build -tags byollvm If you see a compilation error while compiling your code with Go 1.9.4 or later as follows, go build llvm.org/llvm/bindings/go/llvm: invalid flag in #cgo LDFLAGS: -Wl,-headerpad_max_install_names you need to setup $CGO_LDFLAGS_ALLOW to allow a compiler to specify some linker options: $ export CGO_LDFLAGS_ALLOW='-Wl,(-search_paths_first|-headerpad_max_install_names)'