| 1 |
# RUN: yaml2obj %s -o %t |
| 2 |
|
| 3 |
## When targetting non-x86_64, the "large" flag is not allowed: |
| 4 |
# RUN: not llvm-objcopy -O elf64-tradbigmips --set-section-flags=.foo=large %t %t.mips.large 2>&1 | FileCheck %s --check-prefixes=BAD-LARGE |
| 5 |
# BAD-LARGE: error: {{.*}}: section flag SHF_X86_64_LARGE can only be used with x86_64 architecture |
| 6 |
|
| 7 |
## Converting x86_64 to non-x86_64 preserves the flag equivalent to SHF_X86_64_LARGE. |
| 8 |
## (This is not a deliberate feature, but it reflects how preservation/setting of flags |
| 9 |
## works for arch-specific flags.) |
| 10 |
# RUN: llvm-objcopy -O elf64-tradbigmips --set-section-flags=.foo=alloc --set-section-flags=.bar=alloc %t %t.mips |
| 11 |
# RUN: llvm-readobj --sections %t.mips | FileCheck %s --check-prefixes=CHECK,REINTERPRET-GPREL |
| 12 |
|
| 13 |
## Converting non-x86_64 to x86_64 clears the flag equivalent to SHF_X86_64_LARGE, |
| 14 |
## and SHF_X86_64_LARGE is set according to the presence of the "large" flag, |
| 15 |
## as long as --set-section-flags is used. If --set-section-flag is _not_ used, then |
| 16 |
## the section flag is retained. (This latter behaviour is also not deliberate.) |
| 17 |
# RUN: llvm-objcopy -O elf64-x86-64 --set-section-flags=.foo=alloc --set-section-flags=.bar=alloc %t.mips %t.x86_64.no-large |
| 18 |
# RUN: llvm-readobj --sections %t.x86_64.no-large | FileCheck %s --check-prefixes=CHECK,REINTERPRET-LARGE |
| 19 |
# RUN: llvm-objcopy -O elf64-x86-64 --set-section-flags=.foo=alloc,large --set-section-flags=.bar=alloc,large %t.mips %t.x86_64.large |
| 20 |
# RUN: llvm-readobj --sections %t.x86_64.large | FileCheck %s --check-prefixes=CHECK,LARGE,REINTERPRET-LARGE |
| 21 |
|
| 22 |
!ELF |
| 23 |
FileHeader: |
| 24 |
Class: ELFCLASS64 |
| 25 |
Data: ELFDATA2LSB |
| 26 |
Type: ET_REL |
| 27 |
Machine: EM_X86_64 |
| 28 |
Sections: |
| 29 |
- Name: .foo |
| 30 |
Type: SHT_PROGBITS |
| 31 |
Flags: [ ] |
| 32 |
- Name: .bar |
| 33 |
Type: SHT_PROGBITS |
| 34 |
Flags: [ SHF_X86_64_LARGE ] |
| 35 |
- Name: .untouched |
| 36 |
Type: SHT_PROGBITS |
| 37 |
Flags: [ ] |
| 38 |
- Name: .untouched_large |
| 39 |
Type: SHT_PROGBITS |
| 40 |
Flags: [ SHF_X86_64_LARGE ] |
| 41 |
|
| 42 |
# CHECK: Name: .foo |
| 43 |
# CHECK-NEXT: Type: SHT_PROGBITS |
| 44 |
# CHECK-NEXT: Flags [ |
| 45 |
# CHECK-NEXT: SHF_ALLOC (0x2) |
| 46 |
# CHECK-NEXT: SHF_WRITE (0x1) |
| 47 |
# LARGE-NEXT: SHF_X86_64_LARGE (0x10000000) |
| 48 |
# CHECK-NEXT: ] |
| 49 |
|
| 50 |
# CHECK: Name: .bar |
| 51 |
# CHECK-NEXT: Type: SHT_PROGBITS |
| 52 |
# CHECK-NEXT: Flags [ |
| 53 |
# CHECK-NEXT: SHF_ALLOC (0x2) |
| 54 |
# REINTERPRET-GPREL-NEXT: SHF_MIPS_GPREL (0x10000000) |
| 55 |
# CHECK-NEXT: SHF_WRITE (0x1) |
| 56 |
# LARGE-NEXT: SHF_X86_64_LARGE (0x10000000) |
| 57 |
# CHECK-NEXT: ] |
| 58 |
|
| 59 |
# CHECK: Name: .untouched |
| 60 |
# CHECK-NEXT: Type: SHT_PROGBITS |
| 61 |
# CHECK-NEXT: Flags [ |
| 62 |
# CHECK-NEXT: ] |
| 63 |
|
| 64 |
# CHECK: Name: .untouched_large |
| 65 |
# CHECK-NEXT: Type: SHT_PROGBITS |
| 66 |
# CHECK-NEXT: Flags [ |
| 67 |
# REINTERPRET-GPREL-NEXT: SHF_MIPS_GPREL (0x10000000) |
| 68 |
# REINTERPRET-LARGE-NEXT: SHF_X86_64_LARGE (0x10000000) |
| 69 |
# CHECK-NEXT: ] |