aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--test/Object/Inputs/COFF/i386.yaml6
-rw-r--r--test/Object/Inputs/COFF/x86-64.yaml6
-rw-r--r--tools/yaml2obj/yaml2obj.cpp18
3 files changed, 12 insertions, 18 deletions
diff --git a/test/Object/Inputs/COFF/i386.yaml b/test/Object/Inputs/COFF/i386.yaml
index 7c3480645c..f7631821c1 100644
--- a/test/Object/Inputs/COFF/i386.yaml
+++ b/test/Object/Inputs/COFF/i386.yaml
@@ -5,7 +5,8 @@ header: !Header
sections:
- !Section
Name: .text
- Characteristics: [IMAGE_SCN_CNT_CODE, IMAGE_SCN_ALIGN_16BYTES, IMAGE_SCN_MEM_EXECUTE, IMAGE_SCN_MEM_READ, ] # 0x60500020
+ Alignment: 16
+ Characteristics: [IMAGE_SCN_CNT_CODE, IMAGE_SCN_MEM_EXECUTE, IMAGE_SCN_MEM_READ, ] # 0x60500020
SectionData: !hex "83EC0CC744240800000000C7042400000000E800000000E8000000008B44240883C40CC3" # |....D$.......$...............D$.....|
Relocations:
@@ -26,7 +27,8 @@ sections:
- !Section
Name: .data
- Characteristics: [IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_ALIGN_1BYTES, IMAGE_SCN_MEM_READ, IMAGE_SCN_MEM_WRITE, ] # 0xc0100040
+ Alignment: 1
+ Characteristics: [IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_READ, IMAGE_SCN_MEM_WRITE, ] # 0xc0100040
SectionData: !hex "48656C6C6F20576F726C642100" # |Hello World!.|
symbols:
diff --git a/test/Object/Inputs/COFF/x86-64.yaml b/test/Object/Inputs/COFF/x86-64.yaml
index 837663bdfa..5134071cda 100644
--- a/test/Object/Inputs/COFF/x86-64.yaml
+++ b/test/Object/Inputs/COFF/x86-64.yaml
@@ -4,7 +4,8 @@ header: !Header
sections:
- !Section
Name: .text
- Characteristics: [IMAGE_SCN_CNT_CODE, IMAGE_SCN_ALIGN_16BYTES, IMAGE_SCN_MEM_EXECUTE, IMAGE_SCN_MEM_READ, ] # 0x60500020
+ Alignment: 16
+ Characteristics: [IMAGE_SCN_CNT_CODE, IMAGE_SCN_MEM_EXECUTE, IMAGE_SCN_MEM_READ, ] # 0x60500020
SectionData: !hex "4883EC28C744242400000000488D0D00000000E800000000E8000000008B4424244883C428C3" # |H..(.D$$....H.................D$$H..(.|
Relocations:
@@ -25,7 +26,8 @@ sections:
- !Section
Name: .data
- Characteristics: [IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_ALIGN_1BYTES, IMAGE_SCN_MEM_READ, IMAGE_SCN_MEM_WRITE, ] # 0xc0100040
+ Alignment: 1
+ Characteristics: [IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_READ, IMAGE_SCN_MEM_WRITE, ] # 0xc0100040
SectionData: !hex "48656C6C6F20576F726C642100" # |Hello World!.|
symbols:
diff --git a/tools/yaml2obj/yaml2obj.cpp b/tools/yaml2obj/yaml2obj.cpp
index 32dee54dc5..707b6b4d5c 100644
--- a/tools/yaml2obj/yaml2obj.cpp
+++ b/tools/yaml2obj/yaml2obj.cpp
@@ -42,6 +42,7 @@ static cl::opt<std::string>
namespace COFFYAML {
struct Section {
COFF::section Header;
+ unsigned Alignment;
StringRef SectionData;
std::vector<COFF::relocation> Relocations;
StringRef Name;
@@ -102,6 +103,8 @@ struct COFFParser {
Sec.Header.Name[0] = '/';
std::copy(str.begin(), str.end(), Sec.Header.Name + 1);
}
+
+ Sec.Header.Characteristics |= (Log2_32(Sec.Alignment) + 1) << 20;
}
return true;
}
@@ -358,20 +361,6 @@ struct ScalarBitSetTraits<COFF::SectionCharacteristics> {
BCase(IMAGE_SCN_MEM_16BIT);
BCase(IMAGE_SCN_MEM_LOCKED);
BCase(IMAGE_SCN_MEM_PRELOAD);
- BCase(IMAGE_SCN_ALIGN_1BYTES);
- BCase(IMAGE_SCN_ALIGN_2BYTES);
- BCase(IMAGE_SCN_ALIGN_4BYTES);
- BCase(IMAGE_SCN_ALIGN_8BYTES);
- BCase(IMAGE_SCN_ALIGN_16BYTES);
- BCase(IMAGE_SCN_ALIGN_32BYTES);
- BCase(IMAGE_SCN_ALIGN_64BYTES);
- BCase(IMAGE_SCN_ALIGN_128BYTES);
- BCase(IMAGE_SCN_ALIGN_256BYTES);
- BCase(IMAGE_SCN_ALIGN_512BYTES);
- BCase(IMAGE_SCN_ALIGN_1024BYTES);
- BCase(IMAGE_SCN_ALIGN_2048BYTES);
- BCase(IMAGE_SCN_ALIGN_4096BYTES);
- BCase(IMAGE_SCN_ALIGN_8192BYTES);
BCase(IMAGE_SCN_LNK_NRELOC_OVFL);
BCase(IMAGE_SCN_MEM_DISCARDABLE);
BCase(IMAGE_SCN_MEM_NOT_CACHED);
@@ -641,6 +630,7 @@ struct MappingTraits<COFFYAML::Section> {
IO.mapRequired("SectionData", Sec.SectionData);
IO.mapRequired("Characteristics", NC->Characteristics);
IO.mapRequired("Name", Sec.Name);
+ IO.mapOptional("Alignment", Sec.Alignment);
}
};