Hello  everyone,

For integrating the CRC to an ELF I believe I will need to link twice. First to create a binary on which to caclulate the CRC, and using a second pass to actually put the CRC into a the symbol at the last part of the RAM. Using the pointers by Eric  Noulard I have constructed the following CMake code, which links the file, exports a binary BIN file (the actual ROM image, and then calculates the CRC into a file called $<TARGET_FILE:clb_v2_dom.elf>.crc32.

# Exprimental CRC32 support
add_library(clb_v2_dom.objs OBJECT ${F_GEN} ${F__DOM})
target_compile_definitions(clb_v2_dom.objs PUBLIC -DDOM -DCLBV2 )
add_executable(clb_v2_dom.elf $<TARGET_OBJECTS:clb_v2_dom.objs>)
add_custom_command(TARGET clb_v2_dom.elf POST_BUILD
    COMMAND ${CMAKE_OBJCOPY} $<TARGET_FILE:clb_v2_dom.elf> ${SECTIONS} -O binary $<TARGET_FILE:clb_v2_dom.elf>.bin     COMMAND ${Python_EXECUTABLE} ${CMAKE_SOURCE_DIR}/tools/crc32.py $<TARGET_FILE:clb_v2_dom.elf>.bin > $<TARGET_FILE:clb_v2_dom.elf>.crc32
)

with linker flags defined as

# Bring up the linker
add_link_options(
    -nostartfiles
    -nodefaultlibs
    -Wl,--gc-sections
    -nostdlib
    -T ${CMAKE_SOURCE_DIR}/${P_SRC}/romram.ld
    -Wl,--defsym=CRC_VALUE=0
    -Wl,--defsym=_start=0
    )

However, the last part is to link the file again with *exactly* the same invocation as the original linking, except for the '-Wl,--defsym=CRC_VALUE=<<content of .crc32 file>>' instead of 0.

Can anyone give me points on how to achieve this goal?

Kind regards,
Vincent

--
National Institute for Subatomic Physics Nikhef
Department of Computer Technology
Science Park 105
1098 XG AMSTERDAM

tel.  : +31 (0)20 592 2032
e-mail: v.van.beve...@nikhef.nl
site  : http://www.nikhef.nl/~vincentb

--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake

Reply via email to