@@ -148,7 +148,7 @@ GENERATE_RELOC_TAB := $(AWK) ' \
148148 bad_relocs=0; \
149149 print "\# include <wolfssl/wolfcrypt/libwolfssl_sources.h>"; \
150150 printf("%s\n ", \
151- "WOLFSSL_LOCAL const unsigned int wc_linuxkm_pie_reloc_tab[] = { "); \
151+ "WOLFSSL_LOCAL const struct wc_linuxkm_pie_reloc_tab_ent wc_linuxkm_pie_reloc_tab[] = { "); \
152152 if ("SECTION_MAP" in ENVIRON) { \
153153 while (getline <ENVIRON["SECTION_MAP"] > 0) \
154154 section_map[$$1] = $$2; \
@@ -177,44 +177,45 @@ GENERATE_RELOC_TAB := $(AWK) ' \
177177 if (section) { \
178178 switch (section) { \
179179 case ".text_wolfcrypt": \
180- section_tag = 0; \
180+ section_tag = "WC_R_SEG_TEXT"; \
181181 break; \
182182 case ".rodata_wolfcrypt": \
183- section_tag = 1; \
183+ section_tag = "WC_R_SEG_RODATA"; \
184184 break; \
185185 case ".data_wolfcrypt": \
186- section_tag = 2; \
186+ section_tag = "WC_R_SEG_RWDATA"; \
187187 break; \
188188 case ".bss_wolfcrypt": \
189- section_tag = 3; \
189+ section_tag = "WC_R_SEG_BSS"; \
190190 break; \
191191 default: \
192192 print "Unexpected section:\n" $$0 >"/dev/stderr"; \
193193 ++bad_relocs; \
194- section_tag = 4; \
194+ section_tag = "WC_R_SEG_OTHER"; \
195195 } \
196196 } else { \
197197 print "Unresolvable symbol reference for relocation:\n" $$0 >"/dev/stderr";\
198198 ++bad_relocs; \
199- section_tag = 4; \
199+ section_tag = "WC_R_SEG_OTHER"; \
200200 } \
201+ reloc_type = $$3; \
201202 if (strtonum("0x" gensub("^0*","",1,$$1)) >= lshift(1, 29)) { \
202203 print "Relocation offset overflow:" >"/dev/stderr"; \
203204 print >"/dev/stderr"; \
204205 exit(1); \
205206 } \
206- printf("0x%xU%s", \
207- or(strtonum("0x" gensub("^0*","",1,$$1)), \
208- lshift(section_tag, 29)), \
209- ((++n%8) ? ", " : ",\n ")); \
207+ printf(" { .offset = 0x%xU, .dest_segment = %s, .reloc_type = WC_%s },\n", \
208+ strtonum("0x" gensub("^0*","",1,$$1)), \
209+ section_tag, reloc_type); \
210210 } \
211211 } \
212212 END { \
213213 if (bad_relocs) { \
214214 print "Found " bad_relocs " unresolvable relocations." >"/dev/stderr"; \
215215 exit(1); \
216216 } \
217- print "~0U };\nWOLFSSL_LOCAL const unsigned long wc_linuxkm_pie_reloc_tab_length = sizeof wc_linuxkm_pie_reloc_tab / sizeof wc_linuxkm_pie_reloc_tab[0];";\
217+ print " { .offset = ~0U, .dest_segment = WC_R_SEG_NONE, .reloc_type = WC_R_NONE } };"; \
218+ print "WOLFSSL_LOCAL const unsigned long wc_linuxkm_pie_reloc_tab_length = sizeof wc_linuxkm_pie_reloc_tab / sizeof wc_linuxkm_pie_reloc_tab[0];"; \
218219 }'
219220
220221ifeq "$(V ) " "1"
0 commit comments