Skip to content

Commit

Permalink
Fix alloc build
Browse files Browse the repository at this point in the history
  • Loading branch information
philipc committed Jun 6, 2019
1 parent f34cf12 commit 637d971
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/pe/header.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use crate::alloc::vec::Vec;
use crate::error;
use crate::pe::{optional_header, section_table, symbol};
use crate::strtab;
Expand Down
21 changes: 19 additions & 2 deletions src/pe/section_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use crate::alloc::string::{String, ToString};
use scroll::{ctx, Pread, Pwrite};
use crate::error::{self, Error};
use crate::pe::relocation;
use std::io::Write;

#[repr(C)]
#[derive(Debug, PartialEq, Clone, Default)]
Expand Down Expand Up @@ -93,7 +92,25 @@ impl SectionTable {
if idx <= 9_999_999 { // 10^7 - 1
self.name = [0; 8];
self.name[0] = b'/';
write!(&mut self.name[1..], "{}", idx).unwrap();
if idx == 0 {
self.name[1] = b'0';
} else {
let mut i = 0;
while idx != 0 {
let rem = (idx % 10) as u8;
idx /= 10;
self.name[7 - i] = b'0' + rem;
i += 1;
}
if i < 7 {
for j in 0..i {
self.name[1 + j] = self.name[8 - i + j]
}
for j in i..7 {
self.name[1 + j] = 0;
}
}
}
Ok(())
} else if idx as u64 <= 0xfff_fff_fff { // 64^6 - 1
self.name[0] = b'/';
Expand Down
1 change: 1 addition & 0 deletions src/pe/symbol.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use crate::alloc::vec::Vec;
use crate::error;
use crate::strtab;
use core::fmt::{self, Debug};
Expand Down

0 comments on commit 637d971

Please sign in to comment.