[PATCH] D46418: obj2yaml: Correctly round-trip default alignment.
Peter Collingbourne via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu May 3 20:48:11 PDT 2018
pcc created this revision.
pcc added reviewers: hans, ruiu.
Previously we were emitting the "cooked" alignment, which made it hard
to distinguish between that and the default alignment.
https://reviews.llvm.org/D46418
Files:
llvm/test/ObjectYAML/COFF/default-alignment.yaml
llvm/tools/obj2yaml/coff2yaml.cpp
Index: llvm/tools/obj2yaml/coff2yaml.cpp
===================================================================
--- llvm/tools/obj2yaml/coff2yaml.cpp
+++ llvm/tools/obj2yaml/coff2yaml.cpp
@@ -159,7 +159,8 @@
NewYAMLSection.Header.PointerToRelocations =
COFFSection->PointerToRelocations;
NewYAMLSection.Header.SizeOfRawData = COFFSection->SizeOfRawData;
- NewYAMLSection.Alignment = ObjSection.getAlignment();
+ uint32_t Shift = (COFFSection->Characteristics >> 20) & 0xF;
+ NewYAMLSection.Alignment = (1U << Shift) >> 1;
assert(NewYAMLSection.Alignment <= 8192);
ArrayRef<uint8_t> sectionData;
Index: llvm/test/ObjectYAML/COFF/default-alignment.yaml
===================================================================
--- /dev/null
+++ llvm/test/ObjectYAML/COFF/default-alignment.yaml
@@ -0,0 +1,15 @@
+# RUN: yaml2obj %s | obj2yaml | FileCheck %s
+
+# CHECK: Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_READ ]
+# CHECK-NEXT: SectionData: '01'
+
+--- !COFF
+header:
+ Machine: IMAGE_FILE_MACHINE_AMD64
+ Characteristics: []
+sections:
+ - Name: .rdata
+ Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_READ ]
+ SectionData: 01
+symbols:
+...
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D46418.145141.patch
Type: text/x-patch
Size: 1259 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180504/86e2a14f/attachment.bin>
More information about the llvm-commits
mailing list