[v2] rust: Fix rust modules test

Message ID 20200707080803.3635896-1-dxu@dxuuu.xyz
State New
Headers show
Series
  • [v2] rust: Fix rust modules test
Related show

Commit Message

Daniel Xu July 7, 2020, 8:08 a.m.
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/

        PR rust/26121
        * gdb.rust/modules.rs: Prevent linker from discarding test
          symbol

Signed-off-by: Daniel Xu <dxu@dxuuu.xyz>

---

Changes from V1:
* Add issue number to changelog

 gdb/testsuite/gdb.rust/modules.rs | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

-- 
2.27.0

Patch

diff --git a/gdb/testsuite/gdb.rust/modules.rs b/gdb/testsuite/gdb.rust/modules.rs
index 6db082817b..479e6529cd 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();