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

write: fix reserving empty section error #514

Merged
merged 1 commit into from
Feb 17, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions src/write/elf/writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -216,18 +216,19 @@ impl<'a> Writer<'a> {
///
/// Returns the aligned offset of the start of the range.
pub fn reserve(&mut self, len: usize, align_start: usize) -> usize {
if len == 0 {
return self.len;
if align_start > 1 {
self.len = util::align(self.len, align_start);
}
self.len = util::align(self.len, align_start);
let offset = self.len;
self.len += len;
offset
}

/// Write alignment padding bytes.
pub fn write_align(&mut self, align_start: usize) {
util::write_align(self.buffer, align_start);
if align_start > 1 {
util::write_align(self.buffer, align_start);
}
}

/// Write data.
Expand Down