Skip to content

Commit e232333

Browse files
mrutland-armpalmer-dabbelt
authored andcommitted
scripts/sorttable: Unify arm64 & x86 sort functions
The format of the arm64 and x86 exception table entries is essentially the same as of commits: 46d2894 ("x86/extable: Rework the exception table mechanics") d6e2cc5 ("arm64: extable: add `type` and `data` fields") Both use a 12-byte entry consisting of two 32-bit relative offsets and 32 bits of (absolute) data, and their sort functions are identical aside from commentary, with arm64 saying: /* Don't touch the fixup type or data */ ... and x86 saying: /* Don't touch the fixup type */ Unify the two behind a common sort_relative_table_with_data() function, retaining the arm64 commentary. There should be no functional change as a result of this patch. Signed-off-by: Mark Rutland <mark.rutland@arm.com> Cc: Ard Biesheuvel <ardb@kernel.org> Cc: Borislav Petkov <bp@suse.de> Cc: Catalin Marinas <catalin.marinas@arm.com> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Will Deacon <will@kernel.org> Cc: linux-arm-kernel@lists.infradead.org Cc: linux-kernel@vger.kernel.org Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
1 parent fa55b7d commit e232333

1 file changed

Lines changed: 3 additions & 33 deletions

File tree

‎scripts/sorttable.c‎

Lines changed: 3 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ static void sort_relative_table(char *extab_image, int image_size)
231231
}
232232
}
233233

234-
static void arm64_sort_relative_table(char *extab_image, int image_size)
234+
static void sort_relative_table_with_data(char *extab_image, int image_size)
235235
{
236236
int i = 0;
237237

@@ -259,34 +259,6 @@ static void arm64_sort_relative_table(char *extab_image, int image_size)
259259
}
260260
}
261261

262-
static void x86_sort_relative_table(char *extab_image, int image_size)
263-
{
264-
int i = 0;
265-
266-
while (i < image_size) {
267-
uint32_t *loc = (uint32_t *)(extab_image + i);
268-
269-
w(r(loc) + i, loc);
270-
w(r(loc + 1) + i + 4, loc + 1);
271-
/* Don't touch the fixup type */
272-
273-
i += sizeof(uint32_t) * 3;
274-
}
275-
276-
qsort(extab_image, image_size / 12, 12, compare_relative_table);
277-
278-
i = 0;
279-
while (i < image_size) {
280-
uint32_t *loc = (uint32_t *)(extab_image + i);
281-
282-
w(r(loc) - i, loc);
283-
w(r(loc + 1) - (i + 4), loc + 1);
284-
/* Don't touch the fixup type */
285-
286-
i += sizeof(uint32_t) * 3;
287-
}
288-
}
289-
290262
static void s390_sort_relative_table(char *extab_image, int image_size)
291263
{
292264
int i;
@@ -364,15 +336,13 @@ static int do_file(char const *const fname, void *addr)
364336

365337
switch (r2(&ehdr->e_machine)) {
366338
case EM_386:
339+
case EM_AARCH64:
367340
case EM_X86_64:
368-
custom_sort = x86_sort_relative_table;
341+
custom_sort = sort_relative_table_with_data;
369342
break;
370343
case EM_S390:
371344
custom_sort = s390_sort_relative_table;
372345
break;
373-
case EM_AARCH64:
374-
custom_sort = arm64_sort_relative_table;
375-
break;
376346
case EM_PARISC:
377347
case EM_PPC:
378348
case EM_PPC64:

0 commit comments

Comments
 (0)