Skip to content

Commit 9096413

Browse files
committedMay 4, 2018
obj2yaml: Correctly round-trip default alignment.
Previously we were emitting the "cooked" alignment, which made it hard to distinguish between that and the default alignment. Differential Revision: https://reviews.llvm.org/D46418 llvm-svn: 331537
1 parent 8668503 commit 9096413

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed
 
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# RUN: yaml2obj %s | obj2yaml | FileCheck %s
2+
3+
# CHECK: Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_READ ]
4+
# CHECK-NEXT: SectionData: '01'
5+
6+
--- !COFF
7+
header:
8+
Machine: IMAGE_FILE_MACHINE_AMD64
9+
Characteristics: []
10+
sections:
11+
- Name: .rdata
12+
Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_READ ]
13+
SectionData: 01
14+
symbols:
15+
...

‎llvm/tools/obj2yaml/coff2yaml.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,8 @@ void COFFDumper::dumpSections(unsigned NumSections) {
159159
NewYAMLSection.Header.PointerToRelocations =
160160
COFFSection->PointerToRelocations;
161161
NewYAMLSection.Header.SizeOfRawData = COFFSection->SizeOfRawData;
162-
NewYAMLSection.Alignment = ObjSection.getAlignment();
162+
uint32_t Shift = (COFFSection->Characteristics >> 20) & 0xF;
163+
NewYAMLSection.Alignment = (1U << Shift) >> 1;
163164
assert(NewYAMLSection.Alignment <= 8192);
164165

165166
ArrayRef<uint8_t> sectionData;

0 commit comments

Comments
 (0)
Please sign in to comment.