Page MenuHomePhabricator

Fix bug in .eh_frame/.debug_frame PC offset calculation for DW_EH_PE_pcrel
ClosedPublic

Authored by aorlov on Apr 12 2021, 10:34 AM.

Details

Summary

To calculate a correct PC offset we need to apply the target address from the eh_frame.

This fixes the following bugs:
https://bugs.llvm.org/show_bug.cgi?id=27249
https://bugs.llvm.org/show_bug.cgi?id=46414

Diff Detail

Unit TestsFailed

TimeTest
130 msx64 debian > Clang.CodeGen::thinlto-distributed-newpm.ll
Script: -- : 'RUN: at line 6'; /mnt/disks/ssd0/agent/llvm-project/build/bin/opt -thinlto-bc -o /mnt/disks/ssd0/agent/llvm-project/build/tools/clang/test/CodeGen/Output/thinlto-distributed-newpm.ll.tmp.o /mnt/disks/ssd0/agent/llvm-project/clang/test/CodeGen/thinlto-distributed-newpm.ll
150 msx64 debian > lld.ELF::eh-frame-hdr-augmentation.s
Script: -- : 'RUN: at line 2'; /mnt/disks/ssd0/agent/llvm-project/build/bin/llvm-mc -filetype=obj -triple=x86_64-pc-linux /mnt/disks/ssd0/agent/llvm-project/lld/test/ELF/eh-frame-hdr-augmentation.s -o /mnt/disks/ssd0/agent/llvm-project/build/tools/lld/test/ELF/Output/eh-frame-hdr-augmentation.s.tmp.o
330 msx64 windows > Clang.CodeGen::thinlto-distributed-newpm.ll
Script: -- : 'RUN: at line 6'; c:\ws\w16n2-1\llvm-project\premerge-checks\build\bin\opt.exe -thinlto-bc -o C:\ws\w16n2-1\llvm-project\premerge-checks\build\tools\clang\test\CodeGen\Output\thinlto-distributed-newpm.ll.tmp.o C:\ws\w16n2-1\llvm-project\premerge-checks\clang\test\CodeGen\thinlto-distributed-newpm.ll
140 msx64 windows > lld.ELF::eh-frame-hdr-augmentation.s
Script: -- : 'RUN: at line 2'; c:\ws\w16n2-1\llvm-project\premerge-checks\build\bin\llvm-mc.exe -filetype=obj -triple=x86_64-pc-linux C:\ws\w16n2-1\llvm-project\premerge-checks\lld\test\ELF\eh-frame-hdr-augmentation.s -o C:\ws\w16n2-1\llvm-project\premerge-checks\build\tools\lld\test\ELF\Output\eh-frame-hdr-augmentation.s.tmp.o

Event Timeline

aorlov created this revision.Apr 12 2021, 10:34 AM
aorlov requested review of this revision.Apr 12 2021, 10:34 AM
aorlov updated this revision to Diff 336972.Apr 12 2021, 3:05 PM
MaskRay accepted this revision.Apr 14 2021, 4:37 PM

LG. The stored address is used as EHFrameAddress in llvm/lib/DebugInfo/DWARF/DWARFDebugFrame.cpp

1134           // Decode the LSDA if the CIE augmentation string said we should.                                                                                                                                                       
1135           if (Cie->getLSDAPointerEncoding() != DW_EH_PE_omit) {
1136             LSDAAddress = Data.getEncodedPointer(                                                                                                                                                                                 
1137                 &Offset, Cie->getLSDAPointerEncoding(),
1138                 EHFrameAddress ? Offset + EHFrameAddress : 0);
1139           }
llvm/include/llvm/DebugInfo/DWARF/DWARFSection.h
18

= 0

This revision is now accepted and ready to land.Apr 14 2021, 4:37 PM
MaskRay retitled this revision from Fixed bug in eh_frame PC offset calculation for DW_EH_PE_pcrel to Fixed bug in .eh_frame/.debug_frame PC offset calculation for DW_EH_PE_pcrel.Apr 14 2021, 4:40 PM
MaskRay retitled this revision from Fixed bug in .eh_frame/.debug_frame PC offset calculation for DW_EH_PE_pcrel to Fix bug in .eh_frame/.debug_frame PC offset calculation for DW_EH_PE_pcrel.