# RUN: yaml2obj %s -o %t
# RUN: llvm-objcopy --change-section-lma *+0x20 %t %t2
# RUN: llvm-readelf --program-headers %t2 | FileCheck %s --check-prefix=CHECK-PLUS-PROGRAMS
# RUN: llvm-readelf --section-headers %t2 | FileCheck %s --check-prefix=CHECK-PLUS-SECTIONS
# RUN: llvm-objcopy --change-section-lma *-0x30 %t %t3
# RUN: llvm-readelf --program-headers %t3 | FileCheck %s --check-prefix=CHECK-MINUS-PROGRAMS
# RUN: llvm-readelf --section-headers %t3 | FileCheck %s --check-prefix=CHECK-MINUS-SECTIONS
# RUN: not llvm-objcopy --change-section-lma .text3=0x5000 %t 2>&1 | FileCheck %s --check-prefix=ERR-SET-ADDRESS
# RUN: not llvm-objcopy --change-section-lma .text3+0x30 %t 2>&1 | FileCheck %s --check-prefix=ERR-SPECIFIC-SEC
# RUN: not llvm-objcopy --change-section-lma *+0c50 %t 2>&1 | FileCheck %s --check-prefix=ERR-INVALID-VAL
# RUN: not llvm-objcopy --change-section-lma 0 %t 2>&1 | FileCheck %s --check-prefix=ERR-MISSING-OFFSET
# RUN: not llvm-objcopy --change-section-lma *-0x2000 %t 2>&1 | FileCheck %s --check-prefix=ERR-UNDERFLOW
# RUN: not llvm-objcopy --change-section-lma *+0x100000000 %t 2>&1 | FileCheck %s --check-prefix=ERR-OVERFLOW
# CHECK-PLUS-PROGRAMS: Type Offset VirtAddr PhysAddr FileSiz MemSiz
# CHECK-PLUS-PROGRAMS: PHDR 0x000002 0x0000000000001102 0x0000000000001122 0x000038 0x000000
# CHECK-PLUS-PROGRAMS: LOAD 0x000000 0x0000000000001100 0x0000000000001120 0x000258 0x000258
# CHECK-PLUS-PROGRAMS: LOAD 0x000258 0xffffffff00005100 0xffffffff00006120 0x000100 0x000100
# CHECK-PLUS-PROGRAMS: NOTE 0x000358 0x0000000000001200 0x0000000000001220 0x000010 0x000000
# CHECK-PLUS-PROGRAMS: NOTE 0x000368 0x0000000000000000 0x0000000000000000 0x000000 0x000000
# CHECK-MINUS-PROGRAMS: PHDR 0x000002 0x0000000000001102 0x00000000000010d2 0x000038 0x000000
# CHECK-MINUS-PROGRAMS: LOAD 0x000000 0x0000000000001100 0x00000000000010d0 0x000258 0x000258
# CHECK-MINUS-PROGRAMS: LOAD 0x000258 0xffffffff00005100 0xffffffff000060d0 0x000100 0x000100
# CHECK-MINUS-PROGRAMS: NOTE 0x000358 0x0000000000001200 0x00000000000011d0 0x000010 0x000000
# CHECK-MINUS-PROGRAMS: NOTE 0x000368 0x0000000000000000 0x0000000000000000 0x000000 0x000000
# CHECK-PLUS-SECTIONS: [Nr] Name Type Address Off Size ES Flg Lk Inf Al
# CHECK-PLUS-SECTIONS: .text1
# CHECK-PLUS-SECTIONS-SAME: 0000000000000000
# CHECK-PLUS-SECTIONS: .text2
# CHECK-PLUS-SECTIONS-SAME: 0000000000000000
# CHECK-MINUS-SECTIONS: .text1
# CHECK-MINUS-SECTIONS-SAME: 0000000000000000
# CHECK-MINUS-SECTIONS: .text2
# CHECK-MINUS-SECTIONS-SAME: 0000000000000000
# ERR-SET-ADDRESS: error: bad format for --change-section-lma: changing LMA to a specific value is not supported. Use *+val or *-val instead
# ERR-SPECIFIC-SEC: error: bad format for --change-section-lma: changing a specific section LMA is not supported. Use *+val or *-val instead
# ERR-INVALID-VAL: error: bad format for --change-section-lma: value after *+ is 0c50 when it should be an integer
# ERR-MISSING-OFFSET: error: bad format for --change-section-lma: missing LMA offset
# ERR-UNDERFLOW: : address 0x1102 cannot be decreased by 0x2000. The result would underflow
# ERR-OVERFLOW: address 0xffffffff00006100 cannot be increased by 0x100000000. The result would overflow
!ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_EXEC
Sections:
- Name: .text1
Type: SHT_PROGBITS
Size: 0x100
- Name: .text2
Type: SHT_PROGBITS
Size: 0x100
ProgramHeaders:
- Type: PT_PHDR
FileSize: 0x38
Offset: 0x2
VAddr: 0x1102
- Type: PT_LOAD
Offset: 0x0
VAddr: 0x1100
FirstSec: .text1
LastSec: .text1
- Type: PT_LOAD
VAddr: 0xFFFFFFFF00005100
PAddr: 0xFFFFFFFF00006100
FirstSec: .text2
LastSec: .text2
- Type: PT_NOTE
FileSize: 0x10
VAddr: 0x1200
Offset: 0x358
- Type: PT_NOTE
FileSize: 0x0
Offset: 0x368