]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
rust: Fix rust modules test
authorDaniel Xu <dxu@dxuuu.xyz>
Sat, 4 Jul 2020 03:59:53 +0000 (20:59 -0700)
committerTom Tromey <tom@tromey.com>
Sat, 11 Jul 2020 22:08:28 +0000 (16:08 -0600)
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  <dxu@dxuuu.xyz>

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

Signed-off-by: Daniel Xu <dxu@dxuuu.xyz>
gdb/testsuite/ChangeLog
gdb/testsuite/gdb.rust/modules.rs

index c0f1f1cc14c3c50a414823aeaab35b09a7d3b93f..ec0f8322e32722d76b3ddc0cc377cfeb2bea69f9 100644 (file)
@@ -1,3 +1,9 @@
+2020-07-11  Daniel Xu  <dxu@dxuuu.xyz>
+
+       PR rust/26121
+       * gdb.rust/modules.rs: Prevent linker from discarding test
+       symbol.
+
 2020-07-10  Pedro Alves  <pedro@palves.net>
 
        PR gdb/26199
index 6db082817b531c2af96682ad9cd507d25802b8c1..479e6529cdca3bc36d3d943e9da984d7dbf8f86b 100644 (file)
@@ -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();