diff --git a/pwndbg/commands/cymbol.py b/pwndbg/commands/cymbol.py index fa98a8571..20fa776e3 100644 --- a/pwndbg/commands/cymbol.py +++ b/pwndbg/commands/cymbol.py @@ -181,7 +181,10 @@ def load_custom_structure(custom_structure_name, custom_structure_path): pwndbg_debug_symbols_output_file = generate_debug_symbols(custom_structure_path) if not pwndbg_debug_symbols_output_file: return # generate_debug_symbols prints on failures - gdb.execute(f"add-symbol-file {pwndbg_debug_symbols_output_file}", to_string=True) + # Old GDB versions (e.g. 8.2) requires addr argument in add-symbol-file + # we set that address to which to load the symbols to 0 since it doesn't matter here + # (because we are only loading types information) + gdb.execute(f"add-symbol-file {pwndbg_debug_symbols_output_file} 0", to_string=True) loaded_symbols[custom_structure_name] = pwndbg_debug_symbols_output_file print(message.success("Symbols are loaded!")) diff --git a/tests/gdb-tests/tests/test_cymbol.py b/tests/gdb-tests/tests/test_cymbol.py index 77659bc96..0187ad7ca 100644 --- a/tests/gdb-tests/tests/test_cymbol.py +++ b/tests/gdb-tests/tests/test_cymbol.py @@ -51,9 +51,12 @@ def test_cymbol(start_binary): assert pwndbg.commands.cymbol.loaded_symbols.get("example") is not None # Test whether the returned type is what we expect (on x86-64). assert ( - "example_t\n +0x0000 a : int\n +0x0004 b : char [16]\n +0x0018 c : char *\n +0x0020 d : void *" - in pwndbg.gdblib.dt.dt("example_t").strip() - ) + "example_t\n" + " +0x0000 a : int\n" + " +0x0004 b : char [16]\n" + " +0x0018 c : char *\n" + " +0x0020 d : void *" + ) == pwndbg.gdblib.dt.dt("example_t").strip() # Test whether unload_loaded_symbol() works properly. pwndbg.commands.cymbol.unload_loaded_symbol("example")