llvm.org GIT mirror llvm / 28aa6e3
[RuntimeDyld] Fix debug section relocation (pr20457) Summary: Debug info sections, (or non-SHF_ALLOC sections in general) should be linked as if their load address was zero to emulate the behavior of the static linker. This bug was discovered because it was breaking lldb expression evaluation on linux. Reviewers: lhames Subscribers: aprantl, eugene, clayborg, lldb-commits, llvm-commits Differential Revision: https://reviews.llvm.org/D32899 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@303239 91177308-0d34-0410-b5e6-96231b3b80d8 Pavel Labath 2 years ago
2 changed file(s) with 27 addition(s) and 3 deletion(s). Raw diff Collapse all Expand all
704704 unsigned Alignment = (unsigned)Alignment64 & 0xffffffffL;
705705 unsigned PaddingSize = 0;
706706 unsigned StubBufSize = 0;
707 bool IsRequired = isRequiredForExecution(Section) || ProcessAllSections;
707 bool IsRequired = isRequiredForExecution(Section);
708708 bool IsVirtual = Section.isVirtual();
709709 bool IsZeroInit = isZeroInit(Section);
710710 bool IsReadOnly = isReadOnlyData(Section);
744744 Alignment = std::max(Alignment, getStubAlignment());
745745
746746 // Some sections, such as debug info, don't need to be loaded for execution.
747 // Leave those where they are.
748 if (IsRequired) {
747 // Process those only if explicitly requested.
748 if (IsRequired || ProcessAllSections) {
749749 Allocate = DataSize + PaddingSize + StubBufSize;
750750 if (!Allocate)
751751 Allocate = 1;
788788
789789 Sections.push_back(
790790 SectionEntry(Name, Addr, DataSize, Allocate, (uintptr_t)pData));
791
792 // Debug info sections are linked as if their load address was zero
793 if (!IsRequired)
794 Sections.back().setLoadAddress(0);
791795
792796 if (Checker)
793797 Checker->registerSection(Obj.getFileName(), SectionID);
0 # RUN: llvm-mc -triple=x86_64-pc-linux -filetype=obj -o %T/ELF_x86-64_debug_frame.o %s
1 # RUN: llvm-rtdyld -triple=x86_64-pc-linux -verify -check=%s %T/ELF_x86-64_debug_frame.o
2
3 .text
4 .file "debug_frame_test.c"
5 .align 16, 0x90
6 .type foo,@function
7 foo:
8 .cfi_startproc
9 retq
10 .Ltmp0:
11 .size foo, .Ltmp0-foo
12 .cfi_endproc
13 .cfi_sections .debug_frame
14
15 # Check that .debug_frame is mapped to 0.
16 # rtdyld-check: section_addr(ELF_x86-64_debug_frame.o, .debug_frame) = 0
17
18 # Check that The relocated FDE's CIE offset also points to zero.
19 # rtdyld-check: *{4}(section_addr(ELF_x86-64_debug_frame.o, .debug_frame) + 0x1C) = 0