Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
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
2 changes: 2 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,10 @@ jobs:
-DANDROID_PLATFORM=android-33 \
-DANDROID_ABI=arm64-v8a ../..
cmake --build .
${{ steps.setup-ndk.outputs.ndk-path }}/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-strip kptools
mv kptools kptools-android


- name: Release
uses: ncipollo/release-action@v1.14.0
with:
Expand Down
4 changes: 2 additions & 2 deletions kernel/include/kpmodule.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
__attribute__((section(".kpm.info"), unused, aligned(1))) = #name "=" info

#define KPM_NAME_LEN 32
#define KPM_VERSION_LEN 12
#define KPM_VERSION_LEN 32
#define KPM_LICENSE_LEN 32
#define KPM_AUTHOR_LEN 32
#define KPM_DESCRIPTION_LEN 512
Expand Down Expand Up @@ -41,4 +41,4 @@ typedef long (*mod_exitcall_t)(void *reserved);
#define KPM_EXIT(fn) \
static mod_exitcall_t __kpm_exitcall_##fn __attribute__((__used__)) __attribute__((__section__(".kpm.exit"))) = fn

#endif
#endif
3 changes: 2 additions & 1 deletion tools/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ build/*

preset.h
kptools
kptools.exe

#
build_android.sh
build_android.sh
29 changes: 23 additions & 6 deletions tools/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
cmake_minimum_required(VERSION 3.5)
project(kptools)

include_directories(${CMAKE_CURRENT_BINARY_DIR})
file(GLOB_RECURSE LIB_SOURCES "lib/*.c")

include_directories(${CMAKE_CURRENT_BINARY_DIR})
add_definitions(-DZSTD_DISABLE_ASM)
add_definitions(-DXZ_DEC_ANY_CHECK)
set(SOURCES
image.c
kallsym.c
Expand All @@ -13,13 +16,29 @@ set(SOURCES
symbol.c
kpm.c
common.c
sha256.c
bootimg.c
)

add_executable(
kptools
${SOURCES}
${LIB_SOURCES}
)

add_executable(kptools ${SOURCES})
file(GLOB_RECURSE ALL_HEADERS "lib/*.h")
set(LIB_INCLUDE_DIRS "")
foreach(_header_file ${ALL_HEADERS})
get_filename_component(_dir ${_header_file} DIRECTORY)
list(APPEND LIB_INCLUDE_DIRS ${_dir})
endforeach()
list(REMOVE_DUPLICATES LIB_INCLUDE_DIRS)

target_include_directories(kptools PRIVATE ${LIB_INCLUDE_DIRS})
target_compile_definitions(kptools PRIVATE BZ_NO_STDIO)
find_package(ZLIB REQUIRED)

target_include_directories(kptools PRIVATE ${ZLIB_INCLUDE_DIRS})

if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static")
# 显式指定静态库路径
Expand All @@ -28,6 +47,4 @@ elseif(CMAKE_SYSTEM_NAME STREQUAL "Android")
target_link_libraries(kptools PRIVATE ${ZLIB_LIBRARIES})
else()
target_link_libraries(kptools PRIVATE ${ZLIB_LIBRARIES})
endif()

target_include_directories(kptools PRIVATE ${ZLIB_INCLUDE_DIRS})
endif()
23 changes: 14 additions & 9 deletions tools/Makefile
Original file line number Diff line number Diff line change
@@ -1,25 +1,30 @@

CFLAGS = -std=c11 -Wall -Wextra -Wno-unused -Wno-unused-parameter
CFLAGS += -I. -I./lib -DBZ_NO_STDIO -DXZ_DEC_ANY_CHECK
LDFLAGS = -static -lz

ifdef DEBUG
CFLAGS += -DDEBUG -g
CFLAGS += -DDEBUG -g
endif

objs := image.o kallsym.o kptools.o order.o insn.o patch.o symbol.o kpm.o common.o
objs += sha256.o
OBJS := image.o kallsym.o kptools.o order.o insn.o patch.o symbol.o kpm.o common.o bootimg.o

LIB_SRCS := $(wildcard lib/*.c) $(wildcard lib/*/*.c)
LIB_OBJS := $(LIB_SRCS:.c=.o)


ALL_OBJS := $(OBJS) $(LIB_OBJS)

.PHONY: all
all: kptools

.PHONY: kptools
kptools: ${objs}
${CC} -o $@ $^ $(LDFLAGS)
kptools: $(ALL_OBJS)
$(CC) -o $@ $^ $(LDFLAGS)


%.o : %.c
$(CC) -c $(CFLAGS) $(CPPFLAGS) $< -o $@

.PHONY: clean
clean:
rm -rf preset.h
rm -rf kptools
find . -name "*.o" | xargs rm -f
rm *.o
Loading