[libc-commits] [libc] [libc] fortify jmp buffer for x86-64 (PR #112769)
Nick Desaulniers via libc-commits
libc-commits at lists.llvm.org
Wed Nov 13 09:06:23 PST 2024
https://github.com/nickdesaulniers commented:
oh, boy, this is getting harder and harder to follow. This code has maximally factored any repetition via macro expansion. While I'm a big fan of DRY (don't repeat yourself), I don't think we want that for inline asm.
I think rather than having this pattern of:
```
#ifdef __i386
...lots of #defines
#else
...lots of #defines
#endif
#ifdef LIBC_COPT_SETJMP_FORTIFICATION
...
#else
...lots of #defines
#endif
asm (
MACRO_EXPANSION
MACRO_EXPANSION
MACRO_EXPANSION
...
```
it would be easier to maintain/read/understand if:
1. we move i386 implementations to their own file. I split out i386 sources recently; I should have done that for jmp_buf.
2. write checksum in C and call it from inline asm, so that the checksum routine is the same between architectures.
3. perhaps have separate .cpp files selected via cmake depending on LIBC_COPT_SETJMP_FORTIFICATION. Then we can have longjump.cpp and longjump_fortified.cpp, setjump.cpp and setjump_fortified.cpp.
With inline asm, you really want to keep it straightforward what assembler you'll get. As is, I feel like I would need to preprocess setjmp.cpp and longjump.cpp just to fully review the sequence of instructions.
---
Please file an issue to track jmp_buf fortification for all architectures, then add a link to it in the PR description so that we can track implementing this for all other architectures.
https://github.com/llvm/llvm-project/pull/112769
More information about the libc-commits
mailing list