Skip to content

Commit 6a922e3

Browse files
committed
load libs explicitly in testcases
1 parent bf25be5 commit 6a922e3

21 files changed

+34
-27
lines changed

tests/test_aarch64_relocations.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ def test_aarch64_relocs():
1313
"""
1414
test_location = str(os.path.join(os.path.dirname(os.path.realpath(__file__)), "..", "..", "binaries", "tests"))
1515
path = os.path.join(test_location, "aarch64", "aarch64-relocs.o")
16-
loader = cle.Loader(path, main_opts={"base_addr": 0x210120})
16+
loader = cle.Loader(path, main_opts={"base_addr": 0x210120}, auto_load_libs=True)
1717
relocations = loader.main_object.relocs
1818
aarch64_backend = cle.backends.elf.relocation.arm64
1919

tests/test_arch_detect.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class TestArchPcodeDetect(unittest.TestCase):
2424

2525
def test_elf_m68k(self):
2626
binpath = os.path.join(test_location, "m68k/mul_add_sub_xor_m68k_be")
27-
ld = cle.Loader(binpath)
27+
ld = cle.Loader(binpath, auto_load_libs=True)
2828
arch = ld.main_object.arch
2929
assert isinstance(arch, archinfo.ArchPcode)
3030
assert arch.name == "68000:BE:32:default"

tests/test_arm_firmware.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def test_empty_segements():
1717
:return:
1818
"""
1919
path = os.path.join(test_location, "armel", "efm32gg.elf")
20-
cle.Loader(path, rebase_granularity=0x1000)
20+
cle.Loader(path, rebase_granularity=0x1000, auto_load_libs=True)
2121
# If we survive this, we're doing OK!
2222

2323

