Created
May 18, 2023 17:28
-
-
Save jarkkojs/8529b5e06f71c1b80549820075f12a13 to your computer and use it in GitHub Desktop.
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
macro(bin2elf Path Name) | |
set(objcopy_flags -I binary -O elf64-littleriscv -B riscv --rename-section .data=.rodata,alloc,load,readonly,data,contents) | |
string(MAKE_C_IDENTIFIER ${Path} unstripped) | |
add_custom_command( | |
OUTPUT ${Path}.o | |
COMMAND ${CMAKE_OBJCOPY} ${objcopy_flags} ${Path} ${Path}.o | |
COMMAND ${CMAKE_OBJCOPY} --redefine-sym _binary_${unstripped}_start=${Name}_start ${Path}.o | |
COMMAND ${CMAKE_OBJCOPY} --redefine-sym _binary_${unstripped}_end=${Name}_end ${Path}.o | |
COMMAND ${CMAKE_OBJCOPY} --redefine-sym _binary_${unstripped}_size=${Name}_size ${Path}.o | |
) | |
message(${unstripped}) | |
endmacro() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment