Skip to content

Commit f861af7

Browse files
committed
tools: elf: fix copy-elf when gcc links program
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 <[email protected]>
1 parent 3a84578 commit f861af7

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

tools/src/elf.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ pub fn process_program(b: &[u8]) -> Result<ProgramDescription, ElfReadError> {
209209
s.address()
210210
);
211211
continue;
212-
} else if text_offset == 0 && s.size() != 0 {
212+
} else if text_offset == 0 && (s.address() != 0 || s.size() != 0) {
213213
text_offset = s.address() as u32;
214214
text_size += s.size() as u32;
215215
} else {

0 commit comments

Comments
 (0)