Page MenuHomeFreeBSD

kldxref: add LoongArch support
Needs ReviewPublic

Authored by zhaoxiaoqiang007_gmail.com on Tue, Sep 22, 2:26 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sat, Oct 3, 1:22 PM
Unknown Object (File)
Thu, Oct 1, 10:49 PM
Unknown Object (File)
Thu, Oct 1, 4:08 PM
Unknown Object (File)
Thu, Oct 1, 7:46 AM
Unknown Object (File)
Thu, Oct 1, 6:58 AM
Unknown Object (File)
Wed, Sep 30, 6:57 AM
Unknown Object (File)
Wed, Sep 30, 4:14 AM
Unknown Object (File)
Wed, Sep 30, 3:00 AM

Details

Reviewers
jkoshy
Summary

Add the LoongArch ELF relocator.

Signed-off-by: Xiaoqiang Zhao <zhaoxiaoqiang007@gmail.com>

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 77266
Build 74149: arc lint + arc unit

Event Timeline

jkoshy added inline comments.
lib/libkldelf/ef_loongarch.c
5

Do you want to add your (c) line here?

zhaoxiaoqiang007_gmail.com added inline comments.
lib/libkldelf/ef_loongarch.c
5

updated

shipujin.t_gmail.com added inline comments.
lib/libkldelf/ef_loongarch.c
53

commitID(2bb6149): the sys/sys/elf_common.h header has already added the definitions, and D59890 sys/loongarch/loongarch/elf_machdep.c has already implemented data relocations in the kernel.

Here only R_LARCH_64 and R_LARCH_RELATIVE are handled, but the LoongArch ABI defines 100+ relocation types. For 64-bit LoongArch kernel modules, supporting only 2 types will cause a large number of data pointers to fail to resolve.

You could first add the common data relocations, and at the same time change the default branch from returning 0 to returning EINVAL, so that unhandled relocations are not silently ignored.

case R_LARCH_NONE:
	break;
case R_LARCH_64_PCREL:
	addr = EF_SYMADDR(ef, symidx) + addend - (GElf_Addr)where;
	le64enc(where, addr);
	break;
case R_LARCH_JUMP_SLOT:
	addr = EF_SYMADDR(ef, symidx);
	le64enc(where, addr);
	break;
case R_LARCH_IRELATIVE:
	addr = relbase + addend;
	addr = ((GElf_Addr (*)(void))addr)();
	le64enc(where, addr);
	break;
lib/libkldelf/ef_loongarch.c
53

reasonable