This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Linux/PROCESSOR-SDK-AM335X: SPL image size in memory

Part Number: PROCESSOR-SDK-AM335X

Tool/software: Linux

Trying to extend some of the secure boot features utilizing a TPM and would love to take a hash of the SPL when it's loaded in internal memory.   Primary problem now is, I don't know the size of the image after it's loaded as the header information is stripped.  

I know it's located at 0x402F0400 with the Image max size being CONFIG_SPL_MAX_SIZE = (SRAM_SCRATCH_SPACE_ADDR - CONFIG_SPL_TEXT_BASE)

However, when the image size is smaller than this, something utilizes the memory after the image and a SHA-1 Hash of this location changes every-time on boot.

Is there another reference point that marks the end of SPL image in memory or something that denotes the location of whatever is utilizing the memory after the SPL image?  

Code would be executing from SPL - it will hash itself.  

  • Look in u-boot-spl.map and search for __end. That will be the end address of the image.

    Steve K.

  • I'm looking for something that will be available to code in during compile time.   This is a symbol I won't be able to reference in my code, correct?

  • I can't think of a way in code.

    Steve K.
  • Actually, that was perfect! You gave me the lead I needed to find my answer.

    The __end symbol attribute is defined in arch/arm/lib/sections.c attached to a char_end[0]:
    char __bss_start[0] __attribute__((section(".__bss_start")));
    char __bss_end[0] __attribute__((section(".__bss_end")));
    char __image_copy_start[0] __attribute__((section(".__image_copy_start")));
    char __image_copy_end[0] __attribute__((section(".__image_copy_end")));
    char __rel_dyn_start[0] __attribute__((section(".__rel_dyn_start")));
    char __rel_dyn_end[0] __attribute__((section(".__rel_dyn_end")));
    char __secure_start[0] __attribute__((section(".__secure_start")));
    char __secure_end[0] __attribute__((section(".__secure_end")));
    char __efi_runtime_start[0] __attribute__((section(".__efi_runtime_start")));
    char __efi_runtime_stop[0] __attribute__((section(".__efi_runtime_stop")));
    char __efi_runtime_rel_start[0] __attribute__((section(".__efi_runtime_rel_start")));
    char __efi_runtime_rel_stop[0] __attribute__((section(".__efi_runtime_rel_stop")));
    char _end[0] __attribute__((section(".__end")));


    In my code I can:
    extern char _end[];


    And referencing this gives me the address of the end of image! Thanks!