[yaml2obj] - ProgramHeaders: introduce FirstSec/LastSec instead of Sections list.

Imagine we have a YAML declaration of few sections: `foo1`, `<unnamed 2>`, `foo3`, `foo4`.

To put them into segment we can do (1*):

```
Sections:
 - Section: foo1
 - Section: foo4
```

or we can use (2*):

```
Sections:
 - Section: foo1
 - Section: foo3
 - Section: foo4
```

or (3*) :

```
Sections:
 - Section: foo1
## "(index 2)" here is a name that we automatically created for a unnamed section.
 - Section: (index 2)
 - Section: foo3
 - Section: foo4
```

It looks really confusing that we don't have to list all of sections.

At first I've tried to make this rule stricter and report an error when there is a gap
(i.e. when a section is included into segment, but not listed explicitly).
This did not work perfect, because such approach conflicts with unnamed sections/fills (see (3*)).

This patch drops "Sections" key and introduces 2 keys instead: `FirstSec` and `LastSec`.
Both are optional.

Differential revision: https://reviews.llvm.org/D90458
This commit is contained in:
Georgii Rymar 2020-10-30 15:54:03 +03:00
parent 99a6401acc
commit a7a447be0f
111 changed files with 1743 additions and 1938 deletions

View File

@ -100,10 +100,6 @@ struct SectionHeaderTable {
Optional<bool> NoHeaders;
};
struct SectionName {
StringRef Section;
};
struct Symbol {
StringRef Name;
ELF_STT Type;
@ -627,9 +623,10 @@ struct ProgramHeader {
Optional<llvm::yaml::Hex64> FileSize;
Optional<llvm::yaml::Hex64> MemSize;
Optional<llvm::yaml::Hex64> Offset;
Optional<StringRef> FirstSec;
Optional<StringRef> LastSec;
std::vector<SectionName> Sections;
// This vector is parallel to Sections and contains corresponding chunks.
// This vector contains all chunks from [FirstSec, LastSec].
std::vector<Chunk *> Chunks;
};
@ -680,7 +677,6 @@ LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::ELFYAML::VernauxEntry)
LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::ELFYAML::VerneedEntry)
LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::ELFYAML::Relocation)
LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::ELFYAML::SectionOrType)
LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::ELFYAML::SectionName)
LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::ELFYAML::ARMIndexTableEntry)
namespace llvm {
@ -816,6 +812,7 @@ template <> struct MappingTraits<ELFYAML::SectionHeader> {
template <> struct MappingTraits<ELFYAML::ProgramHeader> {
static void mapping(IO &IO, ELFYAML::ProgramHeader &FileHdr);
static std::string validate(IO &IO, ELFYAML::ProgramHeader &FileHdr);
};
template <>
@ -890,10 +887,6 @@ template <> struct MappingTraits<ELFYAML::SectionOrType> {
static void mapping(IO &IO, ELFYAML::SectionOrType &sectionOrType);
};
template <> struct MappingTraits<ELFYAML::SectionName> {
static void mapping(IO &IO, ELFYAML::SectionName &sectionName);
};
} // end namespace yaml
} // end namespace llvm

View File

