[PATCH v2] rust: Fix rust modules test

Daniel Xu dxu@dxuuu.xyz
Tue Jul 7 08:08:03 GMT 2020


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(-)

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();
-- 
2.27.0



More information about the Gdb-patches mailing list