[llvm-commits] [llvm] r115656 - in /llvm/trunk: lib/MC/WinCOFFObjectWriter.cpp test/MC/COFF/symbol-fragment-offset.ll
Michael J. Spencer
bigcheesegs at gmail.com
Tue Oct 5 12:48:03 PDT 2010
Author: mspencer
Date: Tue Oct 5 14:48:03 2010
New Revision: 115656
URL: http://llvm.org/viewvc/llvm-project?rev=115656&view=rev
Log:
MC-COFF: Fix (PR8278) temporary symbol relocations.
Modified:
llvm/trunk/lib/MC/WinCOFFObjectWriter.cpp
llvm/trunk/test/MC/COFF/symbol-fragment-offset.ll
Modified: llvm/trunk/lib/MC/WinCOFFObjectWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/WinCOFFObjectWriter.cpp?rev=115656&r1=115655&r2=115656&view=diff
==============================================================================
--- llvm/trunk/lib/MC/WinCOFFObjectWriter.cpp (original)
+++ llvm/trunk/lib/MC/WinCOFFObjectWriter.cpp Tue Oct 5 14:48:03 2010
@@ -660,7 +660,8 @@
// turn relocations for temporary symbols into section relocations
if (coff_symbol->MCData->getSymbol().isTemporary()) {
Reloc.Symb = coff_symbol->Section->Symbol;
- FixedValue += Layout.getFragmentOffset(coff_symbol->MCData->Fragment);
+ FixedValue += Layout.getFragmentOffset(coff_symbol->MCData->Fragment)
+ + coff_symbol->MCData->getOffset();
} else
Reloc.Symb = coff_symbol;
Modified: llvm/trunk/test/MC/COFF/symbol-fragment-offset.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/COFF/symbol-fragment-offset.ll?rev=115656&r1=115655&r2=115656&view=diff
==============================================================================
--- llvm/trunk/test/MC/COFF/symbol-fragment-offset.ll (original)
+++ llvm/trunk/test/MC/COFF/symbol-fragment-offset.ll Tue Oct 5 14:48:03 2010
@@ -4,13 +4,15 @@
; RUN: llc -filetype=obj -mtriple i686-pc-win32 %s -o - | coff-dump.py | FileCheck %s
; RUN: llc -filetype=obj -mtriple x86_64-pc-win32 %s -o %t
- at .str = private constant [7 x i8] c"Hello \00" ; <[7 x i8]*> [#uses=1]
- at str = internal constant [7 x i8] c"World!\00" ; <[7 x i8]*> [#uses=1]
+ at .str0 = private constant [7 x i8] c"Hello \00" ; <[7 x i8]*> [#uses=1]
+ at .str1 = private constant [7 x i8] c"World!\00" ; <[7 x i8]*> [#uses=1]
+ at .str2 = private constant [19 x i8] c"I'm The Last Line.\00"
define i32 @main() nounwind {
entry:
- %call = tail call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([7 x i8]* @.str, i32 0, i32 0)) nounwind ; <i32> [#uses=0]
- %puts = tail call i32 @puts(i8* getelementptr inbounds ([7 x i8]* @str, i32 0, i32 0)) ; <i32> [#uses=0]
+ %call = tail call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([7 x i8]* @.str0, i32 0, i32 0)) nounwind ; <i32> [#uses=0]
+ %puts0 = tail call i32 @puts(i8* getelementptr inbounds ([7 x i8]* @.str1, i32 0, i32 0)) ; <i32> [#uses=0]
+ %puts1 = tail call i32 @puts(i8* getelementptr inbounds ([19 x i8]* @.str2, i32 0, i32 0)) ; <i32> [#uses=0]
ret i32 0
}
@@ -23,7 +25,7 @@
; CHECK: NumberOfSections = 2
; CHECK: TimeDateStamp = {{[0-9]+}}
; CHECK: PointerToSymbolTable = 0x{{[0-9A-F]+}}
-; CHECK: NumberOfSymbols = 8
+; CHECK: NumberOfSymbols = 7
; CHECK: SizeOfOptionalHeader = 0
; CHECK: Characteristics = 0x0
; CHECK: Sections = [
@@ -35,7 +37,7 @@
; CHECK: PointerToRawData = 0x{{[0-9A-F]+}}
; CHECK: PointerToRelocations = 0x{{[0-9A-F]+}}
; CHECK: PointerToLineNumbers = 0x0
-; CHECK: NumberOfRelocations = 4
+; CHECK: NumberOfRelocations = 6
; CHECK: NumberOfLineNumbers = 0
; CHECK: Charateristics = 0x60500020
; CHECK: IMAGE_SCN_CNT_CODE
@@ -43,28 +45,43 @@
; CHECK: IMAGE_SCN_MEM_EXECUTE
; CHECK: IMAGE_SCN_MEM_READ
; CHECK: SectionData =
+; CHECK: 83 EC 04 C7 04 24 00 00 - 00 00 E8 00 00 00 00 C7 |.....$..........|
+; CHECK: 04 24 07 00 00 00 E8 00 - 00 00 00 C7 04 24 10 00 |.$...........$..|
+; CHECK: 00 00 E8 00 00 00 00 31 - C0 83 C4 04 C3 00 00 00 |.......1........|
; CHECK: Relocations = [
; CHECK: 0 = {
-; CHECK: VirtualAddress = 0x{{[0-9A-F]+}}
+; CHECK: VirtualAddress = 0x6
; CHECK: SymbolTableIndex = 2
; CHECK: Type = IMAGE_REL_I386_DIR32 (6)
; CHECK: SymbolName = .data
; CHECK: }
; CHECK: 1 = {
-; CHECK: VirtualAddress = 0x{{[0-9A-F]+}}
+; CHECK: VirtualAddress = 0xB
; CHECK: SymbolTableIndex = 5
; CHECK: Type = IMAGE_REL_I386_REL32 (20)
; CHECK: SymbolName = _printf
; CHECK: }
; CHECK: 2 = {
-; CHECK: VirtualAddress = 0x{{[0-9A-F]+}}
-; CHECK: SymbolTableIndex = 6
+; CHECK: VirtualAddress = 0x12
+; CHECK: SymbolTableIndex = 2
; CHECK: Type = IMAGE_REL_I386_DIR32 (6)
-; CHECK: SymbolName = _str
+; CHECK: SymbolName = .data
; CHECK: }
; CHECK: 3 = {
-; CHECK: VirtualAddress = 0x{{[0-9A-F]+}}
-; CHECK: SymbolTableIndex = 7
+; CHECK: VirtualAddress = 0x17
+; CHECK: SymbolTableIndex = 6
+; CHECK: Type = IMAGE_REL_I386_REL32 (20)
+; CHECK: SymbolName = _puts
+; CHECK: }
+; CHECK: 4 = {
+; CHECK: VirtualAddress = 0x1E
+; CHECK: SymbolTableIndex = 2
+; CHECK: Type = IMAGE_REL_I386_DIR32 (6)
+; CHECK: SymbolName = .data
+; CHECK: }
+; CHECK: 5 = {
+; CHECK: VirtualAddress = 0x23
+; CHECK: SymbolTableIndex = 6
; CHECK: Type = IMAGE_REL_I386_REL32 (20)
; CHECK: SymbolName = _puts
; CHECK: }
@@ -80,14 +97,15 @@
; CHECK: PointerToLineNumbers = 0x0
; CHECK: NumberOfRelocations = 0
; CHECK: NumberOfLineNumbers = 0
-; CHECK: Charateristics = 0xC0100040
+; CHECK: Charateristics = 0xC0500040
; CHECK: IMAGE_SCN_CNT_INITIALIZED_DATA
-; CHECK: IMAGE_SCN_ALIGN_1BYTES
+; CHECK: IMAGE_SCN_ALIGN_16BYTES
; CHECK: IMAGE_SCN_MEM_READ
; CHECK: IMAGE_SCN_MEM_WRITE
; CHECK: SectionData =
-; CHECK: 48 65 6C 6C 6F 20 00 57 - 6F 72 6C 64 21 00 |Hello .World!.|
-
+; CHECK: 48 65 6C 6C 6F 20 00 57 - 6F 72 6C 64 21 00 00 00 |Hello .World!...|
+; CHECK: 49 27 6D 20 54 68 65 20 - 4C 61 73 74 20 4C 69 6E |I'm The Last Lin|
+; CHECK: 65 2E 00 |e..|
; CHECK: Relocations = None
; CHECK: }
; CHECK: ]
@@ -101,7 +119,7 @@
; CHECK: StorageClass = IMAGE_SYM_CLASS_STATIC (3)
; CHECK: NumberOfAuxSymbols = 1
; CHECK: AuxillaryData =
-; CHECK: 21 00 00 00 04 00 00 00 - 00 00 00 00 01 00 00 00 |!...............|
+; CHECK: 30 00 00 00 06 00 00 00 - 00 00 00 00 01 00 00 00 |0...............|
; CHECK: 00 00 |..|
; CHECK: }
@@ -114,7 +132,7 @@
; CHECK: StorageClass = IMAGE_SYM_CLASS_STATIC (3)
; CHECK: NumberOfAuxSymbols = 1
; CHECK: AuxillaryData =
-; CHECK: 0E 00 00 00 00 00 00 00 - 00 00 00 00 02 00 00 00 |................|
+; CHECK: 23 00 00 00 00 00 00 00 - 00 00 00 00 02 00 00 00 |#...............|
; CHECK: 00 00 |..|
; CHECK: }
@@ -140,17 +158,6 @@
; CHECK: }
; CHECK: 6 = {
-; CHECK: Name = _str
-; CHECK: Value = 7
-; CHECK: SectionNumber = 2
-; CHECK: SimpleType = IMAGE_SYM_TYPE_NULL (0)
-; CHECK: ComplexType = IMAGE_SYM_DTYPE_NULL (0)
-; CHECK: StorageClass = IMAGE_SYM_CLASS_STATIC (3)
-; CHECK: NumberOfAuxSymbols = 0
-; CHECK: AuxillaryData =
-
-; CHECK: }
-; CHECK: 7 = {
; CHECK: Name = _puts
; CHECK: Value = 0
; CHECK: SectionNumber = 0
More information about the llvm-commits
mailing list