| Issue |
243312
|
| Summary |
[Arm64EC] Leading `\x01` no-mangle marker is ignored and leaks into COFF symbol names
|
| Labels |
new issue
|
| Assignees |
|
| Reporter |
cezarbbb
|
On `arm64ec-pc-windows-msvc`, the `\x01` "do not mangle" name prefix is not handled by the Arm64EC mangling path. `llvm::getArm64ECMangledFunctionName()` unconditionally prepends `#` to any name that does not start with `?` or `#`
(https://github.com/llvm/llvm-project/blob/main/llvm/lib/IR/Mangler.cpp#L292-L302), so by the time `Mangler::getNameWithPrefixImpl()` checks for the marker (https://github.com/llvm/llvm-project/blob/main/llvm/lib/IR/Mangler.cpp#L44) it is no longer the first byte.
The `0x01` byte is then emitted literally into the object file.
Reproduce:
```llvm
; arm64ec-x01.ll
target triple = "arm64ec-pc-windows-msvc"
define void @"\01foo"() {
ret void
}
define void @caller() {
call void @"\01foo"()
ret void
}
```
```
$ llc -mtriple=arm64ec-pc-windows-msvc arm64ec-x01.ll -filetype=obj -o arm64ec-x01.o
$ llvm-readobj --symbols arm64ec-x01.o | grep -a foo | xxd
00000000: 2020 2020 4e61 6d65 3a20 2301 666f 6f0a Name: #.foo.
00000010: 2020 2020 4e61 6d65 3a20 0166 6f6f 0a20 Name: .foo.
00000020: 2020 2020 204c 696e 6b65 643a 2023 0166 Linked: #.f
00000030: 6f6f 2028 3829 0a oo (8).
```
The same module compiled for `x86_64-pc-windows-msvc` , names are clean:
```
Name: foo
Name: caller
```
Version: LLVM 23.1.5
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs