We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
hello,
While I am trying to execute a simple bubble sort program in c as provided as an example in the arm development studio IDE, I am facing 3 errors like as shown below: (Target and source must be capability)
/bubblesort.c:45:37: error: invalid target type 'uint32_t *' (aka 'unsigned int *') for __cheri_tocap: target must be a capability seq_t sequence = (__cheri_tocap seq_t)malloc(sizeof(uint32_t) * SEQ_LEN);
../bubblesort.c:57:33: error: invalid source type 'uint32_t *' (aka 'unsigned int *') for __cheri_fromcap: source must be a capability free((__cheri_fromcap void*)sequence);
/bubblesort.c:70:6: error: conflicting types for 'print'void print (seq_t __cheri_input sequence, int size) {
N.B: I am using LLVM 13.0.0 with Morello support.
Many thanks, Kevin. What I noticed is that in line number 24 as compared to my previous code instead of $PROGRAM_NAME, if I replace it with $PROGRAM_NAME.elf after -o, there itself the elf is getting generated. However, is there are any need to run line 25 to generate the elf then..with the llvm-objcopy? Or what is the purpose of executing line 25 please?
# COMPILATION SCRIPT # Script based on instructions from: # https://git.morello-project.org/morello/docs/-/blob/morello/release-1.6/standalone-baremetal-readme.rst # First argument = program name (must match basename of .c file) PROGRAM_NAME=$1 PWD=`pwd` TOOLCHAIN=/opt/llvm-project-releases-morello-baremetal-release-1.6 ################################################ # COMPILE PROGRAM #new technique $TOOLCHAIN/bin/clang -target aarch64-none-elf -march=morello -c $PROGRAM_NAME.c -o $PROGRAM_NAME.o -O3 -g $TOOLCHAIN/bin/clang -target aarch64-none-elf -o $PROGRAM_NAME.elf $PROGRAM_NAME.o -Wl,--image-base,0xe0000000 #$TOOLCHAIN/bin/llvm-objcopy -O binary $PROGRAM_NAME.elf $PROGRAM_NAME # #
Your new version is correct. Using llvm-objcopy is required to generate a raw binary that can be used as non-secure payload, as suggested in the instructions. You cannot directly use an ELF executable as payload.
Many thanks, Kevin for the information. Once I apply the script to generate the elf as shown in line no 25 (script shown below), the elf is generating but I am not sure once I try to view the elf file by right-clicking and viewing through the elf content editor it displays that it is not a valid elf file.
# COMPILATION SCRIPT # Script based on instructions from: # https://git.morello-project.org/morello/docs/-/blob/morello/release-1.6/standalone-baremetal-readme.rst # First argument = program name (must match basename of .c file) PROGRAM_NAME=$1 PWD=`pwd` TOOLCHAIN=/opt/llvm-project-releases-morello-baremetal-release-1.6 ################################################ # COMPILE PROGRAM #new technique $TOOLCHAIN/bin/clang -target aarch64-none-elf -march=morello -c $PROGRAM_NAME.c -o $PROGRAM_NAME.o -O3 -g $TOOLCHAIN/bin/clang -target aarch64-none-elf -o $PROGRAM_NAME $PROGRAM_NAME.o -Wl,--image-base,0xe0000000 $TOOLCHAIN/bin/llvm-objcopy -O binary $PROGRAM_NAME $PROGRAM_NAME.elf # #
ok so is this version correct? changed line 24 with $PROGRAM_NAME.elf after -o and in line 25 used $PROGRAM_NAME.elf as first argument instead of the second as shown below.
_
# COMPILATION SCRIPT # Script based on instructions from: # https://git.morello-project.org/morello/docs/-/blob/morello/release-1.6/standalone-baremetal-readme.rst # First argument = program name (must match basename of .c file) PROGRAM_NAME=$1 PWD=`pwd` TOOLCHAIN=/opt/llvm-project-releases-morello-baremetal-release-1.6 ################################################ # COMPILE PROGRAM #new technique $TOOLCHAIN/bin/clang -target aarch64-none-elf -march=morello -c $PROGRAM_NAME.c -o $PROGRAM_NAME.o -O3 -g $TOOLCHAIN/bin/clang -target aarch64-none-elf -o $PROGRAM_NAME.elf $PROGRAM_NAME.o -Wl,--image-base,0xe0000000 $TOOLCHAIN/bin/llvm-objcopy -O binary $PROGRAM_NAME.elf $PROGRAM_NAME # #