Linking twice for CRC32

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

Linking twice for CRC32

Vincent van Beveren
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

# 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
-O binary $<TARGET_FILE:clb_v2_dom.elf>.bin
$<TARGET_FILE:clb_v2_dom.elf>.bin > $<TARGET_FILE:clb_v2_dom.elf>.crc32

with linker flags defined as

# Bring up the linker
     -T ${CMAKE_SOURCE_DIR}/${P_SRC}/romram.ld

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,

National Institute for Subatomic Physics Nikhef
Department of Computer Technology
Science Park 105

tel.  : +31 (0)20 592 2032
e-mail: [hidden email]
site  :


Powered by

Please keep messages on-topic and check the CMake FAQ at:

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

CMake Support:
CMake Consulting:
CMake Training Courses:

Visit other Kitware open-source projects at

Follow this link to subscribe/unsubscribe: