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.

How I can specify fill for gap after .TI.bound: sections?

I want fill all unused space in image with FF.

My code contain some variable with #pragma LOCATION attribute

#ifdef FOR_BOOTLOADER
#if defined(TMS570) && !defined(NO_OS)
#pragma RETAIN(device_fw_info_ptr)
#pragma LOCATION(device_fw_info_ptr , 0x00018000)
const volatile device_fw_info_t* const device_fw_info_ptr = &device_fw_info;
//#pragma RETAIN(dummy_data)
//#pragma LOCATION(dummy_data , 0x00018004)
//const volatile uint32_t dummy_data=0xFFFFFFFF;
#endif
#endif

Even I  run linker with --fill_value=0xFFFFFFFF hole after device_fw_info_ptr not filled. I try to add line

    .TI.bound:device_fw_info_ptr > FLASH0             palign(8), fill = 0xffffffff
or

    .TI.bound:* > FLASH0             palign(8), fill = 0xffffffff

to link.cmd file - same result.

This memory dump from debugger.

device_fw_info_ptr
0x00041C98    0x00000000
$C$SL1
0x66726571    0x00A00000
$C$SL3
0x2573203D    0x2025670D    0x0A000000
$C$SL4
0x41636365

objcopy --fill_gap=0xFF will this gap with FF

To solve this issue add fake variable dummy_data. But this isn't good solution.

 

  • The section .TI.bound:device_fw_info_ptr is 4 bytes long.  And all 4 bytes are used to contain the address of device_fw_info.  There is nothing to fill.  That why these lines ...

    Vladimir Romanov said:

        .TI.bound:device_fw_info_ptr > FLASH0             palign(8), fill = 0xffffffff
    or

        .TI.bound:* > FLASH0             palign(8), fill = 0xffffffff

    ... do nothing.

    You start by saying this ...

    Vladimir Romanov said:
    I want fill all unused space in image with FF.

    Consider applying the memory fill operator to the definition of the FLASH0 memory range.  Please read more about that in the section titled MEMORY Directive Syntax in the ARM assembly tools manual.

    Thanks and regards,

    -George

  • Fill attribute for MEMORY will lead to huge binary image. I don't want use this solution.

    According to "8.5.4.2.5 Alignment With Padding"

    combination of palign & fill section will lead to fill of padding area.

    If the linker adds padding to an initialized output section then the padding space is also initialized. By

    default, padding space is filled with a value of 0 (zero). However, if a fill value is specified for the output

    section then any padding for the section is also filled with that fill value. For example, consider the

    following section specification:

    .mytext: palign(8), fill = 0xffffffff {} > PMEM

    In this example, the length of the .mytext section is 6 bytes before the palign operator is applied. The

    contents of .mytext are as follows:

    addr content

    ---- -------

    0000 0x1234

    0002 0x1234

    0004 0x1234

    After the palign operator is applied, the length of .mytext is 8 bytes, and its contents are as follows:

    addr content

    ---- -------

    0000 0x1234

    0002 0x1234

    0004 0x1234

    0006 0xffff

  • I apologize for overlooking the palign.  You're right.  This is a problem in the linker.  It appears #pragma LOCATION and palign do not work together.  I filed SDSCM00052872 in the SDOWP system to have this investigated.  You are welcome to follow it with the SDOWP link below in my signature.

    In this meantime, consider this workaround.  In the C file, change the #pragma LOCATION to a #pragma DATA_SECTION ...

    #pragma DATA_SECTION(device_fw_info_ptr, "for_device");
    

    And change the .TI.bound line in the linker command file to this ...

        for_device > 0x00018000, palign(8), fill = 0xffffffff
        /* The section name "for_device" can be whatever you like. */
        /* But it has to match the #pragma DATA_SECTION name.      */

    Thanks and regards,

    -George

  • Now I solve this problem by adding dummy value (commented in my code at topic start)