Skip to content

Commit

Permalink
write: fix reserving empty section error
Browse files Browse the repository at this point in the history
if we copy a elf with a empty section and the sh_addralign is not 0,
it will return a unaligned offset.

Signed-off-by: lzwycc <lzw32321226@163.com>
  • Loading branch information
lzw3232 committed Feb 16, 2023
1 parent a3706b5 commit d0e19ed
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/write/elf/writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,8 @@ 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 {
if align_start == 0 {
self.len += len;
return self.len;
}
self.len = util::align(self.len, align_start);
Expand Down

0 comments on commit d0e19ed

Please sign in to comment.