This repository was archived by the owner on Nov 28, 2023. It is now read-only.
  
  
  
  
  
Description
It could be that something is going wrong with the linker script. A binary of a small example is almost 7 MB in size:
-rwxrwxr-x 2 user user 6.7M Jun  2 18:13 target/riscv64gc-unknown-none-elf/release/interrupt
 
Using size, this seems to be allocated to data sections:
$ size target/riscv64gc-unknown-none-elf/release/interrupt
   text    data     bss     dec     hex filename
  38522 6176916   73732 6289170  5ff712 target/riscv64gc-unknown-none-elf/release/interrupt
 
Digigng further:
$ riscv64-unknown-elf-objdump -x target/riscv64gc-unknown-none-elf/release/interrupt
  4 .bss          00012004  000000008000a000  000000008000a000  0000abf8  2**12
                  ALLOC
  5 .heap         00000000  000000008001c004  000000008001c004  0000abf8  2**0
                  CONTENTS, ALLOC, LOAD, DATA
  6 .stack        005e3ffc  000000008001c004  000000008001c004  0000abf8  2**0
                  CONTENTS, ALLOC, LOAD, DATA
 
It seems the stack section is in the binary, padded fully with zeros:
riscv64-unknown-elf-objdump --section=.stack -s target/riscv64gc-unknown-none-elf/release/interrupt
Contents of section .stack:
 8001c004 00000000 00000000 00000000 00000000  ................
…
 805ffff4 00000000 00000000 00000000           ............    
 
I'm not sure why this is not treated like the .bss section, implicitly implied to be filled with zeros (the section is correctly labeled NOLOAD, but are not generated with ELF section type SHT_NOBITS).