CrossDSOCFIPass is supposed to replace this stub function to a properly aligned function. However the pass is not ran if the file has no executable code, thus producing incorrectly aligned __cfi_check.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
Hmm, this is not 100% correct. CFI by design respects caller's settings for -fsanitize-recover and -fsanitize-trap, communicated through the DiagData argument to __cfi_check. A better default implementation would call __cfi_check_fail instead of trap unconditionally.
I do not see straight away why CrossDSOCFI pass is not run on no-code modules. Do you know the reason? If that's hard to change, we could modify clang codegen to call __cfi_check_fail from the stub __cfi_check. In that case, we also would not need to add __cfi_check_fail to the used globals list.
Seems quite difficult to make CrossDSOCFI run with no code (a lot of interactions with other passes). I implemented your alternative suggestion, ptal.
Looks like this breaks check-clang: http://45.33.8.238/linux/114361/step_7.txt
Please take a look and revert for now if it takes a while to fix.
I think the order is actually reversed? Pls compare codegen with a module that has some code (so that the pass runs) but no valid cfi targets.