Skip to content

Commit 649e570

Browse files
committed
Don't include eh_frame in the flashed firmware
1 parent 7da1a67 commit 649e570

5 files changed

Lines changed: 40 additions & 9 deletions

File tree

build-internals/build.zig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,9 @@ pub const LinkerScript = struct {
276276
/// Place rodata in the first region tagged as ram.
277277
ram,
278278
} = .flash,
279+
/// Give .eh_frame and .eh_frame_hdr the status of other elf debug
280+
/// sections (to not flash them to the device).
281+
eh_frame_no_load: bool = true,
279282
},
280283
};
281284
};

port/espressif/esp/ld/esp32_c3/direct_boot_sections.ld

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,13 @@ SECTIONS
8484
microzig_data_load_start = ORIGIN(DROM) + _irom_size + _drom_size;
8585
PROVIDE(__global_pointer$ = microzig_data_start + 0x800);
8686

87-
/DISCARD/ :
87+
.eh_frame_hdr 0 (INFO) :
8888
{
89-
*(.eh_frame_hdr)
90-
*(.eh_frame)
89+
KEEP(*(.eh_frame_hdr))
90+
}
91+
92+
.eh_frame 0 (INFO) :
93+
{
94+
KEEP(*(.eh_frame))
9195
}
9296
}

port/espressif/esp/ld/esp32_c3/flashless_sections.ld

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,13 @@ SECTIONS
5959

6060
PROVIDE(__global_pointer$ = microzig_data_start + 0x800);
6161

62-
/DISCARD/ :
62+
.eh_frame_hdr 0 (INFO) :
6363
{
64-
*(.eh_frame_hdr)
65-
*(.eh_frame)
64+
KEEP(*(.eh_frame_hdr))
65+
}
66+
67+
.eh_frame 0 (INFO) :
68+
{
69+
KEEP(*(.eh_frame))
6670
}
6771
}

port/espressif/esp/ld/esp32_c3/image_boot_sections.ld

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,9 +116,13 @@ SECTIONS
116116

117117
PROVIDE(__global_pointer$ = microzig_data_start + 0x800);
118118

119-
/DISCARD/ :
119+
.eh_frame_hdr 0 (INFO) :
120120
{
121-
*(.eh_frame_hdr)
122-
*(.eh_frame)
121+
KEEP(*(.eh_frame_hdr))
122+
}
123+
124+
.eh_frame 0 (INFO) :
125+
{
126+
KEEP(*(.eh_frame))
123127
}
124128
}

tools/generate_linker_script.zig

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,22 @@ pub fn main(init: std.process.Init) !void {
268268
, .{flash_region_name});
269269
}
270270

271+
if (options.eh_frame_no_load) {
272+
try writer.interface.writeAll(
273+
\\
274+
\\ .eh_frame_hdr 0 (INFO) :
275+
\\ {
276+
\\ KEEP(*(.eh_frame_hdr))
277+
\\ }
278+
\\
279+
\\ .eh_frame 0 (INFO) :
280+
\\ {
281+
\\ KEEP(*(.eh_frame))
282+
\\ }
283+
\\
284+
);
285+
}
286+
271287
try writer.interface.writeAll(
272288
\\
273289
\\ microzig_data_load_start = LOADADDR(.data);

0 commit comments

Comments
 (0)