Add linking step
This commit is contained in:
5
Makefile
5
Makefile
@@ -28,7 +28,10 @@ ASM_FILES := $(patsubst $(BUILD_DIR)/%.i,$(BUILD_DIR)/%.S,$(PREP_FILES))
|
||||
OBJ_FILES := $(patsubst $(BUILD_DIR)/%.S,$(BUILD_DIR)/%.o,$(ASM_FILES))
|
||||
|
||||
.PHONY: build
|
||||
build: builddir preprocess compile assemble
|
||||
build: builddir preprocess compile assemble $(BUILD_DIR)/final.elf
|
||||
|
||||
$(BUILD_DIR)/final.elf: $(OBJ_FILES)
|
||||
$(CC) $(LDFLAGS) $^ -o $@
|
||||
|
||||
$(BUILD_DIR)/%.i: $(SRC_DIR)/%.c
|
||||
$(CC) $(CFLAGS) -E $^ -o $@
|
||||
|
||||
BIN
build/final.elf
Executable file
BIN
build/final.elf
Executable file
Binary file not shown.
156
build/final.elf.map
Normal file
156
build/final.elf.map
Normal file
@@ -0,0 +1,156 @@
|
||||
|
||||
Discarded input sections
|
||||
|
||||
.text 0x00000000 0x0 build/main.o
|
||||
.data 0x00000000 0x0 build/main.o
|
||||
.bss 0x00000000 0x0 build/main.o
|
||||
.group 0x00000000 0xc build/startup.o
|
||||
.group 0x00000000 0xc build/startup.o
|
||||
.group 0x00000000 0xc build/startup.o
|
||||
.group 0x00000000 0xc build/startup.o
|
||||
.group 0x00000000 0xc build/startup.o
|
||||
.group 0x00000000 0xc build/startup.o
|
||||
.text 0x00000000 0x0 build/startup.o
|
||||
.data 0x00000000 0x0 build/startup.o
|
||||
.bss 0x00000000 0x0 build/startup.o
|
||||
|
||||
Memory Configuration
|
||||
|
||||
Name Origin Length Attributes
|
||||
flash 0x08000000 0x00080000 xr
|
||||
sram 0x20000000 0x00020000 xrw
|
||||
*default* 0x00000000 0xffffffff
|
||||
|
||||
Linker script and memory map
|
||||
|
||||
LOAD /nix/store/yr89i11mszv2az19r26l372zgaiivj1c-gcc-arm-embedded-12.3.rel1/bin/../lib/gcc/arm-none-eabi/12.3.1/../../../../arm-none-eabi/lib/libc_nano.a
|
||||
LOAD /nix/store/yr89i11mszv2az19r26l372zgaiivj1c-gcc-arm-embedded-12.3.rel1/bin/../lib/gcc/arm-none-eabi/12.3.1/libgcc.a
|
||||
LOAD build/main.o
|
||||
LOAD build/startup.o
|
||||
0x20020000 stack_start = (ORIGIN (sram) + LENGTH (sram))
|
||||
|
||||
.isr_vector 0x08000000 0x198
|
||||
0x08000000 . = ALIGN (0x4)
|
||||
*(.isr_vector)
|
||||
.isr_vector 0x08000000 0x198 build/startup.o
|
||||
0x08000000 interrupt_vector_table
|
||||
0x08000198 . = ALIGN (0x4)
|
||||
|
||||
.text 0x08000198 0x84
|
||||
0x08000198 . = ALIGN (0x4)
|
||||
*(.text)
|
||||
*(.text.*)
|
||||
.text.main 0x08000198 0x10 build/main.o
|
||||
0x08000198 main
|
||||
.text.init_memory
|
||||
0x080001a8 0x64 build/startup.o
|
||||
0x080001a8 init_memory
|
||||
.text.reset 0x0800020c 0x10 build/startup.o
|
||||
0x0800020c reset
|
||||
*(.rodata)
|
||||
*(.rodata.*)
|
||||
0x0800021c . = ALIGN (0x4)
|
||||
0x0800021c _data_addr = LOADADDR (.data)
|
||||
|
||||
.glue_7 0x0800021c 0x0
|
||||
.glue_7 0x0800021c 0x0 linker stubs
|
||||
|
||||
.glue_7t 0x0800021c 0x0
|
||||
.glue_7t 0x0800021c 0x0 linker stubs
|
||||
|
||||
.vfp11_veneer 0x0800021c 0x0
|
||||
.vfp11_veneer 0x0800021c 0x0 linker stubs
|
||||
|
||||
.v4_bx 0x0800021c 0x0
|
||||
.v4_bx 0x0800021c 0x0 linker stubs
|
||||
|
||||
.iplt 0x0800021c 0x0
|
||||
.iplt 0x0800021c 0x0 build/startup.o
|
||||
|
||||
.rel.dyn 0x0800021c 0x0
|
||||
.rel.iplt 0x0800021c 0x0 build/startup.o
|
||||
|
||||
.data 0x20000000 0x0 load address 0x0800021c
|
||||
0x20000000 . = ALIGN (0x4)
|
||||
0x20000000 _data_start = .
|
||||
*(.data)
|
||||
*(.data.*)
|
||||
0x20000000 . = ALIGN (0x4)
|
||||
0x20000000 _data_end = .
|
||||
|
||||
.igot.plt 0x20000000 0x0 load address 0x0800021c
|
||||
.igot.plt 0x20000000 0x0 build/startup.o
|
||||
|
||||
.bss 0x20000000 0x0 load address 0x0800021c
|
||||
0x20000000 . = ALIGN (0x4)
|
||||
0x20000000 _bss_start = .
|
||||
*(.bss)
|
||||
*(.bss.*)
|
||||
0x20000000 _bss_end = .
|
||||
0x20000000 . = ALIGN (0x4)
|
||||
OUTPUT(build/final.elf elf32-littlearm)
|
||||
LOAD linker stubs
|
||||
|
||||
.debug_info 0x00000000 0x1be
|
||||
.debug_info 0x00000000 0x48 build/main.o
|
||||
.debug_info 0x00000048 0x176 build/startup.o
|
||||
|
||||
.debug_abbrev 0x00000000 0x14a
|
||||
.debug_abbrev 0x00000000 0x3c build/main.o
|
||||
.debug_abbrev 0x0000003c 0x10e build/startup.o
|
||||
|
||||
.debug_aranges 0x00000000 0x48
|
||||
.debug_aranges
|
||||
0x00000000 0x20 build/main.o
|
||||
.debug_aranges
|
||||
0x00000020 0x28 build/startup.o
|
||||
|
||||
.debug_rnglists
|
||||
0x00000000 0x2c
|
||||
.debug_rnglists
|
||||
0x00000000 0x13 build/main.o
|
||||
.debug_rnglists
|
||||
0x00000013 0x19 build/startup.o
|
||||
|
||||
.debug_macro 0x00000000 0x19f3
|
||||
.debug_macro 0x00000000 0xaaa build/main.o
|
||||
.debug_macro 0x00000aaa 0xafc build/startup.o
|
||||
.debug_macro 0x000015a6 0x22 build/startup.o
|
||||
.debug_macro 0x000015c8 0x8e build/startup.o
|
||||
.debug_macro 0x00001656 0x51 build/startup.o
|
||||
.debug_macro 0x000016a7 0x103 build/startup.o
|
||||
.debug_macro 0x000017aa 0x6a build/startup.o
|
||||
.debug_macro 0x00001814 0x1df build/startup.o
|
||||
|
||||
.debug_line 0x00000000 0x120
|
||||
.debug_line 0x00000000 0x4f build/main.o
|
||||
.debug_line 0x0000004f 0xd1 build/startup.o
|
||||
|
||||
.debug_str 0x00000000 0x3be8
|
||||
.debug_str 0x00000000 0x2da8 build/main.o
|
||||
.debug_str 0x00002da8 0xe40 build/startup.o
|
||||
0x3d41 (size before relaxing)
|
||||
|
||||
.comment 0x00000000 0x45
|
||||
.comment 0x00000000 0x45 build/main.o
|
||||
0x46 (size before relaxing)
|
||||
.comment 0x00000045 0x46 build/startup.o
|
||||
|
||||
.ARM.attributes
|
||||
0x00000000 0x34
|
||||
.ARM.attributes
|
||||
0x00000000 0x34 build/main.o
|
||||
.ARM.attributes
|
||||
0x00000034 0x34 build/startup.o
|
||||
|
||||
.debug_line_str
|
||||
0x00000000 0x210
|
||||
.debug_line_str
|
||||
0x00000000 0x35 build/main.o
|
||||
.debug_line_str
|
||||
0x00000035 0x1db build/startup.o
|
||||
0x21b (size before relaxing)
|
||||
|
||||
.debug_frame 0x00000000 0x84
|
||||
.debug_frame 0x00000000 0x30 build/main.o
|
||||
.debug_frame 0x00000030 0x54 build/startup.o
|
||||
3868
build/startup.S
Normal file
3868
build/startup.S
Normal file
File diff suppressed because it is too large
Load Diff
1538
build/startup.i
Normal file
1538
build/startup.i
Normal file
File diff suppressed because it is too large
Load Diff
BIN
build/startup.o
Normal file
BIN
build/startup.o
Normal file
Binary file not shown.
43
link.ld
Normal file
43
link.ld
Normal file
@@ -0,0 +1,43 @@
|
||||
ENTRY(reset);
|
||||
|
||||
MEMORY {
|
||||
flash(rx) : ORIGIN = 0x08000000, LENGTH = 512K
|
||||
sram(rwx) : ORIGIN = 0x20000000, LENGTH = 128K
|
||||
}
|
||||
stack_start = ORIGIN(sram) + LENGTH(sram); /* stack points to end of sram */
|
||||
|
||||
SECTIONS {
|
||||
.isr_vector : {
|
||||
. = ALIGN(4);
|
||||
KEEP(*(.isr_vector))
|
||||
. = ALIGN(4);
|
||||
} > flash
|
||||
|
||||
.text : { /* code and constants */
|
||||
. = ALIGN(4);
|
||||
*(.text)
|
||||
*(.text.*)
|
||||
*(.rodata)
|
||||
*(.rodata.*)
|
||||
. = ALIGN(4);
|
||||
} > flash
|
||||
|
||||
_data_addr = LOADADDR(.data);
|
||||
.data : { /* intialized variables */
|
||||
. = ALIGN(4);
|
||||
_data_start = .;
|
||||
*(.data)
|
||||
*(.data.*)
|
||||
. = ALIGN(4);
|
||||
_data_end = .;
|
||||
} > sram AT > flash /* loads the section into sram, with initial values stored in flash */
|
||||
|
||||
.bss : { /* unintialized variables */
|
||||
. = ALIGN(4);
|
||||
_bss_start = .;
|
||||
*(.bss)
|
||||
*(.bss.*)
|
||||
_bss_end = .;
|
||||
. = ALIGN(4);
|
||||
} > sram
|
||||
}
|
||||
34
src/startup.c
Normal file
34
src/startup.c
Normal file
@@ -0,0 +1,34 @@
|
||||
#include <stdint.h>
|
||||
|
||||
extern void stack_start(void); // Defined in link.ld
|
||||
extern int main(void);
|
||||
|
||||
void init_memory(void) {
|
||||
// Copy .data SECTION to ram
|
||||
extern uint32_t _data_start, _data_end, _data_addr;
|
||||
for (uint32_t *dst = &_data_start, *src = &_data_addr; dst < &_data_end;) {
|
||||
*dst++ = *src++;
|
||||
}
|
||||
|
||||
// Initialize .bss SECTION with zeros
|
||||
extern uint32_t _bss_start, _bss_end;
|
||||
for (uint32_t *dst = &_bss_start; dst < &_bss_end; dst++) {
|
||||
*dst = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void reset(void) {
|
||||
(void)init_memory();
|
||||
|
||||
main();
|
||||
|
||||
// Infinite loop in case main returns
|
||||
for (;;) (void) 0;
|
||||
}
|
||||
|
||||
// Create minimal interrupt vector table
|
||||
// 16 standard and 86 STM32F411xC/E-specific handlers
|
||||
void (*const interrupt_vector_table[16 + 86])(void) __attribute__((section(".isr_vector"))) = {
|
||||
stack_start, // Defined in link.ld
|
||||
reset
|
||||
};
|
||||
Reference in New Issue
Block a user