build: Update declfuncs.lds.S to only use progmem sections on AVR
On non-avr platforms the declfunc stuff still needs to be in the binary in a rodata section. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
parent
343de9c454
commit
da305e6b61
4
Makefile
4
Makefile
|
@ -39,7 +39,7 @@ CFLAGS-y += -flto -fwhole-program
|
|||
|
||||
LDFLAGS-y := -Wl,--gc-sections
|
||||
|
||||
CPPFLAGS = -P -MD -MT $@
|
||||
CPPFLAGS = -I$(OUT) -P -MD -MT $@
|
||||
|
||||
CFLAGS = $(CFLAGS-y)
|
||||
LDFLAGS = $(LDFLAGS-y)
|
||||
|
@ -87,7 +87,7 @@ $(OUT)klipper.o: $(patsubst %.c, $(OUT)src/%.o,$(src-y)) $(OUT)declfunc.lds
|
|||
|
||||
$(OUT)compile_time_request.o: $(OUT)klipper.o ./scripts/buildcommands.py
|
||||
@echo " Building $@"
|
||||
$(Q)$(OBJCOPY) -j '.compile_time_request' -O binary $< $(OUT)klipper.o.compile_time_request
|
||||
$(Q)$(OBJCOPY) --dump-section '.compile_time_request'=$(OUT)klipper.o.compile_time_request $<
|
||||
$(Q)$(PYTHON) ./scripts/buildcommands.py $(OUT)klipper.o.compile_time_request $(OUT)autoconf.h $(OUT)compile_time_request.c
|
||||
$(Q)$(CC) $(CFLAGS) -c $(OUT)compile_time_request.c -o $@
|
||||
|
||||
|
|
|
@ -1,13 +1,21 @@
|
|||
// Linker script that defines symbols around sections. The DECL_X()
|
||||
// macros need this linker script to place _start and _end symbols
|
||||
// around the list of declared items.
|
||||
#include "autoconf.h" // CONFIG_MACH_AVR
|
||||
#include "compiler.h" // __PASTE
|
||||
|
||||
#if CONFIG_MACH_AVR
|
||||
#define DECL_SECTION .progmem.data.
|
||||
#else
|
||||
#define DECL_SECTION .rodata.
|
||||
#endif
|
||||
|
||||
#define DECLWRAPPER(NAME) \
|
||||
.progmem.data. ## NAME : SUBALIGN(1) { \
|
||||
__PASTE(DECL_SECTION, NAME) : SUBALIGN(1) { \
|
||||
NAME ## _start = . ; \
|
||||
*( .progmem.data. ## NAME ##.pre* ) \
|
||||
*( .progmem.data. ## NAME ##* ) \
|
||||
*( .progmem.data. ## NAME ##.post* ) \
|
||||
*( .rodata. ## NAME ##.pre* ) \
|
||||
*( .rodata. ## NAME ##* ) \
|
||||
*( .rodata. ## NAME ##.post* ) \
|
||||
NAME ## _end = . ; \
|
||||
}
|
||||
|
||||
|
@ -23,4 +31,7 @@ SECTIONS
|
|||
.compile_time_request.parsers 0 (INFO) : {
|
||||
*( .compile_time_request.parsers )
|
||||
}
|
||||
.compile_time_request (INFO) : {
|
||||
*( .compile_time_request )
|
||||
}
|
||||
}
|
||||
|
|
|
@ -42,7 +42,7 @@ struct callback_handler {
|
|||
};
|
||||
#define _DECL_CALLBACK(NAME, FUNC) \
|
||||
const struct callback_handler _DECL_ ## NAME ## _ ## FUNC __visible \
|
||||
__section(".progmem.data." __stringify(NAME) ) = { .func = FUNC }
|
||||
__section(".rodata." __stringify(NAME) ) = { .func = FUNC }
|
||||
|
||||
#define foreachdecl(ITER, NAME) \
|
||||
extern typeof(*ITER) NAME ## _start[], NAME ## _end[]; \
|
||||
|
|
Loading…
Reference in New Issue