Skip to content

Fix shared object start address without program header #7052

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

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

Conversation

hongyu-dev
Copy link
Contributor

This PR is for issue: #6723

Symbols before fix:
Screenshot 2025-07-07 at 2 16 22 PM

Symbols after fix:
Screenshot 2025-07-07 at 2 16 58 PM

Memory map before fix:
Screenshot 2025-07-07 at 2 17 15 PM

Memory map after fix:
Screenshot 2025-07-07 at 2 17 48 PM

The code before fix didn't include the situation for shared object file without program header case and section start address got overwritten by segmentStart which start with value 0.

Current fix creates segments based on sections start address.

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

Copy link
Contributor

@fuzyll fuzyll left a comment

Choose a reason for hiding this comment

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

I am not sure what changes this needs, but I can't imagine this looks the way it's supposed to.

The Raw view shows a whole bunch of data that I assume is code:

image

But, the ELF view shows a bunch of bare symbols that map to 0's:

image

@negasora: Since you provided the original binary, are you able to give us any additional context on how you would like this to look after it's been loaded? I can't imagine we're supposed to have 0 functions and no actual code, given how the Raw view looks, but willing to change my mind if this is somehow expected.

EDIT: I think the problem is that, while we've adjusted where the segments should be loaded, we are not also adjusting where we're looking for functions in this case? Like, the offset in the file needs to be adjusted back for the amount we're 'off' due to loading at a later spot?

@hongyu-dev
Copy link
Contributor Author

hongyu-dev commented Jul 7, 2025

I was very surprised with this binary too. .text section type is NOBITS that's why its all 0s in those functions.

Screenshot 2025-07-07 at 6 50 59 PM

My guess is this is CTF challenge that intentionally used malformed binary the .text section was marked as NOBITS instead of PROGBITS. This caused objdump -d shows no disassembly while readelf -S reveals section structure. The actual code is embedded in the binary but hidden.

size_t size = m_elfSections[i].type == ELF_SHT_NOBITS ? 0 : m_elfSections[i].size;

@fuzyll
Copy link
Contributor

fuzyll commented Jul 8, 2025

With @negasora's help, I've tracked down where this came from, and it's an intentionally 'anonymized' binary from an Enterprise customer. Working with them to see if we can get something that will let us confirm this is fixed or to see if they would be willing to run a test build with these changes to confirm things load properly for them.

Sorry for the longer wait to get this merged, but this is on 'my' plate for the time being.

@fuzyll fuzyll force-pushed the test_no_elf_program_header_fix branch from 23cd212 to fad6f2c Compare July 8, 2025 15:08
@fuzyll fuzyll self-assigned this Jul 8, 2025
@plafosse plafosse added this to the Helion milestone Jul 8, 2025
@fuzyll
Copy link
Contributor

fuzyll commented Jul 8, 2025

Also, I confirmed that the sample, as given to us, is also messed up under objdump.

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.

4 participants