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 - Separates the text section from read-only sections #553

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

Lichtso
Copy link

@Lichtso Lichtso commented Feb 27, 2024

Preparation so that the strict ELF parser can enforce a clear layout in which text and read-only sections are separate.

This PR removes the indirection in which the text section is retrieved from the possibly concatenated read-only sections. There is only ever one text-section and no need to concatenate it. So instead the text section can be borrowed as a sub-slice of the relocated ELF bytes directly. Also removes the mem_size of text_section_info as that was double counted and the debug name, as it was unused.

@Lichtso Lichtso force-pushed the refactor/separate_text_from_readonly_sections branch from 7830546 to d659b9f Compare February 27, 2024 14:20
@Lichtso Lichtso force-pushed the refactor/separate_text_from_readonly_sections branch 2 times, most recently from 63188cf to 7fcd282 Compare February 27, 2024 14:25
@codecov-commenter
Copy link

Codecov Report

Attention: Patch coverage is 94.11765% with 1 lines in your changes are missing coverage. Please review.

Project coverage is 89.47%. Comparing base (179a0f9) to head (63188cf).

❗ Current head 63188cf differs from pull request most recent head 7fcd282. Consider uploading reports for the commit 7fcd282 to get more accurate results

Files Patch % Lines
src/elf.rs 94.11% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #553      +/-   ##
==========================================
+ Coverage   88.34%   89.47%   +1.12%     
==========================================
  Files          24       23       -1     
  Lines       10282     9911     -371     
==========================================
- Hits         9084     8868     -216     
+ Misses       1198     1043     -155     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@Lichtso Lichtso force-pushed the refactor/separate_text_from_readonly_sections branch from 7fcd282 to 5cceb4f Compare February 27, 2024 14:28
@alessandrod
Copy link

There is only ever one text-section and no need to concatenate it

I haven't looked at the change yet but this is not true?

@Lichtso
Copy link
Author

Lichtso commented Feb 28, 2024

There is only ever one text-section and no need to concatenate it

We only consider the byte range of one section:

rbpf/src/elf.rs

Line 415 in 179a0f9

offset_range: text_section.file_range().unwrap_or_default(),

which is exactly named ".text":

rbpf/src/elf.rs

Line 396 in 179a0f9

let text_section = elf.section(b".text")?;

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.

None yet

3 participants