Skip to content

Commit e06060d

Browse files
committed
Fix linker errors in examples
When following the example in the memory layout chapter, I found that linking with rustc 1.39.0 (command `cargo rustc -- -C link-arg=-Tlink.x`) produced the following error: ``` Compiling no_std_app v0.1.0 (/home/austin/repos/personal/no_std_experiment) error: linking with `rust-lld` failed: exit code: 1 | = note: "rust-lld" "-flavor" "gnu" "-L" "/home/austin/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/thumbv7m-none-eabi/lib" "/home/austin/repos/personal/no_std_experiment/target/thumbv7m-none-eabi/debug/deps/no_std_app-1e7c0fdb8e33f523.2ohn928r55zfdn1z.rcgu.o" "-o" "/home/austin/repos/personal/no_std_experiment/target/thumbv7m-none-eabi/debug/deps/no_std_app-1e7c0fdb8e33f523" "--gc-sections" "-L" "/home/austin/repos/personal/no_std_experiment/target/thumbv7m-none-eabi/debug/deps" "-L" "/home/austin/repos/personal/no_std_experiment/target/debug/deps" "-L" "/home/austin/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/thumbv7m-none-eabi/lib" "-Bstatic" "/home/austin/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/thumbv7m-none-eabi/lib/librustc_std_workspace_core-9864ecb2f3ae85f5.rlib" "/home/austin/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/thumbv7m-none-eabi/lib/libcore-a54bcae7919f0f3f.rlib" "/home/austin/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/thumbv7m-none-eabi/lib/libcompiler_builtins-a509ea259a1bcbbf.rlib" "-Tlink.x" "-Bdynamic" = note: rust-lld: error: no memory region specified for section '.ARM.exidx' error: aborting due to previous error error: could not compile `no_std_app`. To learn more, run the command again with --verbose. ``` This can be solved by adding `.ARM.exidx` alone (no `.*` extension) to the `/DISCARD/` portion of `link.x`. This change should be backwards compatible to older versions of tooling which, presumably, do not emit the bare top-level section. It also appears most of the other example linker scripts are prone to this, so I've fixed them as well.
1 parent 21730e8 commit e06060d

File tree

5 files changed

+5
-5
lines changed

5 files changed

+5
-5
lines changed

ci/asm/rt/link.x

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ SECTIONS
5555

5656
/DISCARD/ :
5757
{
58-
*(.ARM.exidx.*);
58+
*(.ARM.exidx .ARM.exidx.*);
5959
}
6060
}
6161

ci/exceptions/rt/link.x

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ SECTIONS
5555

5656
/DISCARD/ :
5757
{
58-
*(.ARM.exidx.*);
58+
*(.ARM.exidx .ARM.exidx.*);
5959
}
6060
}
6161

ci/main/rt/link.x

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,6 @@ SECTIONS
4545

4646
/DISCARD/ :
4747
{
48-
*(.ARM.exidx.*);
48+
*(.ARM.exidx .ARM.exidx.*);
4949
}
5050
}

ci/main/rt2/link.x

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,6 @@ SECTIONS
5151

5252
/DISCARD/ :
5353
{
54-
*(.ARM.exidx.*);
54+
*(.ARM.exidx .ARM.exidx.*);
5555
}
5656
}

ci/memory-layout/link.x

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,6 @@ SECTIONS
2929

3030
/DISCARD/ :
3131
{
32-
*(.ARM.exidx.*);
32+
*(.ARM.exidx .ARM.exidx.*);
3333
}
3434
}

0 commit comments

Comments
 (0)