[PATCH] D20741: [LibFuzzer] Fix weak linking issues building tests under OSX.

Dan Liew via llvm-commits llvm-commits at lists.llvm.org
Tue May 31 17:10:16 PDT 2016


delcypher added a comment.

@kcc:

> The build command line for libFuzzer should remain very simple and the same across platforms.


It's easy to achieve, so we should just do it.

Okay here's the result. I'm not very happy with. It seems that on Linux to get this to work the linker has to be passed `-export-dynamic` (otherwise `dlsym()` can't see the symbols we want to get) and told to link against the `dl` library for this to work.

A little bit ironically I don't have to tell the Darwin linker to do anything special in this patch. So in my original patch I had to tell the Darwin linker to do extra work and in this patch I have to tell GNU ld to do extra work. So now this patch causes hassle under Linux :(

Perhaps a good middle ground would be to make the Linux implementation of `ExternalFunctions::Init()` use weak symbols (as a way of getting the addresses to assign to the function pointers) that way no special linking is required on either platform. Doing this though will either require some ifdefs in `FuzzerExtFunctions.cpp` or require two different versions `FuzzerExtFunctionsLinux.cpp` and `FuzzerExtFunctionsDarwin.cpp`.

Thoughts?


http://reviews.llvm.org/D20741





More information about the llvm-commits mailing list