<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/97116>97116</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Mach-O check for improperly nested .cfi_* regions doesn't take .alt_entry into account
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
filipnavara
</td>
</tr>
</table>
<pre>
This is a similar case to https://github.com/llvm/llvm-project/issues/82261 where an exception was added to for `.alt_entry` to the `non-private labels cannot appear between .cfi_startproc / .cfi_endproc pairs` check.
Commit https://github.com/llvm/llvm-project/commit/0b0672773e8b2ed01ad3fce103f4d84becfdd1ed introduced the `invalid CFI advance_loc expression` error with seemingly similar intentions.
Now, let's look at this example code:
```asm
.section __TEXT,__text
.globl _foo
_foo:
.cfi_startproc
sub sp, sp, 8
.cfi_adjust_cfa_offset 8
.alt_entry _bar
_bar:
add sp, sp, 8
.cfi_adjust_cfa_offset -8
ret
.cfi_endproc
```
My assumption is that `.alt_entry` should be exempt from the "advance_loc" check just like it's exempt from the "cfi_startproc/cfi_endproc" check. Feel free to correct me expectation if they are wrong.
As for the real world use case, this came up as an issue in the Microsoft .NET Runtime. There are some functions written in assembly that may trigger an AV at specified code points. The intention of the labels inside those functions is to mark the address of the instruction that triggers the AV so a signal handler can process it appropriately. It's not a callable entrypoint, just a way to get address of a given instruction.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJycVU1v2zgQ_TXyZRBBoh3ZPviQTWugh3aBRVDszRiRI4kNRQqckR3_-wWpJHW6e-kChiwMOV_vvRkhs-090aG4_6O4_7TCWYYQD511dvJ4xoirNpjr4WmwDJYBge1oHUbQyAQSYBCZuFg_FOpYqGNvZZjbUoexUEfnzm9_d1MMP0hLoY6WeSYu1HGnVFPDZaBIgB7oRdMkNni4IAMaQybF70KEoqlKdHIiL_FaNFWyy0DJ7oO_m6I9o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