[llvm-jitlink] Add -harness option to llvm-jitlink.
authorLang Hames <lhames@gmail.com>
Thu, 30 Jul 2020 05:55:33 +0000 (22:55 -0700)
committerLang Hames <lhames@gmail.com>
Thu, 30 Jul 2020 22:26:19 +0000 (15:26 -0700)
commit8ce8cee1e1d44d480ea87f1ac47eddcf07c433d1
tree7f846589ae7f84ebbb2f488c4955b3829b025409
parent9f1dcdca71c4109354ec916ad27c24caf269c705
[llvm-jitlink] Add -harness option to llvm-jitlink.

The -harness option enables new testing use-cases for llvm-jitlink. It takes a
list of objects to treat as a test harness for any regular objects passed to
llvm-jitlink.

If any files are passed using the -harness option then the following
transformations are applied to all other files:

  (1) Symbols definitions that are referenced by the harness files are promoted
      to default scope. (This enables access to statics from test harness).

  (2) Symbols definitions that clash with definitions in the harness files are
      deleted. (This enables interposition by test harness).

  (3) All other definitions in regular files are demoted to local scope.
      (This causes untested code to be dead stripped, reducing memory cost and
      eliminating spurious unresolved symbol errors from untested code).

These transformations allow the harness files to reference and interpose
symbols in the regular object files, which can be used to support execution
tests (including fuzz tests) of functions in relocatable objects produced by a
build.
llvm/include/llvm/ExecutionEngine/JITLink/JITLink.h
llvm/lib/ExecutionEngine/JITLink/JITLinkGeneric.cpp
llvm/test/ExecutionEngine/JITLink/X86/Inputs/MachO_test_harness_test.s [new file with mode: 0644]
llvm/test/ExecutionEngine/JITLink/X86/MachO_test_harness_harness.s [new file with mode: 0644]
llvm/tools/llvm-jitlink/llvm-jitlink.cpp
llvm/tools/llvm-jitlink/llvm-jitlink.h