Skip to content

Commit eea673e

Browse files
heiherchenhuacai
authored andcommitted
LoongArch: Apply dynamic relocations for LLD
For the following assembly code: .text .global func func: nop .data var: .dword func When linked with `-pie`, GNU LD populates the `var` variable with the pre-relocated value of `func`. However, LLVM LLD does not exhibit the same behavior. This issue also arises with the `kernel_entry` in arch/ loongarch/kernel/head.S: _head: .word MZ_MAGIC /* "MZ", MS-DOS header */ .org 0x8 .dword kernel_entry /* Kernel entry point */ The correct kernel entry from the MS-DOS header is crucial for jumping to vmlinux from zboot. This necessity is why the compressed relocatable kernel compiled by Clang encounters difficulties in booting. To address this problem, it is proposed to apply dynamic relocations to place with `--apply-dynamic-relocs`. Link: ClangBuiltLinux#1962 Signed-off-by: WANG Rui <[email protected]> Signed-off-by: Huacai Chen <[email protected]>
1 parent 33cc938 commit eea673e

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

arch/loongarch/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ endif
8383

8484
ifeq ($(CONFIG_RELOCATABLE),y)
8585
KBUILD_CFLAGS_KERNEL += -fPIE
86-
LDFLAGS_vmlinux += -static -pie --no-dynamic-linker -z notext
86+
LDFLAGS_vmlinux += -static -pie --no-dynamic-linker -z notext $(call ld-option, --apply-dynamic-relocs)
8787
endif
8888

8989
cflags-y += $(call cc-option, -mno-check-zero-division)

0 commit comments

Comments
 (0)