Skip to content

Commit 98fab15

Browse files
committed
enhance relocation for mips32 lkm
1 parent 374f100 commit 98fab15

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

qiling/loader/elf.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -463,7 +463,8 @@ def get_symbol(elffile, name):
463463
rev_reloc_symbols = {}
464464

465465
# dump_mem("XX Original code at 15a1 = ", ql.mem.read(0x15a1, 8))
466-
for section in elffile.iter_sections():
466+
_sections = list(elffile.iter_sections())
467+
for section in _sections:
467468
# only care about reloc section
468469
if not isinstance(section, RelocationSection):
469470
continue
@@ -472,9 +473,15 @@ def get_symbol(elffile, name):
472473
if section.name == ".rela.gnu.linkonce.this_module":
473474
continue
474475

476+
dest_sec_idx = section.header.get('sh_info', None)
477+
if dest_sec_idx is not None and dest_sec_idx < len(_sections):
478+
dest_sec = _sections[dest_sec_idx]
479+
if dest_sec.header['sh_flags'] & 2 == 0:
480+
# The target section is not loaded into memory, so just continue
481+
continue
482+
475483
# The symbol table section pointed to in sh_link
476484
symtable = elffile.get_section(section['sh_link'])
477-
478485
for rel in section.iter_relocations():
479486
if rel['r_info_sym'] == 0:
480487
continue

0 commit comments

Comments
 (0)