Skip to content

Commit

Permalink
tools: elf: fix copy-elf when gcc links program
Browse files Browse the repository at this point in the history
GCC will set the text size to `0` in a certain case that `rust-lld` did
not. This causes the elf copier to add about 512 MB to the image which
it otherwise shouldn't be doing.

Add a workaround that appears to fix the issue.

Signed-off-by: Sean Cross <sean@xobs.io>
  • Loading branch information
xobs committed Nov 4, 2022
1 parent 3a84578 commit f861af7
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion tools/src/elf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ pub fn process_program(b: &[u8]) -> Result<ProgramDescription, ElfReadError> {
s.address()
);
continue;
} else if text_offset == 0 && s.size() != 0 {
} else if text_offset == 0 && (s.address() != 0 || s.size() != 0) {
text_offset = s.address() as u32;
text_size += s.size() as u32;
} else {
Expand Down

0 comments on commit f861af7

Please sign in to comment.