mirror of
https://github.com/RPCSX/llvm.git
synced 2025-01-30 08:56:40 +00:00
MC, COFF: Align section contents to a four byte boundary
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@228879 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
b357516cb4
commit
f50e261e1e
@ -939,7 +939,8 @@ void WinCOFFObjectWriter::WriteObject(MCAssembler &Asm,
|
|||||||
Sec->Header.SizeOfRawData = Layout.getSectionAddressSize(&Section);
|
Sec->Header.SizeOfRawData = Layout.getSectionAddressSize(&Section);
|
||||||
|
|
||||||
if (IsPhysicalSection(Sec)) {
|
if (IsPhysicalSection(Sec)) {
|
||||||
Sec->Header.PointerToRawData = offset;
|
// Align the section data to a four byte boundary.
|
||||||
|
Sec->Header.PointerToRawData = RoundUpToAlignment(offset, 4);
|
||||||
|
|
||||||
offset += Sec->Header.SizeOfRawData;
|
offset += Sec->Header.SizeOfRawData;
|
||||||
}
|
}
|
||||||
@ -1009,9 +1010,15 @@ void WinCOFFObjectWriter::WriteObject(MCAssembler &Asm,
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
if ((*i)->Header.PointerToRawData != 0) {
|
if ((*i)->Header.PointerToRawData != 0) {
|
||||||
assert(OS.tell() == (*i)->Header.PointerToRawData &&
|
assert(OS.tell() <= (*i)->Header.PointerToRawData &&
|
||||||
"Section::PointerToRawData is insane!");
|
"Section::PointerToRawData is insane!");
|
||||||
|
|
||||||
|
unsigned SectionDataPadding = (*i)->Header.PointerToRawData - OS.tell();
|
||||||
|
assert(SectionDataPadding < 4 &&
|
||||||
|
"Should only need at most three bytes of padding!");
|
||||||
|
|
||||||
|
WriteZeros(SectionDataPadding);
|
||||||
|
|
||||||
Asm.writeSectionData(j, Layout);
|
Asm.writeSectionData(j, Layout);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,8 +6,14 @@ entry:
|
|||||||
ret void
|
ret void
|
||||||
}
|
}
|
||||||
|
|
||||||
|
; CHECK: Section {
|
||||||
|
; CHECK: Name: .text
|
||||||
|
; CHECK: PointerToRawData: 0xB4
|
||||||
|
; CHECK: }
|
||||||
|
|
||||||
; CHECK: Section {
|
; CHECK: Section {
|
||||||
; CHECK: Name: .drectve
|
; CHECK: Name: .drectve
|
||||||
|
; CHECK: PointerToRawData: 0xB8
|
||||||
; CHECK: Characteristics [
|
; CHECK: Characteristics [
|
||||||
; CHECK: IMAGE_SCN_ALIGN_1BYTES
|
; CHECK: IMAGE_SCN_ALIGN_1BYTES
|
||||||
; CHECK: IMAGE_SCN_LNK_INFO
|
; CHECK: IMAGE_SCN_LNK_INFO
|
||||||
|
Loading…
x
Reference in New Issue
Block a user