2023-10-18

cmake binary file add.

cmake_minimum_required(VERSION 3.21)

project(example)

add_executable(main main.c)

add_executable(firmware firmware.bin)

target_link_libraries(main firmware)

# 대상의 크기를 바이트로 가져오는 함수 정의
function(get_size_of_data target)
  get_target_property(size ${target} SIZE)
  return(${size})
endfunction()

# 'firmware' 대상의 크기를 가져오고 'CMAKE_SIZE_OF_DATA' 변수에 저장
get_size_of_data(firmware)
set(CMAKE_SIZE_OF_DATA ${size})

# 'FIRMWARE_SIZE'를 킬로바이트(KB)로 변환
math(EXPR FIRMWARE_SIZE "${CMAKE_SIZE_OF_DATA} / 1024")

message("FIRMWARE_SIZE in KB: ${FIRMWARE_SIZE}")


사용법은....................................................................................
#include <stdio.h>

int main() {
  // 펌웨어 데이터를 가져옵니다.
  void *data = ((void(*)())firmware)();

  // 펌웨어 크기를 가져옵니다.
  int size = FIRMWARE_SIZE;

  // 펌웨어 데이터를 처리합니다.
  // ...

  return 0;
}

댓글 없음:

댓글 쓰기

암호화 + base64 하고 쉘스크립트.

 #!/bin/bash # IV와 UserKey를 설정합니다 (아스키 문자열을 그대로 사용). IV="0123456789abcdef"  UserKey="0123456789abcdef" # IV와 UserKey를 16...