Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 19 additions & 9 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,27 @@ project(luzer
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
include(SetClangRTLib)

find_package(Lua 5.1 REQUIRED)
find_package(LLVM REQUIRED CONFIG)

set(LUA_NAME "lua${LUA_VERSION_MAJOR}.${LUA_VERSION_MINOR}")
find_program(LUA_EXECUTABLE "${LUA_NAME}")
if(NOT EXISTS ${LUA_EXECUTABLE})
message(FATAL_ERROR "${LUA_NAME} is required")
if(LUA_INCLUDE_DIR AND LUA_LIBRARIES)
# When a path to a Lua library is passed outside, we should
# mimic a real CMake library to don't break code that depends on
# LUA_LIBRARIES.
add_library(liblua STATIC IMPORTED GLOBAL)
set_target_properties(liblua PROPERTIES
IMPORTED_LOCATION ${LUA_LIBRARIES})
set(LUA_LIBRARIES liblua)
else()
find_package(Lua 5.1 REQUIRED)
set(LUA_NAME "lua${LUA_VERSION_MAJOR}.${LUA_VERSION_MINOR}")
find_program(LUA_EXECUTABLE "${LUA_NAME}")
if(NOT EXISTS ${LUA_EXECUTABLE})
message(FATAL_ERROR "${LUA_NAME} is required")
endif()
message(STATUS "Found Lua ${LUA_VERSION_STRING}")
message(STATUS "Found Lua interpreter ${LUA_EXECUTABLE}")
endif()

message(STATUS "Found Lua ${LUA_VERSION_STRING}")
message(STATUS "Found Lua interpreter ${LUA_EXECUTABLE}")
find_package(LLVM REQUIRED CONFIG)

message(STATUS "Found LLVM ${LLVM_VERSION}")

if(${LLVM_PACKAGE_VERSION} VERSION_LESS 5.0.0)
Expand Down
28 changes: 14 additions & 14 deletions luzer/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,24 @@ set(LUZER_SOURCES luzer.c

add_library(${CMAKE_PROJECT_NAME} SHARED ${LUZER_SOURCES})
target_include_directories(${CMAKE_PROJECT_NAME} PRIVATE
${LUA_INCLUDE_DIR}
${LUA_INCLUDE_DIR}
)
target_link_libraries(${CMAKE_PROJECT_NAME} PRIVATE
${LUA_LIBRARIES}
-fsanitize=fuzzer-no-link
${FUZZER_NO_MAIN_LIBRARY}
${LUA_LIBRARIES}
-fsanitize=fuzzer-no-link
${FUZZER_NO_MAIN_LIBRARY}
)
target_compile_options(${CMAKE_PROJECT_NAME} PRIVATE
-D_FORTIFY_SOURCE=2
-fpie
-fPIC
-Wall
-Wextra
-Werror
-Wpedantic
-Wno-unused-parameter
-pedantic
-fsanitize=fuzzer-no-link
-D_FORTIFY_SOURCE=2
-fpie
-fPIC
-Wall
-Wextra
-Werror
-Wpedantic
-Wno-unused-parameter
-pedantic
-fsanitize=fuzzer-no-link
)
set_target_properties(${CMAKE_PROJECT_NAME} PROPERTIES PREFIX "")

Expand Down
18 changes: 14 additions & 4 deletions luzer/compat.c
Original file line number Diff line number Diff line change
@@ -1,8 +1,18 @@
#include <lua.h>
#include <lualib.h>
#include <lauxlib.h>
#include "lua.h"
#include "lualib.h"
#include "lauxlib.h"

#if !defined(LUA_VERSION_NUM) || LUA_VERSION_NUM == 501
/*
* PUC-Rio Lua uses `lconfig_h` as include guard for `luaconf.h`,
* LuaJIT uses `luaconf_h`. If you use PUC-Rio's include files
* but LuaJIT's library, you will need to define the macro
* IS_LUAJIT yourself!
*/
#if !defined(IS_LUAJIT) && defined(luaconf_h)
#define IS_LUAJIT
#endif

#if !defined(LUA_VERSION_NUM) || (LUA_VERSION_NUM == 501 && !defined(IS_LUAJIT))

static int
countlevels(lua_State *L) {
Expand Down
4 changes: 4 additions & 0 deletions luzer/compat.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
#ifndef LUZER_COMPAT_H_
#define LUZER_COMPAT_H_

#if !defined(LUA_VERSION_NUM) || (LUA_VERSION_NUM == 501 && !defined(IS_LUAJIT))

void luaL_traceback(lua_State *L, lua_State *L1,
const char *msg, int level);

#endif

#endif // LUZER_COMPAT_H_
4 changes: 2 additions & 2 deletions luzer/custom_mutator_lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <lua.h>
#include <lauxlib.h>
#include "lua.h"
#include "lauxlib.h"

#include "luzer.h"

Expand Down
6 changes: 3 additions & 3 deletions luzer/fuzzed_data_provider.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
#ifdef __cplusplus
extern "C" {
#endif
#include <lua.h>
#include <lauxlib.h>
#include <lualib.h>
#include "lua.h"
#include "lauxlib.h"
#include "lualib.h"
#include <float.h>
#ifdef __cplusplus
} /* extern "C" */
Expand Down
6 changes: 3 additions & 3 deletions luzer/luzer.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
*/

#define _GNU_SOURCE
#include <lua.h>
#include <lualib.h>
#include <lauxlib.h>
#include "lua.h"
#include "lualib.h"
#include "lauxlib.h"
#include <stdint.h>
#include <stdlib.h>
#include <stdio.h>
Expand Down
2 changes: 1 addition & 1 deletion luzer/tracer.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
* atheris/src/native/counters.cc
*/

#include <lua.h>
#include "lua.h"
#include <stdint.h>
#include <string.h> /* strlen */

Expand Down