diff --git a/platform.txt b/platform.txt index 230fd2af..8b41cd0a 100644 --- a/platform.txt +++ b/platform.txt @@ -17,7 +17,7 @@ compiler.warning_flags.all=-Wall -Wextra compiler.path={build.compiler_path} compiler.c.cmd={build.crossprefix}gcc -compiler.c.flags=-g -c {compiler.warning_flags} {compiler.zephyr.macros} "@{compiler.zephyr.cflags_file}" -MMD -mcpu={build.mcu} {build.float-abi} {build.fpu} +compiler.c.flags=-g -c {compiler.warning_flags} {compiler.zephyr.macros} "@{compiler.zephyr.cflags_file}" -fdata-sections -ffunction-sections -MMD -mcpu={build.mcu} {build.float-abi} {build.fpu} compiler.c.elf.cmd={build.crossprefix}g++ compiler.c.elf.flags=-Wl,--gc-sections -mcpu={build.mcu} {build.float-abi} {build.fpu} -std=gnu++17 compiler.S.cmd={build.crossprefix}g++ @@ -58,7 +58,8 @@ build.link_command="{compiler.path}{compiler.c.elf.cmd}" "-L{build.path}" "-L{bu build.check_command-dynamic={build.link_command} {build.link_args.check-dynamic} -o "{build.path}/{build.project_name}_check.tmp" build.check_command-static=/bin/true build.check_command-static.windows=cmd /C cd . -build.combine_command={build.link_command} {build.link_args.build-{build.link_mode}} {build.link_args.build-common} +build.combine_command={build.link_command} {build.link_args.build-{build.link_mode}} "-Wl,-Map,{build.path}/{build.project_name}_temp.map" -o "{build.path}/{build.project_name}_temp.elf" +build.combine_command_final={build.link_command} "-T{build.path}/rodata_split.ld" {build.link_args.build-{build.link_mode}} {build.link_args.build-common} # link_args.* are included by any link_command depending on the link_mode build.link_args.dynamic=-e main @@ -116,9 +117,11 @@ recipe.S.o.pattern="{compiler.path}{compiler.S.cmd}" {compiler.S.flags} -DARDUIN ## Create archives recipe.ar.pattern="{compiler.path}{compiler.ar.cmd}" {compiler.ar.flags} {compiler.ar.extra_flags} "{archive_file_path}" "{object_file}" -## Combine gc-sections, archives, and objects +## Combine gc-sections, archives, and objects - Two-pass linking recipe.c.combine.1.pattern={build.check_command-{build.link_mode}} recipe.c.combine.2.pattern={build.combine_command} +recipe.c.combine.3.pattern="{runtime.platform.path}/extra/gen_rodata_ld" "{build.path}/{build.project_name}_temp.elf" "{build.path}/rodata_split.ld" "{build.link_mode}" +recipe.c.combine.4.pattern={build.combine_command_final} recipe.c.combine.pattern={build.combine_command} recipe.hooks.linking.postlink.1.pattern="{compiler.path}{build.crossprefix}strip" --strip-debug "{build.path}/{build.project_name}_debug.elf" -o "{build.path}/{build.project_name}.elf" diff --git a/variants/_ldscripts/build-dynamic.ld b/variants/_ldscripts/build-dynamic.ld index c5e8dc41..e90bff3d 100644 --- a/variants/_ldscripts/build-dynamic.ld +++ b/variants/_ldscripts/build-dynamic.ld @@ -42,12 +42,6 @@ SECTIONS { __static_thread_data_list_end = .; } - .rodata : { - *(.rodata) - *(.rodata1) - *(.rodata.*) - } - .data : { *(.data .data.*) } @@ -82,10 +76,6 @@ SECTIONS { KEEP(*(.shstrtab)) } - .rel : { - KEEP(*(.rel .rel.*)) - } - .got : { KEEP(*(.got .got.* .got.plt .got.plt*)) }