Skip to content

Commit aa0cbc1

Browse files
heiherchenhuacai
authored andcommitted
LoongArch: Record pc instead of offset in la_abs relocation
To clarify, the previous version functioned flawlessly. However, it's worth noting that the LLVM's LoongArch backend currently lacks support for cross-section label calculations. With this patch, we enable the use of clang to compile relocatable kernels. Tested-by: Nathan Chancellor <[email protected]> Signed-off-by: WANG Rui <[email protected]> Signed-off-by: Huacai Chen <[email protected]>
1 parent cbfd44b commit aa0cbc1

File tree

3 files changed

+3
-4
lines changed

3 files changed

+3
-4
lines changed

arch/loongarch/include/asm/asmmacro.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -609,8 +609,7 @@
609609
lu32i.d \reg, 0
610610
lu52i.d \reg, \reg, 0
611611
.pushsection ".la_abs", "aw", %progbits
612-
768:
613-
.dword 768b-766b
612+
.dword 766b
614613
.dword \sym
615614
.popsection
616615
#endif

arch/loongarch/include/asm/setup.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ extern void set_merr_handler(unsigned long offset, void *addr, unsigned long len
2525
#ifdef CONFIG_RELOCATABLE
2626

2727
struct rela_la_abs {
28-
long offset;
28+
long pc;
2929
long symvalue;
3030
};
3131

arch/loongarch/kernel/relocate.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ static inline void __init relocate_absolute(long random_offset)
5252
for (p = begin; (void *)p < end; p++) {
5353
long v = p->symvalue;
5454
uint32_t lu12iw, ori, lu32id, lu52id;
55-
union loongarch_instruction *insn = (void *)p - p->offset;
55+
union loongarch_instruction *insn = (void *)p->pc;
5656

5757
lu12iw = (v >> 12) & 0xfffff;
5858
ori = v & 0xfff;

0 commit comments

Comments
 (0)