From 3a8457852f9c941a8a29001d4b319f3e1eb46a3c Mon Sep 17 00:00:00 2001 From: Sean Cross Date: Fri, 4 Nov 2022 12:26:05 +0800 Subject: [PATCH 1/2] loader: fix build with gcc-ld With Rust 1.65.0, we may be forced to use gdb's linker due to bug that appeared in llvm-15: https://github.com/rust-lang/rust/issues/103949 Signed-off-by: Sean Cross --- loader/link.x | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/loader/link.x b/loader/link.x index 90c023eee..ecb989b85 100644 --- a/loader/link.x +++ b/loader/link.x @@ -1,9 +1,9 @@ MEMORY { - RAM : ORIGIN = 0x40000000, LENGTH = 16M FLASH : ORIGIN = 0x20501000, LENGTH = 188k FONTS : ORIGIN = 0x20530000, LENGTH = 4352k - MEMLCD: ORIGIN = 0xB0000000, LENGTH = 32k + RAM : ORIGIN = 0x40000000, LENGTH = 16M + MEMLCD : ORIGIN = 0xB0000000, LENGTH = 32k } /* Fonts go from 0x2053_0000 to 0x2097_0000 @@ -51,7 +51,7 @@ SECTIONS .text.dummy (NOLOAD) : { /* This section is intended to make _stext address work */ - . = _stext; + . = ABSOLUTE(_stext); } > REGION_TEXT .text _stext : @@ -91,7 +91,7 @@ SECTIONS _edata = .; } > REGION_DATA AT > REGION_RODATA - .fonts ALIGN(65536) : SUBALIGN(65536) + .fonts : ALIGN(65536) { KEEP(*(.fontdata)); } > FONTS From f861af7620ab3c511246522d838e8fd26a628e64 Mon Sep 17 00:00:00 2001 From: Sean Cross Date: Fri, 4 Nov 2022 12:27:13 +0800 Subject: [PATCH 2/2] 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 --- tools/src/elf.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/src/elf.rs b/tools/src/elf.rs index b9dd01320..000749394 100644 --- a/tools/src/elf.rs +++ b/tools/src/elf.rs @@ -209,7 +209,7 @@ pub fn process_program(b: &[u8]) -> Result { 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 {