[lld] r231586 - PECOFF: Fix off-by-one error.
Rui Ueyama
ruiu at google.com
Sat Mar 7 19:23:44 PST 2015
Author: ruiu
Date: Sat Mar 7 21:23:43 2015
New Revision: 231586
URL: http://llvm.org/viewvc/llvm-project?rev=231586&view=rev
Log:
PECOFF: Fix off-by-one error.
We accidentally skipped the last base relocation entry for each block.
Modified:
lld/trunk/lib/ReaderWriter/PECOFF/WriterPECOFF.cpp
lld/trunk/test/pecoff/Inputs/basereloc.obj.yaml
lld/trunk/test/pecoff/base-reloc.test
Modified: lld/trunk/lib/ReaderWriter/PECOFF/WriterPECOFF.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/PECOFF/WriterPECOFF.cpp?rev=231586&r1=231585&r2=231586&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/PECOFF/WriterPECOFF.cpp (original)
+++ lld/trunk/lib/ReaderWriter/PECOFF/WriterPECOFF.cpp Sat Mar 7 21:23:43 2015
@@ -973,7 +973,7 @@ BaseRelocChunk::createContents(ChunkVect
// Base relocations for the same memory page are grouped together
// and passed to createBaseRelocBlock.
- for (size_t i = 0, e = relocSites.size(); i < e; ++i) {
+ for (size_t i = 0, e = relocSites.size(); i < e;) {
const AtomChunk::BaseRelocation *begin = &relocSites[i];
uint64_t pageAddr = (begin->first & ~mask);
for (++i; i < e; ++i)
Modified: lld/trunk/test/pecoff/Inputs/basereloc.obj.yaml
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/pecoff/Inputs/basereloc.obj.yaml?rev=231586&r1=231585&r2=231586&view=diff
==============================================================================
--- lld/trunk/test/pecoff/Inputs/basereloc.obj.yaml (original)
+++ lld/trunk/test/pecoff/Inputs/basereloc.obj.yaml Sat Mar 7 21:23:43 2015
@@ -5,7 +5,30 @@ header:
sections:
- Name: .text
Characteristics: [ IMAGE_SCN_CNT_CODE, IMAGE_SCN_MEM_EXECUTE, IMAGE_SCN_MEM_READ ]
- Alignment: 4
+ Alignment: 4096
+ SectionData: B800000000506800000000680000000050E80000000050E80000000050E800000000
+ Relocations:
+ - VirtualAddress: 0
+ SymbolName: abs_symbol
+ Type: IMAGE_REL_I386_DIR32
+ - VirtualAddress: 7
+ SymbolName: caption
+ Type: IMAGE_REL_I386_DIR32
+ - VirtualAddress: 12
+ SymbolName: message
+ Type: IMAGE_REL_I386_DIR32
+ - VirtualAddress: 18
+ SymbolName: _MessageBoxA at 16
+ Type: IMAGE_REL_I386_REL32
+ - VirtualAddress: 24
+ SymbolName: _ExitProcess at 4
+ Type: IMAGE_REL_I386_REL32
+ - VirtualAddress: 30
+ SymbolName: ___ImageBase
+ Type: IMAGE_REL_I386_DIR32
+ - Name: .text2
+ Characteristics: [ IMAGE_SCN_CNT_CODE, IMAGE_SCN_MEM_EXECUTE, IMAGE_SCN_MEM_READ ]
+ Alignment: 4096
SectionData: B800000000506800000000680000000050E80000000050E80000000050E800000000
Relocations:
- VirtualAddress: 0
@@ -49,13 +72,25 @@ symbols:
StorageClass: IMAGE_SYM_CLASS_STATIC
SectionDefinition:
Length: 28
- NumberOfRelocations: 4
+ NumberOfRelocations: 6
+ NumberOfLinenumbers: 0
+ CheckSum: 0
+ Number: 0
+ - Name: .text2
+ Value: 0
+ SectionNumber: 1
+ SimpleType: IMAGE_SYM_TYPE_NULL
+ ComplexType: IMAGE_SYM_DTYPE_NULL
+ StorageClass: IMAGE_SYM_CLASS_STATIC
+ SectionDefinition:
+ Length: 28
+ NumberOfRelocations: 6
NumberOfLinenumbers: 0
CheckSum: 0
Number: 0
- Name: .data
Value: 0
- SectionNumber: 2
+ SectionNumber: 3
SimpleType: IMAGE_SYM_TYPE_NULL
ComplexType: IMAGE_SYM_DTYPE_NULL
StorageClass: IMAGE_SYM_CLASS_STATIC
Modified: lld/trunk/test/pecoff/base-reloc.test
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/pecoff/base-reloc.test?rev=231586&r1=231585&r2=231586&view=diff
==============================================================================
--- lld/trunk/test/pecoff/base-reloc.test (original)
+++ lld/trunk/test/pecoff/base-reloc.test Sat Mar 7 21:23:43 2015
@@ -25,6 +25,22 @@ BASEREL-NEXT: Entry {
BASEREL-NEXT: Type: ABSOLUTE
BASEREL-NEXT: Address: 0x2000
BASEREL-NEXT: }
+BASEREL-NEXT: Entry {
+BASEREL-NEXT: Type: HIGHLOW
+BASEREL-NEXT: Address: 0x3007
+BASEREL-NEXT: }
+BASEREL-NEXT: Entry {
+BASEREL-NEXT: Type: HIGHLOW
+BASEREL-NEXT: Address: 0x300C
+BASEREL-NEXT: }
+BASEREL-NEXT: Entry {
+BASEREL-NEXT: Type: HIGHLOW
+BASEREL-NEXT: Address: 0x301E
+BASEREL-NEXT: }
+BASEREL-NEXT: Entry {
+BASEREL-NEXT: Type: ABSOLUTE
+BASEREL-NEXT: Address: 0x3000
+BASEREL-NEXT: }
BASEREL-NEXT: ]
NOBASEREL: BaseReloc [
@@ -44,13 +60,13 @@ BASEREL-HEADER-NOT: IMAGE_FILE_RELOCS_ST
NOBASEREL-HEADER: IMAGE_FILE_RELOCS_STRIPPED
-BASEREL-HEADER: BaseRelocationTableRVA: 0x3000
-BASEREL-HEADER: BaseRelocationTableSize: 0x10
+BASEREL-HEADER: BaseRelocationTableRVA: 0x4000
+BASEREL-HEADER: BaseRelocationTableSize: 0x20
BASEREL-HEADER: Name: .reloc (2E 72 65 6C 6F 63 00 00)
-BASEREL-HEADER-NEXT: VirtualSize: 0x10
-BASEREL-HEADER-NEXT: VirtualAddress: 0x3000
+BASEREL-HEADER-NEXT: VirtualSize: 0x20
+BASEREL-HEADER-NEXT: VirtualAddress: 0x4000
BASEREL-HEADER-NEXT: RawDataSize: 512
-BASEREL-HEADER-NEXT: PointerToRawData: 0x600
+BASEREL-HEADER-NEXT: PointerToRawData: 0xA00
BASEREL-HEADER-NEXT: PointerToRelocations: 0x0
BASEREL-HEADER-NEXT: PointerToLineNumbers: 0x0
BASEREL-HEADER-NEXT: RelocationCount: 0
More information about the llvm-commits
mailing list