-
-
Save carbotaniuman/45a1a47c47a30b638b5386c369d65fb1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/src/test/ui/used/auxiliary/issue-47834-linkme-aux.rs b/src/test/ui/used/auxiliary/issue-47834-linkme-aux.rs | |
new file mode 100644 | |
index 00000000000..275e384da64 | |
--- /dev/null | |
+++ b/src/test/ui/used/auxiliary/issue-47834-linkme-aux.rs | |
@@ -0,0 +1,58 @@ | |
+mod sub { | |
+ #[cfg(target_os = "windows")] | |
+ #[link_section = ".linkme_XXX$b"] | |
+ #[used] | |
+ static YYY: fn() = real_fn; | |
+ | |
+ #[cfg(any( | |
+ target_os = "none", | |
+ target_os = "linux", | |
+ target_os = "macos", | |
+ target_os = "ios", | |
+ target_os = "tvos", | |
+ target_os = "illumos", | |
+ target_os = "freebsd", | |
+ ))] | |
+ #[link_section = "linkme_XXX"] | |
+ #[used] | |
+ static YYY: fn() = real_fn; | |
+ fn real_fn() {} | |
+} | |
+ | |
+pub fn byte_offset() -> usize { | |
+ #[cfg(any( | |
+ target_os = "none", | |
+ target_os = "linux", | |
+ target_os = "macos", | |
+ target_os = "ios", | |
+ target_os = "tvos", | |
+ target_os = "illumos", | |
+ target_os = "freebsd", | |
+ ))] | |
+ extern "C" { | |
+ #[link_name = "__start_linkme_XXX"] | |
+ static LINKME_START: fn(); | |
+ #[link_name = "__stop_linkme_XXX"] | |
+ static LINKME_STOP: fn(); | |
+ } | |
+ #[cfg(any( | |
+ target_os = "none", | |
+ target_os = "linux", | |
+ target_os = "illumos", | |
+ target_os = "freebsd" | |
+ ))] | |
+ #[link_section = "linkme_XXX"] | |
+ #[used] | |
+ static mut LINKME_PLEASE: [fn(); 0] = []; | |
+ | |
+ #[cfg(target_os = "windows")] | |
+ #[link_section = ".linkme_XXX$a"] | |
+ static LINKME_START: () = (); | |
+ #[cfg(target_os = "windows")] | |
+ #[link_section = ".linkme_XXX$c"] | |
+ static LINKME_STOP: () = (); | |
+ | |
+ unsafe { | |
+ &LINKME_START as *const _ as usize - &LINKME_STOP as *const _ as usize | |
+ } | |
+} | |
diff --git a/src/test/ui/used/issue-47834-linkme.rs b/src/test/ui/used/issue-47834-linkme.rs | |
new file mode 100644 | |
index 00000000000..2c38f1ea49a | |
--- /dev/null | |
+++ b/src/test/ui/used/issue-47834-linkme.rs | |
@@ -0,0 +1,9 @@ | |
+// run-pass | |
+// aux-build:issue-47834-linkme-aux.rs | |
+ | |
+extern crate issue_47834_linkme_aux as inner; | |
+ | |
+use inner::byte_offset; | |
+fn main() { | |
+ assert!(byte_offset() > 0); | |
+} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment