[PATCH 0/2] riscv: improve __ex_table section handling

Palmer Dabbelt palmer at dabbelt.com
Wed Aug 25 23:47:02 PDT 2021


On Sun, 08 Aug 2021 10:25:09 PDT (-0700), jszhang3 at mail.ustc.edu.cn wrote:
> From: Jisheng Zhang <jszhang at kernel.org>
>
> Enable BUILDTIME_TABLE_SORT to sort the exception table at build time
> then move exception table to RO_DATA segment.
>
> Jisheng Zhang (2):
>   riscv: Enable BUILDTIME_TABLE_SORT
>   riscv: Move EXCEPTION_TABLE to RO_DATA segment
>
>  arch/riscv/Kconfig                  | 1 +
>  arch/riscv/kernel/vmlinux-xip.lds.S | 1 -
>  arch/riscv/kernel/vmlinux.lds.S     | 4 ++--
>  scripts/sorttable.c                 | 1 +
>  4 files changed, 4 insertions(+), 3 deletions(-)

This seems reasonable, but it's failing for some configurations (at 
least tinyconfig) saying there is no __ex_table.  I'm not entirely sure 
how that comes about, as we've got them for futexes and uaccess.

Maybe the right thing to do here is to fix scripts/sorttable.c so it can 
handle files with nothing to sort?  I think it's just as simple as a 
successful early out like this

diff --git a/scripts/sorttable.h b/scripts/sorttable.h
index a2baa2fefb13..207ddeddb506 100644
--- a/scripts/sorttable.h
+++ b/scripts/sorttable.h
@@ -294,8 +294,9 @@ static int do_sort(Elf_Ehdr *ehdr,
                goto out;
        }
 #endif
+       /* If there is no __ex_table section there is no work do to. */
        if (!extab_sec) {
-               fprintf(stderr, "no __ex_table in file: %s\n", fname);
+               rc = 0;
                goto out;
        }

I'm not entirely sure though -- my logic is essentially just "there's no 
__ex_table, so there's nothing to sort, so just don't try".

All the configurations I can actually boot have an __ex_table, so I'm 
not sure how to test that.



More information about the linux-riscv mailing list