-
Notifications
You must be signed in to change notification settings - Fork 126
Open
Labels
Description
Description
stripping an object file drops relocation details in .rela.eh_frame but retains .eh_frame, leaving FDEs unrelocated by pyelftools. Bogus FunctionHints 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 FunctionHints.
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
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:
[<FuncHint@0x400000, 33 bytes>]
function_hints for test_ite_stripped.o:
[<FuncHint@0x400020, 33 bytes>]
Environment
cle @ d817738
pyelftools @ 0.32
Additional context
No response