<feed xmlns='http://www.w3.org/2005/Atom'>
<title>rust/tests/codegen/sanitizer/cfi, branch master</title>
<subtitle>https://github.com/rust-lang/rust
</subtitle>
<id>http://git.dreamy.place/mirrors/rust/atom?h=master</id>
<link rel='self' href='http://git.dreamy.place/mirrors/rust/atom?h=master'/>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/'/>
<updated>2025-07-22T12:28:48+00:00</updated>
<entry>
<title>Rename `tests/codegen` into `tests/codegen-llvm`</title>
<updated>2025-07-22T12:28:48+00:00</updated>
<author>
<name>Guillaume Gomez</name>
<email>guillaume1.gomez@gmail.com</email>
</author>
<published>2025-07-21T12:34:12+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=a27f3e3fd1e4d16160f8885b6b06665b5319f56c'/>
<id>urn:sha1:a27f3e3fd1e4d16160f8885b6b06665b5319f56c</id>
<content type='text'>
</content>
</entry>
<entry>
<title>Fix tests to drop now-skipped codegen</title>
<updated>2025-06-22T16:03:42+00:00</updated>
<author>
<name>Mark Rousskov</name>
<email>mark.simulacrum@gmail.com</email>
</author>
<published>2025-06-14T14:36:53+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=b4568d9135e55cfc8739b465970aa636a0d45c1b'/>
<id>urn:sha1:b4568d9135e55cfc8739b465970aa636a0d45c1b</id>
<content type='text'>
</content>
</entry>
<entry>
<title>Rollup merge of #138349 - 1c3t3a:external-weak-cfi, r=rcvalle</title>
<updated>2025-03-17T15:34:50+00:00</updated>
<author>
<name>Matthias Krüger</name>
<email>476013+matthiaskrgr@users.noreply.github.com</email>
</author>
<published>2025-03-17T15:34:50+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=8f5c09b37cd42bbad105bc6f81eaa681bc157259'/>
<id>urn:sha1:8f5c09b37cd42bbad105bc6f81eaa681bc157259</id>
<content type='text'>
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&lt;unsafe extern "C" fn() -&gt; ()&gt;;
}
```
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
</content>
</entry>
<entry>
<title>Emit function declarations for functions with #[linkage="extern_weak"]</title>
<updated>2025-03-17T08:27:53+00:00</updated>
<author>
<name>Bastian Kersting</name>
<email>bkersting@google.com</email>
</author>
<published>2025-03-11T11:00:42+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=b30cf11b9672cf9d938654a75aded1a2084b9980'/>
<id>urn:sha1:b30cf11b9672cf9d938654a75aded1a2084b9980</id>
<content type='text'>
Currently, when declaring an extern weak function in Rust, we use the
following syntax:
```rust
unsafe extern "C" {
   #[linkage = "extern_weak"]
   static FOO: Option&lt;unsafe extern "C" fn() -&gt; ()&gt;;
}
```
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.

We keep initializing the Rust internal symbol with the function
declaration, which preserves the correct behavior for runtime checking
the Option.

Co-authored-by: Jakob Koschel &lt;jakobkoschel@google.com&gt;
</content>
</entry>
<entry>
<title>Implement `#[define_opaque]` attribute for functions.</title>
<updated>2025-03-11T12:05:02+00:00</updated>
<author>
<name>Oli Scherer</name>
<email>git-spam-no-reply9815368754983@oli-obk.de</email>
</author>
<published>2024-07-26T10:04:02+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=cb4751d4b87e1c8ebdeb381abe3785486a59968e'/>
<id>urn:sha1:cb4751d4b87e1c8ebdeb381abe3785486a59968e</id>
<content type='text'>
</content>
</entry>
<entry>
<title>CFI: Append debug location to CFI blocks</title>
<updated>2024-11-11T09:17:43+00:00</updated>
<author>
<name>Bastian Kersting</name>
<email>bkersting@google.com</email>
</author>
<published>2024-11-08T08:51:19+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=c2102259a04dd9ede1e7faf01daa0dfcb948c214'/>
<id>urn:sha1:c2102259a04dd9ede1e7faf01daa0dfcb948c214</id>
<content type='text'>
</content>
</entry>
<entry>
<title>Set `signext` or `zeroext` for integer arguments on LoongArch64</title>
<updated>2024-10-23T02:42:21+00:00</updated>
<author>
<name>Asuna</name>
<email>SpriteOvO@gmail.com</email>
</author>
<published>2024-10-20T21:17:04+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=57bffe1d59cb6caa39c6ae5f5620c0cb371eea72'/>
<id>urn:sha1:57bffe1d59cb6caa39c6ae5f5620c0cb371eea72</id>
<content type='text'>
</content>
</entry>
<entry>
<title>Add missing module flags for CFI and KCFI sanitizers</title>
<updated>2024-08-21T20:23:56+00:00</updated>
<author>
<name>Sami Tolvanen</name>
<email>samitolvanen@google.com</email>
</author>
<published>2024-08-16T20:33:58+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=40f1d9d15472416c53f9558074899d007fbbd1c1'/>
<id>urn:sha1:40f1d9d15472416c53f9558074899d007fbbd1c1</id>
<content type='text'>
Set the cfi-normalize-integers and kcfi-offset module flags when
Control-Flow Integrity sanitizers are used, so functions generated by
the LLVM backend use the same CFI/KCFI options as rustc.

cfi-normalize-integers tells LLVM to also use integer normalization
for generated functions when -Zsanitizer-cfi-normalize-integers is
used.

kcfi-offset specifies the number of prefix nops between the KCFI
type hash and the function entry when -Z patchable-function-entry is
used. Note that LLVM assumes all indirectly callable functions use the
same number of prefix NOPs with -Zsanitizer=kcfi.
</content>
</entry>
<entry>
<title>Require any function with a tait in its signature to actually constrain a hidden type</title>
<updated>2024-06-12T08:53:59+00:00</updated>
<author>
<name>Oli Scherer</name>
<email>git-spam-no-reply9815368754983@oli-obk.de</email>
</author>
<published>2024-06-10T16:17:38+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=0bc2001879558ba0d51b6a246f5178853f9ff21e'/>
<id>urn:sha1:0bc2001879558ba0d51b6a246f5178853f9ff21e</id>
<content type='text'>
</content>
</entry>
<entry>
<title>Fix codegen test</title>
<updated>2024-06-07T08:50:18+00:00</updated>
<author>
<name>Oli Scherer</name>
<email>git-spam-no-reply9815368754983@oli-obk.de</email>
</author>
<published>2024-06-07T08:50:18+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=321d69d1955fe02d25129a353218f1e56e28a3bb'/>
<id>urn:sha1:321d69d1955fe02d25129a353218f1e56e28a3bb</id>
<content type='text'>
</content>
</entry>
</feed>
