aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Storsjö <martin@martin.st>2019-11-23 00:46:24 +0200
committerMartin Storsjö <martin@martin.st>2019-11-27 10:44:42 +0200
commit47046f05e66c23567d6672ea5a1afd8ed2c411ed (patch)
tree71c24f162960b1305583933b6b54247e11961c32
parent943513b79929fba1a9dccdf81cb68a41ce29cd03 (diff)
downloadllvm-47046f05e66c23567d6672ea5a1afd8ed2c411ed.zip
llvm-47046f05e66c23567d6672ea5a1afd8ed2c411ed.tar.gz
llvm-47046f05e66c23567d6672ea5a1afd8ed2c411ed.tar.bz2
[MC] Produce proper section relative relocations for COFF in .debug_frame
The third parameter to Streamer.EmitSymbolValue() is "bool IsSectionRelative = false". For ELF, these debug sections are mapped to address zero, so a normal, absolute address relocation works just fine, but COFF needs a section relative relocation, and COFF is the only target where needsDwarfSectionOffsetDirective() returns true. This matches how EmitSymbolValue is called elsewhere in the same source file. Differential Revision: https://reviews.llvm.org/D70661
-rw-r--r--llvm/lib/MC/MCDwarf.cpp3
-rw-r--r--llvm/test/MC/COFF/cfi-sections.s26
2 files changed, 28 insertions, 1 deletions
diff --git a/llvm/lib/MC/MCDwarf.cpp b/llvm/lib/MC/MCDwarf.cpp
index bcc7c45..b4b3c99 100644
--- a/llvm/lib/MC/MCDwarf.cpp
+++ b/llvm/lib/MC/MCDwarf.cpp
@@ -1701,7 +1701,8 @@ void FrameEmitterImpl::EmitFDE(const MCSymbol &cieStart,
MakeStartMinusEndExpr(Streamer, SectionStart, cieStart, 0);
emitAbsValue(Streamer, offset, 4);
} else {
- Streamer.EmitSymbolValue(&cieStart, 4);
+ Streamer.EmitSymbolValue(&cieStart, 4,
+ asmInfo->needsDwarfSectionOffsetDirective());
}
// PC Begin
diff --git a/llvm/test/MC/COFF/cfi-sections.s b/llvm/test/MC/COFF/cfi-sections.s
new file mode 100644
index 0000000..00a8d74
--- /dev/null
+++ b/llvm/test/MC/COFF/cfi-sections.s
@@ -0,0 +1,26 @@
+// RUN: llvm-mc -filetype=obj -triple x86_64-mingw32 %s -o - | llvm-objdump -r - | FileCheck --check-prefix=COFF_X86_64 %s
+// RUN: llvm-mc -filetype=obj -triple i686-mingw32 %s -o - | llvm-objdump -r - | FileCheck --check-prefix=COFF_I686 %s
+
+.cfi_sections .debug_frame
+
+f1:
+ .cfi_startproc
+ nop
+ .cfi_endproc
+
+f2:
+ .cfi_startproc
+ nop
+ .cfi_endproc
+
+// COFF_X86_64: RELOCATION RECORDS FOR [.debug_frame]:
+// COFF_X86_64-NEXT: {{.*}} IMAGE_REL_AMD64_SECREL .debug_frame
+// COFF_X86_64-NEXT: {{.*}} IMAGE_REL_AMD64_ADDR64 .text
+// COFF_X86_64-NEXT: {{.*}} IMAGE_REL_AMD64_SECREL .debug_frame
+// COFF_X86_64-NEXT: {{.*}} IMAGE_REL_AMD64_ADDR64 .text
+
+// COFF_I686: RELOCATION RECORDS FOR [.debug_frame]:
+// COFF_I686-NEXT: {{.*}} IMAGE_REL_I386_SECREL .debug_frame
+// COFF_I686-NEXT: {{.*}} IMAGE_REL_I386_DIR32 .text
+// COFF_I686-NEXT: {{.*}} IMAGE_REL_I386_SECREL .debug_frame
+// COFF_I686-NEXT: {{.*}} IMAGE_REL_I386_DIR32 .text