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