This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

NOLOAD section in scatter file

Hello,

I want to create one custom debug section in my elf similar to .comment section, is it possible by scatter load file?

I used to create NOLOAD type section in ld script, but how to do that in scatter file.

For example: 

Loadable :

13 debug_strings 00000064 00060000 00060000 000084c0 2**0 CONTENTS, ALLOC, LOAD, READONLY, DATA

Non-loadable

21 .note 00000048 00000000 00000000 0003c8e0 2**2 CONTENTS, READONLY
22 .comment 00000538 00000000 00000000 0003c928 2**0 CONTENTS, READONLY

these .note and .coment are default sections but I need to create another custom section like this.

With linker script (.ld), it was possible by NOLOAD option but with scatter file, there is no such option, can anyone please point if this is possible or any other alternate way?

Thanks & Regards,

Vivek Rajpara

Parents
  • Hi Vivek,

    Sorry, there is no direct equivalent ld's NOLOAD in armlink scatter-files, however it is possible to do something similar to what you want as follows:

    1) Define your custom .comment-like section as normal program data, e.g. using __attribute__((section("name")))
    developer.arm.com/.../Placing-functions-and-data-in-a-named-section

    2) Place all of the custom section in a separate load region in the scatter-file, with OVERLAY. OVERLAY allows this load region to be placed at an address (e.g. 0x0 in the example below) without clashing with other load regions that might be at the same address, and also prevents the C-library from automatically copying/zero-initialising it.

    MYCUSTOMSECTION_LR 0x0 OVERLAY {
      MYCUSTOMSECTION_ER 0x0 OVERLAY {
        *(.mydebugsection)
      }
    }

    3) Link with --keep=.mydebugsection to prevent the linker from discarding it as unused

    Unfortunately, the program header will still be marked as PT_LOAD in the ELF file i.e. part of the program, which you don't want. You could write a small tool to parse the ELF file and remove the PT_LOAD flag if that is of importance to you.

    Hope this helps

    Stephen

Reply
  • Hi Vivek,

    Sorry, there is no direct equivalent ld's NOLOAD in armlink scatter-files, however it is possible to do something similar to what you want as follows:

    1) Define your custom .comment-like section as normal program data, e.g. using __attribute__((section("name")))
    developer.arm.com/.../Placing-functions-and-data-in-a-named-section

    2) Place all of the custom section in a separate load region in the scatter-file, with OVERLAY. OVERLAY allows this load region to be placed at an address (e.g. 0x0 in the example below) without clashing with other load regions that might be at the same address, and also prevents the C-library from automatically copying/zero-initialising it.

    MYCUSTOMSECTION_LR 0x0 OVERLAY {
      MYCUSTOMSECTION_ER 0x0 OVERLAY {
        *(.mydebugsection)
      }
    }

    3) Link with --keep=.mydebugsection to prevent the linker from discarding it as unused

    Unfortunately, the program header will still be marked as PT_LOAD in the ELF file i.e. part of the program, which you don't want. You could write a small tool to parse the ELF file and remove the PT_LOAD flag if that is of importance to you.

    Hope this helps

    Stephen

Children