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

i#2154 Android64: Adjust loader to remove 'CURIOSITIES' #7205

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

felixc-arm
Copy link
Collaborator

@felixc-arm felixc-arm commented Jan 22, 2025

There was special handling for old Android behaviour where Android did not map the whole file at once. This behaviour is not present in more recent versions of Android, and the associated handling causes 'CURIOSITY'-ies on debug builds, which it was originally introduced to prevent: #1860

This patch also changes the comment relating to 64-bit Android's base address behaviour.

Issues: #2154, #7195, #1860

*/
IF_NOT_ANDROID(ASSERT(out_data->have_dynamic_info));
IF_NOT_ANDROID32(ASSERT(out_data->have_dynamic_info));
Copy link
Contributor

Choose a reason for hiding this comment

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

This is not ASSERT_CURIOSITY: this is a regular fatal assert. I don't see any ASSERT_CURIOSITY being changed here: please update the PR title and description as it talks about CURIOSITIES which does not match the PR changes,

# positioned immediately before the .text portion of the file.
# It seems that for Android, this value is an offset from the start of the
# .text portion rather than a proper address, so the ELF header will be
# placed 0x1000 bytes before the start of the .text portion.
Copy link
Contributor

Choose a reason for hiding this comment

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

set_preferred_base_start_and_end() for lld (the new Android linker, right?) is passing -Ttext so it's not setting the preferred base of the header segment but only the text segment. This is why there is this discrepancy between the preferred "base" and the header, and why a gap is allowed.

What does readelf -l say on libdynamorio.so for the different values here? Presumably it matches the runtime behavior and shows the gap between the header and text segments.

Even if there were a different way to set the header segment base (--section-start with a blank name??) it may not help if the kernel ignores it and always places it up high in the address space: so maybe this -Ttext=0x1000 is the best solution, and maybe -Ttext=0 is ignored or something (presumably readelf -l on that shows a big gap?).

Please update the comment here to make it clear this is not really the header base but instead the text segment base only, and the linker puts a big gap if left at default or set to 0, which is why we set it to 0x1000.

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