@@ -30,7 +30,7 @@ def test_thumb_object():
3030
:return:
3131
"""
3232
path = os.path.join(test_location, "armel", "i2c_api.o")
33-
loader = cle.Loader(path, rebase_granularity=0x1000)
33+
loader = cle.Loader(path, rebase_granularity=0x1000, auto_load_libs=True)
3434
for r in loader.main_object.relocs:
3535
if r.__class__ == cle.backends.elf.relocation.arm.R_ARM_THM_JUMP24:
3636
if r.symbol.name == "HAL_I2C_ER_IRQHandler":

tests/test_blob.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ def test_blob_0():
2222
"entry_point": ENTRYPOINT,
2323
"arch": "ARM",
2424
},
25+
auto_load_libs=True,
2526
)
2627

2728
assert ld.main_object.linked_base == BASE_ADDR
@@ -55,6 +56,7 @@ def test_blob_1():
5556
"arch": "ARM",
5657
"offset": offset,
5758
},
59+
auto_load_libs=True,
5860
)
5961

6062
assert ld.main_object.linked_base == BASE_ADDR

tests/test_coff.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class TestCoff(unittest.TestCase):
1616

1717
def test_x86(self):
1818
exe = os.path.join(TEST_BASE, "tests", "x86", "fauxware.obj")
19-
ld = cle.Loader(exe)
19+
ld = cle.Loader(exe, auto_load_libs=True)
2020
symbol_names = {sym.name for sym in ld.main_object.symbols}
2121
assert "_main" in symbol_names
2222
assert "_accepted" in symbol_names
@@ -25,7 +25,7 @@ def test_x86(self):
2525

2626
def test_x86_64(self):
2727
exe = os.path.join(TEST_BASE, "tests", "x86_64", "fauxware.obj")
28-
ld = cle.Loader(exe)
28+
ld = cle.Loader(exe, auto_load_libs=True)
2929
symbol_names = {sym.name for sym in ld.main_object.symbols}
3030
assert "main" in symbol_names
3131
assert "accepted" in symbol_names

tests/test_elfcore.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def test_remote_file_mapping():
2929
"/tmp/foobar/does-not-exist/libc.so.6": f"{get_binary_directory()}/libc.so.6",
3030
"/tmp/foobar/does-not-exist/ld-linux-x86-64.so.2": f"{get_binary_directory()}/ld-linux-x86-64.so.2",
3131
}
32-
ld = cle.Loader(get_coredump_file(), main_opts={"backend": "elfcore", "remote_file_mapping": remote_file_mapping})
32+
ld = cle.Loader(get_coredump_file(), main_opts={"backend": "elfcore", "remote_file_mapping": remote_file_mapping}, auto_load_libs=True)
3333
check_objects_loaded(ld)
3434

3535

@@ -39,5 +39,5 @@ def test_remote_file_mapper():
3939
def remote_file_mapper(x):
4040
return x.replace("/tmp/foobar/does-not-exist", directory_for_binaries)
4141

42-
ld = cle.Loader(get_coredump_file(), main_opts={"backend": "elfcore", "remote_file_mapper": remote_file_mapper})
42+
ld = cle.Loader(get_coredump_file(), main_opts={"backend": "elfcore", "remote_file_mapper": remote_file_mapper}, auto_load_libs=True)
4343
check_objects_loaded(ld)

tests/test_gdb.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@ def check_addrs(ld):
1818

1919
def test_info_proc_maps():
2020
mappath = os.path.join(test_location, "../tests_data/test_gdb_plugin/procmap")
21-
ld = cle.Loader(binpath, **cle.convert_info_proc_maps(mappath))
21+
ld = cle.Loader(binpath, **cle.convert_info_proc_maps(mappath), auto_load_libs=True)
2222
check_addrs(ld)
2323

2424

2525
def test_info_sharedlibrary():
2626
mappath = os.path.join(test_location, "../tests_data/test_gdb_plugin/info_sharedlibs")
27-
ld = cle.Loader(binpath, **cle.convert_info_sharedlibrary(mappath))
27+
ld = cle.Loader(binpath, **cle.convert_info_sharedlibrary(mappath), auto_load_libs=True)
2828
check_addrs(ld)
2929

3030

tests/test_got.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def test_ppc(self):
2323
def test_mipsel(self):
2424
ping = os.path.join(self.test_location, "mipsel", "darpa_ping")
2525
skip = ["libgcc_s.so.1", "libresolv.so.0"]
26-
ld = cle.Loader(ping, skip_libs=skip)
26+
ld = cle.Loader(ping, skip_libs=skip, auto_load_libs=True)
2727
dep = set(ld._satisfied_deps)
2828
loadedlibs = set(ld.shared_objects)
2929

tests/test_macho_dyld.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ def test_fixups():
1515
Tests the pointer format DYLD_CHAINED_PTR_64_OFFSET
1616
:return:
1717
"""
18-
binary: MachO = cast(MachO, cle.Loader(str(TEST_BASE / "tests" / "aarch64" / "dyld_ios15.macho")).main_object)
18+
binary: MachO = cast(MachO, cle.Loader(str(TEST_BASE / "tests" / "aarch64" / "dyld_ios15.macho"), auto_load_libs=True).main_object)
1919
expected = {
2020
0x100008100: 0x100007A40,
2121
0x1000081E0: 0x1000072B0,
@@ -46,7 +46,7 @@ def test_fixups():
4646

4747

4848
def test_symbols():
49-
loader = cle.Loader(str(TEST_BASE / "tests" / "aarch64" / "dyld_ios15.macho"))
49+
loader = cle.Loader(str(TEST_BASE / "tests" / "aarch64" / "dyld_ios15.macho"), auto_load_libs=True)
5050
binary: MachO = cast(MachO, loader.main_object)
5151

5252
expected = [

tests/test_macho_libs.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def test_library_15():
1616
:return:
1717
"""
1818

19-
ld = cle.Loader(TEST_BASE / "FrameWorkApp.app_15" / "Frameworks" / "dynamicLibrary.framework" / "dynamicLibrary")
19+
ld = cle.Loader(TEST_BASE / "FrameWorkApp.app_15" / "Frameworks" / "dynamicLibrary.framework" / "dynamicLibrary", auto_load_libs=True)
2020
lib = ld.main_object
2121
assert isinstance(lib, MachO)
2222
# The base address should be 0 until full rebasing support is implemented
@@ -30,7 +30,7 @@ def test_library_14():
3030
Test some basics about loading any kind of library
3131
:return:
3232
"""
33-
ld = cle.Loader(TEST_BASE / "FrameWorkApp.app_14" / "Frameworks" / "dynamicLibrary.framework" / "dynamicLibrary")
33+
ld = cle.Loader(TEST_BASE / "FrameWorkApp.app_14" / "Frameworks" / "dynamicLibrary.framework" / "dynamicLibrary", auto_load_libs=True)
3434
lib = ld.main_object
3535
assert isinstance(lib, MachO)
3636
# The base address should be 0 until full rebasing support is implemented
@@ -51,6 +51,7 @@ def test_framework_ios15():
5151
force_load_libs=(
5252
TEST_BASE / "FrameWorkApp.app_15" / "Frameworks" / "dynamicLibrary.framework" / "dynamicLibrary",
5353
),
54+
auto_load_libs=True,
5455
)
5556

5657
assert isinstance(ld.main_object, MachO)

0 commit comments

Comments
 (0)