From 722772a3d801ba07eeca745099b87f4dbf733e78 Mon Sep 17 00:00:00 2001 From: Joel Stanley Date: Wed, 1 Sep 2021 15:43:56 +0930 Subject: [PATCH] microwatt: Fix relocation error when linking When building with GCC 11: ../libbase/crt0.o: in function `_start': litex/soc/cores/cpu/microwatt/crt0.S:54:(.text+0x38): relocation truncated to fit: R_PPC64_GOT16_DS against symbol `_fdata' defined in .data section in bios.elf litex/soc/cores/cpu/microwatt/crt0.S:55:(.text+0x3c): relocation truncated to fit: R_PPC64_GOT16_DS against symbol `_edata' defined in .data section in bios.elf litex/soc/cores/cpu/microwatt/crt0.S:56:(.text+0x40): relocation truncated to fit: R_PPC64_GOT16_DS against symbol `_fdata_rom' defined in *ABS* section in bios.elf litex/soc/cores/cpu/microwatt/crt0.S:68:(.text+0x68): relocation truncated to fit: R_PPC64_GOT16_DS against symbol `_fbss' defined in .bss section in bios.elf litex/soc/cores/cpu/microwatt/crt0.S:69:(.text+0x6c): relocation truncated to fit: R_PPC64_GOT16_DS against symbol `_ebss' defined in .bss section in bios.elf litex/soc/cores/cpu/microwatt/crt0.S:80:(.text+0x90): relocation truncated to fit: R_PPC64_GOT16_DS against symbol `_fstack' defined in .bss section in bios.elf boot.o: in function `copy_file_from_sdcard_to_ram': litex/soc/software/bios/boot.c:622:(.text+0x18): relocation truncated to fit: R_PPC64_TOC16_DS against `.toc' litex/soc/software/bios/boot.c:627:(.text+0x5c): relocation truncated to fit: R_PPC64_TOC16_DS against `.toc'+8 litex/soc/software/bios/boot.c:633:(.text+0x8c): relocation truncated to fit: R_PPC64_TOC16_DS against `.toc'+10 litex/soc/software/bios/boot.c:639:(.text+0xdc): relocation truncated to fit: R_PPC64_TOC16_DS against `.toc'+18 litex/soc/software/bios/boot.c:650:(.text+0x128): additional relocation overflows omitted from the output This is because we pass -mcmodel=small. As the PowerPC ELF ABI describes, the small code model restricts the relocations to 16-bit offsets[1]. If we omit the option we get the default, which is the medium model allowing 32-bit offsets. http://openpowerfoundation.org/wp-content/uploads/resources/leabi/content/dbdoclet.50655240_19143.html Signed-off-by: Joel Stanley --- litex/soc/cores/cpu/microwatt/core.py | 1 - 1 file changed, 1 deletion(-) diff --git a/litex/soc/cores/cpu/microwatt/core.py b/litex/soc/cores/cpu/microwatt/core.py index 4c3c20a31..8b58fcf71 100644 --- a/litex/soc/cores/cpu/microwatt/core.py +++ b/litex/soc/cores/cpu/microwatt/core.py @@ -58,7 +58,6 @@ class Microwatt(CPU): flags += "-mlittle-endian " flags += "-mstrict-align " flags += "-fno-stack-protector " - flags += "-mcmodel=small " flags += "-D__microwatt__ " return flags