1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-25 20:23:11 +01:00
llvm-mirror/tools/llvm-readobj
Reid Kleckner c5216dadb8 [LLD] Implement /guard:[no]longjmp
Summary:
This protects calls to longjmp from transferring control to arbitrary
program points. Instead, longjmp calls are limited to the set of
registered setjmp return addresses.

This also implements /guard:nolongjmp to allow users to link in object
files that call setjmp that weren't compiled with /guard:cf. In this
case, the linker will approximate the set of address taken functions,
but it will leave longjmp unprotected.

I used the following program to test, compiling it with different -guard
flags:
  $ cl -c t.c -guard:cf
  $ lld-link t.obj -guard:cf

  #include <setjmp.h>
  #include <stdio.h>
  jmp_buf buf;
  void g() {
    printf("before longjmp\n");
    fflush(stdout);
    longjmp(buf, 1);
  }
  void f() {
    if (setjmp(buf)) {
      printf("setjmp returned non-zero\n");
      return;
    }
    g();
  }
  int main() {
    f();
    printf("hello world\n");
  }

In particular, the program aborts when the code is compiled *without*
-guard:cf and linked with -guard:cf. That indicates that longjmps are
protected.

Reviewers: ruiu, inglorion, amccarth

Subscribers: llvm-commits

Differential Revision: https://reviews.llvm.org/D43217

llvm-svn: 325047
2018-02-13 20:32:53 +00:00
..
ARMEHABIPrinter.h Instead of ELFFile<ELFT>::Type, use ELFT::Type. NFC. 2018-01-12 02:28:31 +00:00
ARMWinEHPrinter.cpp
ARMWinEHPrinter.h
CMakeLists.txt [tools] Add option to install binutils symlinks 2017-11-02 21:43:32 +00:00
COFFDumper.cpp [LLD] Implement /guard:[no]longjmp 2018-02-13 20:32:53 +00:00
COFFImportDumper.cpp [llvm-readobj] Consistent use of ScopedPrinter 2018-01-10 00:14:19 +00:00
ELFDumper.cpp CodeGen: support an extension to pass linker options on ELF 2018-01-30 16:29:29 +00:00
Error.cpp
Error.h
llvm-readobj.cpp CodeGen: support an extension to pass linker options on ELF 2018-01-30 16:29:29 +00:00
llvm-readobj.h [llvm-readobj] Update readobj to re-use parsing code. 2017-05-03 17:11:11 +00:00
LLVMBuild.txt Move Object format code to lib/BinaryFormat. 2017-06-07 03:48:56 +00:00
MachODumper.cpp [llvm-readobj] Consistent use of ScopedPrinter 2018-01-10 00:14:19 +00:00
ObjDumper.cpp
ObjDumper.h CodeGen: support an extension to pass linker options on ELF 2018-01-30 16:29:29 +00:00
StackMapPrinter.h [llvm-readobj] Consistent use of ScopedPrinter 2018-01-10 00:14:19 +00:00
WasmDumper.cpp [WebAssembly] Remove debug names from symbol table 2018-01-17 19:28:43 +00:00
Win64EHDumper.cpp
Win64EHDumper.h
WindowsResourceDumper.cpp Remove redundant includes from tools. 2017-12-13 21:31:10 +00:00
WindowsResourceDumper.h [llvm-readobj] Teach readobj to dump .res files (WindowsResource). 2017-09-20 18:33:35 +00:00