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

Return an empty file range for SHT_NOBITS sections #253

Merged
merged 2 commits into from Jan 31, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 10 additions & 3 deletions src/elf/section_header.rs
Expand Up @@ -426,9 +426,16 @@ if_alloc! {
sh_entsize: 0,
}
}
/// Returns this section header's file offset range
pub fn file_range(&self) -> Range<usize> {
self.sh_offset as usize..(self.sh_offset as usize).saturating_add(self.sh_size as usize)
/// Returns this section header's file offset range,
/// if the section occupies space in fhe file.
Copy link
Owner

Choose a reason for hiding this comment

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

typo: fhe -> the

pub fn file_range(&self) -> Option<Range<usize>> {
// Sections with type SHT_NOBITS have no data in the file itself,
// they only exist in memory.
if self.sh_type == SHT_NOBITS {
None
} else {
Some(self.sh_offset as usize..(self.sh_offset as usize).saturating_add(self.sh_size as usize))
}
}
/// Returns this section header's virtual memory range
pub fn vm_range(&self) -> Range<usize> {
Expand Down