We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
pwndbg might fail to show the state of the GOT of i386 libc
```console
$ cat a.c
#include <stdio.h>
int main(){puts("hello world");return 0;}
$ gcc -m32 a.c
$ gdb -q a.out -ex 'break main' -ex 'run' -ex 'got -p libc'
```

<img width="1514" alt="image" src="https://github.com/pwndbg/pwndbg/assets/61896187/e0492360-8c33-495a-aad1-99e0a91ad4c8">

The above error was triggered with i386 libc with version: `2.35-0ubuntu3.6`.

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `pwndbg/commands/got.py`
Content:
```
1 from __future__ import annotations
2 
3 import argparse
4 from typing import Dict
5 from typing import List
6 from typing import Union
7 
8 from elftools.elf.elffile import ELFFile
9 
10 import pwndbg.chain
11 import pwndbg.color.memory as M
12 import pwndbg.commands
13 import pwndbg.enhance
14 import pwndbg.gdblib.arch
15 import pwndbg.gdblib.file
16 import pwndbg.gdblib.info
17 import pwndbg.gdblib.proc
18 import pwndbg.gdblib.qemu
19 import pwndbg.gdblib.vmmap
20 import pwndbg.wrappers.checksec
21 import pwndbg.wrappers.readelf
22 from pwndbg.color import message
23 from pwndbg.commands import CommandCategory
24 from pwndbg.wrappers.readelf import RelocationType
25 
26 parser = argparse.ArgumentParser(
27     formatter_class=argparse.RawTextHelpFormatter,
28     description="""Show the state of the Global Offset Table.
29 
30 Examples:
31     got
32     got puts
33     got -p libc
34     got -a
35 """,
36 )
37 group = parser.add_mutually_exclusive_group()
38 group.add_argument(
39     "-p",
40     "--path",
41     help="Filter results by library/objfile path.",
42     type=str,
43     default="",
44     dest="path_filter",
45 )
46 group.add_argument(
47     "-a",
48     "--all",
49     help="Process all libs/obfjiles including the target executable.",
50     action="store_true",
51     default=False,
52     dest="all_",
53 )
54 parser.add_argument(
55     "-r",
56     "--show-readonly",
57     help="Also display read-only entries (which are filtered out by default).",
58     action="store_true",
59     default=False,
60     dest="accept_readonly",
61 )
62 parser.add_argument(
63     "symbol_filter", help="Filter results by symbol name.", type=str, nargs="?", default=""
64 )
65 
66 
67 @pwndbg.commands.ArgparsedCommand(parser, category=CommandCategory.LINUX)
68 @pwndbg.commands.OnlyWhenRunning
69 def got(path_filter: str, all_: bool, accept_readonly: bool, symbol_filter: str) -> None:
70     if pwndbg.gdblib.qemu.is_qemu_usermode():
71         print(
72             "QEMU target detected - the result might not be accurate when checking if the entry is writable and getting the information for libraries/objfiles"
73         )
74         print()
75     # Show the filters we are using
76     if path_filter:
77         print("Filtering by lib/objfile path: " + message.hint(path_filter))
78     if symbol_filter:
79         print("Filtering by symbol name: " + message.hint(symbol_filter))
80     if not accept_readonly:
81         print("Filtering out read-only entries (display them with -r or --show-readonly)")
82 
83     if path_filter or not accept_readonly or symbol_filter:
84         print()
85 
86     # Calculate the base address
87     if not path_filter:
88         first_print = False
89         _got(pwndbg.gdblib.proc.exe, accept_readonly, symbol_filter)
90     else:
91         first_print = True
92 
93     if not all_ and not path_filter:
94         return
95     # TODO: We might fail to find shared libraries if GDB can't find them (can't show them in `info sharedlibrary`)
96     paths = pwndbg.gdblib.info.sharedlibrary_paths()
97     for path in paths:
98         if path_filter not in path:
99             continue
100         if not first_print:
101             print()
102         first_print = False
103         _got(path, accept_readonly, symbol_filter)
104 
105     # Maybe user have a typo or something in the path filter, show the available shared libraries
106     if first_print and path_filter:
107         print(message.error("No shared library matching the path filter found."))
108         if paths:
109             print(message.notice("Available shared libraries:"))
110             for path in paths:
111                 print("    " + path)
112 
113 
114 def _got(path: str, accept_readonly: bool, symbol_filter: str) -> None:
115     # Maybe download the file from remote
116     local_path = pwndbg.gdblib.file.get_file(path, try_local_path=True)
117 
118     relro_status = pwndbg.wrappers.checksec.relro_status(local_path)
119     pie_status = pwndbg.wrappers.checksec.pie_status(local_path)
120     got_entry = pwndbg.wrappers.readelf.get_got_entry(local_path)
121 
122     # The following code is inspired by the "got" command of https://github.com/bata24/gef/blob/dev/gef.py by @bata24, thank you!
123     # TODO/FIXME: Maybe a -v option to show more information will be better
124     outputs: List[Dict[str, Union[str, int]]] = []
125     if path == pwndbg.gdblib.proc.exe:
126         bin_base_offset = pwndbg.gdblib.proc.binary_base_addr if "PIE enabled" in pie_status else 0
127     else:
128         # TODO/FIXME: Is there a better way to get the base address of the loaded shared library?
129         # I guess parsing the vmmap result might also work, but what if it's not reliable or not available? (e.g. debugging with qemu-user)
130         text_section_addr = pwndbg.gdblib.info.parsed_sharedlibrary()[path][0]
131         with open(local_path, "rb") as f:
132             bin_base_offset = (
133                 text_section_addr - ELFFile(f).get_section_by_name(".text").header["sh_addr"]
134             )
135 
136     # Parse the output of readelf line by line
137     for category, lines in got_entry.items():
138         for line in lines:
139             # line might be something like:
140             # 00000000001ec018  0000000000000025 R_X86_64_IRELATIVE                        a0480
141             # or something like:
142             # 00000000001ec030  0000020a00000007 R_X86_64_JUMP_SLOT     000000000009ae80 realloc@@GLIBC_2.2.5 + 0
143             offset, _, rtype, *rest = line.split()[:5]
144             if len(rest) == 1:
145                 value = rest[0]
146                 name = ""
147             else:
148                 value, name = rest
149             address = int(offset, 16) + bin_base_offset
150             # TODO/FIXME: This check might not work correctly if we failed to get the correct vmmap result
151             if not accept_readonly and not pwndbg.gdblib.vmmap.find(address).write:
152                 continue
153             if not name and category == RelocationType.IRELATIVE:
154                 # TODO/FIXME: I don't know the naming logic behind this yet, I'm just modifying @bata24's code here :p
155                 # We might need to add some comments here to explain the logic in the future, and also fix it if something wrong
156                 if pwndbg.gdblib.arch.name == "i386":
157                     name = "*ABS*"
158                 else:
159                     name = f"*ABS*+0x{int(value, 16):x}"
160             if symbol_filter not in name:
161                 continue
162             outputs.append(
163                 {
164                     "name": name or "????",
165                     "address": address,
166                 }
167             )
168     # By sorting the outputs by address, we can get a more intuitive output
169     outputs.sort(key=lambda x: x["address"])
170     relro_color = message.off
171     if "Partial" in relro_status:
172         relro_color = message.warn
173     elif "Full" in relro_status:
174         relro_color = message.on
175     print(f"State of the GOT of {message.notice(path)}:")
176     print(
177         f"GOT protection: {relro_color(relro_status)} | Found {message.hint(len(outputs))} GOT entries passing the filter"
178     )
179     for output in outputs:
180         print(
181             f"[{M.get(output['address'])}] {message.hint(output['name'])} -> {pwndbg.chain.format(pwndbg.gdblib.memory.pvoid(output['address']))}"  # type: ignore[arg-type]
182         )
183
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/pwndbg/commands/got.py b/pwndbg/commands/got.py
--- a/pwndbg/commands/got.py
+++ b/pwndbg/commands/got.py
@@ -136,15 +136,23 @@
     # Parse the output of readelf line by line
     for category, lines in got_entry.items():
         for line in lines:
-            # line might be something like:
-            # 00000000001ec018  0000000000000025 R_X86_64_IRELATIVE                        a0480
-            # or something like:
-            # 00000000001ec030  0000020a00000007 R_X86_64_JUMP_SLOT     000000000009ae80 realloc@@GLIBC_2.2.5 + 0
-            offset, _, rtype, *rest = line.split()[:5]
-            if len(rest) == 1:
-                value = rest[0]
+            # There are 5 fields in the output of readelf:
+            # "Offset", "Info", "Type", "Sym. Value", and "Symbol's Name"
+            # We only care about "Offset", "Sym. Value" and "Symbol's Name" here
+            offset, _, _, *rest = line.split()[:5]
+            if len(rest) < 2:
+                # "Sym. Value" or "Symbol's Name" are not present in this case
+                # The output of readelf might look like this (missing both value and name):
+                # 00004e88  00000008 R_386_RELATIVE
+                # or something like this (only missing name):
+                # 00000000001ec018  0000000000000025 R_X86_64_IRELATIVE                        a0480
+                # TODO: Is it possible that we are missing the value but not the name?
+                value = rest[0] if rest else ""
                 name = ""
             else:
+                # Every fields are present in this case
+                # The output of readelf might look like this:
+                # 00000000001ec030  0000020a00000007 R_X86_64_JUMP_SLOT     000000000009ae80 realloc@@GLIBC_2.2.5 + 0
                 value, name = rest
             address = int(offset, 16) + bin_base_offset
             # TODO/FIXME: This check might not work correctly if we failed to get the correct vmmap result

{"golden_diff": "diff --git a/pwndbg/commands/got.py b/pwndbg/commands/got.py\n--- a/pwndbg/commands/got.py\n+++ b/pwndbg/commands/got.py\n@@ -136,15 +136,23 @@\n     # Parse the output of readelf line by line\n     for category, lines in got_entry.items():\n         for line in lines:\n-            # line might be something like:\n-            # 00000000001ec018  0000000000000025 R_X86_64_IRELATIVE                        a0480\n-            # or something like:\n-            # 00000000001ec030  0000020a00000007 R_X86_64_JUMP_SLOT     000000000009ae80 realloc@@GLIBC_2.2.5 + 0\n-            offset, _, rtype, *rest = line.split()[:5]\n-            if len(rest) == 1:\n-                value = rest[0]\n+            # There are 5 fields in the output of readelf:\n+            # \"Offset\", \"Info\", \"Type\", \"Sym. Value\", and \"Symbol's Name\"\n+            # We only care about \"Offset\", \"Sym. Value\" and \"Symbol's Name\" here\n+            offset, _, _, *rest = line.split()[:5]\n+            if len(rest) < 2:\n+                # \"Sym. Value\" or \"Symbol's Name\" are not present in this case\n+                # The output of readelf might look like this (missing both value and name):\n+                # 00004e88  00000008 R_386_RELATIVE\n+                # or something like this (only missing name):\n+                # 00000000001ec018  0000000000000025 R_X86_64_IRELATIVE                        a0480\n+                # TODO: Is it possible that we are missing the value but not the name?\n+                value = rest[0] if rest else \"\"\n                 name = \"\"\n             else:\n+                # Every fields are present in this case\n+                # The output of readelf might look like this:\n+                # 00000000001ec030  0000020a00000007 R_X86_64_JUMP_SLOT     000000000009ae80 realloc@@GLIBC_2.2.5 + 0\n                 value, name = rest\n             address = int(offset, 16) + bin_base_offset\n             # TODO/FIXME: This check might not work correctly if we failed to get the correct vmmap result\n", "issue": "pwndbg might fail to show the state of the GOT of i386 libc\n```console\r\n$ cat a.c\r\n#include <stdio.h>\r\nint main(){puts(\"hello world\");return 0;}\r\n$ gcc -m32 a.c\r\n$ gdb -q a.out -ex 'break main' -ex 'run' -ex 'got -p libc'\r\n```\r\n\r\n<img width=\"1514\" alt=\"image\" src=\"https://github.com/pwndbg/pwndbg/assets/61896187/e0492360-8c33-495a-aad1-99e0a91ad4c8\">\r\n\r\nThe above error was triggered with i386 libc with version: `2.35-0ubuntu3.6`.\n", "before_files": [{"content": "from __future__ import annotations\n\nimport argparse\nfrom typing import Dict\nfrom typing import List\nfrom typing import Union\n\nfrom elftools.elf.elffile import ELFFile\n\nimport pwndbg.chain\nimport pwndbg.color.memory as M\nimport pwndbg.commands\nimport pwndbg.enhance\nimport pwndbg.gdblib.arch\nimport pwndbg.gdblib.file\nimport pwndbg.gdblib.info\nimport pwndbg.gdblib.proc\nimport pwndbg.gdblib.qemu\nimport pwndbg.gdblib.vmmap\nimport pwndbg.wrappers.checksec\nimport pwndbg.wrappers.readelf\nfrom pwndbg.color import message\nfrom pwndbg.commands import CommandCategory\nfrom pwndbg.wrappers.readelf import RelocationType\n\nparser = argparse.ArgumentParser(\n    formatter_class=argparse.RawTextHelpFormatter,\n    description=\"\"\"Show the state of the Global Offset Table.\n\nExamples:\n    got\n    got puts\n    got -p libc\n    got -a\n\"\"\",\n)\ngroup = parser.add_mutually_exclusive_group()\ngroup.add_argument(\n    \"-p\",\n    \"--path\",\n    help=\"Filter results by library/objfile path.\",\n    type=str,\n    default=\"\",\n    dest=\"path_filter\",\n)\ngroup.add_argument(\n    \"-a\",\n    \"--all\",\n    help=\"Process all libs/obfjiles including the target executable.\",\n    action=\"store_true\",\n    default=False,\n    dest=\"all_\",\n)\nparser.add_argument(\n    \"-r\",\n    \"--show-readonly\",\n    help=\"Also display read-only entries (which are filtered out by default).\",\n    action=\"store_true\",\n    default=False,\n    dest=\"accept_readonly\",\n)\nparser.add_argument(\n    \"symbol_filter\", help=\"Filter results by symbol name.\", type=str, nargs=\"?\", default=\"\"\n)\n\n\n@pwndbg.commands.ArgparsedCommand(parser, category=CommandCategory.LINUX)\n@pwndbg.commands.OnlyWhenRunning\ndef got(path_filter: str, all_: bool, accept_readonly: bool, symbol_filter: str) -> None:\n    if pwndbg.gdblib.qemu.is_qemu_usermode():\n        print(\n            \"QEMU target detected - the result might not be accurate when checking if the entry is writable and getting the information for libraries/objfiles\"\n        )\n        print()\n    # Show the filters we are using\n    if path_filter:\n        print(\"Filtering by lib/objfile path: \" + message.hint(path_filter))\n    if symbol_filter:\n        print(\"Filtering by symbol name: \" + message.hint(symbol_filter))\n    if not accept_readonly:\n        print(\"Filtering out read-only entries (display them with -r or --show-readonly)\")\n\n    if path_filter or not accept_readonly or symbol_filter:\n        print()\n\n    # Calculate the base address\n    if not path_filter:\n        first_print = False\n        _got(pwndbg.gdblib.proc.exe, accept_readonly, symbol_filter)\n    else:\n        first_print = True\n\n    if not all_ and not path_filter:\n        return\n    # TODO: We might fail to find shared libraries if GDB can't find them (can't show them in `info sharedlibrary`)\n    paths = pwndbg.gdblib.info.sharedlibrary_paths()\n    for path in paths:\n        if path_filter not in path:\n            continue\n        if not first_print:\n            print()\n        first_print = False\n        _got(path, accept_readonly, symbol_filter)\n\n    # Maybe user have a typo or something in the path filter, show the available shared libraries\n    if first_print and path_filter:\n        print(message.error(\"No shared library matching the path filter found.\"))\n        if paths:\n            print(message.notice(\"Available shared libraries:\"))\n            for path in paths:\n                print(\"    \" + path)\n\n\ndef _got(path: str, accept_readonly: bool, symbol_filter: str) -> None:\n    # Maybe download the file from remote\n    local_path = pwndbg.gdblib.file.get_file(path, try_local_path=True)\n\n    relro_status = pwndbg.wrappers.checksec.relro_status(local_path)\n    pie_status = pwndbg.wrappers.checksec.pie_status(local_path)\n    got_entry = pwndbg.wrappers.readelf.get_got_entry(local_path)\n\n    # The following code is inspired by the \"got\" command of https://github.com/bata24/gef/blob/dev/gef.py by @bata24, thank you!\n    # TODO/FIXME: Maybe a -v option to show more information will be better\n    outputs: List[Dict[str, Union[str, int]]] = []\n    if path == pwndbg.gdblib.proc.exe:\n        bin_base_offset = pwndbg.gdblib.proc.binary_base_addr if \"PIE enabled\" in pie_status else 0\n    else:\n        # TODO/FIXME: Is there a better way to get the base address of the loaded shared library?\n        # I guess parsing the vmmap result might also work, but what if it's not reliable or not available? (e.g. debugging with qemu-user)\n        text_section_addr = pwndbg.gdblib.info.parsed_sharedlibrary()[path][0]\n        with open(local_path, \"rb\") as f:\n            bin_base_offset = (\n                text_section_addr - ELFFile(f).get_section_by_name(\".text\").header[\"sh_addr\"]\n            )\n\n    # Parse the output of readelf line by line\n    for category, lines in got_entry.items():\n        for line in lines:\n            # line might be something like:\n            # 00000000001ec018  0000000000000025 R_X86_64_IRELATIVE                        a0480\n            # or something like:\n            # 00000000001ec030  0000020a00000007 R_X86_64_JUMP_SLOT     000000000009ae80 realloc@@GLIBC_2.2.5 + 0\n            offset, _, rtype, *rest = line.split()[:5]\n            if len(rest) == 1:\n                value = rest[0]\n                name = \"\"\n            else:\n                value, name = rest\n            address = int(offset, 16) + bin_base_offset\n            # TODO/FIXME: This check might not work correctly if we failed to get the correct vmmap result\n            if not accept_readonly and not pwndbg.gdblib.vmmap.find(address).write:\n                continue\n            if not name and category == RelocationType.IRELATIVE:\n                # TODO/FIXME: I don't know the naming logic behind this yet, I'm just modifying @bata24's code here :p\n                # We might need to add some comments here to explain the logic in the future, and also fix it if something wrong\n                if pwndbg.gdblib.arch.name == \"i386\":\n                    name = \"*ABS*\"\n                else:\n                    name = f\"*ABS*+0x{int(value, 16):x}\"\n            if symbol_filter not in name:\n                continue\n            outputs.append(\n                {\n                    \"name\": name or \"????\",\n                    \"address\": address,\n                }\n            )\n    # By sorting the outputs by address, we can get a more intuitive output\n    outputs.sort(key=lambda x: x[\"address\"])\n    relro_color = message.off\n    if \"Partial\" in relro_status:\n        relro_color = message.warn\n    elif \"Full\" in relro_status:\n        relro_color = message.on\n    print(f\"State of the GOT of {message.notice(path)}:\")\n    print(\n        f\"GOT protection: {relro_color(relro_status)} | Found {message.hint(len(outputs))} GOT entries passing the filter\"\n    )\n    for output in outputs:\n        print(\n            f\"[{M.get(output['address'])}] {message.hint(output['name'])} -> {pwndbg.chain.format(pwndbg.gdblib.memory.pvoid(output['address']))}\"  # type: ignore[arg-type]\n        )\n", "path": "pwndbg/commands/got.py"}], "after_files": [{"content": "from __future__ import annotations\n\nimport argparse\nfrom typing import Dict\nfrom typing import List\nfrom typing import Union\n\nfrom elftools.elf.elffile import ELFFile\n\nimport pwndbg.chain\nimport pwndbg.color.memory as M\nimport pwndbg.commands\nimport pwndbg.enhance\nimport pwndbg.gdblib.arch\nimport pwndbg.gdblib.file\nimport pwndbg.gdblib.info\nimport pwndbg.gdblib.proc\nimport pwndbg.gdblib.qemu\nimport pwndbg.gdblib.vmmap\nimport pwndbg.wrappers.checksec\nimport pwndbg.wrappers.readelf\nfrom pwndbg.color import message\nfrom pwndbg.commands import CommandCategory\nfrom pwndbg.wrappers.readelf import RelocationType\n\nparser = argparse.ArgumentParser(\n    formatter_class=argparse.RawTextHelpFormatter,\n    description=\"\"\"Show the state of the Global Offset Table.\n\nExamples:\n    got\n    got puts\n    got -p libc\n    got -a\n\"\"\",\n)\ngroup = parser.add_mutually_exclusive_group()\ngroup.add_argument(\n    \"-p\",\n    \"--path\",\n    help=\"Filter results by library/objfile path.\",\n    type=str,\n    default=\"\",\n    dest=\"path_filter\",\n)\ngroup.add_argument(\n    \"-a\",\n    \"--all\",\n    help=\"Process all libs/obfjiles including the target executable.\",\n    action=\"store_true\",\n    default=False,\n    dest=\"all_\",\n)\nparser.add_argument(\n    \"-r\",\n    \"--show-readonly\",\n    help=\"Also display read-only entries (which are filtered out by default).\",\n    action=\"store_true\",\n    default=False,\n    dest=\"accept_readonly\",\n)\nparser.add_argument(\n    \"symbol_filter\", help=\"Filter results by symbol name.\", type=str, nargs=\"?\", default=\"\"\n)\n\n\n@pwndbg.commands.ArgparsedCommand(parser, category=CommandCategory.LINUX)\n@pwndbg.commands.OnlyWhenRunning\ndef got(path_filter: str, all_: bool, accept_readonly: bool, symbol_filter: str) -> None:\n    if pwndbg.gdblib.qemu.is_qemu_usermode():\n        print(\n            \"QEMU target detected - the result might not be accurate when checking if the entry is writable and getting the information for libraries/objfiles\"\n        )\n        print()\n    # Show the filters we are using\n    if path_filter:\n        print(\"Filtering by lib/objfile path: \" + message.hint(path_filter))\n    if symbol_filter:\n        print(\"Filtering by symbol name: \" + message.hint(symbol_filter))\n    if not accept_readonly:\n        print(\"Filtering out read-only entries (display them with -r or --show-readonly)\")\n\n    if path_filter or not accept_readonly or symbol_filter:\n        print()\n\n    # Calculate the base address\n    if not path_filter:\n        first_print = False\n        _got(pwndbg.gdblib.proc.exe, accept_readonly, symbol_filter)\n    else:\n        first_print = True\n\n    if not all_ and not path_filter:\n        return\n    # TODO: We might fail to find shared libraries if GDB can't find them (can't show them in `info sharedlibrary`)\n    paths = pwndbg.gdblib.info.sharedlibrary_paths()\n    for path in paths:\n        if path_filter not in path:\n            continue\n        if not first_print:\n            print()\n        first_print = False\n        _got(path, accept_readonly, symbol_filter)\n\n    # Maybe user have a typo or something in the path filter, show the available shared libraries\n    if first_print and path_filter:\n        print(message.error(\"No shared library matching the path filter found.\"))\n        if paths:\n            print(message.notice(\"Available shared libraries:\"))\n            for path in paths:\n                print(\"    \" + path)\n\n\ndef _got(path: str, accept_readonly: bool, symbol_filter: str) -> None:\n    # Maybe download the file from remote\n    local_path = pwndbg.gdblib.file.get_file(path, try_local_path=True)\n\n    relro_status = pwndbg.wrappers.checksec.relro_status(local_path)\n    pie_status = pwndbg.wrappers.checksec.pie_status(local_path)\n    got_entry = pwndbg.wrappers.readelf.get_got_entry(local_path)\n\n    # The following code is inspired by the \"got\" command of https://github.com/bata24/gef/blob/dev/gef.py by @bata24, thank you!\n    # TODO/FIXME: Maybe a -v option to show more information will be better\n    outputs: List[Dict[str, Union[str, int]]] = []\n    if path == pwndbg.gdblib.proc.exe:\n        bin_base_offset = pwndbg.gdblib.proc.binary_base_addr if \"PIE enabled\" in pie_status else 0\n    else:\n        # TODO/FIXME: Is there a better way to get the base address of the loaded shared library?\n        # I guess parsing the vmmap result might also work, but what if it's not reliable or not available? (e.g. debugging with qemu-user)\n        text_section_addr = pwndbg.gdblib.info.parsed_sharedlibrary()[path][0]\n        with open(local_path, \"rb\") as f:\n            bin_base_offset = (\n                text_section_addr - ELFFile(f).get_section_by_name(\".text\").header[\"sh_addr\"]\n            )\n\n    # Parse the output of readelf line by line\n    for category, lines in got_entry.items():\n        for line in lines:\n            # There are 5 fields in the output of readelf:\n            # \"Offset\", \"Info\", \"Type\", \"Sym. Value\", and \"Symbol's Name\"\n            # We only care about \"Offset\", \"Sym. Value\" and \"Symbol's Name\" here\n            offset, _, _, *rest = line.split()[:5]\n            if len(rest) < 2:\n                # \"Sym. Value\" or \"Symbol's Name\" are not present in this case\n                # The output of readelf might look like this (missing both value and name):\n                # 00004e88  00000008 R_386_RELATIVE\n                # or something like this (only missing name):\n                # 00000000001ec018  0000000000000025 R_X86_64_IRELATIVE                        a0480\n                # TODO: Is it possible that we are missing the value but not the name?\n                value = rest[0] if rest else \"\"\n                name = \"\"\n            else:\n                # Every fields are present in this case\n                # The output of readelf might look like this:\n                # 00000000001ec030  0000020a00000007 R_X86_64_JUMP_SLOT     000000000009ae80 realloc@@GLIBC_2.2.5 + 0\n                value, name = rest\n            address = int(offset, 16) + bin_base_offset\n            # TODO/FIXME: This check might not work correctly if we failed to get the correct vmmap result\n            if not accept_readonly and not pwndbg.gdblib.vmmap.find(address).write:\n                continue\n            if not name and category == RelocationType.IRELATIVE:\n                # TODO/FIXME: I don't know the naming logic behind this yet, I'm just modifying @bata24's code here :p\n                # We might need to add some comments here to explain the logic in the future, and also fix it if something wrong\n                if pwndbg.gdblib.arch.name == \"i386\":\n                    name = \"*ABS*\"\n                else:\n                    name = f\"*ABS*+0x{int(value, 16):x}\"\n            if symbol_filter not in name:\n                continue\n            outputs.append(\n                {\n                    \"name\": name or \"????\",\n                    \"address\": address,\n                }\n            )\n    # By sorting the outputs by address, we can get a more intuitive output\n    outputs.sort(key=lambda x: x[\"address\"])\n    relro_color = message.off\n    if \"Partial\" in relro_status:\n        relro_color = message.warn\n    elif \"Full\" in relro_status:\n        relro_color = message.on\n    print(f\"State of the GOT of {message.notice(path)}:\")\n    print(\n        f\"GOT protection: {relro_color(relro_status)} | Found {message.hint(len(outputs))} GOT entries passing the filter\"\n    )\n    for output in outputs:\n        print(\n            f\"[{M.get(output['address'])}] {message.hint(output['name'])} -> {pwndbg.chain.format(pwndbg.gdblib.memory.pvoid(output['address']))}\"  # type: ignore[arg-type]\n        )\n", "path": "pwndbg/commands/got.py"}]}