From 0ed35c9ae0434dcda2d5d3e3f0be77fa1f323283 Mon Sep 17 00:00:00 2001 From: Daniel Xu Date: Fri, 3 Jul 2020 20:59:53 -0700 Subject: [PATCH] rust: Fix rust modules test I noticed that the modules test was failing. Some choice use of `nm` revealed `TWENTY_THREE` was not in the final binary. Fix by taking a pointer to the global, forcing the linker to keep the symbol in. gdb/testsuite/ChangeLog 2020-07-11 Daniel Xu PR rust/26121 * gdb.rust/modules.rs: Prevent linker from discarding test symbol. Signed-off-by: Daniel Xu --- gdb/testsuite/ChangeLog | 6 ++++++ gdb/testsuite/gdb.rust/modules.rs | 3 ++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index c0f1f1cc14c..ec0f8322e32 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2020-07-11 Daniel Xu + + PR rust/26121 + * gdb.rust/modules.rs: Prevent linker from discarding test + symbol. + 2020-07-10 Pedro Alves PR gdb/26199 diff --git a/gdb/testsuite/gdb.rust/modules.rs b/gdb/testsuite/gdb.rust/modules.rs index 6db082817b5..479e6529cdc 100644 --- a/gdb/testsuite/gdb.rust/modules.rs +++ b/gdb/testsuite/gdb.rust/modules.rs @@ -60,7 +60,8 @@ pub mod mod1 { let f2 = || println!("lambda f2"); - let copy = ::TWENTY_THREE; + // Prevent linker from discarding symbol + let ptr: *const u16 = &::TWENTY_THREE; f2(); // set breakpoint here f3(); -- 2.30.2