Matthias Krüger
8f5c09b37c
Rollup merge of #138349 - 1c3t3a:external-weak-cfi, r=rcvalle
...
Emit function declarations for functions with `#[linkage="extern_weak"]`
Currently, when declaring an extern weak function in Rust, we use the following syntax:
```rust
unsafe extern "C" {
#[linkage = "extern_weak"]
static FOO: Option<unsafe extern "C" fn() -> ()>;
}
```
This allows runtime-checking the extern weak symbol through the Option.
When emitting LLVM-IR, the Rust compiler currently emits this static as an i8, and a pointer that is initialized with the value of the global i8 and represents the nullabilty e.g.
```
`@FOO` = extern_weak global i8
`@_rust_extern_with_linkage_FOO` = internal global ptr `@FOO`
```
This approach does not work well with CFI, where we need to attach CFI metadata to a concrete function declaration, which was pointed out in https://github.com/rust-lang/rust/issues/115199 .
This change switches to emitting a proper function declaration instead of a global i8. This allows CFI to work for extern_weak functions. Example:
```
`@_rust_extern_with_linkage_FOO` = internal global ptr `@FOO`
...
declare !type !61 !type !62 !type !63 !type !64 extern_weak void `@FOO(double)` unnamed_addr #6
```
We keep initializing the Rust internal symbol with the function declaration, which preserves the correct behavior for runtime checking the Option.
r? `@rcvalle`
cc `@jakos-sec`
try-job: test-various
2025-03-17 16:34:50 +01:00
..
2025-03-17 11:12:10 +00:00
2025-02-24 09:26:54 +00:00
2024-12-15 19:01:45 +08:00
2025-02-24 09:26:54 +00:00
2024-10-31 18:20:11 +08:00
2025-02-11 13:41:35 -08:00
2024-12-19 20:36:51 +08:00
2024-11-27 07:18:25 -08:00
2025-03-12 00:56:43 -07:00
2025-02-18 16:11:41 +01:00
2025-02-11 13:41:35 -08:00
2024-12-11 21:34:48 +11:00
2025-03-12 00:56:43 -07:00
2025-03-14 01:45:10 +01:00
2025-02-11 13:41:35 -08:00
2025-02-24 09:26:54 +00:00
2025-02-24 09:26:54 +00:00
2024-12-19 20:36:51 +08:00
2025-03-11 00:27:32 +01:00
2025-02-24 09:26:54 +00:00
2025-02-24 09:26:54 +00:00
2025-03-17 16:34:50 +01:00
2025-02-27 12:23:00 +01:00
2025-02-27 12:22:59 +01:00
2025-02-24 09:26:54 +00:00
2025-02-24 09:26:54 +00:00
2025-02-24 09:26:54 +00:00
2025-02-24 09:26:54 +00:00
2025-02-24 09:26:54 +00:00
2025-02-24 09:26:54 +00:00
2025-02-24 09:26:54 +00:00
2025-02-18 16:11:41 +01:00
2025-01-30 11:22:46 +01:00
2025-02-16 18:37:50 +01:00
2025-02-16 18:37:50 +01:00
2025-02-16 18:37:50 +01:00
2025-02-11 13:41:35 -08:00
2025-02-11 13:41:35 -08:00
2025-02-10 21:38:44 +01:00
2025-02-11 13:41:35 -08:00
2025-02-11 13:41:35 -08:00
2025-02-11 13:41:35 -08:00
2025-02-11 13:41:35 -08:00
2025-02-11 13:41:35 -08:00
2024-12-13 00:04:56 +00:00
2024-12-19 20:36:51 +08:00
2025-02-11 13:41:35 -08:00
2025-02-11 13:41:35 -08:00
2025-02-21 21:51:20 -05:00
2025-01-31 22:29:08 -08:00
2025-02-11 13:41:35 -08:00
2025-02-11 13:41:35 -08:00
2025-01-26 03:48:27 -05:00
2025-02-11 13:41:35 -08:00
2025-02-24 09:26:54 +00:00
2025-02-24 09:26:54 +00:00
2025-02-11 13:41:35 -08:00
2025-02-11 13:41:35 -08:00
2025-02-24 09:26:54 +00:00
2025-02-11 13:41:35 -08:00
2025-02-24 09:26:54 +00:00
2025-02-11 13:41:35 -08:00
2025-02-11 13:41:35 -08:00
2025-02-11 13:41:35 -08:00
2025-02-11 13:41:35 -08:00
2025-02-14 18:55:50 +00:00
2025-02-17 16:36:14 -08:00
2025-02-17 16:36:14 -08:00
2024-10-23 04:42:03 +02:00
2025-02-11 13:41:35 -08:00
2025-02-11 13:41:35 -08:00
2025-02-03 10:39:32 -05:00
2025-02-11 13:41:35 -08:00
2024-12-19 20:36:51 +08:00
2025-02-11 13:41:35 -08:00
2024-12-19 20:36:51 +08:00
2025-02-11 13:41:35 -08:00
2025-02-11 13:41:35 -08:00
2025-02-24 09:26:54 +00:00
2025-02-11 13:41:26 -08:00
2025-02-11 13:41:35 -08:00
2025-02-11 13:41:35 -08:00
2025-02-11 13:41:35 -08:00
2025-02-11 13:41:35 -08:00
2025-02-11 13:41:35 -08:00
2025-02-11 13:41:35 -08:00
2025-02-11 13:41:35 -08:00
2025-02-11 13:41:35 -08:00
2025-02-24 09:26:54 +00:00
2025-02-11 13:41:35 -08:00
2025-02-24 09:26:54 +00:00
2025-02-03 10:39:32 -05:00
2025-02-24 09:26:54 +00:00
2025-02-11 13:41:35 -08:00
2025-02-24 09:26:54 +00:00
2025-01-21 06:59:15 -07:00
2025-02-19 15:15:29 +01:00
2025-02-24 09:26:54 +00:00
2025-02-11 13:41:35 -08:00
2025-02-11 13:41:35 -08:00
2025-02-19 08:41:19 +01:00
2024-11-14 17:44:54 +08:00
2025-02-11 13:41:35 -08:00
2025-02-11 13:41:35 -08:00
2025-02-11 13:41:35 -08:00
2025-02-11 13:41:35 -08:00
2025-02-11 13:41:35 -08:00
2025-02-11 13:41:35 -08:00
2025-02-11 13:41:35 -08:00
2025-03-12 00:56:43 -07:00
2025-02-11 13:41:35 -08:00
2024-12-10 01:29:43 -08:00
2025-02-11 13:41:35 -08:00
2025-02-11 13:41:35 -08:00
2025-01-10 22:53:54 +01:00
2025-02-11 13:41:35 -08:00
2025-02-11 13:41:35 -08:00
2025-02-11 13:41:35 -08:00
2025-02-11 13:41:35 -08:00
2024-12-10 21:41:05 +01:00
2025-02-24 09:26:54 +00:00
2025-02-11 13:41:35 -08:00
2025-02-11 13:41:35 -08:00
2025-02-11 13:41:35 -08:00
2025-02-11 13:41:35 -08:00
2025-02-11 13:41:35 -08:00
2025-02-11 13:41:35 -08:00
2025-02-11 13:41:35 -08:00
2025-01-23 17:19:53 +00:00
2025-02-11 13:41:35 -08:00
2025-02-11 13:41:35 -08:00
2025-02-23 21:23:36 +08:00
2025-02-11 13:41:35 -08:00
2025-02-11 13:41:35 -08:00
2025-02-11 13:41:35 -08:00
2025-03-06 10:50:23 +00:00
2025-02-11 13:41:35 -08:00
2025-02-11 13:41:35 -08:00
2025-02-24 09:26:54 +00:00
2025-02-19 11:32:32 +01:00
2025-02-11 13:41:35 -08:00
2025-02-11 13:41:35 -08:00
2025-02-11 13:41:35 -08:00
2025-03-12 22:39:43 -07:00
2025-02-11 13:41:35 -08:00
2025-02-24 09:26:54 +00:00
2025-02-11 13:41:35 -08:00
2025-02-24 09:26:54 +00:00
2025-02-11 13:41:35 -08:00
2025-02-11 13:41:35 -08:00
2025-02-11 13:41:35 -08:00
2025-02-11 13:41:35 -08:00
2025-02-11 13:41:35 -08:00
2025-02-11 13:41:35 -08:00
2025-03-02 18:53:49 +00:00
2024-11-06 02:22:00 -05:00
2025-02-11 13:41:35 -08:00
2025-02-12 23:01:27 -08:00
2025-02-14 22:24:27 -08:00
2025-02-11 13:41:35 -08:00
2025-02-11 13:41:35 -08:00
2025-02-13 21:26:48 -08:00
2025-02-11 13:41:35 -08:00
2025-02-11 13:41:35 -08:00
2025-02-24 09:26:54 +00:00
2025-02-11 13:41:35 -08:00
2025-02-24 09:26:54 +00:00
2025-02-24 09:26:54 +00:00
2025-02-11 13:41:35 -08:00
2025-02-11 13:41:35 -08:00
2025-02-11 13:41:35 -08:00
2025-02-11 13:41:35 -08:00
2025-03-06 19:56:21 +00:00
2025-02-24 09:26:54 +00:00
2025-02-06 18:21:13 +03:00
2025-02-11 13:41:35 -08:00
2025-02-24 09:26:54 +00:00
2025-02-11 13:41:35 -08:00
2025-02-11 13:41:35 -08:00
2025-02-11 13:41:35 -08:00
2025-02-19 11:36:52 -08:00
2025-03-16 05:17:07 +00:00
2025-02-11 13:41:35 -08:00
2025-02-19 11:36:52 -08:00
2025-02-25 17:46:05 -05:00
2025-02-23 21:23:36 +08:00
2025-02-19 11:36:52 -08:00
2025-02-11 13:41:35 -08:00
2025-02-11 13:41:35 -08:00
2025-02-11 13:41:35 -08:00
2025-02-11 13:41:35 -08:00
2025-02-11 13:41:35 -08:00
2025-02-11 13:41:35 -08:00
2025-02-11 13:41:35 -08:00
2025-02-11 13:41:35 -08:00
2025-02-11 13:41:35 -08:00
2025-02-11 13:41:35 -08:00
2025-02-11 13:41:35 -08:00
2025-02-11 13:41:35 -08:00
2025-02-11 13:41:35 -08:00
2025-02-11 13:41:35 -08:00
2025-02-11 13:41:35 -08:00
2025-02-11 13:41:35 -08:00
2025-02-27 12:58:18 +08:00
2025-02-11 13:41:35 -08:00
2025-02-11 13:41:35 -08:00
2025-02-11 13:41:35 -08:00
2025-02-06 23:44:23 +01:00
2025-01-28 19:10:26 +03:00
2025-02-11 13:41:35 -08:00