[arch][riscv] fix bug with gcc 10.2 & binutils 2.35 with section padding
In a two segment binary was previously trying to use MAXPAGESIZE set to 4 to cram the sections in very tight for embedded. This seemed to with this toolchain cause the linker to get confused and sometimes appear to stuff in an extra 4 bytes in the output file, thus misaligning the data segment. It's possible it's still a bug on my side in the linker, but setting max_page_size to 8 seems to work around it for now. Possible there's some implicit 64bit aligning slipped in a stage somewhere in binutils thats causing it to get confused. Either way, 8 byte alignment is no large loss here.
This commit is contained in:
@@ -32,7 +32,9 @@ SECTIONS
|
||||
*(.rodata .rodata.* .gnu.linkonce.r.*)
|
||||
} :rodata
|
||||
|
||||
/* trick to force any extra sections to be emitted here */
|
||||
. = .;
|
||||
|
||||
__rodata_end = .;
|
||||
__rom_end = . ;
|
||||
. = ALIGN(CONSTANT(MAXPAGESIZE));
|
||||
|
||||
@@ -36,7 +36,9 @@ SECTIONS
|
||||
*(.rodata .rodata.* .gnu.linkonce.r.*)
|
||||
} :rodata
|
||||
|
||||
/* trick to force any extra sections to be emitted here */
|
||||
. = .;
|
||||
|
||||
__rodata_end = .;
|
||||
__rom_end = . ;
|
||||
. = ALIGN(CONSTANT(MAXPAGESIZE));
|
||||
@@ -50,7 +52,7 @@ SECTIONS
|
||||
*/
|
||||
. = %MEMBASE%;
|
||||
|
||||
.data : AT ( ADDR (.dummy_post_rodata) + SIZEOF (.dummy_post_rodata) ) {
|
||||
.data : AT ( ADDR (.dummy_post_rodata) ) {
|
||||
__data_start = .;
|
||||
*(.data .data.* .gnu.linkonce.d.*)
|
||||
__ctor_list = .;
|
||||
|
||||
@@ -175,7 +175,11 @@ linkerscript.phony:
|
||||
ifeq (true,$(call TOBOOL,$(ARCH_RISCV_TWOSEGMENT)))
|
||||
GLOBAL_DEFINES += ARCH_RISCV_TWOSEGMENT=1
|
||||
LINKER_SCRIPT += $(BUILDDIR)/linker-twosegment.ld
|
||||
ARCH_LDFLAGS += -z max-page-size=4
|
||||
# set MAXPAGESIZE to 8 to cause the linker script to pack things in much tighter than
|
||||
# a paged sytem would.
|
||||
# NOTE: 8 seems to be about as far as you can go. experienced some extra stuffed words
|
||||
# when using 4.
|
||||
ARCH_LDFLAGS += -z max-page-size=8
|
||||
else
|
||||
GLOBAL_DEFINES += ARCH_RISCV_TWOSEGMENT=0
|
||||
LINKER_SCRIPT += $(BUILDDIR)/linker-onesegment.ld
|
||||
|
||||
Reference in New Issue
Block a user