[llvm] r331537 - obj2yaml: Correctly round-trip default alignment.
Peter Collingbourne via llvm-commits
llvm-commits at lists.llvm.org
Fri May 4 09:28:41 PDT 2018
Author: pcc
Date: Fri May 4 09:28:41 2018
New Revision: 331537
URL: http://llvm.org/viewvc/llvm-project?rev=331537&view=rev
Log:
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
Added:
llvm/trunk/test/ObjectYAML/COFF/
llvm/trunk/test/ObjectYAML/COFF/default-alignment.yaml
Modified:
llvm/trunk/tools/obj2yaml/coff2yaml.cpp
Added: llvm/trunk/test/ObjectYAML/COFF/default-alignment.yaml
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/ObjectYAML/COFF/default-alignment.yaml?rev=331537&view=auto
==============================================================================
--- llvm/trunk/test/ObjectYAML/COFF/default-alignment.yaml (added)
+++ llvm/trunk/test/ObjectYAML/COFF/default-alignment.yaml Fri May 4 09:28:41 2018
@@ -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:
+...
Modified: llvm/trunk/tools/obj2yaml/coff2yaml.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/obj2yaml/coff2yaml.cpp?rev=331537&r1=331536&r2=331537&view=diff
==============================================================================
--- llvm/trunk/tools/obj2yaml/coff2yaml.cpp (original)
+++ llvm/trunk/tools/obj2yaml/coff2yaml.cpp Fri May 4 09:28:41 2018
@@ -159,7 +159,8 @@ void COFFDumper::dumpSections(unsigned N
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;
More information about the llvm-commits
mailing list