Skip to content

rtld: Check for -1 as an-end-of-section marker instead of 1#2270

Open
daniel-levin wants to merge 1 commit into
freebsd:releng/15.0from
daniel-levin:releng/15.0
Open

rtld: Check for -1 as an-end-of-section marker instead of 1#2270
daniel-levin wants to merge 1 commit into
freebsd:releng/15.0from
daniel-levin:releng/15.0

Conversation

@daniel-levin

@daniel-levin daniel-levin commented Jun 8, 2026

Copy link
Copy Markdown

rtld calls functions in the .init_array section one at a time, until it finds a distinguished sentinel value. The C runtime does the same thing (in crtend.c). However, that checks for the sentinel -1 and not 1 . If one is using a linker that unifies .ctors and .init_array, then rtld will miss the sentinel value. I believe the author of this code intended to write -1 instead of 1. Indeed, changing the branch to check for -1 prevents rtld from attempting to call a non-existent function.

Comment thread libexec/rtld-elf/rtld.c
rtld calls functions in the .init_array section one at a time, until
it finds a distinguished sentinel value. The C runtime does the same
thing (in crtend.c). However, that checks for the sentinel -1 and not
1. If one is using a linker that unifies .ctors and .init_array, then
rtld will miss the sentinel value. I believe the author of this code
intended to write -1 instead of 1. Indeed, changing the code to also
check for -1 prevents rtld from attempting to call a non-existent
function. The same is true of .dtors and .fini_array.

Signed-off-by: Daniel Levin <daniellevin2607@gmail.com>
@daniel-levin

Copy link
Copy Markdown
Author

Thank you for the review and approval. However, I don't have merge permissions.

@daniel-levin daniel-levin requested a review from kostikbel June 10, 2026 11:14
@kostikbel

Copy link
Copy Markdown
Member

I already reviewed the change.

There are people with some scripts that take and push the ready to land PRs, wait for them. There are some workflows and formalities for merging PRs which I did not learned.

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