I am trying to build an application manually using arm-none-eabi-gcc. The build goes fine but I get the following error during link time:
error: no memory region specified for loadable section `.bss'
No other errors nor warnings. Just the build's output and this error, I ended up trying back to the most basic type of linker script file that still allows me to build my app. This is the simplest/simplified linker script I can use and stil leads to the above error message:
MEMORY
{
foo : ORIGIN = 0x50000000, LENGTH = 0xF0000000
}
SECTIONS
{
.sram :
{
__sram_bss_start = .;
*(.bss)
*(.bss*)
*(.text)
__sram_bss_end = .;
} > foo
}
That's the linker file. Nothing more, nothing less.
As you can see the .bss segment is clearly defined so it is not clear to me why the linker is complaining.
This is how I am building and linking:
...
SOURCES := source1.c
SOURCES += source2.c
...
OBJECTS := $(SOURCES:$(MYSRCDIR)/%.c=$(MYOBJDIR)/%.o)
LD_FLAGS := -nostartfiles
LD_FLAGS += -T linkerScript.ld
LD_FLAGS += --entry=Reset_Handler
LD_FLAGS += -Wl,-Map,"memoryMap.map"
LD_FLAGS += -mcpu=cortex-m7
LD_FLAGS += -mthumb
LD_FLAGS += -mlittle-endian
LD_FLAGS += -mfloat-abi=hard
LD_FLAGS += -mfpu=fpv5-sp-d16
LD_FLAGS += -specs=nano.specs
LD_FLAGS += -specs=nosys.specs
LD_FLAGS += -lc
LD_FLAGS += -lm
LD_FLAGS += -lgcc
LD_FLAGS += --sysroot="/usr/lib/arm-none-eabi/newlib"
#LD_FLAGS += --verbose
all: $(BIN)
$(BIN): $(OBJECTS)
$(CC) -o $@ $^ $(LD_FLAGS)
$(OBJDIR)/%.o : $(SRCDIR)/%.c
@mkdir -p $(@D)
$(CC) $(INC) $(CFLAGS) -o $@ -c $< $(DEFS)
```
Compiler & linker version:
$ arm-none-eabi-gcc -v
...
gcc version 9.2.1 20191025
$ arm-none-eabi-ld -v
GNU ld (2.34-4ubuntu1+13ubuntu1) 2.34
Did I misunderstand something here?
I expected the application to compile and link fine. I tried going through gnu's documentation to understand what I misunderstood. But no success so far.
UPDATE:
This linker file gets passed the aforementionned issue:
MEMORY
{
foo : ORIGIN = 0x50000000, LENGTH = 0xF0000000
}
SECTIONS
{
/* Works fine */
.sram : { *(.text) } > foo
.bss : { *(.bss) } > foo
/* Does not work */
/*
.text : { *(.text) } > foo
.sram : { *(.bss) } > foo
*/
}
So I presume it maybe somehow has issues with the sectionname .sram? Based on the information I could find online any sectionname can be given and this name is not dependent on any other definition/declaration/... elsewhere in the project