diff options
author | Timur Iskhodzhanov <timurrrr@google.com> | 2014-10-08 18:01:49 +0000 |
---|---|---|
committer | Timur Iskhodzhanov <timurrrr@google.com> | 2014-10-08 18:01:49 +0000 |
commit | 5fcaeebb7234a27dba4bd3a8795a7afa089a3d50 (patch) | |
tree | e5949f7e53c23d58a8a12329bdef8729aee3905c | |
parent | 0bc6d5f97dbbd7f3283e21dbe3b12f64a60922a8 (diff) | |
download | llvm-5fcaeebb7234a27dba4bd3a8795a7afa089a3d50.zip llvm-5fcaeebb7234a27dba4bd3a8795a7afa089a3d50.tar.gz llvm-5fcaeebb7234a27dba4bd3a8795a7afa089a3d50.tar.bz2 |
Fix COFF section index relocation should be 16 bits, not 32
Original patch by Andrey Guskov!
http://reviews.llvm.org/D5651
llvm-svn: 219327
-rw-r--r-- | llvm/lib/CodeGen/AsmPrinter/WinCodeViewLineTables.cpp | 2 | ||||
-rw-r--r-- | llvm/lib/MC/WinCOFFStreamer.cpp | 2 | ||||
-rw-r--r-- | llvm/test/DebugInfo/COFF/asm.ll | 2 | ||||
-rw-r--r-- | llvm/test/DebugInfo/COFF/multifile.ll | 2 | ||||
-rw-r--r-- | llvm/test/DebugInfo/COFF/multifunction.ll | 6 | ||||
-rw-r--r-- | llvm/test/DebugInfo/COFF/simple.ll | 2 | ||||
-rw-r--r-- | llvm/test/MC/COFF/secidx.s | 2 |
7 files changed, 17 insertions, 1 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter/WinCodeViewLineTables.cpp b/llvm/lib/CodeGen/AsmPrinter/WinCodeViewLineTables.cpp index 6a5c431..b3fa2d5 100644 --- a/llvm/lib/CodeGen/AsmPrinter/WinCodeViewLineTables.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/WinCodeViewLineTables.cpp @@ -166,6 +166,8 @@ void WinCodeViewLineTables::emitDebugInfoForFunction(const Function *GV) { // Identify the function this subsection is for. Asm->OutStreamer.EmitCOFFSecRel32(Fn); Asm->OutStreamer.EmitCOFFSectionIndex(Fn); + // Insert padding after a 16-bit section index. + Asm->EmitInt16(0); // Length of the function's code, in bytes. EmitLabelDiff(Asm->OutStreamer, Fn, FI.End); diff --git a/llvm/lib/MC/WinCOFFStreamer.cpp b/llvm/lib/MC/WinCOFFStreamer.cpp index b8d5f2a..078091c 100644 --- a/llvm/lib/MC/WinCOFFStreamer.cpp +++ b/llvm/lib/MC/WinCOFFStreamer.cpp @@ -163,7 +163,7 @@ void MCWinCOFFStreamer::EmitCOFFSectionIndex(MCSymbol const *Symbol) { const MCSymbolRefExpr *SRE = MCSymbolRefExpr::Create(Symbol, getContext()); MCFixup Fixup = MCFixup::Create(DF->getContents().size(), SRE, FK_SecRel_2); DF->getFixups().push_back(Fixup); - DF->getContents().resize(DF->getContents().size() + 4, 0); + DF->getContents().resize(DF->getContents().size() + 2, 0); } void MCWinCOFFStreamer::EmitCOFFSecRel32(MCSymbol const *Symbol) { diff --git a/llvm/test/DebugInfo/COFF/asm.ll b/llvm/test/DebugInfo/COFF/asm.ll index da58583..45fb87c 100644 --- a/llvm/test/DebugInfo/COFF/asm.ll +++ b/llvm/test/DebugInfo/COFF/asm.ll @@ -28,6 +28,7 @@ ; X86-NEXT: [[F2_START]]: ; X86-NEXT: .secrel32 _f ; X86-NEXT: .secidx _f +; X86-NEXT: .short 0 ; X86-NEXT: .long [[END_OF_F]]-_f ; X86-NEXT: [[FILE_SEGMENT_START:[^:]*]]: ; X86-NEXT: .long 0 @@ -97,6 +98,7 @@ ; X64-NEXT: [[F2_START]]: ; X64-NEXT: .secrel32 f ; X64-NEXT: .secidx f +; X64-NEXT: .short 0 ; X64-NEXT: .long [[END_OF_F]]-f ; X64-NEXT: [[FILE_SEGMENT_START:[^:]*]]: ; X64-NEXT: .long 0 diff --git a/llvm/test/DebugInfo/COFF/multifile.ll b/llvm/test/DebugInfo/COFF/multifile.ll index 018a0c8..2a654d7c 100644 --- a/llvm/test/DebugInfo/COFF/multifile.ll +++ b/llvm/test/DebugInfo/COFF/multifile.ll @@ -35,6 +35,7 @@ ; X86-NEXT: [[F2_START]]: ; X86-NEXT: .secrel32 _f ; X86-NEXT: .secidx _f +; X86-NEXT: .short 0 ; X86-NEXT: .long [[END_OF_F]]-_f ; Segment for file 'D:\\one.c' begins ; X86-NEXT: [[FILE_SEGMENT_START:[^:]*]]: @@ -129,6 +130,7 @@ ; X64-NEXT: [[F2_START]]: ; X64-NEXT: .secrel32 f ; X64-NEXT: .secidx f +; X64-NEXT: .short 0 ; X64-NEXT: .long [[END_OF_F]]-f ; Segment for file 'D:\\input.c' begins ; X64-NEXT: [[FILE_SEGMENT_START:[^:]*]]: diff --git a/llvm/test/DebugInfo/COFF/multifunction.ll b/llvm/test/DebugInfo/COFF/multifunction.ll index be0bb69..365281a 100644 --- a/llvm/test/DebugInfo/COFF/multifunction.ll +++ b/llvm/test/DebugInfo/COFF/multifunction.ll @@ -58,6 +58,7 @@ ; X86-NEXT: [[F2_START]]: ; X86-NEXT: .secrel32 _x ; X86-NEXT: .secidx _x +; X86-NEXT: .short 0 ; X86-NEXT: .long [[END_OF_X]]-_x ; X86-NEXT: [[FILE_SEGMENT_START:[^:]*]]: ; X86-NEXT: .long 0 @@ -75,6 +76,7 @@ ; X86-NEXT: [[F2_START]]: ; X86-NEXT: .secrel32 _y ; X86-NEXT: .secidx _y +; X86-NEXT: .short 0 ; X86-NEXT: .long [[END_OF_Y]]-_y ; X86-NEXT: [[FILE_SEGMENT_START:[^:]*]]: ; X86-NEXT: .long 0 @@ -92,6 +94,7 @@ ; X86-NEXT: [[F2_START]]: ; X86-NEXT: .secrel32 _f ; X86-NEXT: .secidx _f +; X86-NEXT: .short 0 ; X86-NEXT: .long [[END_OF_F]]-_f ; X86-NEXT: [[FILE_SEGMENT_START:[^:]*]]: ; X86-NEXT: .long 0 @@ -208,6 +211,7 @@ ; X64-NEXT: [[F2_START]]: ; X64-NEXT: .secrel32 x ; X64-NEXT: .secidx x +; X64-NEXT: .short 0 ; X64-NEXT: .long [[END_OF_X]]-x ; X64-NEXT: [[FILE_SEGMENT_START:[^:]*]]: ; X64-NEXT: .long 0 @@ -227,6 +231,7 @@ ; X64-NEXT: [[F2_START]]: ; X64-NEXT: .secrel32 y ; X64-NEXT: .secidx y +; X64-NEXT: .short 0 ; X64-NEXT: .long [[END_OF_Y]]-y ; X64-NEXT: [[FILE_SEGMENT_START:[^:]*]]: ; X64-NEXT: .long 0 @@ -246,6 +251,7 @@ ; X64-NEXT: [[F2_START]]: ; X64-NEXT: .secrel32 f ; X64-NEXT: .secidx f +; X64-NEXT: .short 0 ; X64-NEXT: .long [[END_OF_F]]-f ; X64-NEXT: [[FILE_SEGMENT_START:[^:]*]]: ; X64-NEXT: .long 0 diff --git a/llvm/test/DebugInfo/COFF/simple.ll b/llvm/test/DebugInfo/COFF/simple.ll index bb1c6ab..d233124 100644 --- a/llvm/test/DebugInfo/COFF/simple.ll +++ b/llvm/test/DebugInfo/COFF/simple.ll @@ -26,6 +26,7 @@ ; X86-NEXT: [[F2_START]]: ; X86-NEXT: .secrel32 _f ; X86-NEXT: .secidx _f +; X86-NEXT: .short 0 ; X86-NEXT: .long [[END_OF_F]]-_f ; X86-NEXT: [[FILE_SEGMENT_START:[^:]*]]: ; X86-NEXT: .long 0 @@ -88,6 +89,7 @@ ; X64-NEXT: [[F2_START]]: ; X64-NEXT: .secrel32 f ; X64-NEXT: .secidx f +; X64-NEXT: .short 0 ; X64-NEXT: .long [[END_OF_F]]-f ; X64-NEXT: [[FILE_SEGMENT_START:[^:]*]]: ; X64-NEXT: .long 0 diff --git a/llvm/test/MC/COFF/secidx.s b/llvm/test/MC/COFF/secidx.s index 619d777..022804d 100644 --- a/llvm/test/MC/COFF/secidx.s +++ b/llvm/test/MC/COFF/secidx.s @@ -4,7 +4,9 @@ Lfoo: .secidx Lfoo + .short 0 .secidx Lbar + .short 0 .section spam Lbar: |