Skip to content

Commit 49cbf4c

Browse files
committed
1 parent 6adebe3 commit 49cbf4c

5 files changed

Lines changed: 22 additions & 13 deletions

File tree

‎lld/test/ELF/eh-frame-hdr-augmentation.s‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// CHECK-NEXT: Code alignment factor: 1
1313
// CHECK-NEXT: Data alignment factor: -8
1414
// CHECK-NEXT: Return address column: 16
15-
// CHECK-NEXT: Personality Address: 0000000000001029
15+
// CHECK-NEXT: Personality Address: 000000000000127c
1616
// CHECK-NEXT: Augmentation data:
1717

1818
// CHECK: DW_CFA_def_cfa: reg7 +8
@@ -21,9 +21,9 @@
2121
// CHECK-NEXT: DW_CFA_nop:
2222

2323
/// FIXME Handle relocation correctly
24-
// CHECK: 00000020 00000014 00000024 FDE cie=00000000 pc=0000103c...0000103c
24+
// CHECK: 00000020 00000014 00000024 FDE cie=00000000 pc=0000127c...0000127c
2525
// CHECK-NEXT: Format: DWARF32
26-
// CHECK-NEXT: LSDA Address: 000000000000100b
26+
// CHECK-NEXT: LSDA Address: 000000000000127c
2727
// CHECK-NEXT: DW_CFA_nop:
2828
// CHECK-NEXT: DW_CFA_nop:
2929
// CHECK-NEXT: DW_CFA_nop:

‎llvm/include/llvm/DebugInfo/DWARF/DWARFSection.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ namespace llvm {
1515

1616
struct DWARFSection {
1717
StringRef Data;
18+
uint64_t Address = 0;
1819
};
1920

2021
struct SectionName {

‎llvm/lib/DebugInfo/DWARF/DWARFContext.cpp‎

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -823,6 +823,8 @@ Expected<const DWARFDebugFrame *> DWARFContext::getDebugFrame() {
823823
if (DebugFrame)
824824
return DebugFrame.get();
825825

826+
const DWARFSection &DS = DObj->getFrameSection();
827+
826828
// There's a "bug" in the DWARFv3 standard with respect to the target address
827829
// size within debug frame sections. While DWARF is supposed to be independent
828830
// of its container, FDEs have fields with size being "target address size",
@@ -832,10 +834,11 @@ Expected<const DWARFDebugFrame *> DWARFContext::getDebugFrame() {
832834
// provides this information). This problem is fixed in DWARFv4
833835
// See this dwarf-discuss discussion for more details:
834836
// http://lists.dwarfstd.org/htdig.cgi/dwarf-discuss-dwarfstd.org/2011-December/001173.html
835-
DWARFDataExtractor debugFrameData(*DObj, DObj->getFrameSection(),
836-
isLittleEndian(), DObj->getAddressSize());
837-
auto DF = std::make_unique<DWARFDebugFrame>(getArch(), /*IsEH=*/false);
838-
if (Error E = DF->parse(debugFrameData))
837+
DWARFDataExtractor DebugFrameData(*DObj, DS, isLittleEndian(),
838+
DObj->getAddressSize());
839+
auto DF =
840+
std::make_unique<DWARFDebugFrame>(getArch(), /*IsEH=*/false, DS.Address);
841+
if (Error E = DF->parse(DebugFrameData))
839842
return std::move(E);
840843

841844
DebugFrame.swap(DF);
@@ -846,11 +849,13 @@ Expected<const DWARFDebugFrame *> DWARFContext::getEHFrame() {
846849
if (EHFrame)
847850
return EHFrame.get();
848851

849-
DWARFDataExtractor debugFrameData(*DObj, DObj->getEHFrameSection(),
850-
isLittleEndian(), DObj->getAddressSize());
852+
const DWARFSection &DS = DObj->getEHFrameSection();
853+
DWARFDataExtractor DebugFrameData(*DObj, DS, isLittleEndian(),
854+
DObj->getAddressSize());
851855

852-
auto DF = std::make_unique<DWARFDebugFrame>(getArch(), /*IsEH=*/true);
853-
if (Error E = DF->parse(debugFrameData))
856+
auto DF =
857+
std::make_unique<DWARFDebugFrame>(getArch(), /*IsEH=*/true, DS.Address);
858+
if (Error E = DF->parse(DebugFrameData))
854859
return std::move(E);
855860
DebugFrame.swap(DF);
856861
return DebugFrame.get();
@@ -1707,6 +1712,9 @@ class DWARFObjInMemory final : public DWARFObject {
17071712
if (Name == "debug_ranges") {
17081713
// FIXME: Use the other dwo range section when we emit it.
17091714
RangesDWOSection.Data = Data;
1715+
} else if (Name == "debug_frame" || Name == "eh_frame") {
1716+
if (DWARFSection *S = mapNameToDWARFSection(Name))
1717+
S->Address = Section.getAddress();
17101718
}
17111719
} else if (InfoSectionMap *Sections =
17121720
StringSwitch<InfoSectionMap *>(Name)

‎llvm/test/tools/llvm-dwarfdump/X86/debug_frame_offset.test‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ CHECK-NOT: pc
99
RUN: llvm-dwarfdump %p/../../dsymutil/Inputs/basic1.macho.x86_64.o \
1010
RUN: -eh-frame=0x00000018 | FileCheck %s --check-prefix=EH
1111
EH: .eh_frame contents:
12-
EH-NEXT: 00000018 00000024 0000001c FDE cie=00000000 pc=fffffffffffffd20...fffffffffffffd44
12+
EH-NEXT: 00000018 00000024 0000001c FDE cie=00000000 pc=00000000...00000024
1313
EH-NEXT: Format: DWARF32
1414
EH-NEXT: DW_CFA_advance_loc: 1
1515
EH-NOT: pc

‎llvm/test/tools/llvm-objdump/MachO/eh_frame-arm64.test‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
# CHECK: DW_CFA_def_cfa: reg31 +0
1414

15-
# CHECK: 00000014 00000020 00000018 FDE cie=00000000 pc=00000000...00000020
15+
# CHECK: 00000014 00000020 00000018 FDE cie=00000000 pc=00000050...00000070
1616
# CHECK: DW_CFA_advance_loc: 8
1717
# CHECK: DW_CFA_def_cfa_offset: +16
1818
# CHECK: DW_CFA_offset: reg30 -8

0 commit comments

Comments
 (0)