Skip to content

Commit

Permalink
Enable 'unwind_tables' for all platforms
Browse files Browse the repository at this point in the history
For ARM-based embedded firmware this requires
explicit declaration of `ARM.extab` sections in linker.d,
otherwise the exception tables can incorrectly end up in RAM.
(See ziglang/zig#22685.)
  • Loading branch information
marnix committed Feb 1, 2025
1 parent 68b5ad1 commit 590ab7b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,7 @@ pub fn MicroBuild(port_select: PortSelect) type {
.linkage = .static,
.root_source_file = mb.core_dep.path("src/start.zig"),
.strip = options.strip,
.unwind_tables = true,
}),
.app_mod = app_mod,
.target = target,
Expand Down
4 changes: 4 additions & 0 deletions tools/generate_linker_script.zig
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,10 @@ pub fn main() !void {

switch (program_args.cpu_arch) {
.arm, .thumb => try writer.writeAll(
\\ .ARM.extab : {
\\ *(.ARM.extab* .gnu.linkonce.armextab.*)
\\ } >flash0
\\
\\ .ARM.exidx : {
\\ *(.ARM.exidx* .gnu.linkonce.armexidx.*)
\\ } >flash0
Expand Down

0 comments on commit 590ab7b

Please sign in to comment.