[llvm-dev] [lld] [arm] Linker Cannot Set Custom Section Type to NOBITS

Daniel Way via llvm-dev llvm-dev at lists.llvm.org
Tue Sep 1 00:26:25 PDT 2020


I am linking a program to be loaded in an ARM Cortex-M0+ based
microcontroller. In the linker script, I have a section allocated for the
stack which roughly looks like the following.
.stack : { . += __stack_size__; } > ram

Using the linker in the gcc arm toolchain, arm-none-eabi-ld, this section
is automatically set to type NOBITS, however, when linking with version
10.0.0 of ld.lld, the section type is PROGBITS.
Here is the output when using readelf.

*ld.lld*
Section Headers:
  [Nr] Name              Type            Addr     Off    Size   ES Flg Lk
Inf Al
  ...
  [ 5] .stack            PROGBITS        1ffff000 0014f0 000400 00   A  0
0  1

*arm-none-eabi-ld*
Section Headers:
  [Nr] Name              Type            Addr     Off    Size   ES Flg Lk
Inf Al
  ...
  [ 5] .stack            NOBITS          1ffff000 01f000 000400 00  WA  0
0  1

Reading online, I found that I should add the (NOLOAD) directive to my
linker script, so I tried the following.
.stack (NOLOAD) :  { . += __stack_size__; } > ram

But this change to the linker script does not seem to affect the output ELF
file. Interestingly, if I add the (NOLOAD) directive to the script's
.data section,
the .data section will change to type NOBITS.
I'd like to know if I'm making any errors, either in the section definition
itself or when I call the linker.

Thank you,
Daniel Way
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20200901/db091826/attachment.html>


More information about the llvm-dev mailing list