Skip to content

dylink: Remove dynamic linking startup code and allocation - #18643

Merged
sbc100 merged 1 commit into
mainfrom
dylink_simplify
Feb 2, 2023
Merged

sbc100 merged 1 commit into
mainfrom
dylink_simplify

Conversation

@sbc100

@sbc100 sbc100 commented Feb 1, 2023

Copy link
Copy Markdown
Collaborator

With this change I completely remove the ensure_init function and the associated allocation in favor a static handle for the "main" dso.

I also avoid the initial _dlinit call out to JS.

This change relies on the fact that dlopen(NULL, ..) return a handle the is equivalent of RTLD_DEFAULT when passed to dlsym. See: https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man3/dlopen.3.html

@sbc100
sbc100 force-pushed the dylink_simplify branch 4 times, most recently from d2e398e to 3bfadad Compare February 1, 2023 02:29
@sbc100 sbc100 changed the title dylink: Remove dynamic linking start code and allocation dylink: Remove dynamic linking startup code and allocation Feb 1, 2023
@sbc100
sbc100 requested a review from tlively February 1, 2023 23:12
@sbc100
sbc100 force-pushed the dylink_simplify branch 4 times, most recently from 2b5106f to 487391e Compare February 2, 2023 00:49
@sbc100
sbc100 requested a review from dschuff February 2, 2023 00:52
With this change I completely remove the `ensure_init` function and the
associated allocation in favor a static handle for the "main" dso.

I also avoid the initial `_dlinit` call out to JS.

This change relies on the fact that `dlopen(NULL, ..`) return a handle
the is equivalent of `RTLD_DEFAULT` when passed to `dlsym`.  See:
https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man3/dlopen.3.html
@sbc100
sbc100 enabled auto-merge (squash) February 2, 2023 05:34
@sbc100

sbc100 commented Feb 2, 2023

Copy link
Copy Markdown
Collaborator Author

PTAL. I'd like to land this before #18376

@tlively tlively left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Not entirely versed in the context here, but I think I figured enough out that this LGTM.

Comment thread src/library_dylink.js
global: true,
};
LDSO.loadedLibsByName[name] = dso;
if (handle != undefined) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

When is the handle undefined? It would be simpler to reason about if the handle could always be assumed to exist.

@sbc100 sbc100 Feb 2, 2023 •

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

This is for DSOs are loaded during the JS start process, before native code is run. We load all any needed shared libraries by name, but these don't have any native "dso" struct/handler associated with them. They get handles don't someone calls "dlopen" on them... which is often never in the case of load time dynamic libraries.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Makes sense, thanks!

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.

2 participants