Hello everyone,

I'm setting up a new build targeting an embedded platform (LM32) and trying to integrate a CRC32 into the resulting ELF. I have previously done this using plain Makefiles with the following steps (pseudo code):

target.elf: <obj-files>
   link <obj-files> --symbol CRC_VALUE=0 intermediate.elf
   objcopy --binary intermediate.elf intermediate.bin
   link <obj-files> --symbol CRC_VALUE=`crc32 intermediate.bin` target.elf
   rm intermediate.bin

Now I would like to achieve the same thing with CMake. I'm using add_executable with multiple targets. The end of my CMakeLists.txt looks like this, where F_GEN contains generic source files and F__* source files specific for that variant of the build:

# [...defining of cross compiler, and source files, some compile flags, etc...]
# Educate the linker
add_link_options(
    -nostartfiles
    -nodefaultlibs
    -nostdlib
    -Wl,--gc-sections
    -T ${CMAKE_SOURCE_DIR}/${P_SRC}/romram.ld
    -Wl,--defsym=CRC_VALUE=0
    -Wl,--defsym=_start=0
    )

# DOM v2 target
add_executable( clb_v2_dom.elf ${F_GEN} ${F__DOM} )
target_compile_definitions(clb_v2_dom.elf PUBLIC -DDOM -DCLBV2 )

# BASE v2 target
add_executable( clb_v2_base.elf ${F_GEN} ${F__BASE} )
# TODO migrate define 'DUBASE' -> 'BASE'
target_compile_definitions(clb_v2_base.elf PUBLIC -DDUBASE -DBASE -DCLBV2)

# Golden v2 target
add_executable( clb_v2_golden.elf ${F_GEN} ${F__GLD} )
target_compile_definitions( clb_v2_golden.elf PUBLIC -DGOLDEN -DCLBV2 )

==

As you can see CRC_VALUE is now simply defined 0 for every target. Which works well for compiling but during runtime poses a problem to the ROM verification procedure. What would a 'proper' way be of adding a CRC to an ELF file be using CMake, and be different for each target. Any help is welcome!

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