forked from OSchip/llvm-project
[yaml2obj] - Add a support for changing EntSize.
I was trying to add a test case for LLD and found that it is impossible to set sh_entsize via yaml. The patch implements the missing part. Differential revision: https://reviews.llvm.org/D50235 llvm-svn: 339113
This commit is contained in:
parent
d51f702f22
commit
65a6828b17
|
@ -123,6 +123,7 @@ struct Section {
|
|||
StringRef Link;
|
||||
StringRef Info;
|
||||
llvm::yaml::Hex64 AddressAlign;
|
||||
Optional<llvm::yaml::Hex64> EntSize;
|
||||
|
||||
Section(SectionKind Kind) : Kind(Kind) {}
|
||||
virtual ~Section();
|
||||
|
|
|
@ -816,6 +816,7 @@ static void commonSectionMapping(IO &IO, ELFYAML::Section &Section) {
|
|||
IO.mapOptional("Address", Section.Address, Hex64(0));
|
||||
IO.mapOptional("Link", Section.Link, StringRef());
|
||||
IO.mapOptional("AddressAlign", Section.AddressAlign, Hex64(0));
|
||||
IO.mapOptional("EntSize", Section.EntSize);
|
||||
IO.mapOptional("Info", Section.Info, StringRef());
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,50 @@
|
|||
# RUN: yaml2obj %s -o %t
|
||||
# RUN: llvm-readobj -sections %t | FileCheck %s
|
||||
|
||||
!ELF
|
||||
FileHeader:
|
||||
Class: ELFCLASS64
|
||||
Data: ELFDATA2LSB
|
||||
OSABI: ELFOSABI_FREEBSD
|
||||
Type: ET_REL
|
||||
Machine: EM_X86_64
|
||||
Sections:
|
||||
- Type: SHT_PROGBITS
|
||||
Name: .strings
|
||||
Flags: [ SHF_ALLOC, SHF_MERGE, SHF_STRINGS ]
|
||||
AddressAlign: 0x04
|
||||
Content: "FFFFFFFFFFFFFFFF"
|
||||
EntSize: 0x1
|
||||
- Name: .mydynamic
|
||||
Type: SHT_DYNAMIC
|
||||
EntSize: 0x0
|
||||
|
||||
|
||||
## Check we were able to set entry size for .strings and .mydynamic
|
||||
# CHECK: Name: .strings
|
||||
# CHECK-NEXT: Type: SHT_PROGBITS
|
||||
# CHECK-NEXT: Flags [
|
||||
# CHECK-NEXT: SHF_ALLOC
|
||||
# CHECK-NEXT: SHF_MERGE
|
||||
# CHECK-NEXT: SHF_STRINGS
|
||||
# CHECK-NEXT: ]
|
||||
# CHECK-NEXT: Address:
|
||||
# CHECK-NEXT: Offset:
|
||||
# CHECK-NEXT: Size:
|
||||
# CHECK-NEXT: Link:
|
||||
# CHECK-NEXT: Info:
|
||||
# CHECK-NEXT: AddressAlignment:
|
||||
# CHECK-NEXT: EntrySize: 1
|
||||
# CHECK-NEXT: }
|
||||
# CHECK: Name: .mydynamic
|
||||
# CHECK-NEXT: Type: SHT_DYNAMIC
|
||||
# CHECK-NEXT: Flags [
|
||||
# CHECK-NEXT: ]
|
||||
# CHECK-NEXT: Address:
|
||||
# CHECK-NEXT: Offset:
|
||||
# CHECK-NEXT: Size:
|
||||
# CHECK-NEXT: Link:
|
||||
# CHECK-NEXT: Info:
|
||||
# CHECK-NEXT: AddressAlignment:
|
||||
# CHECK-NEXT: EntrySize: 0
|
||||
# CHECK-NEXT: }
|
|
@ -461,7 +461,9 @@ ELFState<ELFT>::writeSectionContent(Elf_Shdr &SHeader,
|
|||
Section.Content.writeAsBinary(OS);
|
||||
for (auto i = Section.Content.binary_size(); i < Section.Size; ++i)
|
||||
OS.write(0);
|
||||
if (Section.Type == llvm::ELF::SHT_RELR)
|
||||
if (Section.EntSize)
|
||||
SHeader.sh_entsize = *Section.EntSize;
|
||||
else if (Section.Type == llvm::ELF::SHT_RELR)
|
||||
SHeader.sh_entsize = sizeof(Elf_Relr);
|
||||
else if (Section.Type == llvm::ELF::SHT_DYNAMIC)
|
||||
SHeader.sh_entsize = sizeof(Elf_Dyn);
|
||||
|
|
Loading…
Reference in New Issue