5 Commits

8 changed files with 31 additions and 5 deletions

3
.gitmodules vendored
View File

@@ -4,3 +4,6 @@
[submodule "linklist-lib"] [submodule "linklist-lib"]
path = linklist-lib path = linklist-lib
url = https://git.shimatta.de/mhu/linklist-lib.git url = https://git.shimatta.de/mhu/linklist-lib.git
[submodule "test/catch2"]
path = test/catch2
url = https://git.shimatta.de/3rd-party/catch2.git

View File

@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.5) cmake_minimum_required(VERSION 3.5...3.18)
project(patchelfcrc LANGUAGES C) project(patchelfcrc LANGUAGES C)
@@ -91,3 +91,5 @@ else (DOXYGEN_FOUND)
message("${BoldMagenta}Doxygen needs to be installed to generate the doxygen documentation${ColorReset}") message("${BoldMagenta}Doxygen needs to be installed to generate the doxygen documentation${ColorReset}")
message("${BoldMagenta}doxygen target will not be available${ColorReset}") message("${BoldMagenta}doxygen target will not be available${ColorReset}")
endif (DOXYGEN_FOUND) endif (DOXYGEN_FOUND)
add_subdirectory(test)

View File

@@ -0,0 +1,9 @@
#!/bin/bash
function _patchelfcrc() {
echo "Cursor index: $COMP_CWORD"
echo "line as array: $COMP_WORDS"
echo "line as string: $COMP_LINE"
}
complete -F _patchelfcrc patchelfcrc

View File

@@ -61,7 +61,7 @@
: Export the calculated files to an XML file *XMLFILE*. : Export the calculated files to an XML file *XMLFILE*.
**--import**=*XMLFILE* **--import**=*XMLFILE*
: Import the CRCs from an XML file *XMLFILE* and do not caclulate anything in the given *ELF* : Import the CRCs from an XML file *XMLFILE* and do not calculate anything in the given *ELF*
**--help**, **-h**, **-?** **--help**, **-h**, **-?**
: Print help. : Print help.
@@ -134,7 +134,7 @@
**patchelfcrc** -l -g word --start-magic=0x12345678 --end-magic=0x8754321 -p crc-32-mpeg -f bare -O .outputsection -S .text executable.elf **patchelfcrc** -l -g word --start-magic=0x12345678 --end-magic=0x8754321 -p crc-32-mpeg -f bare -O .outputsection -S .text executable.elf
: Calculate the CRC over *.text* section and place the result in the *.outputsection* section. : Calculate the CRC over *.text* section and place the result in the *.outputsection* section.
The output sections start and end are checked for the given magic numbers in order to assure correct memory layout. The output sections start and end are checked for the given magic numbers in order to ensure correct memory layout.
*CRC-32-MPEG* is used as CRC algorithm. *CRC-32-MPEG* is used as CRC algorithm.
The memory is interpreted as *little endian* and the CRC calculation granularity is a 32 bit *word*. The memory is interpreted as *little endian* and the CRC calculation granularity is a 32 bit *word*.

11
test/CMakeLists.txt Normal file
View File

@@ -0,0 +1,11 @@
cmake_minimum_required(VERSION 3.5)
project(patchelfcrc-test LANGUAGES CXX C)
add_subdirectory(catch2 EXCLUDE_FROM_ALL)
add_custom_target(test "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}" "-r compact" "-s" DEPENDS ${PROJECT_NAME})
aux_source_directory("src" TEST_SOURCES)
set(DUT_SOURCES ${CMAKE_CURRENT_LIST_DIR}/../src/crc.c)
add_executable(${PROJECT_NAME} EXCLUDE_FROM_ALL ${TEST_SOURCES} ${DUT_SOURCES})
target_link_libraries(${PROJECT_NAME} PRIVATE Catch2::Catch2WithMain)

1
test/catch2 Submodule

Submodule test/catch2 added at 0631b607ee