[yaml2obj] Add support for sh_addralign via AddressAlign key.

For consistency, change the address in the test case from 0xDEADBEEF to
0xCAFEBABE since 0xCAFEBABE that actually has a 2-byte alignment.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@183962 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Sean Silva 2013-06-14 00:38:02 +00:00
parent 38084db681
commit 97d37e8181
4 changed files with 7 additions and 3 deletions

View File

@ -55,6 +55,7 @@ struct Section {
ELF_SHF Flags;
llvm::yaml::Hex64 Address;
object::yaml::BinaryRef Content;
llvm::yaml::Hex64 AddressAlign;
};
struct Object {
FileHeader Header;

View File

@ -267,6 +267,7 @@ void MappingTraits<ELFYAML::Section>::mapping(IO &IO,
IO.mapOptional("Flags", Section.Flags, ELFYAML::ELF_SHF(0));
IO.mapOptional("Address", Section.Address, Hex64(0));
IO.mapOptional("Content", Section.Content);
IO.mapOptional("AddressAlign", Section.AddressAlign, Hex64(0));
}
void MappingTraits<ELFYAML::Object>::mapping(IO &IO, ELFYAML::Object &Object) {

View File

@ -9,8 +9,9 @@ Sections:
- Name: .text
Type: SHT_PROGBITS
Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
Address: 0xDEADBEEF
Address: 0xCAFEBABE
Content: EBFE
AddressAlign: 2
# CHECK: Section {
# CHECK: Index: 0
@ -23,8 +24,9 @@ Sections:
# CHECK-NEXT: SHF_ALLOC (0x2)
# CHECK-NEXT: SHF_EXECINSTR (0x4)
# CHECK-NEXT: ]
# CHECK-NEXT: Address: 0xDEADBEEF
# CHECK-NEXT: Address: 0xCAFEBABE
# CHECK: Size: 2
# CHECK: AddressAlignment: 2
# CHECK: SectionData (
# CHECK-NEXT: 0000: EBFE
# CHECK-NEXT: )

View File

@ -161,7 +161,7 @@ static void writeELF(raw_ostream &OS, const ELFYAML::Object &Doc) {
SHeader.sh_link = 0;
SHeader.sh_info = 0;
SHeader.sh_addralign = 1;
SHeader.sh_addralign = Sec.AddressAlign;
SHeader.sh_entsize = 0;
SHeaders.push_back(SHeader);
}