Skip to content

Commit 8aa00e2

Browse files
committed
modpost: factor out Elf_Sym pointer calculation to section_rel()
Pass the Elf_Sym pointer to addend_arm_rel() as well as to check_section_mismatch(). Signed-off-by: Masahiro Yamada <masahiroy@kernel.org> Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
1 parent b31db65 commit 8aa00e2

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

scripts/mod/modpost.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1295,10 +1295,9 @@ static int32_t sign_extend32(int32_t value, int index)
12951295
return (int32_t)(value << shift) >> shift;
12961296
}
12971297

1298-
static int addend_arm_rel(void *loc, struct elf_info *elf, Elf_Rela *r)
1298+
static int addend_arm_rel(void *loc, Elf_Sym *sym, Elf_Rela *r)
12991299
{
13001300
unsigned int r_typ = ELF_R_TYPE(r->r_info);
1301-
Elf_Sym *sym = elf->symtab_start + ELF_R_SYM(r->r_info);
13021301
uint32_t inst, upper, lower, sign, j1, j2;
13031302
int32_t offset;
13041303

@@ -1493,6 +1492,7 @@ static void section_rel(struct module *mod, struct elf_info *elf,
14931492
return;
14941493

14951494
for (rel = start; rel < stop; rel++) {
1495+
Elf_Sym *tsym;
14961496
void *loc;
14971497

14981498
r.r_offset = TO_NATIVE(rel->r_offset);
@@ -1514,14 +1514,15 @@ static void section_rel(struct module *mod, struct elf_info *elf,
15141514
r.r_addend = 0;
15151515

15161516
loc = sym_get_data_by_offset(elf, fsecndx, r.r_offset);
1517+
tsym = elf->symtab_start + ELF_R_SYM(r.r_info);
15171518

15181519
switch (elf->hdr->e_machine) {
15191520
case EM_386:
15201521
if (addend_386_rel(loc, &r))
15211522
continue;
15221523
break;
15231524
case EM_ARM:
1524-
if (addend_arm_rel(loc, elf, &r))
1525+
if (addend_arm_rel(loc, tsym, &r))
15251526
continue;
15261527
break;
15271528
case EM_MIPS:
@@ -1532,7 +1533,7 @@ static void section_rel(struct module *mod, struct elf_info *elf,
15321533
fatal("Please add code to calculate addend for this architecture\n");
15331534
}
15341535

1535-
check_section_mismatch(mod, elf, elf->symtab_start + r_sym,
1536+
check_section_mismatch(mod, elf, tsym,
15361537
fsecndx, fromsec, r.r_offset, r.r_addend);
15371538
}
15381539
}

0 commit comments

Comments
 (0)