[PATCH] D29752: [libFuzzer] Export external functions.

Zachary Turner via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 9 16:16:10 PST 2017


zturner added a comment.

How about this:

  set(Tests
    AbsNegAndConstantTest
    AbsNegAndConstant64Test
    AccumulateAllocationsTest
    BufferOverflowOnInput
    CallerCalleeTest
    CounterTest
    CxxStringEqTest
    DivTest
    EmptyTest
    EquivalenceATest
    EquivalenceBTest
    FourIndependentBranchesTest
    FullCoverageSetTest
    MemcmpTest
    LeakTest
    LeakTimeoutTest
    LoadTest
    NullDerefTest
    NullDerefOnEmptyTest
    NthRunCrashTest
    OneHugeAllocTest
    OutOfMemoryTest
    OutOfMemorySingleLargeMallocTest
    RepeatedMemcmp
    RepeatedBytesTest
    SimpleCmpTest
    SimpleDictionaryTest
    SimpleHashTest
    SimpleTest
    SimpleThreadedTest
    SingleByteInputTest
    SingleMemcmpTest
    SingleStrcmpTest
    SingleStrncmpTest
    SpamyTest
    ShrinkControlFlowTest
    ShrinkValueProfileTest
    StrcmpTest
    StrncmpOOBTest
    StrncmpTest
    StrstrTest
    SwapCmpTest
    SwitchTest
    Switch2Test
    ThreadedLeakTest
    ThreadedTest
    TimeoutTest
    TimeoutEmptyTest
    TraceMallocTest
    )
  
  set(ExportingTests
    BogusInitializeTest
    CustomCrossOverTest
    InitializeTest
    CustomMutatorTest
    )
  
  foreach(Test ${ExportingTests})
    add_libfuzzer_test(${Test} SOURCES ${Test}.cpp EXPORT ${ExportSymbolName})
  endforeach()

Then change `add_libfuzzer_test()` so that it has some code like this:

  if(MSVC)
    string(CONCAT ExportSymbolName "LLVM" ${Test})
    set_target_properties(LLVMFuzzer-${target} PROPERTIES LINK_FLAGS
        "-export:${symbol}")
  endif()

Probably some details need to be worked out, but the main idea here is that the *only* thing anyone has to do to get a test to be correct here is add it to the correct list.  They just add one line to the `set(ExportingTests` and everything works.

One thing is that you would need to change the test .cpp file to change the name of of the fuzzer function so that it can be deduced from the name of the test.  Currently the `Bogus` test wouldn't work like this.

All that said, I'm fine with the original change as it is proposed, but I think this might make it a little easier, so maybe kcc@ likes this more?  Up to him :)


https://reviews.llvm.org/D29752





More information about the llvm-commits mailing list