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

Refactor load_module to support 64-bit ELF loading #85

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

WangONC
Copy link

@WangONC WangONC commented Nov 7, 2024

Description

This PR refactors the load_module function to provide better support for both 32-bit and 64-bit ELF loading.

Key Changes

Program Header (PHDR) Loading

  • Prioritize loading essential information from Program Headers (PHDR)
  • Construct virtual Section Headers (SHDR) from PHDR data when SHDR is missing
  • Build dynamic symbol information from PT_DYNAMIC segment
  • Create virtual sections (.dynsym, .dynstr, etc.) based on PHDR data
  • Maintain binary loading stability even with missing section headers
  • Handle both 32-bit and 64-bit ELF formats

DT_INIT and DT_INIT_ARRAY

  • Add support for .init section execution
  • Ensure .init is called before .init_array
  • Improve initialization order handling
  • Switch .init_array parsing from file to memory to support relocations
  • Add 64-bit .init_array pointer size support

Relocation Improvements

  • Add support for RELA relocations
  • Prioritize dynamic relocations from PHDR
  • Add 64-bit relocation types support:
    • R_AARCH64_ABS64
    • R_AARCH64_RELATIVE
    • R_AARCH64_GLOB_DAT
    • R_AARCH64_JUMP_SLOT
  • Note: TLS and IRELATIVE relocations are not yet supported

@WangONC WangONC force-pushed the master branch 2 times, most recently from 67ba6af to 417c81f Compare November 7, 2024 18:23
@WangONC WangONC changed the title Fix: Support loading SO files when relocation and symbol table sections are missing Refactor load_module to support 64-bit ELF loading Nov 8, 2024
@AeonLucid
Copy link
Owner

Hey, thanks for the pull request! Good start to support 64 bit files.
It would be nice if we can fix the CI before merging.

@WangONC
Copy link
Author

WangONC commented Nov 11, 2024

Thank you for pointing out the issue; I believe I have now fixed it.

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