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

options/rtld: Call fini functions on exit #1092

Merged
merged 1 commit into from
Oct 13, 2024
Merged

Conversation

Qwinci
Copy link
Contributor

@Qwinci Qwinci commented Jul 17, 2024

This is needed to support functions marked with attribute gnu::destructor. The way I implemented it it destructs the objects in reverse order that they were initialized in and first runs functions registered with __cxa_atexit for the object and after that the fini functions for that object, I am not sure if that's completely correct but to me it seems reasonable enough so in case of an object that doesn't have any circular dependencies both the atexit functions and destructor functions are run after the object can't be used by anything anymore. It turned out that there is an autogenerated call to __cxa_finalize that should call the functions registered for that dso, so I implemented that.

Copy link
Member

@Dennisbonke Dennisbonke left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Member

@no92 no92 left a comment

Choose a reason for hiding this comment

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

LGTM with my limited understanding of how this works.

Copy link
Member

@Geertiebear Geertiebear left a comment

Choose a reason for hiding this comment

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

LGTM, could you add some tests for this?

@64
Copy link
Member

64 commented Oct 13, 2024

Fixes #607

@mintsuki mintsuki merged commit 2f19345 into managarm:master Oct 13, 2024
35 checks passed
@64 64 mentioned this pull request Oct 15, 2024
@Qwinci Qwinci deleted the fini branch October 17, 2024 16:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants