xref: /llvm-project/llvm/test/tools/llvm-objcopy/ELF/binary-no-paddr.test (revision 0c01f42fad413163320c24ab4e513fbd282e4168)
1*0c01f42fSFangrui Song# RUN: yaml2obj -D PADDR1=0x1000 -D PADDR2=0x1004 %s -o %t1
2fd624e62SFangrui Song# RUN: llvm-objcopy -O binary %t1 %t1.out
3fd624e62SFangrui Song# RUN: od -t x2 -v %t1.out | FileCheck %s --ignore-case
4fd624e62SFangrui Song
5fd624e62SFangrui Song## When all p_paddr fields are 0, GNU objcopy resets LMA to VMA
6fd624e62SFangrui Song## and gives a different output.
7fd624e62SFangrui Song## https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=6ffd79000b45e77b3625143932ffbf781b6aecab
8*0c01f42fSFangrui Song## We don't implement this special rule. For the p_paddr=0 case: .text and
9*0c01f42fSFangrui Song## .data are rewritten to the same place. The size is 4. # the p_paddr=1 case.
10*0c01f42fSFangrui Song# RUN: yaml2obj %s -o %t0
11fd624e62SFangrui Song# RUN: llvm-objcopy -O binary %t0 %t0.out
12*0c01f42fSFangrui Song# RUN: od -t x2 -v %t0.out | FileCheck %s --check-prefix=CHECK0 --ignore-case
136e4dc6f2SAlexander Shaposhnikov
146e4dc6f2SAlexander Shaposhnikov!ELF
156e4dc6f2SAlexander ShaposhnikovFileHeader:
166e4dc6f2SAlexander Shaposhnikov  Class:           ELFCLASS64
176e4dc6f2SAlexander Shaposhnikov  Data:            ELFDATA2LSB
186e4dc6f2SAlexander Shaposhnikov  Type:            ET_EXEC
196e4dc6f2SAlexander Shaposhnikov  Machine:         EM_X86_64
206e4dc6f2SAlexander ShaposhnikovSections:
216e4dc6f2SAlexander Shaposhnikov  - Name:            .text
226e4dc6f2SAlexander Shaposhnikov    Type:            SHT_PROGBITS
236e4dc6f2SAlexander Shaposhnikov    Flags:           [ SHF_ALLOC, SHF_EXECINSTR ]
246e4dc6f2SAlexander Shaposhnikov    Address:         0x1000
256e4dc6f2SAlexander Shaposhnikov    AddressAlign:    0x0000000000001000
266e4dc6f2SAlexander Shaposhnikov    Content:         "c3c3c3c3"
276e4dc6f2SAlexander Shaposhnikov  - Name:            .data
286e4dc6f2SAlexander Shaposhnikov    Type:            SHT_PROGBITS
296e4dc6f2SAlexander Shaposhnikov    Flags:           [ SHF_ALLOC ]
306e4dc6f2SAlexander Shaposhnikov    Address:         0x1004
316e4dc6f2SAlexander Shaposhnikov    AddressAlign:    0x0000000000000004
326e4dc6f2SAlexander Shaposhnikov    Content:         "3232"
336e4dc6f2SAlexander ShaposhnikovProgramHeaders:
346e4dc6f2SAlexander Shaposhnikov  - Type:     PT_LOAD
356e4dc6f2SAlexander Shaposhnikov    Flags:    [ PF_X, PF_R ]
366e4dc6f2SAlexander Shaposhnikov    VAddr:    0x1000
37*0c01f42fSFangrui Song    PAddr:    [[PADDR1=0]]
38a7a447beSGeorgii Rymar    FirstSec: .text
39a7a447beSGeorgii Rymar    LastSec:  .text
406e4dc6f2SAlexander Shaposhnikov  - Type:     PT_LOAD
416e4dc6f2SAlexander Shaposhnikov    Flags:    [ PF_R, PF_W ]
426e4dc6f2SAlexander Shaposhnikov    VAddr:    0x1004
43*0c01f42fSFangrui Song    PAddr:    [[PADDR2=0]]
44a7a447beSGeorgii Rymar    FirstSec: .data
45a7a447beSGeorgii Rymar    LastSec:  .data
466e4dc6f2SAlexander Shaposhnikov
47*0c01f42fSFangrui Song# CHECK:       0000000 c3c3 c3c3 3232
48*0c01f42fSFangrui Song# CHECK-NEXT:  0000006
49*0c01f42fSFangrui Song
50*0c01f42fSFangrui Song# CHECK0:      0000000 3232 c3c3
51*0c01f42fSFangrui Song# CHECK0-NEXT: 0000004
52