@ -467,12 +467,16 @@ void ELFState<ELFT>::writeELFHeader(raw_ostream &OS, Optional<uint64_t> SHOff) {
template <class ELFT>
void ELFState<ELFT>::initProgramHeaders(std::vector<Elf_Phdr> &PHeaders) {
DenseMap<StringRef, ELFYAML::Fill *> NameToFill;
for (const std::unique_ptr<ELFYAML::Chunk> &D : Doc.Chunks)
if (auto S = dyn_cast<ELFYAML::Fill>(D.get()))
DenseMap<StringRef, size_t> NameToIndex;
for (size_t I = 0, E = Doc.Chunks.size(); I != E; ++I) {
if (auto S = dyn_cast<ELFYAML::Fill>(Doc.Chunks[I].get()))
NameToFill[S->Name] = S;
NameToIndex[Doc.Chunks[I]->Name] = I + 1;
}
std::vector<ELFYAML::Section *> Sections = Doc.getSections();
for (ELFYAML::ProgramHeader &YamlPhdr : Doc.ProgramHeaders) {
for (size_t I = 0, E = Doc.ProgramHeaders.size(); I != E; ++I) {
ELFYAML::ProgramHeader &YamlPhdr = Doc.ProgramHeaders[I];
Elf_Phdr Phdr;
zero(Phdr);
Phdr.p_type = YamlPhdr.Type;
@ -481,22 +485,30 @@ void ELFState<ELFT>::initProgramHeaders(std::vector<Elf_Phdr> &PHeaders) {
Phdr.p_paddr = YamlPhdr.PAddr;
PHeaders.push_back(Phdr);
// Map Sections list to corresponding chunks.
for (const ELFYAML::SectionName &SecName : YamlPhdr.Sections) {
if (ELFYAML::Fill *Fill = NameToFill.lookup(SecName.Section)) {
YamlPhdr.Chunks.push_back(Fill);
continue;
}
if (!YamlPhdr.FirstSec && !YamlPhdr.LastSec)
continue;
unsigned Index;
if (SN2I.lookup(SecName.Section, Index)) {
YamlPhdr.Chunks.push_back(Sections[Index]);
continue;
}
// Get the index of the section, or 0 in the case when the section doesn't exist.
size_t First = NameToIndex[*YamlPhdr.FirstSec];
if (!First)
reportError("unknown section or fill referenced: '" + *YamlPhdr.FirstSec +
"' by the 'FirstSec' key of the program header with index " +
Twine(I));
size_t Last = NameToIndex[*YamlPhdr.LastSec];
if (!Last)
reportError("unknown section or fill referenced: '" + *YamlPhdr.LastSec +
"' by the 'LastSec' key of the program header with index " +
Twine(I));
if (!First || !Last)
continue;
reportError("unknown section or fill referenced: '" + SecName.Section +
"' by program header");
}
if (First > Last)
reportError("program header with index " + Twine(I) +
": the section index of " + *YamlPhdr.FirstSec +
" is greater than the index of " + *YamlPhdr.LastSec);
for (size_t I = First; I <= Last; ++I)
YamlPhdr.Chunks.push_back(Doc.Chunks[I - 1].get());
}
}

View File

@ -904,7 +904,8 @@ void MappingTraits<ELFYAML::ProgramHeader>::mapping(
IO &IO, ELFYAML::ProgramHeader &Phdr) {
IO.mapRequired("Type", Phdr.Type);
IO.mapOptional("Flags", Phdr.Flags, ELFYAML::ELF_PF(0));
IO.mapOptional("Sections", Phdr.Sections);
IO.mapOptional("FirstSec", Phdr.FirstSec);
IO.mapOptional("LastSec", Phdr.LastSec);
IO.mapOptional("VAddr", Phdr.VAddr, Hex64(0));
IO.mapOptional("PAddr", Phdr.PAddr, Phdr.VAddr);
IO.mapOptional("Align", Phdr.Align);
@ -913,6 +914,15 @@ void MappingTraits<ELFYAML::ProgramHeader>::mapping(
IO.mapOptional("Offset", Phdr.Offset);
}
std::string MappingTraits<ELFYAML::ProgramHeader>::validate(
IO &IO, ELFYAML::ProgramHeader &FileHdr) {
if (!FileHdr.FirstSec && FileHdr.LastSec)
return "the \"LastSec\" key can't be used without the \"FirstSec\" key";
if (FileHdr.FirstSec && !FileHdr.LastSec)
return "the \"FirstSec\" key can't be used without the \"LastSec\" key";
return "";
}
LLVM_YAML_STRONG_TYPEDEF(StringRef, StOtherPiece)
template <> struct ScalarTraits<StOtherPiece> {
@ -1260,11 +1270,6 @@ void MappingTraits<ELFYAML::SectionOrType>::mapping(
IO.mapRequired("SectionOrType", sectionOrType.sectionNameOrType);
}
void MappingTraits<ELFYAML::SectionName>::mapping(
IO &IO, ELFYAML::SectionName &sectionName) {
IO.mapRequired("Section", sectionName.Section);
}
static void sectionMapping(IO &IO, ELFYAML::ARMIndexTableSection &Section) {
commonSectionMapping(IO, Section);
IO.mapOptional("Entries", Section.Entries);

View File

@ -17,7 +17,7 @@ Sections:
Flags: [ SHF_ALLOC ]
Content: 0123456789
ProgramHeaders:
- Type: PT_NOTE
Flags: [ PF_R ]
Sections:
- Section: .note.invalid
- Type: PT_NOTE
Flags: [ PF_R ]
FirstSec: .note.invalid
LastSec: .note.invalid

View File

@ -22,7 +22,7 @@ Sections:
Flags: [ SHF_ALLOC ]
Content: 040000000800000003000000474e5500abb50d82b6bdc861
ProgramHeaders:
- Type: PT_NOTE
Flags: [ PF_R ]
Sections:
- Section: .note.gnu.build-id
- Type: PT_NOTE
Flags: [ PF_R ]
FirstSec: .note.gnu.build-id
LastSec: .note.gnu.build-id

View File

@ -454,10 +454,10 @@ Sections:
- Tag: DT_NULL
Value: 0x0
ProgramHeaders:
- Type: PT_LOAD
VAddr: 0x1000
Sections:
- Section: .dynamic
- Type: PT_LOAD
VAddr: 0x1000
FirstSec: .dynamic
LastSec: .dynamic
## Check that llvm-readobj reports a warning when a dynamic relocation section
## has sh_entsize field with size != sizeof(Elf_Rela).
@ -529,8 +529,8 @@ Sections:
ProgramHeaders:
- Type: PT_DYNAMIC
FileSize: 0xffff0000
Sections:
- Section: .dynamic
FirstSec: .dynamic
LastSec: .dynamic
# RUN: yaml2obj --docnum=24 %s -o %t24
# RUN: not obj2yaml 2>&1 %t24 | FileCheck %s -DFILE=%t24 --check-prefix=INVALID-SHSTRNDX

View File

@ -660,17 +660,17 @@ Symbols:
# ELF-AVR-NEXT: Machine: EM_AVR
# ELF-AVR-NEXT: Flags: [ EF_AVR_ARCH_AVR2 ]
# ELF-AVR-NEXT: ProgramHeaders:
# ELF-AVR-NEXT: - Type: PT_LOAD
# ELF-AVR-NEXT: Flags: [ PF_X, PF_R ]
# ELF-AVR-NEXT: Sections:
# ELF-AVR-NEXT: - Section: .text
# ELF-AVR-NEXT: Align: 0x0000000000000002
# ELF-AVR-NEXT: - Type: PT_LOAD
# ELF-AVR-NEXT: Flags: [ PF_W, PF_R ]
# ELF-AVR-NEXT: Sections:
# ELF-AVR-NEXT: - Section: .data
# ELF-AVR-NEXT: VAddr: 0x0000000000800060
# ELF-AVR-NEXT: PAddr: 0x0000000000000004
# ELF-AVR-NEXT: - Type: PT_LOAD
# ELF-AVR-NEXT: Flags: [ PF_X, PF_R ]
# ELF-AVR-NEXT: FirstSec: .text
# ELF-AVR-NEXT: LastSec: .text
# ELF-AVR-NEXT: Align: 0x0000000000000002
# ELF-AVR-NEXT: - Type: PT_LOAD
# ELF-AVR-NEXT: Flags: [ PF_W, PF_R ]
# ELF-AVR-NEXT: FirstSec: .data
# ELF-AVR-NEXT: LastSec: .data
# ELF-AVR-NEXT: VAddr: 0x0000000000800060
# ELF-AVR-NEXT: PAddr: 0x0000000000000004
# ELF-AVR-NEXT: Sections:
# ELF-AVR-NEXT: - Name: .text
# ELF-AVR-NEXT: Type: SHT_PROGBITS

View File

@ -30,18 +30,17 @@ Sections:
- Tag: DT_NULL
Value: 0x0000000000000000
ProgramHeaders:
- Type: PT_LOAD
Flags: [ PF_R ]
VAddr: 0x0000
Align: 8
Sections:
- Section: .dynstr
- Section: .dynamic
- Type: PT_LOAD
Flags: [ PF_R ]
VAddr: 0x0000
Align: 8
FirstSec: .dynstr
LastSec: .dynamic
- Type: PT_DYNAMIC
Flags: [ PF_X, PF_R ]
VAddr: 0x0008
Sections:
- Section: .dynamic
FirstSec: .dynamic
LastSec: .dynamic
# CHECK: --- !tapi-tbe
# CHECK-NEXT: TbeVersion: {{[1-9]\d*\.(0|([1-9]\d*))}}

View File

@ -30,18 +30,17 @@ Sections:
- Tag: DT_NULL
Value: 0x0000000000000000
ProgramHeaders:
- Type: PT_LOAD
Flags: [ PF_R ]
VAddr: 0x0000
Align: 8
Sections:
- Section: .dynstr
- Section: .dynamic
- Type: PT_DYNAMIC
Flags: [ PF_X, PF_R ]
VAddr: 0x0008
Sections:
- Section: .dynamic
- Type: PT_LOAD
Flags: [ PF_R ]
VAddr: 0x0000
Align: 8
FirstSec: .dynstr
LastSec: .dynamic
- Type: PT_DYNAMIC
Flags: [ PF_X, PF_R ]
VAddr: 0x0008
FirstSec: .dynamic
LastSec: .dynamic
# CHECK: --- !tapi-tbe
# CHECK-NEXT: TbeVersion: {{[1-9]\d*\.(0|([1-9]\d*))}}

View File

@ -32,17 +32,16 @@ Sections:
- Tag: DT_NULL
Value: 0x0000000000000000
ProgramHeaders:
- Type: PT_LOAD
Flags: [ PF_R ]
VAddr: 0x0000
Align: 8
Sections:
- Section: .dynstr
- Section: .dynamic
- Type: PT_DYNAMIC
Flags: [ PF_X, PF_R ]
VAddr: 0x0008
Sections:
- Section: .dynamic
- Type: PT_LOAD
Flags: [ PF_R ]
VAddr: 0x0000
Align: 8
FirstSec: .dynstr
LastSec: .dynamic
- Type: PT_DYNAMIC
Flags: [ PF_X, PF_R ]
VAddr: 0x0008
FirstSec: .dynamic
LastSec: .dynamic
# CHECK: DT_SONAME string offset (0x000000000000000d) outside of dynamic string table

View File

@ -32,17 +32,16 @@ Sections:
- Tag: DT_NULL
Value: 0x0000000000000000
ProgramHeaders:
- Type: PT_LOAD
Flags: [ PF_R ]
VAddr: 0x1000
Align: 8
Sections:
- Section: .dynstr
- Section: .dynamic
- Type: PT_DYNAMIC
Flags: [ PF_X, PF_R ]
VAddr: 0x1008
Sections:
- Section: .dynamic
- Type: PT_LOAD
Flags: [ PF_R ]
VAddr: 0x1000
Align: 8
FirstSec: .dynstr
LastSec: .dynamic
- Type: PT_DYNAMIC
Flags: [ PF_X, PF_R ]
VAddr: 0x1008
FirstSec: .dynamic
LastSec: .dynamic
# CHECK: virtual address is not in any segment: 0x260 when locating .dynstr section contents

View File

@ -36,16 +36,14 @@ Sections:
- Tag: DT_NULL
Value: 0x0000000000000000
ProgramHeaders:
- Type: PT_LOAD
Flags: [ PF_R ]
VAddr: 0x1000
Align: 8
Sections:
- Section: .dynstr
- Section: .dynamic
- Type: PT_DYNAMIC
- Type: PT_LOAD
Flags: [ PF_R ]
VAddr: 0x1000
Align: 8
FirstSec: .dynstr
LastSec: .dynamic
- Type: PT_DYNAMIC
Flags: [ PF_X, PF_R ]
VAddr: 0x1024
Sections:
# CHECK: DT_NEEDED string offset (0x000000000000ffff) outside of dynamic string table

View File

@ -35,17 +35,15 @@ Sections:
- Tag: DT_NULL
Value: 0x0000000000000000
ProgramHeaders:
- Type: PT_LOAD
Flags: [ PF_R ]
VAddr: 0x1000
Align: 8
Sections:
- Section: .dynstr
- Section: .dynamic
- Type: PT_LOAD
Flags: [ PF_R ]
VAddr: 0x1000
Align: 8
FirstSec: .dynstr
LastSec: .dynamic
- Type: PT_DYNAMIC
Flags: [ PF_X, PF_R ]
VAddr: 0x1024
Sections:
# CHECK: NeededLibs:
# CHECK-NEXT: - libfoo.so{{$}}

View File

@ -27,17 +27,16 @@ Sections:
- Tag: DT_NULL
Value: 0x0000000000000000
ProgramHeaders:
- Type: PT_LOAD
Flags: [ PF_R ]
VAddr: 0x0000
Align: 8
Sections:
- Section: .dynstr
- Section: .dynamic
- Type: PT_DYNAMIC
Flags: [ PF_X, PF_R ]
VAddr: 0x0008
Sections:
- Section: .dynamic
- Type: PT_LOAD
Flags: [ PF_R ]
VAddr: 0x0000
Align: 8
FirstSec: .dynstr
LastSec: .dynamic
- Type: PT_DYNAMIC
Flags: [ PF_X, PF_R ]
VAddr: 0x0008
FirstSec: .dynamic
LastSec: .dynamic
# CHECK: Couldn't determine dynamic string table size (no DT_STRSZ entry)

View File

@ -26,17 +26,16 @@ Sections:
- Tag: DT_NULL
Value: 0x0000000000000000
ProgramHeaders:
- Type: PT_LOAD
Flags: [ PF_R ]
VAddr: 0x0000
Align: 8
Sections:
- Section: .dynstr
- Section: .dynamic
- Type: PT_DYNAMIC
Flags: [ PF_X, PF_R ]
VAddr: 0x0008
Sections:
- Section: .dynamic
- Type: PT_LOAD
Flags: [ PF_R ]
VAddr: 0x0000
Align: 8
FirstSec: .dynstr
LastSec: .dynamic
- Type: PT_DYNAMIC
Flags: [ PF_X, PF_R ]
VAddr: 0x0008
FirstSec: .dynamic
LastSec: .dynamic
# CHECK: Couldn't locate dynamic string table (no DT_STRTAB entry)

View File

@ -34,18 +34,17 @@ Sections:
- Tag: DT_NULL
Value: 0x0000000000000000
ProgramHeaders:
- Type: PT_LOAD
Flags: [ PF_R ]
VAddr: 0x1000
Align: 8
Sections:
- Section: .dynstr
- Section: .dynamic
- Type: PT_DYNAMIC
Flags: [ PF_X, PF_R ]
VAddr: 0x1018
Sections:
- Section: .dynamic
- Type: PT_LOAD
Flags: [ PF_R ]
VAddr: 0x1000
Align: 8
FirstSec: .dynstr
LastSec: .dynamic
- Type: PT_DYNAMIC
Flags: [ PF_X, PF_R ]
VAddr: 0x1018
FirstSec: .dynamic
LastSec: .dynamic
# ORIGINAL: SoName: somelib.so{{$}}

View File

@ -33,17 +33,16 @@ Sections:
- Tag: DT_NULL
Value: 0x0000000000000000
ProgramHeaders:
- Type: PT_LOAD
Flags: [ PF_R ]
VAddr: 0x1000
Align: 8
Sections:
- Section: .dynstr
- Section: .dynamic
- Type: PT_DYNAMIC
Flags: [ PF_X, PF_R ]
VAddr: 0x1018
Sections:
- Section: .dynamic
- Type: PT_LOAD
Flags: [ PF_R ]
VAddr: 0x1000
Align: 8
FirstSec: .dynstr
LastSec: .dynamic
- Type: PT_DYNAMIC
Flags: [ PF_X, PF_R ]
VAddr: 0x1018
FirstSec: .dynamic
LastSec: .dynamic
# CHECK: String overran bounds of string table (no null terminator) when reading DT_SONAME

View File

@ -33,18 +33,17 @@ Sections:
- Tag: DT_NULL
Value: 0x0000000000000000
ProgramHeaders:
- Type: PT_LOAD
Flags: [ PF_R ]
VAddr: 0x1000
Align: 8
Sections:
- Section: .dynstr
- Section: .dynamic
- Type: PT_DYNAMIC
Flags: [ PF_X, PF_R ]
VAddr: 0x1018
Sections:
- Section: .dynamic
- Type: PT_LOAD
Flags: [ PF_R ]
VAddr: 0x1000
Align: 8
FirstSec: .dynstr
LastSec: .dynamic
- Type: PT_DYNAMIC
Flags: [ PF_X, PF_R ]
VAddr: 0x1018
FirstSec: .dynamic
LastSec: .dynamic
# CHECK: --- !tapi-tbe
# CHECK-NEXT: TbeVersion: {{[1-9]\d*\.(0|([1-9]\d*))}}

View File

@ -389,26 +389,8 @@ ProgramHeaders:
Flags: [ PF_X, PF_R ]
VAddr: 0x0000000000400000
Align: 1024
Sections:
- Section: .interp
- Section: .interp
- Section: .note.ABI-tag
- Section: .note.gnu.build-id
- Section: .gnu.hash
- Section: .gnu.version
- Section: .gnu.version_r
- Section: .rela.dyn
- Section: .rela.plt
- Section: .init
- Section: .plt
- Section: .plt.got
- Section: .text
- Section: .fini
- Section: .rodata
- Section: .eh_frame_hdr
- Section: .eh_frame
- Section: .dynsym
- Section: .dynstr
FirstSec: .interp
LastSec: .dynstr
Symbols:
- Name: .interp
Type: STT_SECTION

View File

@ -12,9 +12,9 @@ Sections:
AddressAlign: 0x8
Content: "0001020304"
ProgramHeaders:
- Type: PT_NULL
Flags: [ PF_X, PF_R ]
VAddr: 0xF00000000
PAddr: 0x100000
Sections:
- Section: .text
- Type: PT_NULL
Flags: [ PF_X, PF_R ]
VAddr: 0xF00000000
PAddr: 0x100000
FirstSec: .text
LastSec: .text

View File

@ -48,13 +48,9 @@ Sections:
Size: 65536
AddressAlign: 0x8
ProgramHeaders:
- Type: PT_LOAD
Flags: [ PF_X, PF_R ]
VAddr: 0xF00000000
PAddr: 0x100000
Sections:
- Section: .text
- Section: .data1
- Section: .data2
- Section: .data3
- Section: .bss
- Type: PT_LOAD
Flags: [ PF_X, PF_R ]
VAddr: 0xF00000000
PAddr: 0x100000
FirstSec: .text
LastSec: .bss

View File

@ -44,18 +44,18 @@ Sections:
AddressAlign: 0x0000000000001000
Size: 64
ProgramHeaders:
- Type: PT_LOAD
Flags: [ PF_X, PF_R ]
VAddr: 0x1000
Align: 0x1000
Sections:
- Section: .text
- Type: PT_LOAD
Flags: [ PF_R, PF_W ]
VAddr: 0x2000
Align: 0x1000
Sections:
- Section: .data
- Type: PT_LOAD
Flags: [ PF_X, PF_R ]
VAddr: 0x1000
Align: 0x1000
FirstSec: .text
LastSec: .text
- Type: PT_LOAD
Flags: [ PF_R, PF_W ]
VAddr: 0x2000
Align: 0x1000
FirstSec: .data
LastSec: .data
## TODO (grimar): llvm-objcopy seems produce a broken output without
## the following line, i.e. when there is no symbol table in the input.
Symbols: []

View File

@ -23,14 +23,14 @@ Sections:
AddressAlign: 0x10
Size: 16
ProgramHeaders:
- Type: PT_LOAD
Flags: [ PF_X, PF_R ]
Sections:
- Section: .text
- Type: PT_LOAD
Flags: [ PF_X, PF_R ]
Sections:
- Section: .text2
- Type: PT_LOAD
Flags: [ PF_X, PF_R ]
FirstSec: .text
LastSec: .text
- Type: PT_LOAD
Flags: [ PF_X, PF_R ]
FirstSec: .text2
LastSec: .text2
#CHECK: ProgramHeaders [
#CHECK-NEXT: ProgramHeader {

View File

@ -15,7 +15,7 @@ Sections:
Flags: [ SHF_ALLOC ]
Content: 040000000100000003000000474E55004F000000
ProgramHeaders:
- Type: PT_NOTE
Flags: [ PF_R ]
Sections:
- Section: .note.gnu.build-id
- Type: PT_NOTE
Flags: [ PF_R ]
FirstSec: .note.gnu.build-id
LastSec: .note.gnu.build-id

View File

@ -16,10 +16,10 @@ Sections:
AddressAlign: 0x0000000000001000
Content: "c3c3c3c3"
ProgramHeaders:
- Type: PT_LOAD
Flags: [ PF_X, PF_R ]
Sections:
- Section: .text
- Type: PT_LOAD
Flags: [ PF_X, PF_R ]
FirstSec: .text
LastSec: .text
# CHECK: 0000000 c3c3 c3c3
# SIZE: 4

View File

@ -23,11 +23,10 @@ Sections:
Size: 4064
Content: "DEADBEEF"
ProgramHeaders:
- Type: PT_LOAD
Flags: [ PF_R ]
VAddr: 0x1000
Sections:
- Section: .note
- Section: .rodata
- Type: PT_LOAD
Flags: [ PF_R ]
VAddr: 0x1000
FirstSec: .note
LastSec: .rodata
# CHECK: 000000 de ad be ef

View File

@ -32,18 +32,18 @@ Sections:
AddressAlign: 0x0000000000000004
Content: "3232"
ProgramHeaders:
- Type: PT_LOAD
Flags: [ PF_X, PF_R ]
VAddr: 0x1000
PAddr: [[PADDR]]
Sections:
- Section: .text
- Type: PT_LOAD
Flags: [ PF_R, PF_W ]
VAddr: 0x1004
PAddr: [[PADDR]]
Sections:
- Section: .data
- Type: PT_LOAD
Flags: [ PF_X, PF_R ]
VAddr: 0x1000
PAddr: [[PADDR]]
FirstSec: .text
LastSec: .text
- Type: PT_LOAD
Flags: [ PF_R, PF_W ]
VAddr: 0x1004
PAddr: [[PADDR]]
FirstSec: .data
LastSec: .data
# CHECK: 0000000 3232 c3c3
# SIZE: 4

View File

@ -35,11 +35,10 @@ Sections:
AddressAlign: 0x1000
Content: "3232"
ProgramHeaders:
- Type: PT_LOAD
Flags: [ PF_R, PF_W ]
Sections:
- Section: .text
- Section: .data
- Type: PT_LOAD
Flags: [ PF_R, PF_W ]
FirstSec: .text
LastSec: .data
## The computed LMA of a section not in a PT_LOAD equals its sh_addr.
@ -78,13 +77,13 @@ Sections:
AddressAlign: 0x1000
Content: "3232"
ProgramHeaders:
- Type: PT_LOAD
Flags: [ PF_R, PF_W ]
VAddr: 0x2000
- Type: PT_LOAD
Flags: [ PF_R, PF_W ]
VAddr: 0x2000
## p_vaddr is increased from 0x2000 to 0x4000.
PAddr: 0x4000
Sections:
- Section: .data
PAddr: 0x4000
FirstSec: .data
LastSec: .data
## Check that we use sh_offset instead of sh_addr to decide where to write section contents.
@ -124,11 +123,11 @@ Sections:
AddressAlign: 0x1000
Content: "3232"
ProgramHeaders:
- Type: PT_LOAD
Flags: [ PF_R, PF_W ]
VAddr: 0x3000
Sections:
- Section: .data
- Type: PT_LOAD
Flags: [ PF_R, PF_W ]
VAddr: 0x3000
FirstSec: .data
LastSec: .data
## The first section (.text) is empty. Test that we skip its LMA until the first
## non-empty section, otherwise we would leave a large number of leading zeroes.

View File

@ -32,13 +32,11 @@ Sections:
Content: "32323232"
Size: 0x1000
ProgramHeaders:
- Type: PT_LOAD
Flags: [ PF_R ]
VAddr: 0x1000
Sections:
- Section: .text
- Section: .text2
- Section: .text3
- Type: PT_LOAD
Flags: [ PF_R ]
VAddr: 0x1000
FirstSec: .text
LastSec: .text3
# CHECK: 000000 de ad be ef

View File

@ -32,13 +32,11 @@ Sections:
Content: "32323232"
Size: 0x1000
ProgramHeaders:
- Type: PT_LOAD
Flags: [ PF_R ]
VAddr: 0x1000
Sections:
- Section: .text
- Section: .text2
- Section: .text3
- Type: PT_LOAD
Flags: [ PF_R ]
VAddr: 0x1000
FirstSec: .text
LastSec: .text3
# CHECK: 000000 c3 c3 c3 c3
# CHECK: 001000 de ad be ef

View File

@ -32,13 +32,11 @@ Sections:
Content: "32323232"
Size: 0x1000
ProgramHeaders:
- Type: PT_LOAD
Flags: [ PF_R ]
VAddr: 0x1000
Sections:
- Section: .text
- Section: .text2
- Section: .text3
- Type: PT_LOAD
Flags: [ PF_R ]
VAddr: 0x1000
FirstSec: .text
LastSec: .text3
# CHECK: 000000 c3 c3 c3 c3
# CHECK: 001000 00 00 00 00

View File

@ -23,16 +23,16 @@ Sections:
Address: 0x08
Content: "3232"
ProgramHeaders:
- Type: PT_LOAD
Flags: [ PF_X, PF_R ]
VAddr: 0x00
Sections:
- Section: .text
- Type: PT_LOAD
Flags: [ PF_R ]
VAddr: 0x08
Sections:
- Section: .data
- Type: PT_LOAD
Flags: [ PF_X, PF_R ]
VAddr: 0x00
FirstSec: .text
LastSec: .text
- Type: PT_LOAD
Flags: [ PF_R ]
VAddr: 0x08
FirstSec: .data
LastSec: .data
# CHECK: 0000000 c3c3 c3c3 0000 0000 3232
# SIZE: 10

View File

@ -50,7 +50,7 @@ Sections:
Flags: [ SHF_ALLOC ]
Content: 040000001000000003000000474E55004FCB712AA6387724A9F465A32CD8C14B
ProgramHeaders:
- Type: PT_NOTE
Flags: [ PF_R ]
Sections:
- Section: .note.gnu.build-id
- Type: PT_NOTE
Flags: [ PF_R ]
FirstSec: .note.gnu.build-id
LastSec: .note.gnu.build-id

View File

@ -22,17 +22,17 @@ Sections:
AddressAlign: 0x0000000000000008
Content: "3232"
ProgramHeaders:
- Type: PT_LOAD
Flags: [ PF_X, PF_R ]
VAddr: 0x1000
Align: 0x1000
Sections:
- Section: .text
- Type: PT_LOAD
Flags: [ PF_R, PF_W ]
VAddr: 0x1008
Align: 0x1000
Sections:
- Section: .data
- Type: PT_LOAD
Flags: [ PF_X, PF_R ]
VAddr: 0x1000
Align: 0x1000
FirstSec: .text
LastSec: .text
- Type: PT_LOAD
Flags: [ PF_R, PF_W ]
VAddr: 0x1008
Align: 0x1000
FirstSec: .data
LastSec: .data
# CHECK: 0000000 c3 c3 c3 c3 00 00 00 00 32 32

View File

@ -22,18 +22,18 @@ Sections:
AddressAlign: 0x0000000000000008
Content: "3232"
ProgramHeaders:
- Type: PT_LOAD
Flags: [ PF_X, PF_R ]
VAddr: 0x1000
Align: 0x1000
Sections:
- Section: .text
- Type: PT_LOAD
Flags: [ PF_R, PF_W ]
VAddr: 0x1008
Align: 0x1000
Sections:
- Section: .data
- Type: PT_LOAD
Flags: [ PF_X, PF_R ]
VAddr: 0x1000
Align: 0x1000
FirstSec: .text
LastSec: .text
- Type: PT_LOAD
Flags: [ PF_R, PF_W ]
VAddr: 0x1008
Align: 0x1000
FirstSec: .data
LastSec: .data
#CHECK: ProgramHeaders [
#CHECK-NEXT: ProgramHeader {

View File

@ -21,6 +21,6 @@ Sections:
Type: SHT_PROGBITS
Content: 'facefeed'
ProgramHeaders:
- Type: PT_LOAD
Sections:
- Section: .text
- Type: PT_LOAD
FirstSec: .text
LastSec: .text

View File

@ -35,10 +35,10 @@ Sections:
Type: SHT_NOBITS
Flags: [ SHF_WRITE ]
ProgramHeaders:
- Type: PT_LOAD
Flags: [ PF_X, PF_R ]
Sections:
- Section: .text
- Type: PT_LOAD
Flags: [ PF_X, PF_R ]
FirstSec: .text
LastSec: .text
# CHECK: 0000000 de ad be ef

View File

@ -79,14 +79,13 @@ Sections:
Address: 0x1000
Size: 0x100
ProgramHeaders:
- Type: PT_LOAD
VAddr: 0
Align: 0x100
Sections:
- Section: .foo
- Type: PT_LOAD
VAddr: 0x1000
Align: 0x1000
Sections:
- Section: .empty
- Section: .baz
- Type: PT_LOAD
VAddr: 0
Align: 0x100
FirstSec: .foo
LastSec: .foo
- Type: PT_LOAD
VAddr: 0x1000
Align: 0x1000
FirstSec: .empty
LastSec: .baz

View File

@ -24,20 +24,18 @@ Sections:
AddressAlign: 0x1000
Size: 4096
ProgramHeaders:
- Type: PT_LOAD
Flags: [ PF_X, PF_R ]
Sections:
- Section: .text2
- Type: PT_LOAD
Flags: [ PF_X, PF_R ]
Sections:
- Section: .text
- Section: .text2
- Type: PT_LOAD
Flags: [ PF_X, PF_R ]
Sections:
- Section: .text
- Section: .text2
- Type: PT_LOAD
Flags: [ PF_X, PF_R ]
FirstSec: .text2
LastSec: .text2
- Type: PT_LOAD
Flags: [ PF_X, PF_R ]
FirstSec: .text
LastSec: .text2
- Type: PT_LOAD
Flags: [ PF_X, PF_R ]
FirstSec: .text
LastSec: .text2
#CHECK: ProgramHeaders [
#CHECK-NEXT: ProgramHeader {

View File

@ -16,10 +16,10 @@ Sections:
- Name: .foo
Type: SHT_PROGBITS
ProgramHeaders:
- Type: PT_LOAD
FileSize: 0x100000
Sections:
- Section: .foo
- Type: PT_LOAD
FileSize: 0x100000
FirstSec: .foo
LastSec: .foo
## A similar case, but now the p_offset property of the program header is too large.

View File

@ -29,28 +29,27 @@ Sections:
Flags: [ SHF_ALLOC ]
Size: 64
ProgramHeaders:
- Type: PT_LOAD
Flags: [ PF_X, PF_R ]
VAddr: 0x1000
Align: 0x1000
Sections:
- Section: .text
- Type: PT_LOAD
Flags: [ PF_R, PF_W ]
VAddr: 0x2000
Align: 0x1000
Sections:
- Section: .data
- Type: PT_LOAD
Flags: [ PF_X, PF_R ]
VAddr: 0x1000
Align: 0x1000
FirstSec: .text
LastSec: .text
- Type: PT_LOAD
Flags: [ PF_R, PF_W ]
VAddr: 0x2000
Align: 0x1000
FirstSec: .data
LastSec: .data
- Type: PT_GNU_STACK
Flags: [ PF_R, PF_W ]
VAddr: 0x0000
Align: 0x0000
- Type: PT_LOAD
Flags: [ PF_R ]
VAddr: 0x2010
Sections:
- Section: .xdata
- Section: .after
- Type: PT_LOAD
Flags: [ PF_R ]
VAddr: 0x2010
FirstSec: .xdata
LastSec: .after
#CHECK: ProgramHeaders [
#CHECK-NEXT: ProgramHeader {

View File

@ -15,7 +15,7 @@ Sections:
Flags: [ SHF_ALLOC ]
Content: 000000000000000000000000
ProgramHeaders:
- Type: PT_NOTE
Flags: [ PF_R ]
Sections:
- Section: .note.foo
- Type: PT_NOTE
Flags: [ PF_R ]
FirstSec: .note.foo
LastSec: .note.foo

View File

@ -97,28 +97,23 @@ ProgramHeaders:
Flags: [ PF_R, PF_X ]
Offset: 0
Align: 0x1000
Sections:
- Section: .note1
- Section: .note2
- Section: .text
FirstSec: .note1
LastSec: .text
- Type: PT_LOAD
Flags: [ PF_R, PF_W ]
VAddr: 0x1480 # Ensure Offset=VAddr (mod Align) if Offset changes
Align: 0x1000
Sections:
- Section: .tdata
- Section: .bss
FirstSec: .tdata
LastSec: .bss
- Type: PT_TLS
Flags: [ PF_R, PF_W ]
VAddr: 0x1480 # Ensure Offset=VAddr (mod Align) if Offset changes
Sections:
- Section: .tdata
- Section: .tbss
FirstSec: .tdata
LastSec: .tbss
- Type: PT_NOTE
VAddr: 0x400
Sections:
- Section: .note1
- Section: .note2
FirstSec: .note1
LastSec: .note2
...
# RUN: yaml2obj --docnum=2 %s -o %t2
@ -175,9 +170,8 @@ ProgramHeaders:
Flags: [ PF_R, PF_X ]
Offset: 0
Align: 4096
Sections:
- Section: .text
- Section: .note
FirstSec: .text
LastSec: .note
- Type: PT_LOAD
Flags: [ PF_R, PF_W ]
Offset: 0x202

View File

@ -40,26 +40,22 @@ Sections:
AddressAlign: 0x1000
Size: 4096
ProgramHeaders:
- Type: PT_LOAD
Flags: [ PF_X, PF_R ]
Sections:
- Section: .text
- Section: .text2
- Type: PT_LOAD
Flags: [ PF_X, PF_R ]
Sections:
- Section: .text4
- Section: .text5
- Type: PT_LOAD
Flags: [ PF_X, PF_R ]
Sections:
- Section: .text3
- Section: .text4
- Type: PT_LOAD
Flags: [ PF_X, PF_R ]
Sections:
- Section: .text2
- Section: .text3
- Type: PT_LOAD
Flags: [ PF_X, PF_R ]
FirstSec: .text
LastSec: .text2
- Type: PT_LOAD
Flags: [ PF_X, PF_R ]
FirstSec: .text4
LastSec: .text5
- Type: PT_LOAD
Flags: [ PF_X, PF_R ]
FirstSec: .text3
LastSec: .text4
- Type: PT_LOAD
Flags: [ PF_X, PF_R ]
FirstSec: .text2
LastSec: .text3
#CHECK: ProgramHeaders [
#CHECK-NEXT: ProgramHeader {

View File

@ -33,16 +33,15 @@ Sections:
Size: 4064
Content: "DEADBEEF"
ProgramHeaders:
- Type: PT_LOAD
Flags: [ PF_R ]
VAddr: 0x1000
Sections:
- Section: .note
- Section: .rodata
- Type: PT_NOTE
Flags: [ PF_R ]
VAddr: 0x1000
Sections:
- Section: .note
- Type: PT_LOAD
Flags: [ PF_R ]
VAddr: 0x1000
FirstSec: .note
LastSec: .rodata
- Type: PT_NOTE
Flags: [ PF_R ]
VAddr: 0x1000
FirstSec: .note
LastSec: .note
# CHECK: 000000 de ad be ef

View File

@ -37,6 +37,6 @@ ProgramHeaders:
Offset: 0
FileSize: 176 # sizeof(Elf64_Ehdr) + 2 * sizeof(Elf64_Phdr)
- Type: PT_LOAD
Sections:
- Section: .keep_me
FirstSec: .keep_me
LastSec: .keep_me
Symbols: []

View File

@ -311,188 +311,153 @@ Sections:
Address: 0x5038
ProgramHeaders:
# First segment has unlabelled space at start and end.
- Type: 0x6ABCDEF0 # Non-specific segment type.
VAddr: 0x2000
Align: 0x2000
Sections:
- Section: blob1
- Section: section1
- Section: blob2
- Section: section2 # nobits
- Section: blob3
- Section: section3
- Section: blob4
- Type: 0x6ABCDEF0 # Non-specific segment type.
VAddr: 0x2000
Align: 0x2000
FirstSec: blob1
LastSec: blob4
# Second segment has sections at start and end.
- Type: 0x6ABCDEF0
VAddr: 0x2100
Align: 0x100
Sections:
- Section: section4
- Section: blob5
- Section: section5
- Type: 0x6ABCDEF0
VAddr: 0x2100
Align: 0x100
FirstSec: section4
LastSec: section5
# Third segment is all covered by a section.
- Type: 0x6ABCDEF0
VAddr: 0x2200
Align: 0x100
Sections:
- Section: section6
- Type: 0x6ABCDEF0
VAddr: 0x2200
Align: 0x100
FirstSec: section6
LastSec: section6
# Fourth segment has no sections (after removing blob headers).
- Type: 0x6ABCDEF0
VAddr: 0x2300
Align: 0x100
Sections:
- Section: blob6
- Type: 0x6ABCDEF0
VAddr: 0x2300
Align: 0x100
FirstSec: blob6
LastSec: blob6
# Fifth segment is empty.
- Type: 0x6ABCDEF0
VAddr: 0x2308
Offset: 0x2308
# The next few segments test behaviour of fully nested segments.
# Sixth segment is the "parent" segment.
- Type: 0x6ABCDEF0
VAddr: 0x3000
Align: 0x1000
Sections:
- Section: sectionA
- Section: sectionB
- Section: blobA
- Section: sectionC
- Section: blobB
- Section: sectionD
- Section: blobC
- Section: sectionE
- Section: blobD
- Section: sectionF
- Section: blobE
- Section: blobF
- Section: sectionG
- Section: blobG
- Section: sectionH
- Section: blobH
- Section: sectionI
- Type: 0x6ABCDEF0
VAddr: 0x3000
Align: 0x1000
FirstSec: sectionA
LastSec: sectionI
# Seventh segment is empty and nested.
- Type: 0x6ABCDEF0
VAddr: 0x3002
Offset: 0x3002
# Eighth segment contains only a section and is nested.
- Type: 0x6ABCDEF0
VAddr: 0x3004
Sections:
- Section: sectionB
- Type: 0x6ABCDEF0
VAddr: 0x3004
FirstSec: sectionB
LastSec: sectionB
# Ninth segment contains only unlabelled space and is nested.
- Type: 0x6ABCDEF0
VAddr: 0x3008
Sections:
- Section: blobA
- Type: 0x6ABCDEF0
VAddr: 0x3008
FirstSec: blobA
LastSec: blobA
# Tenth segment contains two sections with space between and is nested.
- Type: 0x6ABCDEF0
VAddr: 0x300C
Sections:
- Section: sectionC
- Section: blobB
- Section: sectionD
- Type: 0x6ABCDEF0
VAddr: 0x300C
FirstSec: sectionC
LastSec: sectionD
# Eleventh segment contains two sections with space between and at ends and is nested.
- Type: 0x6ABCDEF0
VAddr: 0x3018
Sections:
- Section: blobC
- Section: sectionE
- Section: blobD
- Section: sectionF
- Section: blobE
- Type: 0x6ABCDEF0
VAddr: 0x3018
FirstSec: blobC
LastSec: blobE
# Twelfth segment contains one section with space at ends adjacent to space in parent segment.
- Type: 0x6ABCDEF0
VAddr: 0x302E
Offset: 0x302E
FileSize: 8
Sections:
- Section: sectionG
FirstSec: sectionG
LastSec: sectionG
# Thirteenth segment contains overlaps sections at either end in parent segment.
- Type: 0x6ABCDEF0
VAddr: 0x303A
Offset: 0x303A
FileSize: 0x8
Sections:
- Section: blobH
FirstSec: blobH
LastSec: blobH
# The next batch of segments are segments that only partially overlap other segments.
# Segment14: |-unlabelled-|-Sec-|
# Segment15: |--|-Sec-|-unlabelled-|
- Type: 0x6ABCDEF0
VAddr: 0x4000
Sections:
- Section: blobz
- Section: sectionz
- Type: 0x6ABCDEF0
VAddr: 0x4002
Offset: 0x4002
Sections:
- Section: sectionz
- Section: bloby
- Type: 0x6ABCDEF0
VAddr: 0x4000
FirstSec: blobz
LastSec: sectionz
- Type: 0x6ABCDEF0
VAddr: 0x4002
Offset: 0x4002
FirstSec: sectionz
LastSec: bloby
# Segment16: |-Sec-|--|
# Segment17: |--|----unlabelled---|
- Type: 0x6ABCDEF0
VAddr: 0x400C
- Type: 0x6ABCDEF0
VAddr: 0x400C
FileSize: 6
Sections:
- Section: sectiony
- Type: 0x6ABCDEF0
VAddr: 0x400E
Offset: 0x400E
Sections:
- Section: blobx
FirstSec: sectiony
LastSec: sectiony
- Type: 0x6ABCDEF0
VAddr: 0x400E
Offset: 0x400E
FirstSec: blobx
LastSec: blobx
# Segment18: |-unlabelled-|-Sec-|
# Segment19: |-Sec-|-unlabelled-|
- Type: 0x6ABCDEF0
VAddr: 0x4014
Sections:
- Section: blobw
- Section: sectionx
- Type: 0x6ABCDEF0
VAddr: 0x4018
Sections:
- Section: sectionx
- Section: blobv
- Type: 0x6ABCDEF0
VAddr: 0x4014
FirstSec: blobw
LastSec: sectionx
- Type: 0x6ABCDEF0
VAddr: 0x4018
FirstSec: sectionx
LastSec: blobv
# Segment20: |-Sec-|
# Segment21: |--|-unlabelled-|-Sec-|
- Type: 0x6ABCDEF0
VAddr: 0x4020
Sections:
- Section: sectionw
- Type: 0x6ABCDEF0
VAddr: 0x4020
FirstSec: sectionw
LastSec: sectionw
- Type: 0x6ABCDEF0
VAddr: 0x4022
Offset: 0x4022
Sections:
- Section: blobu
- Section: sectionv
FirstSec: blobu
LastSec: sectionv
# Segment22: |-Sec-|
# Segment23: |--|-Sec-|
- Type: 0x6ABCDEF0
VAddr: 0x402C
Sections:
- Section: sectionu
- Type: 0x6ABCDEF0
VAddr: 0x402E
Offset: 0x402E
Sections:
- Section: sectiont
- Type: 0x6ABCDEF0
VAddr: 0x402C
FirstSec: sectionu
LastSec: sectionu
- Type: 0x6ABCDEF0
VAddr: 0x402E
Offset: 0x402E
FirstSec: sectiont
LastSec: sectiont
# Segment24: |-unlabelled-|--|
# Segment25: |--Sec--|
- Type: 0x6ABCDEF0
VAddr: 0x4034
- Type: 0x6ABCDEF0
VAddr: 0x4034
FileSize: 6
Sections:
- Section: blobt
- Type: 0x6ABCDEF0
VAddr: 0x4038
Sections:
- Section: sections
FirstSec: blobt
LastSec: blobt
- Type: 0x6ABCDEF0
VAddr: 0x4038
FirstSec: sections
LastSec: sections
# The next batch of segments represent groups of three nested/overlapping segments,
# with one parent segment containing two overlapping segments.
@ -500,100 +465,85 @@ ProgramHeaders:
# Segment26: |-unlabelled-|-Sec-|-unlabelled-|
# Segment27: |------------|--|
# Segment28: |-Sec-|------------|
- Type: 0x6ABCDEF0
VAddr: 0x5000
Align: 0x1000
Sections:
- Section: bloba
- Section: sectiona
- Section: blobb
- Type: 0x6ABCDEF0
VAddr: 0x5000
- Type: 0x6ABCDEF0
VAddr: 0x5000
Align: 0x1000
FirstSec: bloba
LastSec: blobb
- Type: 0x6ABCDEF0
VAddr: 0x5000
FileSize: 6
Sections:
- Section: bloba
- Type: 0x6ABCDEF0
VAddr: 0x5004
Sections:
- Section: sectiona
- Section: blobb
FirstSec: bloba
LastSec: bloba
- Type: 0x6ABCDEF0
VAddr: 0x5004
FirstSec: sectiona
LastSec: blobb
# Segment29: |-Sec-|-unlabelled-|-Sec-|
# Segment30: |-Sec-|--------|
# Segment31: |---------|-Sec-|
- Type: 0x6ABCDEF0
VAddr: 0x500C
Sections:
- Section: sectionb
- Section: blobc
- Section: sectionc
- Type: 0x6ABCDEF0
VAddr: 0x500C
- Type: 0x6ABCDEF0
VAddr: 0x500C
FirstSec: sectionb
LastSec: sectionc
- Type: 0x6ABCDEF0
VAddr: 0x500C
FileSize: 7
Sections:
- Section: sectionb
- Type: 0x6ABCDEF0
VAddr: 0x5011
Offset: 0x5011
Sections:
- Section: sectionc
FirstSec: sectionb
LastSec: sectionb
- Type: 0x6ABCDEF0
VAddr: 0x5011
Offset: 0x5011
FirstSec: sectionc
LastSec: sectionc
# Segment32: |-Sec-|-unlabelled-|-Sec-|
# Segment33: |-Sec-|------------|
# Segment34: |------------|-Sec-|
- Type: 0x6ABCDEF0
VAddr: 0x5018
Sections:
- Section: sectiond
- Section: blobd
- Section: sectione
- Type: 0x6ABCDEF0
VAddr: 0x5018
Sections:
- Section: sectiond
- Section: blobd
- Type: 0x6ABCDEF0
VAddr: 0x501C
Sections:
- Section: blobd
- Section: sectione
- Type: 0x6ABCDEF0
VAddr: 0x5018
FirstSec: sectiond
LastSec: sectione
- Type: 0x6ABCDEF0
VAddr: 0x5018
FirstSec: sectiond
LastSec: blobd
- Type: 0x6ABCDEF0
VAddr: 0x501C
FirstSec: blobd
LastSec: sectione
# Segment35: |-unlabelled-|-Sec-|-unlabelled-|
# Segment36: |------------|-Sec-|
# Segment37: |-Sec-|------------|
- Type: 0x6ABCDEF0
VAddr: 0x5024
Sections:
- Section: blobe
- Section: sectionf
- Section: blobf
- Type: 0x6ABCDEF0
VAddr: 0x5024
Sections:
- Section: blobe
- Section: sectionf
- Type: 0x6ABCDEF0
VAddr: 0x5028
Sections:
- Section: sectionf
- Section: blobf
- Type: 0x6ABCDEF0
VAddr: 0x5024
FirstSec: blobe
LastSec: blobf
- Type: 0x6ABCDEF0
VAddr: 0x5024
FirstSec: blobe
LastSec: sectionf
- Type: 0x6ABCDEF0
VAddr: 0x5028
FirstSec: sectionf
LastSec: blobf
# Segment38: |-unlabelled-|-Sec-|-unlabelled-|
# Segment39: |------------|---|
# Segment40: |---|------------|
- Type: 0x6ABCDEF0
VAddr: 0x5030
Sections:
- Section: blobg
- Section: sectiong
- Section: blobh
- Type: 0x6ABCDEF0
VAddr: 0x5030
- Type: 0x6ABCDEF0
VAddr: 0x5030
FirstSec: blobg
LastSec: blobh
- Type: 0x6ABCDEF0
VAddr: 0x5030
FileSize: 7
Sections:
- Section: blobg
- Type: 0x6ABCDEF0
VAddr: 0x5035
Offset: 0x5035
Sections:
- Section: blobh
FirstSec: blobg
LastSec: blobg
- Type: 0x6ABCDEF0
VAddr: 0x5035
Offset: 0x5035
FirstSec: blobh
LastSec: blobh

View File

@ -28,19 +28,18 @@ Sections:
Address: 0xAAAA2000
AddressAlign: 0x0000000000001000
ProgramHeaders:
- Type: PT_LOAD
Flags: [ PF_X, PF_R ]
VAddr: 0xAAAA1000
PAddr: 0xFFFF1000
Sections:
- Section: .text
- Section: .init
- Type: PT_LOAD
Flags: [ PF_R ]
VAddr: 0xAAAA2000
PAddr: 0xFFFF2000
Sections:
- Section: .data
- Type: PT_LOAD
Flags: [ PF_X, PF_R ]
VAddr: 0xAAAA1000
PAddr: 0xFFFF1000
FirstSec: .text
LastSec: .init
- Type: PT_LOAD
Flags: [ PF_R ]
VAddr: 0xAAAA2000
PAddr: 0xFFFF2000
FirstSec: .data
LastSec: .data
#CHECK: ProgramHeaders [
#CHECK-NEXT: ProgramHeader {

View File

@ -42,6 +42,5 @@ Sections:
ProgramHeaders:
# Use an arbitrary segment type to show that the segment type is unimportant.
- Type: 0x61234567
Sections:
- Section: shf_alloc
- Section: non_alloc
FirstSec: shf_alloc
LastSec: non_alloc

View File

@ -28,16 +28,16 @@ Sections:
AddressAlign: 0x1000
Size: 0x1000
ProgramHeaders:
- Type: PT_LOAD
Flags: [ PF_R ]
VAddr: 0x1000
Sections:
- Section: .text
- Type: PT_LOAD
Flags: [ PF_X, PF_R ]
VAddr: 0x3000
Sections:
- Section: .text3
- Type: PT_LOAD
Flags: [ PF_R ]
VAddr: 0x1000
FirstSec: .text
LastSec: .text
- Type: PT_LOAD
Flags: [ PF_X, PF_R ]
VAddr: 0x3000
FirstSec: .text3
LastSec: .text3
## TODO (grimar): without the following line (i.e. without an empty symbol table),
## llvm-objcopy adds an empty .strtab section. It doesn't look correct.
Symbols: []

View File

@ -28,16 +28,16 @@ Sections:
AddressAlign: 0x1000
Size: 0x1000
ProgramHeaders:
- Type: PT_LOAD
Flags: [ PF_R ]
VAddr: 0x1000
Sections:
- Section: .text
- Type: PT_LOAD
Flags: [ PF_X, PF_R ]
VAddr: 0x3000
Sections:
- Section: .text3
- Type: PT_LOAD
Flags: [ PF_R ]
VAddr: 0x1000
FirstSec: .text
LastSec: .text
- Type: PT_LOAD
Flags: [ PF_X, PF_R ]
VAddr: 0x3000
FirstSec: .text3
LastSec: .text3
# CHECK: ProgramHeaders [
# CHECK-NEXT: ProgramHeader {

View File

@ -36,12 +36,10 @@ Sections:
AddressAlign: 0x1000
Size: 4096
ProgramHeaders:
- Type: PT_LOAD
Flags: [ PF_X, PF_R ]
Sections:
- Section: .text
- Section: .text2
- Section: .text3
- Type: PT_LOAD
Flags: [ PF_X, PF_R ]
FirstSec: .text
LastSec: .text3
## TODO (grimar): without the following line (i.e. without an empty symbol table),
## llvm-objcopy adds an empty .strtab section. It doesn't look correct.
Symbols: []

View File

@ -56,9 +56,9 @@ Sections:
Info: .text
ProgramHeaders:
# Use an arbitrary segment type to show that the segment type is unimportant.
- Type: 0x61234567
Sections:
- Section: .debug_in_segment
- Type: 0x61234567
FirstSec: .debug_in_segment
LastSec: .debug_in_segment
# CHECK: SectionHeaderCount: 8

View File

@ -70,9 +70,9 @@ Sections:
Type: SHT_PROGBITS
ProgramHeaders:
# Use an arbitrary segment type to show that the segment type is unimportant.
- Type: 0x61234567
Sections:
- Section: non_alloc_in_segment
- Type: 0x61234567
FirstSec: non_alloc_in_segment
LastSec: non_alloc_in_segment
# CHECK: SectionHeaderCount: 6

View File

@ -27,9 +27,9 @@ Sections:
Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
ProgramHeaders:
# Use an arbitrary segment type to show that the segment type is unimportant.
- Type: 0x61234567
Sections:
- Section: non_alloc_in_segment
- Type: 0x61234567
FirstSec: non_alloc_in_segment
LastSec: non_alloc_in_segment
# RUN: yaml2obj --docnum=2 %s -o %t2
# RUN: llvm-objcopy --strip-non-alloc %t2 %t2.out
@ -57,6 +57,6 @@ Sections:
Type: SHT_PROGBITS
Content: 00
ProgramHeaders:
- Type: 0x61234567
Sections:
- Section: .text
- Type: 0x61234567
FirstSec: .text
LastSec: .text

View File

@ -34,11 +34,10 @@ Sections:
Flags: [ ]
Content: "FEEDFACE"
ProgramHeaders:
- Type: PT_LOAD
Flags: [ PF_X, PF_R ]
Sections:
- Section: .text
- Section: .non_alloc_in_segment
- Type: PT_LOAD
Flags: [ PF_X, PF_R ]
FirstSec: .text
LastSec: .non_alloc_in_segment
# DATA: {{^[^[:blank:]]+}} de ad be ef ca fe ba be
# DATA-NOT: fe ed fa ce

View File

@ -40,32 +40,22 @@ Sections:
AddressAlign: 0x1000
Size: 4096
ProgramHeaders:
- Type: PT_LOAD
Flags: [ PF_X, PF_R ]
Sections:
- Section: .text4
- Section: .text5
- Type: PT_LOAD
Flags: [ PF_X, PF_R ]
Sections:
- Section: .text3
- Section: .text4
- Section: .text5
- Type: PT_LOAD
Flags: [ PF_X, PF_R ]
Sections:
- Section: .text
- Section: .text2
- Section: .text3
- Section: .text4
- Section: .text5
- Type: PT_LOAD
Flags: [ PF_X, PF_R ]
Sections:
- Section: .text2
- Section: .text3
- Section: .text4
- Section: .text5
- Type: PT_LOAD
Flags: [ PF_X, PF_R ]
FirstSec: .text4
LastSec: .text5
- Type: PT_LOAD
Flags: [ PF_X, PF_R ]
FirstSec: .text3
LastSec: .text5
- Type: PT_LOAD
Flags: [ PF_X, PF_R ]
FirstSec: .text
LastSec: .text5
- Type: PT_LOAD
Flags: [ PF_X, PF_R ]
FirstSec: .text2
LastSec: .text5
#CHECK: ProgramHeaders [
#CHECK-NEXT: ProgramHeader {

View File

@ -39,18 +39,16 @@ Sections:
Content: "FFFFFFFF"
Size: 0x1000
ProgramHeaders:
- Type: PT_LOAD
Flags: [ PF_R ]
VAddr: 0x1000
Sections:
- Section: .text
- Section: .text2
- Type: PT_LOAD
Flags: [ PF_R ]
VAddr: 0x3000
Sections:
- Section: .text3
- Section: .text4
- Type: PT_LOAD
Flags: [ PF_R ]
VAddr: 0x1000
FirstSec: .text
LastSec: .text2
- Type: PT_LOAD
Flags: [ PF_R ]
VAddr: 0x3000
FirstSec: .text3
LastSec: .text4
# CHECK: 000000 c3 c3 c3 c3
# CHECK: 001000 de ad be ef

View File

@ -39,18 +39,16 @@ Sections:
Content: "FFFFFFFF"
Size: 0x1000
ProgramHeaders:
- Type: PT_LOAD
Flags: [ PF_R ]
VAddr: 0x1000
Sections:
- Section: .text
- Section: .text2
- Type: PT_LOAD
Flags: [ PF_R ]
VAddr: 0x3000
Sections:
- Section: .text3
- Section: .text4
- Type: PT_LOAD
Flags: [ PF_R ]
VAddr: 0x1000
FirstSec: .text
LastSec: .text2
- Type: PT_LOAD
Flags: [ PF_R ]
VAddr: 0x3000
FirstSec: .text3
LastSec: .text4
# CHECK: 000000 de ad be ef
# CHECK: 001000 32 32 32 32

View File

@ -39,18 +39,16 @@ Sections:
Content: "FFFFFFFF"
Size: 0x1000
ProgramHeaders:
- Type: PT_LOAD
Flags: [ PF_R ]
VAddr: 0x1000
Sections:
- Section: .text
- Section: .text2
- Type: PT_LOAD
Flags: [ PF_R ]
VAddr: 0x3000
Sections:
- Section: .text3
- Section: .text4
- Type: PT_LOAD
Flags: [ PF_R ]
VAddr: 0x1000
FirstSec: .text
LastSec: .text2
- Type: PT_LOAD
Flags: [ PF_R ]
VAddr: 0x3000
FirstSec: .text3
LastSec: .text4
# CHECK: 000000 c3 c3 c3 c3
# CHECK: 001000 de ad be ef

View File

@ -28,12 +28,12 @@ Sections:
- Tag: DT_NULL
Value: 0
ProgramHeaders:
- Type: PT_LOAD
Sections:
- Section: .dynamic
- Type: PT_DYNAMIC
Sections:
- Section: .dynamic
- Type: PT_LOAD
FirstSec: .dynamic
LastSec: .dynamic
- Type: PT_DYNAMIC
FirstSec: .dynamic
LastSec: .dynamic
## Case 2: Test that MIPS machine-specific tags can be dumped.
## MIPS has a few long tag names. Show that we indent columns properly.
@ -190,12 +190,12 @@ Sections:
- Tag: DT_NULL
Value: 0
ProgramHeaders:
- Type: PT_LOAD
Sections:
- Section: .dynamic
- Type: PT_DYNAMIC
Sections:
- Section: .dynamic
- Type: PT_LOAD
FirstSec: .dynamic
LastSec: .dynamic
- Type: PT_DYNAMIC
FirstSec: .dynamic
LastSec: .dynamic
## Case 3: Test that PPC machine-specific tags can be dumped.
# RUN: yaml2obj --docnum=3 -o %t.ppc %s
@ -222,12 +222,12 @@ Sections:
- Tag: DT_NULL
Value: 0
ProgramHeaders:
- Type: PT_LOAD
Sections:
- Section: .dynamic
- Type: PT_DYNAMIC
Sections:
- Section: .dynamic
- Type: PT_LOAD
FirstSec: .dynamic
LastSec: .dynamic
- Type: PT_DYNAMIC
FirstSec: .dynamic
LastSec: .dynamic
## Case 4: Test that PPC64 machine-specific tags can be dumped.
# RUN: yaml2obj --docnum=4 -o %t.ppc64 %s
@ -251,12 +251,12 @@ Sections:
- Tag: DT_NULL
Value: 0
ProgramHeaders:
- Type: PT_LOAD
Sections:
- Section: .dynamic
- Type: PT_DYNAMIC
Sections:
- Section: .dynamic
- Type: PT_LOAD
FirstSec: .dynamic
LastSec: .dynamic
- Type: PT_DYNAMIC
FirstSec: .dynamic
LastSec: .dynamic
## Case 5: Test that AARCH64 machine-specific tags can be dumped.
# RUN: yaml2obj --docnum=5 -o %t.aarch64 %s
@ -283,9 +283,9 @@ Sections:
- Tag: DT_NULL
Value: 0
ProgramHeaders:
- Type: PT_LOAD
Sections:
- Section: .dynamic
- Type: PT_DYNAMIC
Sections:
- Section: .dynamic
- Type: PT_LOAD
FirstSec: .dynamic
LastSec: .dynamic
- Type: PT_DYNAMIC
FirstSec: .dynamic
LastSec: .dynamic

View File

@ -205,15 +205,14 @@ Sections:
- Tag: DT_NULL
Value: 0x0
ProgramHeaders:
- Type: PT_LOAD
VAddr: 0x1000
Sections:
- Section: .dynstr
- Section: .dynamic
- Type: PT_DYNAMIC
VAddr: 0x1010
Sections:
- Section: .dynamic
- Type: PT_LOAD
VAddr: 0x1000
FirstSec: .dynstr
LastSec: .dynamic
- Type: PT_DYNAMIC
VAddr: 0x1010
FirstSec: .dynamic
LastSec: .dynamic
# RUN: yaml2obj --docnum=2 %s -o %t2
# RUN: llvm-objdump -p %t2 | FileCheck %s --strict-whitespace --match-full-lines --check-prefix=ELF32
@ -421,15 +420,14 @@ Sections:
- Tag: DT_NULL
Value: 0x0
ProgramHeaders:
- Type: PT_LOAD
VAddr: 0x1000
Sections:
- Section: .dynstr
- Section: .dynamic
- Type: PT_DYNAMIC
VAddr: 0x1010
Sections:
- Section: .dynamic
- Type: PT_LOAD
VAddr: 0x1000
FirstSec: .dynstr
LastSec: .dynamic
- Type: PT_DYNAMIC
VAddr: 0x1010
FirstSec: .dynamic
LastSec: .dynamic
## When printing the value column we want to have the minimal possible indentation.
## Use an arbitrary dynamic tag to demonstrate that.

View File

@ -56,10 +56,10 @@ Sections:
Address: 0x1000
Content: 909090909090909090909090
ProgramHeaders:
- Type: PT_LOAD
VAddr: 0x1000
Sections:
- Section: .text
- Type: PT_LOAD
VAddr: 0x1000
FirstSec: .text
LastSec: .text
Symbols:
- Name: both_static
Value: 0x1001

View File

@ -94,17 +94,13 @@ ProgramHeaders:
- Type: PT_LOAD
VAddr: 0x100000
Align: 0x100
Sections:
- Section: .foo
- Section: .rela.dyn
- Section: .rela.plt
- Section: .rel.dyn
- Section: .dynamic
FirstSec: .foo
LastSec: .dynamic
- Type: PT_DYNAMIC
VAddr: 0x100500
Align: 0x100
Sections:
- Section: .dynamic
FirstSec: .dynamic
LastSec: .dynamic
DynamicSymbols:
- Name: foo
Section: .foo

View File

@ -33,16 +33,15 @@ Sections:
Content: "00000000"
Address: 0x00002000
ProgramHeaders:
- Type: PT_LOAD
Flags: [ PF_X, PF_R ]
VAddr: 0x00001000
PAddr: 0x00002000
Sections:
- Section: .text
- Section: .init
- Type: PT_LOAD
Flags: [ PF_R ]
VAddr: 0x00002000
PAddr: 0x00003000
Sections:
- Section: .data
- Type: PT_LOAD
Flags: [ PF_X, PF_R ]
VAddr: 0x00001000
PAddr: 0x00002000
FirstSec: .text
LastSec: .init
- Type: PT_LOAD
Flags: [ PF_R ]
VAddr: 0x00002000
PAddr: 0x00003000
FirstSec: .data
LastSec: .data

View File

@ -45,14 +45,13 @@ Sections:
Content: "00000000"
Address: 0x00002000
ProgramHeaders:
- Type: PT_LOAD
Flags: [ PF_X, PF_R ]
VAddr: 0x00001000
Sections:
- Section: .text
- Section: .init
- Type: PT_LOAD
Flags: [ PF_R ]
VAddr: 0x00002000
Sections:
- Section: .data
- Type: PT_LOAD
Flags: [ PF_X, PF_R ]
VAddr: 0x00001000
FirstSec: .text
LastSec: .init
- Type: PT_LOAD
Flags: [ PF_R ]
VAddr: 0x00002000
FirstSec: .data
LastSec: .data

View File

@ -40,22 +40,21 @@ Sections:
AddressAlign: 0x10
Size: 1
ProgramHeaders:
- Type: PT_LOAD
VAddr: 0x400
PAddr: 0x1000
Sections:
- Section: .text
- Section: .text2
- Type: PT_LOAD
VAddr: 0x410
PAddr: 0x2000
Sections:
- Section: .data
- Type: PT_LOAD
VAddr: 0x420
PAddr: 0x3000
Sections:
- Section: .bss
- Type: PT_LOAD
VAddr: 0x400
PAddr: 0x1000
FirstSec: .text
LastSec: .text2
- Type: PT_LOAD
VAddr: 0x410
PAddr: 0x2000
FirstSec: .data
LastSec: .data
- Type: PT_LOAD
VAddr: 0x420
PAddr: 0x3000
FirstSec: .bss
LastSec: .bss
## Test that --section works with --fault-map-section.
# RUN: yaml2obj %s --docnum=2 -o %t.o

View File

@ -151,9 +151,8 @@ ProgramHeaders:
Flags: [ PF_X, PF_R ]
VAddr: 0x1000
FileSize: 0x500
Sections:
- Section: .text
- Section: .text2
FirstSec: .text
LastSec: .text2
--- !ELF
FileHeader:
@ -172,8 +171,8 @@ ProgramHeaders:
Flags: [ PF_X, PF_R ]
VAddr: 0x1000
FileSize: 0x4
Sections:
- Section: .text
FirstSec: .text
LastSec: .text
--- !ELF
FileHeader:

View File

@ -97,20 +97,19 @@ Sections:
## An arbitrary linker-generated valid content.
Content: 040000001000000003000000474E55004FCB712AA6387724A9F465A32CD8C14B
ProgramHeaders:
- Type: PT_LOAD
VAddr: 0x1000
Sections:
- Section: .dynamic
- Section: .hash
- Type: PT_DYNAMIC
Sections:
- Section: .dynamic
- Type: PT_GNU_EH_FRAME
Sections:
- Section: .eh_frame_hdr
- Type: PT_NOTE
Sections:
- Section: .note.gnu.build-id
- Type: PT_LOAD
VAddr: 0x1000
FirstSec: .dynamic
LastSec: .hash
- Type: PT_DYNAMIC
FirstSec: .dynamic
LastSec: .dynamic
- Type: PT_GNU_EH_FRAME
FirstSec: .eh_frame_hdr
LastSec: .eh_frame_hdr
- Type: PT_NOTE
FirstSec: .note.gnu.build-id
LastSec: .note.gnu.build-id
Symbols: []
DynamicSymbols:
- Name: foo

View File

@ -44,10 +44,9 @@ Sections:
DynamicSymbols:
- StName: 0x1234
ProgramHeaders:
- Type: PT_LOAD
Sections:
- Section: .rela.dyn
- Section: .dynamic
- Type: PT_LOAD
FirstSec: .rela.dyn
LastSec: .dynamic
## Show we print a warning for an invalid relocation table size stored in a DT_RELASZ entry.
# RUN: yaml2obj --docnum=2 -DRELTYPE=RELA -DTAG1=DT_RELASZ -DTAG1VAL=0xFF -DTAG2=DT_RELAENT %s -o %t2
@ -77,10 +76,9 @@ Sections:
Value: 0x0
DynamicSymbols: []
ProgramHeaders:
- Type: PT_LOAD
Sections:
- Section: .relx.dyn
- Section: .dynamic
- Type: PT_LOAD
FirstSec: .relx.dyn
LastSec: .dynamic
## Show we print a warning for an invalid relocation table entry size stored in a DT_RELAENT entry.
# RUN: yaml2obj --docnum=2 -DRELTYPE=RELA -DTAG1=DT_RELASZ -DTAG2=DT_RELAENT -DTAG2VAL=0xFF %s -o %t3
@ -158,10 +156,9 @@ Sections:
Value: 0x0
DynamicSymbols: []
ProgramHeaders:
- Type: PT_LOAD
Sections:
- Section: .rela.plt
- Section: .dynamic
- Type: PT_LOAD
FirstSec: .rela.plt
LastSec: .dynamic
## Show we print a warning when dumping dynamic relocations if there is no dynamic symbol table.
# RUN: yaml2obj --docnum=4 %s -o %t11
@ -207,10 +204,9 @@ Sections:
- Tag: DT_NULL
Value: 0x0
ProgramHeaders:
- Type: PT_LOAD
Sections:
- Section: .rela.dyn
- Section: .dynamic
- Type: PT_LOAD
FirstSec: .rela.dyn
LastSec: .dynamic
## Show we print a warning when the symbol index of a dynamic relocation is too
## large (goes past the end of the dynamic symbol table).
@ -254,10 +250,9 @@ Sections:
DynamicSymbols:
- Name: foo
ProgramHeaders:
- Type: PT_LOAD
Sections:
- Section: .rela.dyn
- Section: .dynamic
- Type: PT_LOAD
FirstSec: .rela.dyn
LastSec: .dynamic
## Show that when we have both REL and RELA relocations, we dump both sets.
# RUN: yaml2obj --docnum=6 %s -o %t13
@ -314,11 +309,9 @@ Sections:
Value: 0x0
DynamicSymbols: []
ProgramHeaders:
- Type: PT_LOAD
Sections:
- Section: .rela.dyn
- Section: .rel.dyn
- Section: .dynamic
- Type: PT_LOAD
FirstSec: .rela.dyn
LastSec: .dynamic
## Check that llvm-readobj/llvm-readelf reports a warning when dumping a relocation
## which refers to a symbol past the end of the file.
@ -402,14 +395,12 @@ Sections:
DynamicSymbols:
- Name: foo
ProgramHeaders:
- Type: PT_LOAD
Offset: 0x0
Sections:
- Section: .dynamic
- Section: .rela.dyn
- Section: .dynsym
- Type: PT_DYNAMIC
Sections:
- Section: .dynamic
- Type: PT_LOAD
Offset: 0x0
FirstSec: .dynamic
LastSec: .dynsym
- Type: PT_DYNAMIC
FirstSec: .dynamic
LastSec: .dynamic
SectionHeaderTable:
NoHeaders: true

View File

@ -40,6 +40,6 @@ Sections:
Value: 0
Symbols: []
ProgramHeaders:
- Type: PT_DYNAMIC
Sections:
- Section: .dynamic
- Type: PT_DYNAMIC
FirstSec: .dynamic
LastSec: .dynamic

View File

@ -216,17 +216,13 @@ DynamicSymbols:
- Name: _Z3fooi
Binding: STB_GLOBAL
ProgramHeaders:
- Type: PT_LOAD
Flags: [ PF_R, PF_X ]
VAddr: 0x0
Sections:
- Section: .dynstr
- Section: .dynsym
- Section: .rela.dyn
- Section: .dynamic
- Section: .text.foo
- Type: PT_DYNAMIC
Flags: [ PF_R ]
VAddr: 0x1000
Sections:
- Section: .dynamic
- Type: PT_LOAD
Flags: [ PF_R, PF_X ]
VAddr: 0x0
FirstSec: .dynstr
LastSec: .text.foo
- Type: PT_DYNAMIC
Flags: [ PF_R ]
VAddr: 0x1000
FirstSec: .dynamic
LastSec: .dynamic

View File

@ -123,22 +123,18 @@ DynamicSymbols:
Section: .data
Value: 0x200
ProgramHeaders:
- Type: PT_LOAD
VAddr: 0
Sections:
- Section: .text
- Section: .data
- Type: PT_LOAD
VAddr: 0x400
Sections:
- Section: .dynsym
- Section: .hash
- Section: .dynstr
- Section: .dynamic
- Type: PT_DYNAMIC
VAddr: 0xA00
Sections:
- Section: .dynamic
- Type: PT_LOAD
VAddr: 0
FirstSec: .text
LastSec: .data
- Type: PT_LOAD
VAddr: 0x400
FirstSec: .dynsym
LastSec: .dynamic
- Type: PT_DYNAMIC
VAddr: 0xA00
FirstSec: .dynamic
LastSec: .dynamic
## Case 2: Table size from DT_HASH does not match size from section header.
# RUN: yaml2obj --docnum=2 %s -o %t2-smaller -DCHAIN="[1, 2]"
@ -290,22 +286,18 @@ DynamicSymbols:
Section: .data
Value: 0x300
ProgramHeaders:
- Type: PT_LOAD
VAddr: 0
Sections:
- Section: .text
- Section: .data
- Type: PT_LOAD
VAddr: 0x400
Sections:
- Section: .dynsym
- Section: .hash
- Section: .dynstr
- Section: .dynamic
- Type: PT_DYNAMIC
VAddr: 0xA00
Sections:
- Section: .dynamic
- Type: PT_LOAD
VAddr: 0
FirstSec: .text
LastSec: .data
- Type: PT_LOAD
VAddr: 0x400
FirstSec: .dynsym
LastSec: .dynamic
- Type: PT_DYNAMIC
VAddr: 0xA00
FirstSec: .dynamic
LastSec: .dynamic
## Case 3: DT_HASH is missing.
## Show that no warning occurs if there are section headers.
@ -409,9 +401,7 @@ Sections:
NChain: 0xFFFFFFFF
DynamicSymbols: []
ProgramHeaders:
- Type: PT_LOAD
Sections:
- Section: .rela.plt
- Section: .dynamic
- Section: .hash
- Type: PT_LOAD
FirstSec: .rela.plt
LastSec: .hash
VAddr: 0x1000

View File

@ -63,10 +63,10 @@ DynamicSymbols:
- Name: foo
- Name: bar
ProgramHeaders:
- Type: PT_LOAD
VAddr: 0x100
Sections:
- Section: .dynsym
- Type: PT_LOAD
VAddr: 0x100
FirstSec: .dynsym
LastSec: .dynsym
## Case 2: Check the output for aliases.
## a) Check the two-letter alias --dt is equivalent to the --dyn-symbols
@ -201,10 +201,10 @@ Sections:
DynamicSymbols:
- Name: foo
ProgramHeaders:
- Type: PT_LOAD
VAddr: 0x0000
Sections:
- Section: .dynsym
- Type: PT_LOAD
VAddr: 0x0000
FirstSec: .dynsym
LastSec: .dynsym
## Case 6: Check that if we can get the location of the dynamic symbol table using both the DT_SYMTAB value
## and the section headers table then we prefer the former and report a warning.
@ -238,10 +238,10 @@ Sections:
DynamicSymbols:
- Name: foo
ProgramHeaders:
- Type: PT_LOAD
VAddr: 0x0000
Sections:
- Section: .mydynsym
- Type: PT_LOAD
VAddr: 0x0000
FirstSec: .mydynsym
LastSec: .mydynsym
## Case 7: Check how we dump versioned symbols. Use both -V and --dyn-symbols
## to check that printed version is consistent.
@ -488,10 +488,10 @@ Sections:
Address: 0x100
Size: 0x1
ProgramHeaders:
- Type: PT_LOAD
VAddr: 0x100
Sections:
- Section: .dynsym
- Type: PT_LOAD
VAddr: 0x100
FirstSec: .dynsym
LastSec: .dynsym
--- !ELF
FileHeader:
@ -582,11 +582,10 @@ DynamicSymbols:
## An arbitrary valid symbol to document we report an error before dumping it.
- StName: 0x1
ProgramHeaders:
- Type: PT_LOAD
Flags: [ PF_R ]
Sections:
- Section: .dynstr
- Section: .dynamic
- Type: PT_LOAD
Flags: [ PF_R ]
FirstSec: .dynstr
LastSec: .dynamic
## Case 11: check various warnings we report when fields of the SHT_DYNSYM section are broken.

View File

@ -18,11 +18,11 @@ Sections:
Type: SHT_DYNAMIC
Address: 0x1000
ProgramHeaders:
- Type: PT_LOAD
VAddr: 0x1000
Sections:
- Section: .dynamic
- Type: PT_DYNAMIC
VAddr: 0x1000
Sections:
- Section: .dynamic
- Type: PT_LOAD
VAddr: 0x1000
FirstSec: .dynamic
LastSec: .dynamic
- Type: PT_DYNAMIC
VAddr: 0x1000
FirstSec: .dynamic
LastSec: .dynamic

View File

@ -35,14 +35,14 @@ Sections:
Content: "01234567"
Symbols: []
ProgramHeaders:
- Type: PT_LOAD
VAddr: 0x1000
Sections:
- Section: .dynamic
- Type: PT_DYNAMIC
VAddr: 0x1000
Sections:
- Section: .dynamic
- Type: PT_LOAD
VAddr: 0x1000
FirstSec: .dynamic
LastSec: .dynamic
- Type: PT_DYNAMIC
VAddr: 0x1000
FirstSec: .dynamic
LastSec: .dynamic
## Test handling of a .dynamic section with an invalid entsize (i.e. not 2 * sizeof(Elf_Dyn)).
# RUN: yaml2obj %s --docnum=2 -o %t.bad-entsize
@ -77,14 +77,14 @@ Sections:
Value: 0
Symbols: []
ProgramHeaders:
- Type: PT_LOAD
VAddr: 0x1000
Sections:
- Section: .dynamic
- Type: PT_DYNAMIC
VAddr: 0x1000
Sections:
- Section: .dynamic
- Type: PT_LOAD
VAddr: 0x1000
FirstSec: .dynamic
LastSec: .dynamic
- Type: PT_DYNAMIC
VAddr: 0x1000
FirstSec: .dynamic
LastSec: .dynamic
## Test handling of string references pointing past the end of the dynamic string table.
# RUN: yaml2obj %s --docnum=3 -o %t.bad-string
@ -171,15 +171,14 @@ Sections:
Value: 0
Symbols: []
ProgramHeaders:
- Type: PT_LOAD
VAddr: 0x1000
Sections:
- Section: .dynstr
- Section: .dynamic
- Type: PT_DYNAMIC
VAddr: 0x1010
Sections:
- Section: .dynamic
- Type: PT_LOAD
VAddr: 0x1000
FirstSec: .dynstr
LastSec: .dynamic
- Type: PT_DYNAMIC
VAddr: 0x1010
FirstSec: .dynamic
LastSec: .dynamic
## Test handling of DT_STRTAB pointing outside the file's address space.
# RUN: yaml2obj %s --docnum=4 -o %t.bad-strtab
@ -226,14 +225,14 @@ Sections:
Value: 0x0
Symbols: []
ProgramHeaders:
- Type: PT_LOAD
VAddr: 0x1000
Sections:
- Section: .dynamic
- Type: PT_DYNAMIC
VAddr: 0x1000
Sections:
- Section: .dynamic
- Type: PT_LOAD
VAddr: 0x1000
FirstSec: .dynamic
LastSec: .dynamic
- Type: PT_DYNAMIC
VAddr: 0x1000
FirstSec: .dynamic
LastSec: .dynamic
## Test handling of other d_ptr tags pointing outside the file's address space.
# RUN: yaml2obj %s --docnum=5 -o %t.bad-rela
@ -268,14 +267,14 @@ Sections:
Value: 0x0
Symbols: []
ProgramHeaders:
- Type: PT_LOAD
VAddr: 0x1000
Sections:
- Section: .dynamic
- Type: PT_DYNAMIC
VAddr: 0x1000
Sections:
- Section: .dynamic
- Type: PT_LOAD
VAddr: 0x1000
FirstSec: .dynamic
LastSec: .dynamic
- Type: PT_DYNAMIC
VAddr: 0x1000
FirstSec: .dynamic
LastSec: .dynamic
## Check how we handle cases when the dynamic string table is not null-terminated.
@ -365,15 +364,14 @@ Sections:
- Tag: DT_NULL
Value: 0
ProgramHeaders:
- Type: PT_LOAD
VAddr: 0x1000
Sections:
- Section: .dynstr
- Section: .dynamic
- Type: PT_DYNAMIC
VAddr: 0x1100
Sections:
- Section: .dynamic
- Type: PT_LOAD
VAddr: 0x1000
FirstSec: .dynstr
LastSec: .dynamic
- Type: PT_DYNAMIC
VAddr: 0x1100
FirstSec: .dynamic
LastSec: .dynamic
## Check that we emit an appropriate warning when the dynamic string table ends past the end of the file.

View File

@ -32,7 +32,7 @@ Sections:
- Tag: DT_NULL
Value: 0
ProgramHeaders:
- Type: PT_LOAD
VAddr: 0x1000
Sections:
- Section: .dynamic
- Type: PT_LOAD
VAddr: 0x1000
FirstSec: .dynamic
LastSec: .dynamic

View File

@ -50,15 +50,14 @@ Sections:
AddressAlign: 0x100
Content: "00"
ProgramHeaders:
- Type: PT_LOAD
VAddr: 0x1000
Sections:
- Section: .dynamic
- Section: .text
- Type: PT_DYNAMIC
VAddr: 0x1000
Sections:
- Section: .text
- Type: PT_LOAD
VAddr: 0x1000
FirstSec: .dynamic
LastSec: .text
- Type: PT_DYNAMIC
VAddr: 0x1000
FirstSec: .text
LastSec: .text
## Case 2: The dynamic table found using the dynamic program header is different from the
## table found using the section header table.
@ -104,15 +103,14 @@ Sections:
AddressAlign: 0x100
Content: "00000000000000000000000000000000"
ProgramHeaders:
- Type: PT_LOAD
VAddr: 0x1000
Sections:
- Section: .dynamic
- Section: .text
- Type: PT_DYNAMIC
VAddr: 0x1000
Sections:
- Section: .text
- Type: PT_LOAD
VAddr: 0x1000
FirstSec: .dynamic
LastSec: .text
- Type: PT_DYNAMIC
VAddr: 0x1000
FirstSec: .text
LastSec: .text
## Case 3: Both dynamic tables found using SHT_DYNAMIC/PT_DYNAMIC are corrupted.
@ -145,12 +143,11 @@ Sections:
AddressAlign: 0x100
Content: "00"
ProgramHeaders:
- Type: PT_LOAD
VAddr: 0x1000
Sections:
- Section: .dynamic
- Section: .text
- Type: PT_DYNAMIC
VAddr: 0x1000
Sections:
- Section: .text
- Type: PT_LOAD
VAddr: 0x1000
FirstSec: .dynamic
LastSec: .text
- Type: PT_DYNAMIC
VAddr: 0x1000
FirstSec: .text
LastSec: .text

View File

@ -53,14 +53,11 @@ Sections:
DynamicSymbols:
- Name: foo
ProgramHeaders:
- Type: PT_LOAD
Sections:
- Section: .rela.dyn
- Section: .dynamic
Section: .dynsym
Section: .dynstr
- Type: PT_DYNAMIC
Sections:
- Section: .dynamic
- Type: PT_LOAD
FirstSec: .rela.dyn
LastSec: .dynstr
- Type: PT_DYNAMIC
FirstSec: .dynamic
LastSec: .dynamic
SectionHeaderTable:
NoHeaders: true

View File

@ -125,10 +125,6 @@ Symbols:
DynamicSymbols:
- Name: foo
ProgramHeaders:
- Type: PT_LOAD
Sections:
- Section: .rela.dyn
- Section: .rel.dyn
- Section: .relr.dyn
- Section: .plt
- Section: .dynamic
- Type: PT_LOAD
FirstSec: .rela.dyn
LastSec: .dynamic

View File

@ -25,12 +25,12 @@ Sections:
- Tag: DT_DEBUG
Value: 0x0000000000000000
ProgramHeaders:
- Type: PT_LOAD
Sections:
- Section: .dynamic
- Type: PT_DYNAMIC
Sections:
- Section: .dynamic
- Type: PT_LOAD
FirstSec: .dynamic
LastSec: .dynamic
- Type: PT_DYNAMIC
FirstSec: .dynamic
LastSec: .dynamic
# Sometimes .dynamic section content length can be greater than the
# length of its entries. In this case, we should not try to dump anything
@ -67,9 +67,9 @@ Sections:
- Tag: DT_NULL
Value: 0x0000000000000000
ProgramHeaders:
- Type: PT_LOAD
Sections:
- Section: .dynamic
- Type: PT_DYNAMIC
Sections:
- Section: .dynamic
- Type: PT_LOAD
FirstSec: .dynamic
LastSec: .dynamic
- Type: PT_DYNAMIC
FirstSec: .dynamic
LastSec: .dynamic

View File

@ -39,12 +39,12 @@ Sections:
- Tag: DT_NULL
Value: 0
ProgramHeaders:
- Type: PT_LOAD
Sections:
- Section: .dynamic
- Type: PT_DYNAMIC
Sections:
- Section: .dynamic
- Type: PT_LOAD
FirstSec: .dynamic
LastSec: .dynamic
- Type: PT_DYNAMIC
FirstSec: .dynamic
LastSec: .dynamic
## Case 2: Test that MIPS machine-specific tags can be dumped.
# RUN: yaml2obj --docnum=2 %s -o %t.mips
@ -259,12 +259,12 @@ Sections:
- Tag: DT_NULL
Value: 0
ProgramHeaders:
- Type: PT_LOAD
Sections:
- Section: .dynamic
- Type: PT_DYNAMIC
Sections:
- Section: .dynamic
- Type: PT_LOAD
FirstSec: .dynamic
LastSec: .dynamic
- Type: PT_DYNAMIC
FirstSec: .dynamic
LastSec: .dynamic
## Case 3: Test that PPC machine-specific tags can be dumped.
# RUN: yaml2obj --docnum=3 %s -o %t.ppc
@ -301,12 +301,12 @@ Sections:
- Tag: DT_NULL
Value: 0
ProgramHeaders:
- Type: PT_LOAD
Sections:
- Section: .dynamic
- Type: PT_DYNAMIC
Sections:
- Section: .dynamic
- Type: PT_LOAD
FirstSec: .dynamic
LastSec: .dynamic
- Type: PT_DYNAMIC
FirstSec: .dynamic
LastSec: .dynamic
## Case 4: Test that PPC64 machine-specific tags can be dumped.
# RUN: yaml2obj --docnum=4 %s -o %t.ppc64
@ -339,12 +339,12 @@ Sections:
- Tag: DT_NULL
Value: 0
ProgramHeaders:
- Type: PT_LOAD
Sections:
- Section: .dynamic
- Type: PT_DYNAMIC
Sections:
- Section: .dynamic
- Type: PT_LOAD
FirstSec: .dynamic
LastSec: .dynamic
- Type: PT_DYNAMIC
FirstSec: .dynamic
LastSec: .dynamic
## Case 5: Test that AARCH64 machine-specific tags can be dumped.
# RUN: yaml2obj --docnum=5 %s -o %t.aarch64
@ -381,9 +381,9 @@ Sections:
- Tag: DT_NULL
Value: 0
ProgramHeaders:
- Type: PT_LOAD
Sections:
- Section: .dynamic
- Type: PT_DYNAMIC
Sections:
- Section: .dynamic
- Type: PT_LOAD
FirstSec: .dynamic
LastSec: .dynamic
- Type: PT_DYNAMIC
FirstSec: .dynamic
LastSec: .dynamic

View File

@ -281,15 +281,14 @@ Sections:
- Tag: DT_NULL
Value: 0x0
ProgramHeaders:
- Type: PT_LOAD
VAddr: 0x1000
Sections:
- Section: .dynstr
- Section: .dynamic
- Type: PT_DYNAMIC
VAddr: 0x1010
Sections:
- Section: .dynamic
- Type: PT_LOAD
VAddr: 0x1000
FirstSec: .dynstr
LastSec: .dynamic
- Type: PT_DYNAMIC
VAddr: 0x1010
FirstSec: .dynamic
LastSec: .dynamic
# RUN: yaml2obj %s --docnum=1 -DBITS=32 -DSYMBOLIC=0x12345678 -DDEBUG=0xfedcba09 \
# RUN: -DTEXTREL=0x11223344 -DBINDNOW=0x88776655 -DFLAGS=0xffffffff \

View File

@ -104,10 +104,10 @@ Sections:
AddressAlign: 0x0000000000000004
Content: 040000000900000004000000474E5500676F6C6420312E3131000000
ProgramHeaders:
- Type: PT_NOTE
- Type: PT_NOTE
FileSize: 0x20
Sections:
- Section: .note.gnu.build-id
FirstSec: .note.gnu.build-id
LastSec: .note.gnu.build-id
## Test tools report an error if a note section has an invalid offset
## that goes past the end of file.
@ -186,10 +186,10 @@ Sections:
Type: SHT_NOTE
Notes: []
ProgramHeaders:
- Type: PT_NOTE
- Type: PT_NOTE
FileSize: 0xffff0000
Sections:
- Section: .note
FirstSec: .note
LastSec: .note
## Check we report a warning when we are unable to locate the PT_NOTE
## segment because of broken program headers.

View File

@ -39,19 +39,17 @@ Sections:
Size: 0x4
ProgramHeaders:
## Case 1: an arbitrary segment with sections.
- Type: PT_PHDR
Flags: [ PF_W ]
VAddr: 0x1000
Sections:
- Section: .foo.begin
- Section: .foo.end
- Type: PT_PHDR
Flags: [ PF_W ]
VAddr: 0x1000
FirstSec: .foo.begin
LastSec: .foo.end
## Case 2: another segment with different sections.
- Type: PT_PHDR
Flags: [ PF_X ]
VAddr: 0x2000
Sections:
- Section: .bar.begin
- Section: .bar.end
- Type: PT_PHDR
Flags: [ PF_X ]
VAddr: 0x2000
FirstSec: .bar.begin
LastSec: .bar.end
## Check that --section-mapping=false --program-headers produces just program headers.
# RUN: llvm-readelf --section-mapping=false --program-headers %t64.elf \

View File

@ -57,11 +57,10 @@ DynamicSymbols:
- Name: ddd
Binding: STB_GLOBAL
ProgramHeaders:
- Type: PT_LOAD
Flags: [ PF_R, PF_X ]
Sections:
- Section: .gnu.hash
- Section: .dynamic
- Type: PT_LOAD
Flags: [ PF_R, PF_X ]
FirstSec: .gnu.hash
LastSec: .dynamic
## Check we report a warning if there is no dynamic symbol section in the object.
@ -103,11 +102,10 @@ Sections:
- Tag: DT_NULL
Value: 0x0
ProgramHeaders:
- Type: PT_LOAD
Flags: [ PF_R, PF_X ]
Sections:
- Section: .gnu.hash
- Section: .dynamic
- Type: PT_LOAD
Flags: [ PF_R, PF_X ]
FirstSec: .gnu.hash
LastSec: .dynamic
## Check what we do when the index of the first symbol in the dynamic symbol table
## included in the hash table is larger than the number of dynamic symbols.
@ -156,11 +154,10 @@ DynamicSymbols:
- Name: aaa
Binding: STB_GLOBAL
ProgramHeaders:
- Type: PT_LOAD
Flags: [ PF_R, PF_X ]
Sections:
- Section: .gnu.hash
- Section: .dynamic
- Type: PT_LOAD
Flags: [ PF_R, PF_X ]
FirstSec: .gnu.hash
LastSec: .dynamic
## Check we emit a warning when the dynamic symbol table is empty.
## A valid dynamic symbol table should have at least one symbol: the symbol with index 0.
@ -209,11 +206,10 @@ Sections:
Type: SHT_DYNSYM
Size: 0
ProgramHeaders:
- Type: PT_LOAD
Flags: [ PF_R, PF_X ]
Sections:
- Section: .gnu.hash
- Section: .dynamic
- Type: PT_LOAD
Flags: [ PF_R, PF_X ]
FirstSec: .gnu.hash
LastSec: .dynamic
## Linkers might produce an empty no-op SHT_GNU_HASH section when
## there are no dynamic symbols or when all dynamic symbols are undefined.
@ -277,11 +273,10 @@ Sections:
Value: 0x0
DynamicSymbols: []
ProgramHeaders:
- Type: PT_LOAD
Flags: [ PF_R, PF_X ]
Sections:
- Section: .gnu.hash
- Section: .dynamic
- Type: PT_LOAD
Flags: [ PF_R, PF_X ]
FirstSec: .gnu.hash
LastSec: .dynamic
## Check we report a proper warning when a hash table goes past the end of the file.

View File

@ -63,11 +63,9 @@ DynamicSymbols:
- Name: c
- Name: d
ProgramHeaders:
- Type: PT_LOAD
Sections:
- Section: .hash
- Section: .gnu.hash
- Section: .dynamic
- Type: PT_LOAD
FirstSec: .hash
LastSec: .dynamic
## Show that we report a warning for a hash table which contains an entry of
## the bucket array pointing to a cycle.
@ -106,10 +104,9 @@ Sections:
DynamicSymbols:
- Name: foo
ProgramHeaders:
- Type: PT_LOAD
Sections:
- Section: .hash
- Section: .dynamic
- Type: PT_LOAD
FirstSec: .hash
LastSec: .dynamic
## Each SHT_HASH section starts with two 32-bit fields: nbucket and nchain.
## Check we report an error when a DT_HASH value points to data that has size less than 8 bytes.
@ -142,9 +139,8 @@ DynamicSymbols: []
ProgramHeaders:
- Type: PT_LOAD
FileSize: 0x23a
Sections:
- Section: .hash
- Section: .dynamic
FirstSec: .hash
LastSec: .dynamic
## Check we report a warning when the hash table goes past the end of the file.
@ -201,10 +197,9 @@ Sections:
Value: 0x0
DynamicSymbols: []
ProgramHeaders:
- Type: PT_LOAD
Sections:
- Section: .hash
- Section: .dynamic
- Type: PT_LOAD
FirstSec: .hash
LastSec: .dynamic
## Check we dump a histogram for the .gnu.hash table even when the .hash table is skipped.
@ -258,11 +253,9 @@ Sections:
DynamicSymbols:
- Name: foo
ProgramHeaders:
- Type: PT_LOAD
Sections:
- Section: .hash
- Section: .gnu.hash
- Section: .dynamic
- Type: PT_LOAD
FirstSec: .hash
LastSec: .dynamic
## Check we report a proper warning when the GNU hash table goes past the end of the file.
@ -308,10 +301,9 @@ Sections:
Value: 0x0
DynamicSymbols: []
ProgramHeaders:
- Type: PT_LOAD
Sections:
- Section: .gnu.hash
- Section: .dynamic
- Type: PT_LOAD
FirstSec: .gnu.hash
LastSec: .dynamic
## Linkers might produce an empty no-op SHT_GNU_HASH section when
## there are no dynamic symbols or when all dynamic symbols are undefined.
@ -369,10 +361,9 @@ Sections:
Value: 0x0
DynamicSymbols: []
ProgramHeaders:
- Type: PT_LOAD
Sections:
- Section: .gnu.hash
- Section: .dynamic
- Type: PT_LOAD
FirstSec: .gnu.hash
LastSec: .dynamic
## Check we report warnings when the dynamic symbol table is absent or empty.
@ -416,6 +407,6 @@ Sections:
Type: [[TYPE]]
Size: 0
ProgramHeaders:
- Type: PT_LOAD
Sections:
- Section: .gnu.hash
- Type: PT_LOAD
FirstSec: .gnu.hash
LastSec: .gnu.hash

View File

@ -104,12 +104,10 @@ DynamicSymbols:
Value: 0x0000000000001001
Type: [[TYPE=STT_NOTYPE]]
ProgramHeaders:
- Type: PT_LOAD
Flags: [ PF_R, PF_X ]
Sections:
- Section: .hash
- Section: .gnu.hash
- Section: .dynamic
- Type: PT_LOAD
Flags: [ PF_R, PF_X ]
FirstSec: .hash
LastSec: .dynamic
## Check what we print for unnamed section symbols.
# RUN: yaml2obj --docnum=1 -DBITS=64 -DTYPE=STT_SECTION -DNAME="''" %s -o %t1-sec-syms.so
@ -188,11 +186,10 @@ DynamicSymbols:
Binding: STB_WEAK
Value: 0x0000000000001001
ProgramHeaders:
- Type: PT_LOAD
Flags: [ PF_R, PF_X ]
Sections:
- Section: .hash
- Section: .dynamic
- Type: PT_LOAD
Flags: [ PF_R, PF_X ]
FirstSec: .hash
LastSec: .dynamic
## Check the output when only .gnu.hash section is present.
@ -252,11 +249,10 @@ DynamicSymbols:
Binding: STB_WEAK
Value: 0x0000000000001001
ProgramHeaders:
- Type: PT_LOAD
Flags: [ PF_R, PF_X ]
Sections:
- Section: .gnu.hash
- Section: .dynamic
- Type: PT_LOAD
Flags: [ PF_R, PF_X ]
FirstSec: .gnu.hash
LastSec: .dynamic
## Show that if there are no hash sections, we do not print anything.
# RUN: yaml2obj --docnum=4 %s -o %t4.so
@ -317,19 +313,16 @@ DynamicSymbols:
- Name: _Z3fooi
Binding: STB_GLOBAL
ProgramHeaders:
- Type: PT_LOAD
Flags: [ PF_R, PF_X ]
VAddr: 0x0
Sections:
- Section: .dynstr
- Section: .dynsym
- Section: .dynamic
- Section: .text.foo
- Type: PT_DYNAMIC
Flags: [ PF_R ]
VAddr: 0x1000
Sections:
- Section: .dynamic
- Type: PT_LOAD
Flags: [ PF_R, PF_X ]
VAddr: 0x0
FirstSec: .dynstr
LastSec: .text.foo
- Type: PT_DYNAMIC
Flags: [ PF_R ]
VAddr: 0x1000
FirstSec: .dynamic
LastSec: .dynamic
## Show that we report a warning for a hash table which contains an entry of
## the bucket array pointing to a cycle.
@ -365,10 +358,9 @@ DynamicSymbols:
- Name: aaa
- Name: bbb
ProgramHeaders:
- Type: PT_LOAD
Sections:
- Section: .hash
- Section: .dynamic
- Type: PT_LOAD
FirstSec: .hash
LastSec: .dynamic
## Each SHT_HASH section starts with two 32-bit fields: nbucket and nchain.
## Check we report an error when a DT_HASH value points to data that has size less than 8 bytes.
@ -401,9 +393,8 @@ DynamicSymbols: []
ProgramHeaders:
- Type: PT_LOAD
FileSize: 0x23a
Sections:
- Section: .hash
- Section: .dynamic
FirstSec: .hash
LastSec: .dynamic
## Check we report a warning when the hash table goes past the end of the file.
@ -465,10 +456,9 @@ Sections:
Value: 0x0
DynamicSymbols: []
ProgramHeaders:
- Type: PT_LOAD
Sections:
- Section: .hash
- Section: .dynamic
- Type: PT_LOAD
FirstSec: .hash
LastSec: .dynamic
## Check we report a proper warning when a GNU hash table goes past the end of the file.
@ -524,11 +514,10 @@ DynamicSymbols:
- Name: ddd
Binding: STB_GLOBAL
ProgramHeaders:
- Type: PT_LOAD
Flags: [ PF_R, PF_X ]
Sections:
- Section: .gnu.hash
- Section: .dynamic
- Type: PT_LOAD
Flags: [ PF_R, PF_X ]
FirstSec: .gnu.hash
LastSec: .dynamic
## Check the behavior when the dynamic symbol table is empty or not found.
@ -576,12 +565,10 @@ Sections:
Flags: [ SHF_ALLOC ]
Size: 0
ProgramHeaders:
- Type: PT_LOAD
Flags: [ PF_R, PF_X ]
Sections:
- Section: .hash
- Section: .dynamic
- Section: .dynstr
- Type: PT_LOAD
Flags: [ PF_R, PF_X ]
FirstSec: .hash
LastSec: .dynstr
## Case A.2: similar to A.1, but now check that we report a warning when the dynamic symbol table was not found.
## To do that, set the type of the .dynsym to SHT_PROGBITS to hide it.
@ -649,12 +636,10 @@ Sections:
Flags: [ SHF_ALLOC ]
Size: 0
ProgramHeaders:
- Type: PT_LOAD
Flags: [ PF_R, PF_X ]
Sections:
- Section: .gnu.hash
- Section: .dynamic
- Section: .dynstr
- Type: PT_LOAD
Flags: [ PF_R, PF_X ]
FirstSec: .gnu.hash
LastSec: .dynstr
## In this case we have a broken value in the hash buckets array. Normally it contains an
## index into the dynamic symbol table and also is used to get a hash value from the hash values array.
@ -699,11 +684,10 @@ DynamicSymbols:
- Name: foo
Binding: STB_GLOBAL
ProgramHeaders:
- Type: PT_LOAD
Flags: [ PF_R, PF_X ]
Sections:
- Section: .gnu.hash
- Section: .dynamic
- Type: PT_LOAD
Flags: [ PF_R, PF_X ]
FirstSec: .gnu.hash
LastSec: .dynamic
## In this case we are unable to read a hash value for a symbol with
## an index that is less than the index of the first hashed symbol.

View File

@ -38,10 +38,9 @@ Sections:
- Tag: DT_NULL
Value: 0x0
ProgramHeaders:
- Type: PT_LOAD
Sections:
- Section: .hash
- Section: .dynamic
- Type: PT_LOAD
FirstSec: .hash
LastSec: .dynamic
## Document that we ignore the sh_entsize value when dumping the hash section.
## Implementation assumes that the size of entries is 4, matching the ELF specification.
@ -117,14 +116,13 @@ Sections:
SectionHeaderTable:
NoHeaders: [[NOHEADERS=false]]
ProgramHeaders:
- Type: PT_LOAD
Sections:
- Section: .hash
- Section: .dynamic
- Type: PT_DYNAMIC
VAddr: 0x10
Sections:
- Section: .dynamic
- Type: PT_LOAD
FirstSec: .hash
LastSec: .dynamic
- Type: PT_DYNAMIC
VAddr: 0x10
FirstSec: .dynamic
LastSec: .dynamic
## Document we don't report a warning when the value of the sh_entsize field of the SHT_HASH section is not 4.
@ -179,9 +177,8 @@ DynamicSymbols: []
ProgramHeaders:
- Type: PT_LOAD
FileSize: 0x23a
Sections:
- Section: .hash
- Section: .dynamic
FirstSec: .hash
LastSec: .dynamic
## Check we report a warning when the hash table goes past the end of the file.
@ -274,10 +271,9 @@ Sections:
Value: 0x0
DynamicSymbols: []
ProgramHeaders:
- Type: PT_LOAD
Sections:
- Section: .hash
- Section: .dynamic
- Type: PT_LOAD
FirstSec: .hash
LastSec: .dynamic
## Show we do not duplicate warnings when printing both the hash table and the hash histogram.
## Note that --elf-hash-histogram is only implemented for llvm-readelf currently.

View File

@ -47,9 +47,8 @@ ProgramHeaders:
Flags: [ PF_R ]
VAddr: 0x0000
FileSize: [[PHDRFILESIZE]]
Sections:
- Section: .dynstr
- Section: .dynamic
FirstSec: .dynstr
LastSec: .dynamic
## Check we do not crash when an object contains a DT_STRTAB entry whose address
## is past the end of the object.

View File

@ -140,7 +140,7 @@ Sections:
ProgramHeaders:
- Type: PT_DYNAMIC
FileSize: [[FILESIZE=<none>]]
Sections:
- Section: .dynamic
FirstSec: .dynamic
LastSec: .dynamic
SectionHeaderTable:
NoHeaders: [[NOHEADERS=false]]

View File

@ -51,9 +51,8 @@ Sections:
ProgramHeaders:
- Type: PT_LOAD
VAddr: 0x0
Sections:
- Section: .dynstr
- Section: .dynamic
FirstSec: .dynstr
LastSec: .dynamic
## Check what we print when the dynamic string table is empty.
# RUN: yaml2obj %s --docnum=2 -o %t2
@ -94,8 +93,7 @@ Sections:
- Tag: DT_NULL
Value: 0x0
ProgramHeaders:
- Type: PT_LOAD
VAddr: 0x0
Sections:
- Section: .dynstr
- Section: .dynamic
- Type: PT_LOAD
VAddr: 0x0
FirstSec: .dynstr
LastSec: .dynamic

View File

@ -48,16 +48,14 @@ Sections:
- Tag: DT_NULL
Value: 0x0
ProgramHeaders:
- Type: PT_LOAD
VAddr: 0x1000
Sections:
- Section: .text
- Section: .dynamic
- Type: PT_DYNAMIC
VAddr: 0x1000
Sections:
- Section: .text
- Section: .dynamic
- Type: PT_LOAD
VAddr: 0x1000
FirstSec: .text
LastSec: .dynamic
- Type: PT_DYNAMIC
VAddr: 0x1000
FirstSec: .text
LastSec: .dynamic
## In this case .text goes after .dynamic and we don't display any warnings,
## though the content of the .text is used for dumping the dynamic table.
@ -102,16 +100,14 @@ Sections:
AddressAlign: 0x100
Content: "00000000000000000000000000000000"
ProgramHeaders:
- Type: PT_LOAD
VAddr: 0x1000
Sections:
- Section: .dynamic
- Section: .text
- Type: PT_DYNAMIC
VAddr: 0x1000
Sections:
- Section: .dynamic
- Section: .text
- Type: PT_LOAD
VAddr: 0x1000
FirstSec: .dynamic
LastSec: .text
- Type: PT_DYNAMIC
VAddr: 0x1000
FirstSec: .dynamic
LastSec: .text
## In this case .text goes after .dynamic, but (PT_DYNAMIC segment size % dynamic entry size != 0)
## and we have to use the information from the section header instead.
@ -157,13 +153,11 @@ Sections:
AddressAlign: 0x100
Content: "00"
ProgramHeaders:
- Type: PT_LOAD
VAddr: 0x1000
Sections:
- Section: .dynamic
- Section: .text
- Type: PT_DYNAMIC
VAddr: 0x1000
Sections:
- Section: .dynamic
- Section: .text
- Type: PT_LOAD
VAddr: 0x1000
FirstSec: .dynamic
LastSec: .text
- Type: PT_DYNAMIC
VAddr: 0x1000
FirstSec: .dynamic
LastSec: .text

View File

@ -32,9 +32,9 @@ Sections:
Type: SHT_NOTE
Content: 0500000008000000454C4946434F5245000000000000000000000000
ProgramHeaders:
- Type: PT_NOTE
Sections:
- Section: .note.foo
- Type: PT_NOTE
FirstSec: .note.foo
LastSec: .note.foo
# RUN: yaml2obj --docnum=2 %s -o %t2.o
# RUN: llvm-readelf -n %t2.o 2>&1 | FileCheck -DFILE=%t2.o %s --check-prefix=ERR-NULL-TERM
@ -66,9 +66,9 @@ Sections:
Type: SHT_NOTE
Content: 050000002C000000454C4946434F5245000000000100000000000000001000000000000000100000000000000020000000000000003000000000000078787878
ProgramHeaders:
- Type: PT_NOTE
Sections:
- Section: .note.foo
- Type: PT_NOTE
FirstSec: .note.foo
LastSec: .note.foo
# RUN: yaml2obj --docnum=3 %s -o %t3.o
# RUN: llvm-readelf -n %t3.o 2>&1 | FileCheck -DFILE=%t3.o %s --check-prefix=ERR-FILE-COUNT
@ -100,9 +100,9 @@ Sections:
Type: SHT_NOTE
Content: 050000002C000000454C4946434F5245000000000200000000000000001000000000000000100000000000000020000000000000003000000000000078797A00
ProgramHeaders:
- Type: PT_NOTE
Sections:
- Section: .note.foo
- Type: PT_NOTE
FirstSec: .note.foo
LastSec: .note.foo
# RUN: yaml2obj --docnum=4 %s -o %t4.o
# RUN: llvm-readelf -n %t4.o 2>&1 | FileCheck -DFILE=%t4.o %s --check-prefix=ERR-FILE-END-EARLY
@ -137,6 +137,6 @@ Sections:
Type: SHT_NOTE
Content: 0500000044000000454C4946434F5245000000000200000000000000001000000000000000100000000000000020000000000000003000000000000000400000000000000050000000000000006000000000000078797A00
ProgramHeaders:
- Type: PT_NOTE
Sections:
- Section: .note.foo
- Type: PT_NOTE
FirstSec: .note.foo
LastSec: .note.foo

View File

@ -45,9 +45,9 @@ Sections:
Type: SHT_NOTE
Content: 0500000080000000454C4946434F524500000000030000000000000000100000000000000010000000000000002000000000000000300000000000000040000000000000005000000000000000600000000000000070000000000000008000000000000000900000000000002F706174682F746F2F612E6F7574002F706174682F746F2F6C6962632E736F005B737461636B5D00
ProgramHeaders:
- Type: PT_NOTE
Sections:
- Section: .note.foo
- Type: PT_NOTE
FirstSec: .note.foo
LastSec: .note.foo
# GNU: Displaying notes found
# GNU-NEXT: Owner Data size Description

View File

@ -271,6 +271,6 @@ Sections:
- Name: CORE
Type: [[TYPE]]
ProgramHeaders:
- Type: PT_NOTE
Sections:
- Section: .note.foo
- Type: PT_NOTE
FirstSec: .note.foo
LastSec: .note.foo

View File

@ -445,146 +445,125 @@ Sections:
Size: 0x1
ProgramHeaders:
## Case 1: an arbitrary segment with sections.
- Type: PT_PHDR
Flags: [ PF_W ]
VAddr: 0x1000
Sections:
- Section: .foo.begin
- Section: .foo.end
- Type: PT_PHDR
Flags: [ PF_W ]
VAddr: 0x1000
FirstSec: .foo.begin
LastSec: .foo.end
## Case 2: another segment with different sections.
- Type: PT_PHDR
Flags: [ PF_X ]
VAddr: 0x2000
Sections:
- Section: .bar.begin
- Section: .bar.end
- Type: PT_PHDR
Flags: [ PF_X ]
VAddr: 0x2000
FirstSec: .bar.begin
LastSec: .bar.end
## Case 3: the PT_NULL segment.
- Type: PT_NULL
Flags: [ PF_X ]
VAddr: 0x2000
Sections:
- Section: .bar.begin
- Section: .bar.end
- Type: PT_NULL
Flags: [ PF_X ]
VAddr: 0x2000
FirstSec: .bar.begin
LastSec: .bar.end
## Case 4: the PT_DYNAMIC segment.
- Type: PT_DYNAMIC
Flags: [ PF_R, PF_W, PF_X ]
VAddr: 0x1000
Sections:
- Section: .foo.begin
- Section: .foo.end
- Type: PT_DYNAMIC
Flags: [ PF_R, PF_W, PF_X ]
VAddr: 0x1000
FirstSec: .foo.begin
LastSec: .foo.end
## Case 5: the PT_INTERP segment.
- Type: PT_INTERP
Flags: [ PF_R, PF_W ]
VAddr: 0x3000
Sections:
- Section: .interp
- Type: PT_INTERP
Flags: [ PF_R, PF_W ]
VAddr: 0x3000
FirstSec: .interp
LastSec: .interp
## Case 6: the PT_NOTE segment.
- Type: PT_NOTE
VAddr: 0x1000
Sections:
- Section: .foo.begin
- Section: .foo.end
- Type: PT_NOTE
VAddr: 0x1000
FirstSec: .foo.begin
LastSec: .foo.end
## Case 7: the PT_SHLIB segment.
- Type: PT_SHLIB
VAddr: 0x1000
Sections:
- Section: .foo.begin
- Type: PT_SHLIB
VAddr: 0x1000
FirstSec: .foo.begin
LastSec: .foo.begin
## Case 8: the PT_TLS segment.
- Type: PT_TLS
VAddr: 0x4000
Sections:
- Section: .tls
- Type: PT_TLS
VAddr: 0x4000
FirstSec: .tls
LastSec: .tls
## Case 9: the PT_LOOS segment.
- Type: 0x60000000 ## PT_LOOS
VAddr: 0x1000
Sections:
- Section: .foo.begin
- Section: .foo.end
- Type: 0x60000000 ## PT_LOOS
VAddr: 0x1000
FirstSec: .foo.begin
LastSec: .foo.end
## Case 10: the PT_GNU_EH_FRAME segment.
- Type: PT_GNU_EH_FRAME
VAddr: 0x1000
Sections:
- Section: .foo.begin
- Section: .foo.end
- Type: PT_GNU_EH_FRAME
VAddr: 0x1000
FirstSec: .foo.begin
LastSec: .foo.end
## Case 11: the PT_SUNW_UNWIND segment.
- Type: 0x6464e550 ## PT_SUNW_UNWIND
VAddr: 0x1000
Sections:
- Section: .foo.begin
- Section: .foo.end
- Type: 0x6464e550 ## PT_SUNW_UNWIND
VAddr: 0x1000
FirstSec: .foo.begin
LastSec: .foo.end
## Case 12: the PT_GNU_STACK segment.
- Type: PT_GNU_STACK
Sections:
VAddr: 0x1000
Sections:
- Section: .foo.begin
- Section: .foo.end
- Type: PT_GNU_STACK
VAddr: 0x1000
FirstSec: .foo.begin
LastSec: .foo.end
## Case 13: the PT_GNU_RELRO segment.
- Type: PT_GNU_RELRO
VAddr: 0x1000
Sections:
- Section: .foo.begin
- Section: .foo.end
- Type: PT_GNU_RELRO
VAddr: 0x1000
FirstSec: .foo.begin
LastSec: .foo.end
## Case 14: the PT_GNU_PROPERTY segment.
- Type: PT_GNU_PROPERTY
VAddr: 0x1000
Sections:
- Section: .foo.begin
- Section: .foo.end
- Type: PT_GNU_PROPERTY
VAddr: 0x1000
FirstSec: .foo.begin
LastSec: .foo.end
## Case 15: the PT_OPENBSD_RANDOMIZE segment.
- Type: 0x65a3dbe6 ## PT_OPENBSD_RANDOMIZE
VAddr: 0x1000
Sections:
- Section: .foo.begin
- Section: .foo.end
- Type: 0x65a3dbe6 ## PT_OPENBSD_RANDOMIZE
VAddr: 0x1000
FirstSec: .foo.begin
LastSec: .foo.end
## Case 16: the PT_OPENBSD_WXNEEDED segment.
- Type: 0x65a3dbe7 ## PT_OPENBSD_WXNEEDED
VAddr: 0x1000
Sections:
- Section: .foo.begin
- Section: .foo.end
- Type: 0x65a3dbe7 ## PT_OPENBSD_WXNEEDED
VAddr: 0x1000
FirstSec: .foo.begin
LastSec: .foo.end
## Case 17: the PT_OPENBSD_BOOTDATA segment.
- Type: 0x65a41be6 ## PT_OPENBSD_BOOTDATA
VAddr: 0x1000
Sections:
- Section: .foo.begin
- Section: .foo.end
- Type: 0x65a41be6 ## PT_OPENBSD_BOOTDATA
VAddr: 0x1000
FirstSec: .foo.begin
LastSec: .foo.end
## Case 18: the PT_HIOS segment.
- Type: 0x6fffffff ## PT_HIOS
VAddr: 0x1000
Sections:
- Section: .foo.begin
- Section: .foo.end
- Type: 0x6fffffff ## PT_HIOS
VAddr: 0x1000
FirstSec: .foo.begin
LastSec: .foo.end
## Case 19: the PT_LOPROC/PT_ARM_ARCHEXT/PT_MIPS_REGINFO segment.
- Type: 0x70000000 ## PT_LOPROC/PT_ARM_ARCHEXT/PT_MIPS_REGINFO
VAddr: 0x1000
Sections:
- Section: .foo.begin
- Section: .foo.end
- Type: 0x70000000 ## PT_LOPROC/PT_ARM_ARCHEXT/PT_MIPS_REGINFO
VAddr: 0x1000
FirstSec: .foo.begin
LastSec: .foo.end
## Case 20: the PT_ARM_EXIDX/PT_MIPS_RTPROC segment.
- Type: 0x70000001 ## PT_ARM_EXIDX, PT_MIPS_RTPROC
VAddr: 0x1000
Sections:
- Section: .foo.begin
- Section: .foo.end
- Type: 0x70000001 ## PT_ARM_EXIDX, PT_MIPS_RTPROC
VAddr: 0x1000
FirstSec: .foo.begin
LastSec: .foo.end
## Case 20: the PT_MIPS_OPTIONS segment.
- Type: 0x70000002 ## PT_MIPS_OPTIONS
VAddr: 0x1000
Sections:
- Section: .foo.begin
- Section: .foo.end
- Type: 0x70000002 ## PT_MIPS_OPTIONS
VAddr: 0x1000
FirstSec: .foo.begin
LastSec: .foo.end
## Case 21: the PT_MIPS_ABIFLAGS segment.
- Type: 0x70000003 ## PT_MIPS_ABIFLAGS
VAddr: 0x1000
Sections:
- Section: .foo.begin
- Section: .foo.end
- Type: 0x70000003 ## PT_MIPS_ABIFLAGS
VAddr: 0x1000
FirstSec: .foo.begin
LastSec: .foo.end
## Case 22: the PT_HIPROC segment.
- Type: 0x7fffffff ## PT_HIPROC
VAddr: 0x1000
Sections:
- Section: .foo.begin
- Section: .foo.end
- Type: 0x7fffffff ## PT_HIPROC
VAddr: 0x1000
FirstSec: .foo.begin
LastSec: .foo.end
## Check how we dump ARM specific program headers.
# RUN: yaml2obj --docnum=1 -DBITS=64 -DMACHINE=EM_ARM %s -o %tarm.elf
@ -702,9 +681,9 @@ Sections:
- Name: .foo
Type: SHT_PROGBITS
ProgramHeaders:
- Type: PT_PHDR
Sections:
- Section: .foo
- Type: PT_PHDR
FirstSec: .foo
LastSec: .foo
## Case B: the value of the e_phoff field is invalid.

View File

@ -62,12 +62,11 @@ DynamicSymbols:
- Name: force_dynsym
Binding: STB_GLOBAL
ProgramHeaders:
- Type: PT_LOAD
VAddr: 0x1000
Sections:
- Section: .dynamic
- Section: .rela.dyn
- Type: PT_DYNAMIC
VAddr: 0x1000
Sections:
- Section: .dynamic
- Type: PT_LOAD
VAddr: 0x1000
FirstSec: .dynamic
LastSec: .rela.dyn
- Type: PT_DYNAMIC
VAddr: 0x1000
FirstSec: .dynamic
LastSec: .dynamic

View File

@ -133,12 +133,11 @@ DynamicSymbols:
Section: .text
Binding: STB_GLOBAL
ProgramHeaders:
- Type: PT_LOAD
VAddr: 0x1000
Sections:
- Section: .dynamic
- Section: .rela.dyn
- Type: PT_DYNAMIC
VAddr: 0x1000
Sections:
- Section: .dynamic
- Type: PT_LOAD
VAddr: 0x1000
FirstSec: .dynamic
LastSec: .rela.dyn
- Type: PT_DYNAMIC
VAddr: 0x1000
FirstSec: .dynamic
LastSec: .dynamic

View File

@ -217,16 +217,16 @@ ProgramHeaders:
Flags: [ PF_X, PF_R ]
VAddr: 0x00400000
PAddr: 0x00400000
Sections:
- Section: .text
- Type: PT_GNU_EH_FRAME
Flags: [ PF_X, PF_R ]
VAddr: 0x004013C0
PAddr: 0x004013C0
FirstSec: .text
LastSec: .text
- Type: PT_GNU_EH_FRAME
Flags: [ PF_X, PF_R ]
VAddr: 0x004013C0
PAddr: 0x004013C0
MemSize: [[MEMSIZE]]
FileSize: [[FILESIZE]]
Sections:
- Section: .eh_frame_hdr
FirstSec: .eh_frame_hdr
LastSec: .eh_frame_hdr
## Document we report a error when the memory size of the PT_GNU_EH_FRAME does not match its file size.
## TODO: we want to report a warning and continue dumping instead.
@ -326,11 +326,10 @@ FileHeader:
Data: ELFDATA2LSB
Type: ET_EXEC
ProgramHeaders:
- Type: PT_GNU_EH_FRAME
- Type: PT_GNU_EH_FRAME
MemSize: [[SIZE]]
FileSize: [[SIZE]]
Offset: [[OFFSET]]
Sections: []
## Case B: test we report an error when the file size of the PT_GNU_EH_FRAME
## is invalid (goes past the end of the file).

Some files were not shown because too many files have changed in this diff Show More