forked from OSchip/llvm-project
[PECOFF] Fix base relocation block alignment
Base relocation block should be aligned on a 32-bit boundary. While the PECOFF spec mentions only aligning the blocks, and not padding them, link.exe seems to add an extra IMAGE_REL_I386_ABSOLUTE entry (just a zeroed WORD) in order to pad the blocks. Patch by Ron Ofir. llvm-svn: 190951
This commit is contained in:
parent
740839260b
commit
ccd21fe418
|
@ -665,6 +665,7 @@ public:
|
|||
: COFFLinkerInternalAtom(file, std::move(data)) {}
|
||||
|
||||
virtual ContentType contentType() const { return typeData; }
|
||||
virtual Alignment alignment() const { return Alignment(2); }
|
||||
};
|
||||
|
||||
/// A BaseRelocChunk represents ".reloc" section.
|
||||
|
@ -736,8 +737,10 @@ private:
|
|||
// Create the content of a relocation block.
|
||||
DefinedAtom *createBaseRelocBlock(const File &file, uint64_t pageAddr,
|
||||
const std::vector<uint16_t> &offsets) {
|
||||
uint32_t size = sizeof(ulittle32_t) * 2
|
||||
+ sizeof(ulittle16_t) * offsets.size();
|
||||
// Relocation blocks should be padded with IMAGE_REL_I386_ABSOLUTE to be
|
||||
// aligned to a DWORD size boundary.
|
||||
uint32_t size = llvm::RoundUpToAlignment(sizeof(ulittle32_t) * 2
|
||||
+ sizeof(ulittle16_t) * offsets.size(), sizeof(ulittle32_t));
|
||||
std::vector<uint8_t> contents(size);
|
||||
uint8_t *ptr = &contents[0];
|
||||
|
||||
|
|
Loading…
Reference in New Issue