Quantcast
Channel: Active questions tagged gcc - Stack Overflow
Viewing all articles
Browse latest Browse all 22009

How to link file without additional sections at the end?

$
0
0

I build a .bin file from one .c file with some constant arrays, which contain a website, I would like to flash to my STM32M7 using the arm-none-eabi-toolchain. While linking the .o file together with a .ld file I dump a .map file. At the end of the .map file after my arrays I recognised some additional sections. For my application it would be beneficial when the .bin would end exactly with the end of my arrays.

I tried some different atrributes while compiling and linking, but the sections are still there.

The end of the .map file looks like this:

 .rodata.file__status_html
                0x00000000080cfb2c       0x14 build/file.o
                0x00000000080cfb2c                file__status_html
 .rodata.file__style_css
                0x00000000080cfb40       0x14 build/file.o
                0x00000000080cfb40                file__style_css
 .comment       0x00000000080cfb54       0x7b build/file.o
                                         0x7c (size before relaxing)
 .ARM.attributes
                0x00000000080cfbcf       0x30 build/file.o
 .iplt          0x00000000080cfbff        0x0 build/file.o
 .rel.iplt      0x00000000080cfbff        0x0 build/file.o
 .igot.plt      0x00000000080cfbff        0x0 build/file.o
                0x00000000080cfbff                __website_section_end__ = .
OUTPUT(build/file.elf elf32-littlearm)

I run the follwing commands to get the .map file

arm-none-eabi-gcc file.c -std=gnu11 -g0 -DUSE_HAL_DRIVER -DSTM32F756xx -c -I "./inc/" -O2 -ffunction-sections -fdata-sections -Wall -Wunused-const-variable=0 -MMD -MP -MT"build/file.o" -MF"build/file.d" --specs=nano.specs -o "build/file.o"

arm-none-eabi-gcc -o "build/file.elf""build/file.o" -mcpu=cortex-m7 -T"my_linker_script.ld" -nostdlib -Wl,-Map,build/file.map

The linker script looks like this:

/* Memories definition */
MEMORY
{
    WEBSITE_MEMORY  (rx)    : ORIGIN = 0x080C0000,  LENGTH = 256K   
}

/* Sections */
SECTIONS
{
  .website_section :
  {
      . = ALIGN(4);
      __website_section_start__ = .;
      *(.website_section*)
      *file.o 
      __website_section_end__ = .;
  } > WEBSITE_MEMORY
}

I would rather get something like this:

.rodata.file__status_html
                0x00000000080cfb2c       0x14 build/file.o
                0x00000000080cfb2c                file__status_html
 .rodata.file__style_css
                0x00000000080cfb40       0x14 build/file.o
                0x00000000080cfb40                file__style_css
                0x00000000080cfb54                __website_section_end__ = .
OUTPUT(build/file.elf elf32-littlearm)

How is it possible to get rid of the .comment, .ARM.attributes, .iplt, .rel.iplt, .igot.plt sections?


Viewing all articles
Browse latest Browse all 22009

Trending Articles