-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix objcopy and nm on ARM platforms (0.2.x) (#30)
* objcopy and nm commands now executed via cmake to use architecture specific tool. * Adding ARM build to CI. * Updated build script functions to use cmake for nm and objcopy. * Switched check_errors.sh script to use the sh interpreter rather than bash.
- Loading branch information
Showing
7 changed files
with
147 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[package] | ||
name = "cyclors" | ||
version = "0.2.2" | ||
version = "0.2.3" | ||
authors = ["kydos <[email protected]>"] | ||
license = "Apache-2.0" | ||
readme = "README.md" | ||
|
@@ -25,7 +25,7 @@ serde = { version = "1.0.154", features = ["derive"] } | |
serde_json = "1.0.94" | ||
|
||
[build-dependencies] | ||
bindgen = "0.68" | ||
bindgen = "0.69" | ||
cmake = "0.1" | ||
|
||
[features] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
cmake_minimum_required(VERSION 3.12) | ||
project(NM) | ||
|
||
# Include the CMakeFindBinUtils module to find nm | ||
include(CMakeFindBinUtils) | ||
|
||
# Ensure nm is available | ||
if(NOT CMAKE_NM) | ||
message(FATAL_ERROR "CMAKE_NM is not defined. Ensure nm is installed on your system!") | ||
else() | ||
message(STATUS "CMAKE_NM found: ${CMAKE_NM}") | ||
endif() | ||
|
||
# Ensure LIB_PATH is defined and exists | ||
if(NOT DEFINED LIB_PATH) | ||
message(FATAL_ERROR "LIB_PATH not specified!") | ||
else() | ||
if(NOT EXISTS ${LIB_PATH}) | ||
message(FATAL_ERROR "Library not found: ${LIB_PATH}") | ||
else() | ||
message(STATUS "LIB_PATH: ${LIB_PATH}") | ||
endif() | ||
endif() | ||
|
||
# Custom target to run nm on the library | ||
add_custom_target(read_symbols ALL | ||
COMMAND ${CMAKE_COMMAND} -E echo "Running nm on ${LIB_PATH}..." | ||
|
||
# Run nm and redirect stderr to a file | ||
COMMAND ${CMAKE_NM} --defined-only --print-file-name ${LIB_PATH} 1> ${LIB_PATH}.nm 2> ${LIB_PATH}.stderr | ||
|
||
# Check if stderr is empty (i.e., no errors were produced) | ||
COMMAND ${CMAKE_COMMAND} -E echo "Checking for nm errors..." | ||
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/check_errors.sh ${LIB_PATH}.stderr | ||
|
||
# Clean up stderr.txt after checking for errors | ||
COMMAND ${CMAKE_COMMAND} -E remove ${LIB_PATH}.stderr | ||
COMMENT "Reading library symbols with nm..." | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#!/bin/sh | ||
|
||
if [ ! -s $1 ]; then | ||
echo 'Command succeeded with no stderr output.' | ||
exit 0 | ||
else | ||
echo 'Command failed with errors:' | ||
cat stderr.txt | ||
exit 1 | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
cmake_minimum_required(VERSION 3.12) | ||
project(Objcopy) | ||
|
||
# Include the CMakeFindBinUtils module to find objcopy | ||
include(CMakeFindBinUtils) | ||
|
||
# Ensure objcopy is available | ||
if(NOT CMAKE_OBJCOPY) | ||
message(FATAL_ERROR "CMAKE_OBJCOPY is not defined. Ensure objcopy is installed on your system!") | ||
else() | ||
message(STATUS "CMAKE_OBJCOPY found: ${CMAKE_OBJCOPY}") | ||
endif() | ||
|
||
# Ensure LIB_PATH is defined and exists | ||
if(NOT DEFINED LIB_PATH) | ||
message(FATAL_ERROR "LIB_PATH not specified!") | ||
else() | ||
if(NOT EXISTS ${LIB_PATH}) | ||
message(FATAL_ERROR "Library not found: ${LIB_PATH}") | ||
else() | ||
message(STATUS "LIB_PATH: ${LIB_PATH}") | ||
endif() | ||
endif() | ||
|
||
# Ensure SYMBOL_FILE_PATH is defined and exists | ||
if(NOT DEFINED SYMBOL_FILE_PATH) | ||
message(FATAL_ERROR "SYMBOL_FILE_PATH not specified!") | ||
else() | ||
if(NOT EXISTS ${SYMBOL_FILE_PATH}) | ||
message(FATAL_ERROR "Symbol file not found: ${SYMBOL_FILE_PATH}") | ||
else() | ||
message(STATUS "SYMBOL_FILE_PATH: ${SYMBOL_FILE_PATH}") | ||
endif() | ||
endif() | ||
|
||
# Custom target to mangle the library | ||
add_custom_target(mangle_library ALL | ||
COMMAND ${CMAKE_COMMAND} -E echo "Running objcopy --redefine-syms on ${LIB_PATH} with symbols from ${SYMBOL_FILE_PATH}..." | ||
|
||
# Run objcopy and redirect stderr to a file | ||
COMMAND ${CMAKE_OBJCOPY} --redefine-syms=${SYMBOL_FILE_PATH} ${LIB_PATH} 2> ${LIB_PATH}.stderr | ||
|
||
# Check if stderr is empty (i.e., no errors were produced) | ||
COMMAND ${CMAKE_COMMAND} -E echo "Checking for objcopy errors..." | ||
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/check_errors.sh ${LIB_PATH}.stderr | ||
|
||
# Clean up stderr.txt after checking for errors | ||
COMMAND ${CMAKE_COMMAND} -E remove ${LIB_PATH}.stderr | ||
COMMENT "Mangling library with objcopy..." | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#!/bin/sh | ||
|
||
if [ ! -s $1 ]; then | ||
echo 'Command succeeded with no stderr output.' | ||
exit 0 | ||
else | ||
echo 'Command failed with errors:' | ||
cat stderr.txt | ||
exit 1 | ||
fi |