From 1927d230043fbcbadd11ac63d9fe621adb706a50 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Quentin?= Date: Mon, 18 Dec 2023 16:15:59 +0100 Subject: [PATCH] Merge .text_init into .text on RISC-V (#1038) * Merge `.text_init` into `.text` * Only merge `init.*` into `.text` for RISC-V --- esp-hal-common/ld/esp32c2/esp32c2.x | 13 +------------ esp-hal-common/ld/esp32c3/esp32c3.x | 13 +------------ esp-hal-common/ld/esp32c6/esp32c6.x | 11 ----------- esp-hal-common/ld/esp32h2/esp32h2.x | 11 ----------- esp-hal-common/ld/sections/text.x | 5 +++++ 5 files changed, 7 insertions(+), 46 deletions(-) diff --git a/esp-hal-common/ld/esp32c2/esp32c2.x b/esp-hal-common/ld/esp32c2/esp32c2.x index 9bb183a5401..dd800c29363 100644 --- a/esp-hal-common/ld/esp32c2/esp32c2.x +++ b/esp-hal-common/ld/esp32c2/esp32c2.x @@ -43,17 +43,6 @@ SECTIONS { . = ABSOLUTE(_stext); } > ROTEXT } -INSERT BEFORE .text_init; - -SECTIONS { - /* These symbols/functions need to be near eachother, group them together at the start of text */ - .text_init _stext : ALIGN(4) - { - KEEP(*(.init)); - KEEP(*(.init.rust)); - KEEP(*(.text.abort)); - } > ROTEXT -} INSERT BEFORE .text; SECTIONS { @@ -75,7 +64,7 @@ SECTIONS { /* Start at the same alignement constraint than .text */ . = ALIGN(4); /* Create an empty gap as big as .text section */ - . = . + SIZEOF(.text) + SIZEOF(.text_init); + . = . + SIZEOF(.text); /* Prepare the alignement of the section above. Few bytes (0x20) must be * added for the mapping header. */ . = ALIGN(0x10000) + 0x20; diff --git a/esp-hal-common/ld/esp32c3/esp32c3.x b/esp-hal-common/ld/esp32c3/esp32c3.x index 52a51ae1990..2584e7a6418 100644 --- a/esp-hal-common/ld/esp32c3/esp32c3.x +++ b/esp-hal-common/ld/esp32c3/esp32c3.x @@ -43,17 +43,6 @@ SECTIONS { . = ABSOLUTE(_stext); } > ROTEXT } -INSERT BEFORE .text_init; - -SECTIONS { - /* These symbols/functions need to be near eachother, group them together at the start of text */ - .text_init _stext : ALIGN(4) - { - KEEP(*(.init)); - KEEP(*(.init.rust)); - KEEP(*(.text.abort)); - } > ROTEXT -} INSERT BEFORE .text; SECTIONS { @@ -75,7 +64,7 @@ SECTIONS { /* Start at the same alignement constraint than .text */ . = ALIGN(4); /* Create an empty gap as big as .text section */ - . = . + SIZEOF(.text) + SIZEOF(.text_init); + . = . + SIZEOF(.text); /* Prepare the alignement of the section above. Few bytes (0x20) must be * added for the mapping header. */ . = ALIGN(0x10000) + 0x20; diff --git a/esp-hal-common/ld/esp32c6/esp32c6.x b/esp-hal-common/ld/esp32c6/esp32c6.x index daabd82b805..52282c7796b 100644 --- a/esp-hal-common/ld/esp32c6/esp32c6.x +++ b/esp-hal-common/ld/esp32c6/esp32c6.x @@ -49,17 +49,6 @@ PROVIDE(interrupt0 = DefaultHandler); /* Must be called __global_pointer$ for linker relaxations to work. */ PROVIDE(__global_pointer$ = _data_start + 0x800); -SECTIONS { - /* These symbols/functions need to be near eachother, group them together at the start of text */ - .text_init _stext : ALIGN(4) - { - KEEP(*(.init)); - KEEP(*(.init.rust)); - KEEP(*(.text.abort)); - } > ROTEXT -} -INSERT BEFORE .text; - SECTIONS { .trap : ALIGN(4) { diff --git a/esp-hal-common/ld/esp32h2/esp32h2.x b/esp-hal-common/ld/esp32h2/esp32h2.x index ec76f6309bf..8565d94e3aa 100644 --- a/esp-hal-common/ld/esp32h2/esp32h2.x +++ b/esp-hal-common/ld/esp32h2/esp32h2.x @@ -43,17 +43,6 @@ PROVIDE(_start_trap = default_start_trap); /* Must be called __global_pointer$ for linker relaxations to work. */ PROVIDE(__global_pointer$ = _data_start + 0x800); -SECTIONS { - /* These symbols/functions need to be near eachother, group them together at the start of text */ - .text_init _stext : ALIGN(4) - { - KEEP(*(.init)); - KEEP(*(.init.rust)); - KEEP(*(.text.abort)); - } > ROTEXT -} -INSERT BEFORE .text; - SECTIONS { .trap : ALIGN(4) { diff --git a/esp-hal-common/ld/sections/text.x b/esp-hal-common/ld/sections/text.x index bda6b67b69f..2f7c0cb4484 100644 --- a/esp-hal-common/ld/sections/text.x +++ b/esp-hal-common/ld/sections/text.x @@ -4,6 +4,11 @@ SECTIONS { .text : ALIGN(4) { + #IF riscv + KEEP(*(.init)); + KEEP(*(.init.rust)); + KEEP(*(.text.abort)); + #ENDIF *(.literal .text .literal.* .text.*) } > ROTEXT