aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/sorttable.c
diff options
context:
space:
mode:
authorJisheng Zhang <jszhang@kernel.org>2021-11-18 19:22:51 +0800
committerPalmer Dabbelt <palmer@rivosinc.com>2022-01-05 17:52:20 -0800
commitbb1f85d6046f0db757ac52ed60a5eba5df394819 (patch)
tree0f08ecba35bbe486c8e0130153f143a567cfb936 /scripts/sorttable.c
parentriscv: consolidate __ex_table construction (diff)
downloadlinux-dev-bb1f85d6046f0db757ac52ed60a5eba5df394819.tar.xz
linux-dev-bb1f85d6046f0db757ac52ed60a5eba5df394819.zip
riscv: switch to relative exception tables
Similar as other architectures such as arm64, x86 and so on, use offsets relative to the exception table entry values rather than absolute addresses for both the exception locationand the fixup. However, RISCV label difference will actually produce two relocations, a pair of R_RISCV_ADD32 and R_RISCV_SUB32. Take below simple code for example: $ cat test.S .section .text 1: nop .section __ex_table,"a" .balign 4 .long (1b - .) .previous $ riscv64-linux-gnu-gcc -c test.S $ riscv64-linux-gnu-readelf -r test.o Relocation section '.rela__ex_table' at offset 0x100 contains 2 entries: Offset Info Type Sym. Value Sym. Name + Addend 000000000000 000600000023 R_RISCV_ADD32 0000000000000000 .L1^B1 + 0 000000000000 000500000027 R_RISCV_SUB32 0000000000000000 .L0 + 0 The modpost will complain the R_RISCV_SUB32 relocation, so we need to patch modpost.c to skip this relocation for .rela__ex_table section. After this patch, the __ex_table section size of defconfig vmlinux is reduced from 7072 Bytes to 3536 Bytes. Signed-off-by: Jisheng Zhang <jszhang@kernel.org> Reviewed-by: Kefeng Wang <wangkefeng.wang@huawei.com> Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
Diffstat (limited to 'scripts/sorttable.c')
-rw-r--r--scripts/sorttable.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/scripts/sorttable.c b/scripts/sorttable.c
index ca9db62bf766..f4a8255036b5 100644
--- a/scripts/sorttable.c
+++ b/scripts/sorttable.c
@@ -346,6 +346,7 @@ static int do_file(char const *const fname, void *addr)
case EM_PARISC:
case EM_PPC:
case EM_PPC64:
+ case EM_RISCV:
custom_sort = sort_relative_table;
break;
case EM_ARCOMPACT:
@@ -353,7 +354,6 @@ static int do_file(char const *const fname, void *addr)
case EM_ARM:
case EM_MICROBLAZE:
case EM_MIPS:
- case EM_RISCV:
case EM_XTENSA:
break;
default: