Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

modpost: pass r_type to addend_*_rel()

All of addend_*_rel() need the Elf_Rela pointer just for calculating
ELF_R_TYPE(r->r_info).

You can do it on the caller to de-duplicate the code.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>

+11 -13
+11 -13
scripts/mod/modpost.c
··· 1257 1257 tosec, taddr); 1258 1258 } 1259 1259 1260 - static Elf_Addr addend_386_rel(uint32_t *location, Elf_Rela *r) 1260 + static Elf_Addr addend_386_rel(uint32_t *location, unsigned int r_type) 1261 1261 { 1262 - unsigned int r_typ = ELF_R_TYPE(r->r_info); 1263 - 1264 - switch (r_typ) { 1262 + switch (r_type) { 1265 1263 case R_386_32: 1266 1264 return TO_NATIVE(*location); 1267 1265 case R_386_PC32: ··· 1310 1312 return (int32_t)(value << shift) >> shift; 1311 1313 } 1312 1314 1313 - static Elf_Addr addend_arm_rel(void *loc, Elf_Sym *sym, Elf_Rela *r) 1315 + static Elf_Addr addend_arm_rel(void *loc, Elf_Sym *sym, unsigned int r_type) 1314 1316 { 1315 - unsigned int r_typ = ELF_R_TYPE(r->r_info); 1316 1317 uint32_t inst, upper, lower, sign, j1, j2; 1317 1318 int32_t offset; 1318 1319 1319 - switch (r_typ) { 1320 + switch (r_type) { 1320 1321 case R_ARM_ABS32: 1321 1322 case R_ARM_REL32: 1322 1323 inst = TO_NATIVE(*(uint32_t *)loc); ··· 1394 1397 return (Elf_Addr)(-1); 1395 1398 } 1396 1399 1397 - static Elf_Addr addend_mips_rel(uint32_t *location, Elf_Rela *r) 1400 + static Elf_Addr addend_mips_rel(uint32_t *location, unsigned int r_type) 1398 1401 { 1399 - unsigned int r_typ = ELF_R_TYPE(r->r_info); 1400 1402 uint32_t inst; 1401 1403 1402 1404 inst = TO_NATIVE(*location); 1403 - switch (r_typ) { 1405 + switch (r_type) { 1404 1406 case R_MIPS_LO16: 1405 1407 return inst & 0xffff; 1406 1408 case R_MIPS_26: ··· 1496 1500 Elf_Sym *tsym; 1497 1501 Elf_Addr taddr = 0; 1498 1502 void *loc; 1503 + unsigned int r_type; 1499 1504 1500 1505 r.r_offset = TO_NATIVE(rel->r_offset); 1501 1506 #if KERNEL_ELFCLASS == ELFCLASS64 ··· 1517 1520 1518 1521 loc = sym_get_data_by_offset(elf, fsecndx, r.r_offset); 1519 1522 tsym = elf->symtab_start + r_sym; 1523 + r_type = ELF_R_TYPE(r.r_info); 1520 1524 1521 1525 switch (elf->hdr->e_machine) { 1522 1526 case EM_386: 1523 - taddr = addend_386_rel(loc, &r); 1527 + taddr = addend_386_rel(loc, r_type); 1524 1528 break; 1525 1529 case EM_ARM: 1526 - taddr = addend_arm_rel(loc, tsym, &r); 1530 + taddr = addend_arm_rel(loc, tsym, r_type); 1527 1531 break; 1528 1532 case EM_MIPS: 1529 - taddr = addend_mips_rel(loc, &r); 1533 + taddr = addend_mips_rel(loc, r_type); 1530 1534 break; 1531 1535 default: 1532 1536 fatal("Please add code to calculate addend for this architecture\n");