angr / angr/cle

Loading stripped object files with `load_debug_info=True` may produce bogus `FunctionHint`s

Open
#597 1 comment 0 reactions 0 assignees View on GitHub
bug
Dominant language
Python
Stars
485
Forks
135
Avg merge
2d 2h
Merged PRs (30d)
15

Description

### Description

`strip`ping an object file drops relocation details in `.rela.eh_frame` but retains `.eh_frame`, leaving FDEs unrelocated by pyelftools. Bogus `FunctionHint`s created from unrelocated FDEs may have incorrect offsets, but will be relocated with the object section and appear typical.

Having stripped object files is unusual, nevertheless the backend should probably avoid producing bogus `FunctionHint`s.

### Steps to reproduce the bug

```
$ python pyelftools/scripts/readelf.py --debug-dump frames ./test_ite.o
Contents of the .eh_frame section:

00000000 0000000000000014 00000000 CIE
Version: 1
Augmentation: "zR"
Code alignment factor: 1
Data alignment factor: -8
Return address column: 16
Augmentation data: 1b

DW_CFA_def_cfa: r7 (rsp) ofs 8
DW_CFA_offset: r16 (rip) at cfa-8
DW_CFA_nop
DW_CFA_nop

00000018 0000000000000014 0000001c FDE cie=00000000 pc=0000000000000000..0000000000000021
DW_CFA_nop
DW_CFA_nop
DW_CFA_nop
DW_CFA_nop
DW_CFA_nop
DW_CFA_nop
DW_CFA_nop

$ python pyelftools/scripts/readelf.py --debug-dump frames ./test_ite_stripped.o
Contents of the .eh_frame section:

00000000 0000000000000014 00000000 CIE
Version: 1
Augmentation: "zR"
Code alignment factor: 1
Data alignment factor: -8
Return address column: 16
Augmentation data: 1b

DW_CFA_def_cfa: r7 (rsp) ofs 8
DW_CFA_offset: r16 (rip) at cfa-8
DW_CFA_nop
DW_CFA_nop

00000018 0000000000000014 0000001c FDE cie=00000000 pc=0000000000000020..0000000000000041
DW_CFA_nop
DW_CFA_nop
DW_CFA_nop
DW_CFA_nop
DW_CFA_nop
DW_CFA_nop
DW_CFA_nop
```

```py
import cle

def print_hints(bin_path):
ld = cle.Loader(bin_path, load_debug_info=True)
print(f"function_hints for {bin_path}:")
print(ld.main_object.function_hints)

print_hints("test_ite.o")
print_hints("test_ite_stripped.o")
```
```
$ python bogus_hints.py
function_hints for test_ite.o:
[]
function_hints for test_ite_stripped.o:
[]
```
[test_ite.zip](https://github.com/user-attachments/files/21692859/test_ite.zip)

### Environment

cle @ d817738a4ad79ee9397d55383a57219fdeb03885
pyelftools @ 0.32

### Additional context

_No response_

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.