Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

c18n, libgcc_s: Support a c18n-aware libunwind. #2032

Merged
merged 4 commits into from
Apr 16, 2024
Merged

c18n, libgcc_s: Support a c18n-aware libunwind. #2032

merged 4 commits into from
Apr 16, 2024

Conversation

dstolfa
Copy link
Contributor

@dstolfa dstolfa commented Mar 4, 2024

These 2 commits are bundled together with CTSRD-CHERI/llvm-project#731 into #2003 for easy testing. There is currently a lot of code duplication across longjmp, resume and unsealed resume, and I'm not too sure how to eliminate it since we're in a context where we can't perform a function call, so any function would have to be always inlined (while the compiler supports this, I'm not sure if it's good practice here?). I also wanted to avoid making too much of it a macro so that debugging of these functions doesn't become painful.

@dstolfa
Copy link
Contributor Author

dstolfa commented Mar 26, 2024

Update the diff to more closely match the semantics of what we have in the demo-2024-03 branch. This temporarily works around the fact that this patch doesn't currently include ubiquitous c18n, and all that is required to support it is to remove the two #ifndefs around C18N_ENABLED.

@dstolfa
Copy link
Contributor Author

dstolfa commented Mar 26, 2024

Removed an unused argument in _rtld_unw_setcontext and _rtld_unw_setcontext_unsealed.

@dstolfa dstolfa force-pushed the c18n-libunwind branch 2 times, most recently from 04f1319 to 2a35164 Compare March 27, 2024 16:16
@dstolfa
Copy link
Contributor Author

dstolfa commented Mar 27, 2024

Update to cherry-pick a different commit from @dpgao and improve the workaround for ubiq-c18n not being in dev yet.

Copy link
Contributor

@dpgao dpgao left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This all looks good to me apart from some minor changes. Let's try to remove the symbol files in libgcc_s and see if CI is happy.
2a35164 can be squashed into b6fb884.

libexec/rtld-elf/rtld_c18n.c Outdated Show resolved Hide resolved
@dstolfa
Copy link
Contributor Author

dstolfa commented Mar 27, 2024

This all looks good to me apart from some minor changes. Let's try to remove the symbol files in libgcc_s and see ...

Seems like the weak symbols don't get replaced in that case (running on top of rtld-c18n):

Breakpoint 4, _rtld_unw_getcontext () at /home/ds815/cppexcept_otypes/contrib/subrepo-cheri-libunwind/src/UnwindRegistersSave.S:842
842     /home/ds815/cppexcept_otypes/contrib/subrepo-cheri-libunwind/src/UnwindRegistersSave.S: No such file or directory.
(gdb) disas
Dump of assembler code for function _rtld_unw_getcontext:
=> 0x0000000040487efc <+0>:     mov     c2, csp
   0x0000000040487f00 <+4>:     str     c2, [c1]
   0x0000000040487f04 <+8>:     ret     c30
End of assembler dump.

@dstolfa dstolfa force-pushed the c18n-libunwind branch 2 times, most recently from c6d09e6 to b9424e6 Compare April 2, 2024 12:40
@dstolfa
Copy link
Contributor Author

dstolfa commented Apr 2, 2024

Fix a conflict with ubiq-c18n

libexec/rtld-elf/Symbol-c18n.map Outdated Show resolved Hide resolved
libexec/rtld-elf/rtld_c18n_policy.txt Show resolved Hide resolved
@dstolfa
Copy link
Contributor Author

dstolfa commented Apr 3, 2024

Update to address @dpgao's comments.

@dpgao dpgao force-pushed the c18n-libunwind branch 3 times, most recently from 7fdfafa to 390c43f Compare April 15, 2024 21:17
This commit implements the functionality necessary to support exception
handling for libunwind. Additionally, it adds a new otype which is
reserved for the unwinding library to use.
@dpgao dpgao merged commit af5403b into dev Apr 16, 2024
28 checks passed
@dpgao dpgao deleted the c18n-libunwind branch April 16, 2024 14:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants