angr / angr/cle

Loading DWARF fails

Ouverte
#454 0 commentaires 0 réactions 0 personnes assignées Voir sur GitHub
bug needs-triage
Langage dominant
Python
Étoiles
485
Forks
135
Merge moyen
2 j 2 h
PR mergées (30 j)
15

Description

### Description

I can't load debug info from a binary.
`file: CWE121_Stack_Based_Buffer_Overflow__CWE193_char_alloca_cpy_72a.o: ELF 64-bit LSB relocatable, x86-64, version 1 (SYSV), with debug_info, not stripped`
I get the following stack trace:
```
Python 3.11.6 (main, Oct 8 2023, 05:06:43) [GCC 13.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import cle
>>> cle.Loader("/home/julius/Documents/ML/C/testcases/CWE121_Stack_Based_Buffer_Overflow/s01/CWE121_Stack_Based_Buffer_Overflow__CWE193_char_alloca_cpy_72a.o", load_debug_info=True)
Traceback (most recent call last):
File "", line 1, in
File "/home/julius/Documents/ML/venv/lib/python3.11/site-packages/cle/loader.py", line 188, in __init__
self.initial_load_objects = self._internal_load(
^^^^^^^^^^^^^^^^^^^^
File "/home/julius/Documents/ML/venv/lib/python3.11/site-packages/cle/loader.py", line 782, in _internal_load
obj = self._load_object_isolated(main_spec)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/julius/Documents/ML/venv/lib/python3.11/site-packages/cle/loader.py", line 985, in _load_object_isolated
result = backend_cls(binary, binary_stream, is_main_bin=self._main_object is None, loader=self, **options)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/julius/Documents/ML/venv/lib/python3.11/site-packages/cle/backends/elf/elf.py", line 208, in __init__
self._load_exception_handling(dwarf)
File "/home/julius/Documents/ML/venv/lib/python3.11/site-packages/cle/backends/elf/elf.py", line 620, in _load_exception_handling
lsda_exception_table = lsda.parse_lsda(entry.lsda_pointer, file_offset)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/julius/Documents/ML/venv/lib/python3.11/site-packages/cle/backends/elf/lsda.py", line 89, in parse_lsda
header = self._parse_lsda_header()
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/julius/Documents/ML/venv/lib/python3.11/site-packages/cle/backends/elf/lsda.py", line 107, in _parse_lsda_header
lpstart = struct_parse(Struct("dummy", self._formats[base_encoding]("LPStart")), self.stream)["LPStart"]
~~~~~~~~~~~~~^^^^^^^^^^^^^^^
KeyError: 5
>>> cle.__version__
'9.2.84'
>>>
```
Loader works fine if i set load_debug_info=False.

### Steps to reproduce the bug

import the attached binary with load_debug_info=True

```
import cle
cle.Loader("CWE121_Stack_Based_Buffer_Overflow__CWE193_char_alloca_cpy_72a.o", load_debug_info=True)
```

### Environment

Python 3.11.6 (main, Oct 8 2023, 05:06:43) [GCC 13.2.0] on linux

### Additional context

[CWE121_Stack_Based_Buffer_Overflow__CWE193_char_alloca_cpy_72a.zip](https://github.com/angr/cle/files/13940370/CWE121_Stack_Based_Buffer_Overflow__CWE193_char_alloca_cpy_72a.zip)

Guide de contribution

Aucun guide de contribution indexé pour ce dépôt

Évaluation

Cette issue n'a pas encore été évaluée.

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.