From a8af56431385a58b878931c3d67bda85c4aa7f92 Mon Sep 17 00:00:00 2001 From: Gabriel Hansson Date: Mon, 30 Jun 2025 15:19:02 +0200 Subject: [PATCH] Minor linker script touchups. (#3717) * refactor(esp-hal/ld): inline `rodata_desc.x` * refactor(esp-hal/ld): consolidate `.trap` section definition --- esp-hal/ld/esp32/esp32.x | 1 - esp-hal/ld/esp32c2/esp32c2.x | 10 ---------- esp-hal/ld/esp32c3/esp32c3.x | 10 ---------- esp-hal/ld/esp32c6/esp32c6.x | 10 ---------- esp-hal/ld/esp32h2/esp32h2.x | 9 --------- esp-hal/ld/esp32s2/esp32s2.x | 1 - esp-hal/ld/esp32s3/esp32s3.x | 1 - esp-hal/ld/sections/rodata.x | 11 ++++++++--- esp-hal/ld/sections/rodata_desc.x | 5 ----- esp-hal/ld/sections/rwtext.x | 8 ++++++++ 10 files changed, 16 insertions(+), 50 deletions(-) delete mode 100644 esp-hal/ld/sections/rodata_desc.x diff --git a/esp-hal/ld/esp32/esp32.x b/esp-hal/ld/esp32/esp32.x index 3b16c8759..e8c4a40be 100644 --- a/esp-hal/ld/esp32/esp32.x +++ b/esp-hal/ld/esp32/esp32.x @@ -16,7 +16,6 @@ INCLUDE "fixups/rtc_fast_rwdata_dummy.x" /* Shared sections - ordering matters */ SECTIONS { - INCLUDE "rodata_desc.x" INCLUDE "rwtext.x" INCLUDE "rwdata.x" } diff --git a/esp-hal/ld/esp32c2/esp32c2.x b/esp-hal/ld/esp32c2/esp32c2.x index cab75f215..e752191c7 100644 --- a/esp-hal/ld/esp32c2/esp32c2.x +++ b/esp-hal/ld/esp32c2/esp32c2.x @@ -1,14 +1,5 @@ /* esp32c2 fixups */ -SECTIONS { - .trap : ALIGN(4) - { - KEEP(*(.trap)); - *(.trap.*); - } > RWTEXT -} -INSERT BEFORE .rwtext; - SECTIONS { .rotext_dummy (NOLOAD) : { @@ -52,7 +43,6 @@ INSERT BEFORE .data; /* Shared sections - ordering matters */ SECTIONS { - INCLUDE "rodata_desc.x" INCLUDE "rwtext.x" INCLUDE "rwdata.x" } diff --git a/esp-hal/ld/esp32c3/esp32c3.x b/esp-hal/ld/esp32c3/esp32c3.x index 8012b939d..764f808b5 100644 --- a/esp-hal/ld/esp32c3/esp32c3.x +++ b/esp-hal/ld/esp32c3/esp32c3.x @@ -1,14 +1,5 @@ /* esp32c3 fixups */ -SECTIONS { - .trap : ALIGN(4) - { - KEEP(*(.trap)); - *(.trap.*); - } > RWTEXT -} -INSERT BEFORE .rwtext; - SECTIONS { .rotext_dummy (NOLOAD) : { @@ -52,7 +43,6 @@ INSERT BEFORE .data; /* Shared sections - ordering matters */ SECTIONS { - INCLUDE "rodata_desc.x" INCLUDE "rwtext.x" INCLUDE "rwdata.x" } diff --git a/esp-hal/ld/esp32c6/esp32c6.x b/esp-hal/ld/esp32c6/esp32c6.x index 535ff6b8e..4e45c6dbc 100644 --- a/esp-hal/ld/esp32c6/esp32c6.x +++ b/esp-hal/ld/esp32c6/esp32c6.x @@ -5,12 +5,6 @@ PROVIDE(interrupt0 = DefaultHandler); SECTIONS { - .trap : ALIGN(4) - { - KEEP(*(.trap)); - *(.trap.*); - } > RWTEXT - /* Shared sections - ordering matters */ INCLUDE "rwtext.x" INCLUDE "rwdata.x" @@ -36,10 +30,6 @@ INSERT BEFORE .text; /* end of esp32c6 fixups */ /* Shared sections #2 - ordering matters */ -SECTIONS { - INCLUDE "rodata_desc.x" -} - INCLUDE "rodata.x" INCLUDE "text.x" INCLUDE "rtc_fast.x" diff --git a/esp-hal/ld/esp32h2/esp32h2.x b/esp-hal/ld/esp32h2/esp32h2.x index 899951a80..3d2f098ae 100644 --- a/esp-hal/ld/esp32h2/esp32h2.x +++ b/esp-hal/ld/esp32h2/esp32h2.x @@ -4,12 +4,6 @@ PROVIDE(interrupt0 = DefaultHandler); SECTIONS { - .trap : ALIGN(4) - { - KEEP(*(.trap)); - *(.trap.*); - } > RWTEXT - /* Shared sections - ordering matters */ INCLUDE "rwtext.x" INCLUDE "rwdata.x" @@ -34,9 +28,6 @@ SECTIONS { INSERT BEFORE .text; /* Shared sections #2 - ordering matters */ -SECTIONS { - INCLUDE "rodata_desc.x" -} INCLUDE "rodata.x" INCLUDE "text.x" INCLUDE "rtc_fast.x" diff --git a/esp-hal/ld/esp32s2/esp32s2.x b/esp-hal/ld/esp32s2/esp32s2.x index 277807be2..9ddd4547c 100644 --- a/esp-hal/ld/esp32s2/esp32s2.x +++ b/esp-hal/ld/esp32s2/esp32s2.x @@ -24,7 +24,6 @@ INCLUDE "fixups/rtc_fast_rwdata_dummy.x" /* Shared sections - ordering matters */ SECTIONS { - INCLUDE "rodata_desc.x" INCLUDE "rwtext.x" INCLUDE "rwdata.x" } diff --git a/esp-hal/ld/esp32s3/esp32s3.x b/esp-hal/ld/esp32s3/esp32s3.x index 38395cf83..b8123d8dd 100644 --- a/esp-hal/ld/esp32s3/esp32s3.x +++ b/esp-hal/ld/esp32s3/esp32s3.x @@ -50,7 +50,6 @@ INSERT BEFORE .data; /* Shared sections - ordering matters */ SECTIONS { - INCLUDE "rodata_desc.x" INCLUDE "rwtext.x" INCLUDE "rwdata.x" } diff --git a/esp-hal/ld/sections/rodata.x b/esp-hal/ld/sections/rodata.x index 4d1832a86..5e484c26a 100644 --- a/esp-hal/ld/sections/rodata.x +++ b/esp-hal/ld/sections/rodata.x @@ -1,6 +1,11 @@ - - SECTIONS { + /* For ESP App Description, must be placed first in image */ + .rodata_desc : ALIGN(4) + { + KEEP(*(.rodata_desc)); + KEEP(*(.rodata_desc.*)); + } > RODATA + .rodata : ALIGN(4) { . = ALIGN (4); @@ -17,4 +22,4 @@ SECTIONS { *( .rodata_wlog_*.* ) . = ALIGN(4); } > RODATA -} \ No newline at end of file +} diff --git a/esp-hal/ld/sections/rodata_desc.x b/esp-hal/ld/sections/rodata_desc.x deleted file mode 100644 index ad102fc3b..000000000 --- a/esp-hal/ld/sections/rodata_desc.x +++ /dev/null @@ -1,5 +0,0 @@ -.rodata_desc : ALIGN(4) -{ - KEEP(*(.rodata_desc)); - KEEP(*(.rodata_desc.*)); -} > RODATA diff --git a/esp-hal/ld/sections/rwtext.x b/esp-hal/ld/sections/rwtext.x index d4ae0327e..7cd72b367 100644 --- a/esp-hal/ld/sections/rwtext.x +++ b/esp-hal/ld/sections/rwtext.x @@ -1,3 +1,11 @@ +#IF riscv +.trap : ALIGN(4) +{ + KEEP(*(.trap)); + *(.trap.*); +} > RWTEXT +#ENDIF + .rwtext : ALIGN(4) { . = ALIGN (4);