diff options
Diffstat (limited to 'toolchain/elf2flt/patches')
7 files changed, 369 insertions, 0 deletions
diff --git a/toolchain/elf2flt/patches/26dfb54a59c8c0106418a0c46ccb4288d9e066fd/0001-riscv32.patch b/toolchain/elf2flt/patches/26dfb54a59c8c0106418a0c46ccb4288d9e066fd/0001-riscv32.patch new file mode 100644 index 000000000..a99de4f9f --- /dev/null +++ b/toolchain/elf2flt/patches/26dfb54a59c8c0106418a0c46ccb4288d9e066fd/0001-riscv32.patch @@ -0,0 +1,42 @@ +diff -Nur elf2flt-v2023.04.orig/elf2flt.c elf2flt-v2023.04/elf2flt.c +--- elf2flt-v2023.04.orig/elf2flt.c 2023-09-04 11:29:05.952417209 +0200 ++++ elf2flt-v2023.04/elf2flt.c 2023-09-04 11:30:05.371065966 +0200 +@@ -81,7 +81,7 @@ + #include <elf/v850.h> + #elif defined(TARGET_xtensa) + #include <elf/xtensa.h> +-#elif defined(TARGET_riscv64) ++#elif defined(TARGET_riscv64) || defined(TARGET_riscv32) + #include <elf/riscv.h> + #endif + +@@ -127,6 +127,8 @@ + #define ARCH "xtensa" + #elif defined(TARGET_riscv64) + #define ARCH "riscv64" ++#elif defined(TARGET_riscv32) ++#define ARCH "riscv32" + #else + #error "Don't know how to support your CPU architecture??" + #endif +@@ -822,7 +824,7 @@ + goto good_32bit_resolved_reloc_update_text; + default: + goto bad_resolved_reloc; +-#elif defined(TARGET_riscv64) ++#elif defined(TARGET_riscv64) || defined(TARGET_riscv32) + case R_RISCV_NONE: + case R_RISCV_32_PCREL: + case R_RISCV_ADD8: +diff -Nur elf2flt-v2023.04.orig/ld-elf2flt.c elf2flt-v2023.04/ld-elf2flt.c +--- elf2flt-v2023.04.orig/ld-elf2flt.c 2023-09-04 11:28:59.072573514 +0200 ++++ elf2flt-v2023.04/ld-elf2flt.c 2023-09-04 11:29:32.507813592 +0200 +@@ -327,7 +327,7 @@ + /* riscv adds a global pointer symbol to the linker file with the + "RISCV_GP:" prefix. Remove the prefix for riscv64 architecture and + the entire line for other architectures. */ +- if (streq(TARGET_CPU, "riscv64")) ++ if (streq(TARGET_CPU, "riscv64") || streq(TARGET_CPU, "riscv32")) + append_sed(&sed, "^RISCV_GP:", ""); + else + append_sed(&sed, "^RISCV_GP:", NULL); diff --git a/toolchain/elf2flt/patches/26dfb54a59c8c0106418a0c46ccb4288d9e066fd/0002-lm32.patch b/toolchain/elf2flt/patches/26dfb54a59c8c0106418a0c46ccb4288d9e066fd/0002-lm32.patch new file mode 100644 index 000000000..b24b214c7 --- /dev/null +++ b/toolchain/elf2flt/patches/26dfb54a59c8c0106418a0c46ccb4288d9e066fd/0002-lm32.patch @@ -0,0 +1,167 @@ +diff -Nur elf2flt.orig/elf2flt.c elf2flt/elf2flt.c +--- elf2flt.orig/elf2flt.c 2023-09-07 15:59:10.019349031 +0200 ++++ elf2flt/elf2flt.c 2023-09-07 16:40:06.281961316 +0200 +@@ -62,6 +62,8 @@ + #include <elf/bfin.h> + #elif defined(TARGET_h8300) + #include <elf/h8.h> ++#elif defined(TARGET_lm32) ++#include <elf/lm32.h> + #elif defined(TARGET_m68k) + #include <elf/m68k.h> + #elif defined(TARGET_microblaze) +@@ -123,6 +125,11 @@ + #define ARCH "nios" + #elif defined(TARGET_nios2) + #define ARCH "nios2" ++#elif defined(TARGET_lm32) ++#define ARCH "lm32" ++#define FLAT_LM32_RELOC_TYPE_32_BIT 0 ++#define FLAT_LM32_RELOC_TYPE_HI16_BIT 1 ++#define FLAT_LM32_RELOC_TYPE_LO16_BIT 2 + #elif defined(TARGET_xtensa) + #define ARCH "xtensa" + #elif defined(TARGET_riscv64) +@@ -373,7 +380,7 @@ + int bad_relocs = 0; + asymbol **symb; + long nsymb; +-#ifdef TARGET_bfin ++#if defined (TARGET_bfin) || defined (TARGET_lm32) + unsigned long persistent_data = 0; + #endif + +@@ -690,6 +697,36 @@ + break; + default: + goto bad_resolved_reloc; ++#elif defined(TARGET_lm32) ++ case R_LM32_HI16: ++ case R_LM32_LO16: ++ if (q->howto->type == R_LM32_HI16) { ++ pflags = FLAT_LM32_RELOC_TYPE_HI16_BIT << 29; ++ } else { ++ pflags = FLAT_LM32_RELOC_TYPE_LO16_BIT << 29; ++ } ++ ++ relocation_needed = 1; ++ ++ /* remember the upper 16 bits */ ++ if ((0xffff0000 & sym_addr) != persistent_data) { ++ flat_relocs = (uint32_t *) ++ (realloc (flat_relocs, (flat_reloc_count + 1) * sizeof (uint32_t))); ++ if (verbose) ++ printf ("New persistent data for %08lx\n", sym_addr); ++ persistent_data = 0xffff0000 & sym_addr; ++ flat_relocs[flat_reloc_count++] = (sym_addr >> 16) | (3 << 29); ++ } ++ break; ++ case R_LM32_32: ++ pflags = FLAT_LM32_RELOC_TYPE_32_BIT << 29; ++ relocation_needed = 1; ++ break; ++ case R_LM32_CALL: ++ relocation_needed = 0; ++ break; ++ default: ++ goto bad_resolved_reloc; + #elif defined(TARGET_m68k) + case R_68K_32: + goto good_32bit_resolved_reloc; +@@ -1478,6 +1515,63 @@ + #undef _30BITS_RELOC + #undef _28BITS_RELOC + #endif ++#ifdef TARGET_lm32 ++ case R_LM32_32: ++ { ++ pflags = FLAT_LM32_RELOC_TYPE_32_BIT << 29; ++ sym_vma = elf2flt_bfd_section_vma(sym_section); ++ sym_addr += sym_vma + q->addend; ++ relocation_needed = 1; ++ break; ++ } ++ case R_LM32_CALL: ++ { ++ sym_vma = 0; ++ sym_addr += sym_vma + q->addend; ++ sym_addr -= q->address; ++ sym_addr = (int32_t)sym_addr >> q->howto->rightshift; ++ ++ if ((int32_t)sym_addr < -0x8000000 || (int32_t)sym_addr > 0x7ffffff) { ++ printf("ERROR: Relocation overflow for R_LM32_CALL relocation against %s\n", sym_name); ++ bad_relocs++; ++ continue; ++ } ++ ++ r_mem[0] |= (sym_addr >> 24) & 0x03; ++ r_mem[1] = (sym_addr >> 16) & 0xff; ++ r_mem[2] = (sym_addr >> 8) & 0xff; ++ r_mem[3] = sym_addr & 0xff; ++ break; ++ } ++ case R_LM32_HI16: ++ case R_LM32_LO16: ++ { ++ if (q->howto->type == R_LM32_HI16) { ++ pflags = FLAT_LM32_RELOC_TYPE_HI16_BIT << 29; ++ } else { ++ pflags = FLAT_LM32_RELOC_TYPE_LO16_BIT << 29; ++ } ++ ++ sym_vma = elf2flt_bfd_section_vma(sym_section); ++ sym_addr += sym_vma + q->addend; ++ ++ relocation_needed = 1; ++ ++ /* remember the upper 16 bits */ ++ if ((0xffff0000 & sym_addr) != persistent_data) { ++ flat_relocs = (uint32_t *) ++ (realloc (flat_relocs, (flat_reloc_count + 1) * sizeof (uint32_t))); ++ if (verbose) ++ printf ("New persistent data for %08lx\n", sym_addr); ++ persistent_data = 0xffff0000 & sym_addr; ++ flat_relocs[flat_reloc_count++] = (sym_addr >> 16) | (3 << 29); ++ } ++ ++ r_mem[2] = (sym_addr >> 8) & 0xff; ++ r_mem[3] = sym_addr & 0xff; ++ break; ++ } ++#endif /* TARGET_lm32 */ + default: + /* missing support for other types of relocs */ + printf("ERROR: bad reloc type (%s)%d\n", q->howto->name, (*p)->howto->type); +@@ -1616,6 +1710,13 @@ + break; + #endif + ++#ifdef TARGET_lm32 ++ case R_LM32_HI16: ++ case R_LM32_LO16: ++ case R_LM32_CALL: ++ /* entry has already been written */ ++ break; ++#endif + default: + /* The alignment of the build host + might be stricter than that of the +diff -Nur elf2flt.orig/elf2flt.ld.in elf2flt/elf2flt.ld.in +--- elf2flt.orig/elf2flt.ld.in 2023-09-07 11:32:34.223463015 +0200 ++++ elf2flt/elf2flt.ld.in 2023-09-07 16:06:02.781672190 +0200 +@@ -73,6 +73,7 @@ + W_RODAT: *(.rodata1) + W_RODAT: *(.rodata.*) + W_RODAT: *(.gnu.linkonce.r*) ++W_RODAT: *(.rofixup) + + /* .ARM.extab name sections containing exception unwinding information */ + *(.ARM.extab* .gnu.linkonce.armextab.*) +@@ -111,6 +112,7 @@ + R_RODAT: *(.rodata1) + R_RODAT: *(.rodata.*) + R_RODAT: *(.gnu.linkonce.r*) ++R_RODAT: *(.rofixup) + *(.data) + *(.data1) + *(.data.*) diff --git a/toolchain/elf2flt/patches/26dfb54a59c8c0106418a0c46ccb4288d9e066fd/0003-sh2.patch b/toolchain/elf2flt/patches/26dfb54a59c8c0106418a0c46ccb4288d9e066fd/0003-sh2.patch new file mode 100644 index 000000000..9587a0315 --- /dev/null +++ b/toolchain/elf2flt/patches/26dfb54a59c8c0106418a0c46ccb4288d9e066fd/0003-sh2.patch @@ -0,0 +1,52 @@ +diff -Nur elf2flt-26dfb54a59c8c0106418a0c46ccb4288d9e066fd.orig/elf2flt.c elf2flt-26dfb54a59c8c0106418a0c46ccb4288d9e066fd/elf2flt.c +--- elf2flt-26dfb54a59c8c0106418a0c46ccb4288d9e066fd.orig/elf2flt.c 2023-09-08 08:49:00.529082893 +0200 ++++ elf2flt-26dfb54a59c8c0106418a0c46ccb4288d9e066fd/elf2flt.c 2023-09-08 08:51:08.117679134 +0200 +@@ -75,7 +75,7 @@ + #define FLAT_NIOS2_R_HIADJ_LO 2 + #define FLAT_NIOS2_R_CALL26 4 + #include <elf/nios2.h> +-#elif defined(TARGET_sh) ++#elif defined(TARGET_sh2eb) + #include <elf/sh.h> + #elif defined(TARGET_sparc) + #include <elf/sparc.h> +@@ -111,7 +111,7 @@ + #define ARCH "sparc" + #elif defined(TARGET_v850) + #define ARCH "v850" +-#elif defined(TARGET_sh) ++#elif defined(TARGET_sh2eb) + #define ARCH "sh" + #elif defined(TARGET_h8300) + #define ARCH "h8300" +@@ -795,6 +795,12 @@ + + flat_reloc_count++; + break; ++#elif defined (TARGET_sh2eb) ++ case R_SH_DIR32: ++ goto good_32bit_resolved_reloc; ++ case R_SH_REL32: ++ relocation_needed = 0; ++ continue; + #elif defined (TARGET_h8300) + case R_H8_DIR32: + case R_H8_DIR32A16: +@@ -1328,7 +1334,7 @@ + #endif /* TARGET_sparc */ + + +-#ifdef TARGET_sh ++#ifdef TARGET_sh2eb + case R_SH_DIR32: + relocation_needed = 1; + sym_vma = elf2flt_bfd_section_vma(sym_section); +@@ -1339,7 +1345,7 @@ + sym_addr += sym_vma + q->addend; + sym_addr -= q->address; + break; +-#endif /* TARGET_sh */ ++#endif /* TARGET_sh2eb */ + + #ifdef TARGET_e1 + #define htoe1l(x) htonl(x) diff --git a/toolchain/elf2flt/patches/3051fec89bbd30de6f952dc3100712feff3ca076/0001-.rofixup-fix.patch b/toolchain/elf2flt/patches/3051fec89bbd30de6f952dc3100712feff3ca076/0001-.rofixup-fix.patch new file mode 100644 index 000000000..79186642e --- /dev/null +++ b/toolchain/elf2flt/patches/3051fec89bbd30de6f952dc3100712feff3ca076/0001-.rofixup-fix.patch @@ -0,0 +1,33 @@ +From 270b461e88b47781b3ef9bba2779074d0eb4996b Mon Sep 17 00:00:00 2001 +From: Waldemar Brodkorb <wbx@openadk.org> +Date: Fri, 25 Aug 2023 05:04:53 +0200 +Subject: [PATCH] .rofixup fix + +Signed-off-by: Waldemar Brodkorb <wbx@openadk.org> +--- + elf2flt.ld.in | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/elf2flt.ld.in b/elf2flt.ld.in +index c7e01a6..c69531e 100644 +--- a/elf2flt.ld.in ++++ b/elf2flt.ld.in +@@ -31,6 +31,7 @@ W_RODAT *(.rodata) + W_RODAT *(.rodata1) + W_RODAT *(.rodata.*) + W_RODAT *(.gnu.linkonce.r*) ++W_RODAT *(.rofixup) + + /* This is special code area at the end of the normal + text section. It contains a small lookup table at +@@ -60,6 +61,7 @@ R_RODAT *(.rodata) + R_RODAT *(.rodata1) + R_RODAT *(.rodata.*) + R_RODAT *(.gnu.linkonce.r*) ++R_RODAT *(.rofixup) + *(.data) + *(.data1) + *(.data.*) +-- +2.30.2 + diff --git a/toolchain/elf2flt/patches/v2024.02/0001-sh2.patch b/toolchain/elf2flt/patches/v2024.02/0001-sh2.patch new file mode 100644 index 000000000..b14a78e23 --- /dev/null +++ b/toolchain/elf2flt/patches/v2024.02/0001-sh2.patch @@ -0,0 +1,43 @@ +diff -Nur elf2flt-v2023.09.orig/elf2flt.c elf2flt-v2023.09/elf2flt.c +--- elf2flt-v2023.09.orig/elf2flt.c 2023-12-22 10:44:11.000000000 +0100 ++++ elf2flt-v2023.09/elf2flt.c 2023-12-23 02:26:06.323239781 +0100 +@@ -73,7 +73,7 @@ + #define FLAT_NIOS2_R_HIADJ_LO 2 + #define FLAT_NIOS2_R_CALL26 4 + #include <elf/nios2.h> +-#elif defined(TARGET_sh) ++#elif defined(TARGET_sh2) || defined(TARGET_sh2eb) + #include <elf/sh.h> + #elif defined(TARGET_sparc) + #include <elf/sparc.h> +@@ -109,8 +109,10 @@ + #define ARCH "sparc" + #elif defined(TARGET_v850) + #define ARCH "v850" +-#elif defined(TARGET_sh) +-#define ARCH "sh" ++#elif defined(TARGET_sh2) ++#define ARCH "sh2" ++#elif defined(TARGET_sh2eb) ++#define ARCH "sh2" + #elif defined(TARGET_h8300) + #define ARCH "h8300" + #elif defined(TARGET_microblaze) +@@ -1289,7 +1291,7 @@ + #endif /* TARGET_sparc */ + + +-#ifdef TARGET_sh ++#if defined(TARGET_sh2) || defined(TARGET_sh2eb) + case R_SH_DIR32: + relocation_needed = 1; + sym_vma = elf2flt_bfd_section_vma(sym_section); +@@ -1300,7 +1302,7 @@ + sym_addr += sym_vma + q->addend; + sym_addr -= q->address; + break; +-#endif /* TARGET_sh */ ++#endif /* TARGET_sh2 / TARGET_sh2eb */ + + #ifdef TARGET_e1 + #define htoe1l(x) htonl(x) diff --git a/toolchain/elf2flt/patches/v2024.02/0002-h8300.patch b/toolchain/elf2flt/patches/v2024.02/0002-h8300.patch new file mode 100644 index 000000000..2c7b73482 --- /dev/null +++ b/toolchain/elf2flt/patches/v2024.02/0002-h8300.patch @@ -0,0 +1,20 @@ +diff -Nur elf2flt-v2023.09.orig/flthdr.c elf2flt-v2023.09/flthdr.c +--- elf2flt-v2023.09.orig/flthdr.c 2023-12-23 03:20:20.000000000 +0100 ++++ elf2flt-v2023.09/flthdr.c 2023-12-23 17:11:22.699413170 +0100 +@@ -164,8 +164,16 @@ + r = ntohl(relocs[i]); + raddr = flat_get_relocate_addr(r); + printf(" %u\t0x%08lx (0x%08"PRIx32")\t", i, r, raddr); ++#if defined(TARGET_h8300) ++ raddr &= ~0x00000001; ++#endif + fseek_stream(&ifp, sizeof(old_hdr) + raddr, SEEK_SET); + fread_stream(&addr, sizeof(addr), 1, &ifp); ++#if defined(TARGET_h8300) ++ addr = ntohl(addr); ++ if (r & 1) ++ addr &= 0x00ffffff; ++#endif + printf("%"PRIx32"\n", addr); + } + diff --git a/toolchain/elf2flt/patches/v2024.02/0003-riscv64-alignment.patch b/toolchain/elf2flt/patches/v2024.02/0003-riscv64-alignment.patch new file mode 100644 index 000000000..9feef7951 --- /dev/null +++ b/toolchain/elf2flt/patches/v2024.02/0003-riscv64-alignment.patch @@ -0,0 +1,12 @@ +diff -Nur elf2flt-v2024.02.orig/elf2flt.ld.in elf2flt-v2024.02/elf2flt.ld.in +--- elf2flt-v2024.02.orig/elf2flt.ld.in 2024-03-22 04:51:08.000000000 +0100 ++++ elf2flt-v2024.02/elf2flt.ld.in 2024-03-22 13:08:31.793773247 +0100 +@@ -139,7 +139,7 @@ + @SYMBOL_PREFIX@_ssro_size = @SYMBOL_PREFIX@_essro - @SYMBOL_PREFIX@_ssro; + PROVIDE(@SYMBOL_PREFIX@_SDA2_BASE_ = @SYMBOL_PREFIX@_ssro + (@SYMBOL_PREFIX@_ssro_size / 2)); + +- . = ALIGN(4) ; ++ . = ALIGN(8) ; + TOR: @SYMBOL_PREFIX@__CTOR_LIST__ = .; + TOR: LONG((@SYMBOL_PREFIX@__CTOR_END__ - @SYMBOL_PREFIX@__CTOR_LIST__) / 4 - 2) + SINGLE_LINK: /* gcc uses crtbegin.o to find the start of |