diff options
| author | Dimitry Andric <dim@FreeBSD.org> | 2020-01-17 20:45:01 +0000 |
|---|---|---|
| committer | Dimitry Andric <dim@FreeBSD.org> | 2020-01-17 20:45:01 +0000 |
| commit | 706b4fc47bbc608932d3b491ae19a3b9cde9497b (patch) | |
| tree | 4adf86a776049cbf7f69a1929c4babcbbef925eb /llvm/lib/ObjectYAML/COFFEmitter.cpp | |
| parent | 7cc9cf2bf09f069cb2dd947ead05d0b54301fb71 (diff) | |
Notes
Diffstat (limited to 'llvm/lib/ObjectYAML/COFFEmitter.cpp')
| -rw-r--r-- | llvm/lib/ObjectYAML/COFFEmitter.cpp | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/llvm/lib/ObjectYAML/COFFEmitter.cpp b/llvm/lib/ObjectYAML/COFFEmitter.cpp index efcdc51e16703..ec3ec55011f95 100644 --- a/llvm/lib/ObjectYAML/COFFEmitter.cpp +++ b/llvm/lib/ObjectYAML/COFFEmitter.cpp @@ -260,9 +260,12 @@ static bool layoutCOFF(COFFParser &CP) { CurrentSectionDataOffset += S.Header.SizeOfRawData; if (!S.Relocations.empty()) { S.Header.PointerToRelocations = CurrentSectionDataOffset; - S.Header.NumberOfRelocations = S.Relocations.size(); - CurrentSectionDataOffset += - S.Header.NumberOfRelocations * COFF::RelocationSize; + if (S.Header.Characteristics & COFF::IMAGE_SCN_LNK_NRELOC_OVFL) { + S.Header.NumberOfRelocations = 0xffff; + CurrentSectionDataOffset += COFF::RelocationSize; + } else + S.Header.NumberOfRelocations = S.Relocations.size(); + CurrentSectionDataOffset += S.Relocations.size() * COFF::RelocationSize; } } else { // Leave SizeOfRawData unaltered. For .bss sections in object files, it @@ -506,6 +509,10 @@ static bool writeCOFF(COFFParser &CP, raw_ostream &OS) { S.SectionData.writeAsBinary(OS); assert(S.Header.SizeOfRawData >= S.SectionData.binary_size()); OS.write_zeros(S.Header.SizeOfRawData - S.SectionData.binary_size()); + if (S.Header.Characteristics & COFF::IMAGE_SCN_LNK_NRELOC_OVFL) + OS << binary_le<uint32_t>(/*VirtualAddress=*/ S.Relocations.size() + 1) + << binary_le<uint32_t>(/*SymbolTableIndex=*/ 0) + << binary_le<uint16_t>(/*Type=*/ 0); for (const COFFYAML::Relocation &R : S.Relocations) { uint32_t SymbolTableIndex; if (R.SymbolTableIndex) { |
