• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1## Show how yaml2obj sets physical and virtual addresses of program headers.
2
3# RUN: yaml2obj %s -o %t
4# RUN: llvm-readelf --sections --segments %t | FileCheck %s
5
6# CHECK: Section Headers:
7# CHECK:  [Nr] Name Type     Address          Off    Size   ES Flg
8# CHECK:  [ 1] .foo PROGBITS 0000000000001234 000120 000001 00   A
9
10# CHECK:      Program Headers:
11# CHECK-NEXT:  Type Offset   VirtAddr           PhysAddr           FileSiz  MemSiz   Flg Align
12# CHECK-NEXT:  LOAD 0x000000 0x0000000000000000 0x0000000000000000 0x000000 0x000000 R E 0x1
13# CHECK-NEXT:  LOAD 0x000120 0x0000000000000000 0x0000000000000000 0x000001 0x000001 R E 0x1
14# CHECK-NEXT:  LOAD 0x000120 0x00000000aaaa1000 0x00000000aaaa1000 0x000001 0x000001 R E 0x1
15# CHECK-NEXT:  LOAD 0x000120 0x00000000aaaa1000 0x00000000bbbb2000 0x000001 0x000001 R E 0x1
16
17--- !ELF
18FileHeader:
19  Class: ELFCLASS64
20  Data:  ELFDATA2LSB
21  Type:  ET_EXEC
22Sections:
23  - Name:    .foo
24    Type:    SHT_PROGBITS
25    Flags:   [ SHF_ALLOC ]
26    Size:    0x1
27    Address: 0x1234
28ProgramHeaders:
29## Show what virtual and physical address we set by default for the case where
30## a program header has no sections.
31  - Type:  PT_LOAD
32    Flags: [ PF_X, PF_R ]
33## Show what virtual and physical address we set by default for the case
34## where a program header includes a section with a virtual address that
35## is explicitly set.
36  - Type:     PT_LOAD
37    Flags:    [ PF_X, PF_R ]
38    FirstSec: .foo
39    LastSec:  .foo
40## Now we have a program header that has a virtual address different to
41## the address of the section included. Show that the default physical address
42## is equal to the program header's virtual address.
43  - Type:     PT_LOAD
44    Flags:    [ PF_X, PF_R ]
45    VAddr:    0xAAAA1000
46    FirstSec: .foo
47    LastSec:  .foo
48## Show that we are able to set different virtual and physical addresses.
49  - Type:     PT_LOAD
50    Flags:    [ PF_X, PF_R ]
51    VAddr:    0xAAAA1000
52    PAddr:    0xBBBB2000
53    FirstSec: .foo
54    LastSec:  .foo
55