binutils: update to 2.43.1
[openadk.git] / toolchain / elf2flt / patches / 7e33f28df198c46764021ed14408bd262751e148 / 0001-lm32.patch
blob44757171bc07550544423c7df76df45615bb1814
1 diff -Nur elf2flt-6d80ab6c93409e796f85da404bde84b841231531.orig/elf2flt.c elf2flt-6d80ab6c93409e796f85da404bde84b841231531/elf2flt.c
2 --- elf2flt-6d80ab6c93409e796f85da404bde84b841231531.orig/elf2flt.c 2017-09-27 06:06:04.000000000 +0200
3 +++ elf2flt-6d80ab6c93409e796f85da404bde84b841231531/elf2flt.c 2017-09-27 06:07:51.032597579 +0200
4 @@ -61,6 +61,8 @@
5 #include <elf/bfin.h>
6 #elif defined(TARGET_h8300)
7 #include <elf/h8.h>
8 +#elif defined(TARGET_lm32)
9 +#include <elf/lm32.h>
10 #elif defined(TARGET_m68k)
11 #include <elf/m68k.h>
12 #elif defined(TARGET_microblaze)
13 @@ -120,6 +122,11 @@
14 #define ARCH "nios"
15 #elif defined(TARGET_nios2)
16 #define ARCH "nios2"
17 +#elif defined(TARGET_lm32)
18 +#define ARCH "lm32"
19 +#define FLAT_LM32_RELOC_TYPE_32_BIT 0
20 +#define FLAT_LM32_RELOC_TYPE_HI16_BIT 1
21 +#define FLAT_LM32_RELOC_TYPE_LO16_BIT 2
22 #elif defined(TARGET_xtensa)
23 #define ARCH "xtensa"
24 #else
25 @@ -357,7 +364,7 @@
26 int bad_relocs = 0;
27 asymbol **symb;
28 long nsymb;
29 -#ifdef TARGET_bfin
30 +#if defined (TARGET_bfin) || defined (TARGET_lm32)
31 unsigned long persistent_data = 0;
32 #endif
34 @@ -682,6 +689,36 @@
35 break;
36 default:
37 goto bad_resolved_reloc;
38 +#elif defined(TARGET_lm32)
39 + case R_LM32_HI16:
40 + case R_LM32_LO16:
41 + if (q->howto->type == R_LM32_HI16) {
42 + pflags = FLAT_LM32_RELOC_TYPE_HI16_BIT << 29;
43 + } else {
44 + pflags = FLAT_LM32_RELOC_TYPE_LO16_BIT << 29;
45 + }
47 + relocation_needed = 1;
49 + /* remember the upper 16 bits */
50 + if ((0xffff0000 & sym_addr) != persistent_data) {
51 + flat_relocs = (uint32_t *)
52 + (realloc (flat_relocs, (flat_reloc_count + 1) * sizeof (uint32_t)));
53 + if (verbose)
54 + printf ("New persistent data for %08lx\n", sym_addr);
55 + persistent_data = 0xffff0000 & sym_addr;
56 + flat_relocs[flat_reloc_count++] = (sym_addr >> 16) | (3 << 29);
57 + }
58 + break;
59 + case R_LM32_32:
60 + pflags = FLAT_LM32_RELOC_TYPE_32_BIT << 29;
61 + relocation_needed = 1;
62 + break;
63 + case R_LM32_CALL:
64 + relocation_needed = 0;
65 + break;
66 + default:
67 + goto bad_resolved_reloc;
68 #elif defined(TARGET_m68k)
69 case R_68K_32:
70 goto good_32bit_resolved_reloc;
71 @@ -1459,6 +1496,63 @@
72 #undef _30BITS_RELOC
73 #undef _28BITS_RELOC
74 #endif
75 +#ifdef TARGET_lm32
76 + case R_LM32_32:
77 + {
78 + pflags = FLAT_LM32_RELOC_TYPE_32_BIT << 29;
79 + sym_vma = bfd_section_vma(abs_bfd, sym_section);
80 + sym_addr += sym_vma + q->addend;
81 + relocation_needed = 1;
82 + break;
83 + }
84 + case R_LM32_CALL:
85 + {
86 + sym_vma = 0;
87 + sym_addr += sym_vma + q->addend;
88 + sym_addr -= q->address;
89 + sym_addr = (int32_t)sym_addr >> q->howto->rightshift;
91 + if ((int32_t)sym_addr < -0x8000000 || (int32_t)sym_addr > 0x7ffffff) {
92 + printf("ERROR: Relocation overflow for R_LM32_CALL relocation against %s\n", sym_name);
93 + bad_relocs++;
94 + continue;
95 + }
97 + r_mem[0] |= (sym_addr >> 24) & 0x03;
98 + r_mem[1] = (sym_addr >> 16) & 0xff;
99 + r_mem[2] = (sym_addr >> 8) & 0xff;
100 + r_mem[3] = sym_addr & 0xff;
101 + break;
103 + case R_LM32_HI16:
104 + case R_LM32_LO16:
106 + if (q->howto->type == R_LM32_HI16) {
107 + pflags = FLAT_LM32_RELOC_TYPE_HI16_BIT << 29;
108 + } else {
109 + pflags = FLAT_LM32_RELOC_TYPE_LO16_BIT << 29;
112 + sym_vma = bfd_section_vma(abs_bfd, sym_section);
113 + sym_addr += sym_vma + q->addend;
115 + relocation_needed = 1;
117 + /* remember the upper 16 bits */
118 + if ((0xffff0000 & sym_addr) != persistent_data) {
119 + flat_relocs = (uint32_t *)
120 + (realloc (flat_relocs, (flat_reloc_count + 1) * sizeof (uint32_t)));
121 + if (verbose)
122 + printf ("New persistent data for %08lx\n", sym_addr);
123 + persistent_data = 0xffff0000 & sym_addr;
124 + flat_relocs[flat_reloc_count++] = (sym_addr >> 16) | (3 << 29);
127 + r_mem[2] = (sym_addr >> 8) & 0xff;
128 + r_mem[3] = sym_addr & 0xff;
129 + break;
131 +#endif /* TARGET_lm32 */
132 default:
133 /* missing support for other types of relocs */
134 printf("ERROR: bad reloc type %d\n", (*p)->howto->type);
135 @@ -1596,6 +1690,13 @@
136 break;
137 #endif
139 +#ifdef TARGET_lm32
140 + case R_LM32_HI16:
141 + case R_LM32_LO16:
142 + case R_LM32_CALL:
143 + /* entry has already been written */
144 + break;
145 +#endif
146 default:
147 /* The alignment of the build host
148 might be stricter than that of the
149 diff -Nur elf2flt-6d80ab6c93409e796f85da404bde84b841231531.orig/elf2flt.ld.in elf2flt-6d80ab6c93409e796f85da404bde84b841231531/elf2flt.ld.in
150 --- elf2flt-6d80ab6c93409e796f85da404bde84b841231531.orig/elf2flt.ld.in 2017-09-27 06:06:04.000000000 +0200
151 +++ elf2flt-6d80ab6c93409e796f85da404bde84b841231531/elf2flt.ld.in 2017-09-29 18:11:30.999698955 +0200
152 @@ -34,6 +34,7 @@
153 W_RODAT *(.rodata1)
154 W_RODAT *(.rodata.*)
155 W_RODAT *(.gnu.linkonce.r*)
156 +W_RODAT *(.rofixup)
158 /* .ARM.extab name sections containing exception unwinding information */
159 *(.ARM.extab* .gnu.linkonce.armextab.*)