Skip to content

Commit 2772ae4

Browse files
xen0nchenhuacai
authored andcommitted
modpost: Ignore relaxation and alignment marker relocs on LoongArch
With recent trunk versions of binutils and gcc, alignment directives are represented with R_LARCH_ALIGN relocs on LoongArch, which is necessary for the linker to maintain alignment requirements during its relaxation passes. And even though the kernel is built with relaxation disabled, so far a small number of R_LARCH_RELAX marker relocs are still emitted as part of la.* pseudo instructions in assembly. These two kinds of relocs do not refer to symbols, which can trip up modpost's section mismatch checks, because the r_offset of said relocs can be zero or any other meaningless value, eventually leading to a `from == NULL` condition in default_mismatch_handler and SIGSEGV. As the two kinds of relocs are not concerned with symbols, just ignore them for section mismatch check purposes. Signed-off-by: WANG Xuerui <[email protected]> Signed-off-by: Huacai Chen <[email protected]>
1 parent 0dd3ee3 commit 2772ae4

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

scripts/mod/modpost.c

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1346,6 +1346,14 @@ static Elf_Addr addend_mips_rel(uint32_t *location, unsigned int r_type)
13461346
#define R_LARCH_SUB32 55
13471347
#endif
13481348

1349+
#ifndef R_LARCH_RELAX
1350+
#define R_LARCH_RELAX 100
1351+
#endif
1352+
1353+
#ifndef R_LARCH_ALIGN
1354+
#define R_LARCH_ALIGN 102
1355+
#endif
1356+
13491357
static void get_rel_type_and_sym(struct elf_info *elf, uint64_t r_info,
13501358
unsigned int *r_type, unsigned int *r_sym)
13511359
{
@@ -1400,9 +1408,16 @@ static void section_rela(struct module *mod, struct elf_info *elf,
14001408
continue;
14011409
break;
14021410
case EM_LOONGARCH:
1403-
if (!strcmp("__ex_table", fromsec) &&
1404-
r_type == R_LARCH_SUB32)
1411+
switch (r_type) {
1412+
case R_LARCH_SUB32:
1413+
if (!strcmp("__ex_table", fromsec))
1414+
continue;
1415+
break;
1416+
case R_LARCH_RELAX:
1417+
case R_LARCH_ALIGN:
1418+
/* These relocs do not refer to symbols */
14051419
continue;
1420+
}
14061421
break;
14071422
}
14081423

0 commit comments

Comments
 (0)