File: set-section-flags-large-multiarch.test

package info (click to toggle)
llvm-toolchain-19 1%3A19.1.7-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,998,520 kB
  • sloc: cpp: 6,951,680; ansic: 1,486,157; asm: 913,598; python: 232,024; f90: 80,126; objc: 75,281; lisp: 37,276; pascal: 16,990; sh: 10,009; ml: 5,058; perl: 4,724; awk: 3,523; makefile: 3,167; javascript: 2,504; xml: 892; fortran: 664; cs: 573
file content (69 lines) | stat: -rw-r--r-- 2,807 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# RUN: yaml2obj %s -o %t

## When targetting non-x86_64, the "large" flag is not allowed:
# RUN: not llvm-objcopy -O elf64-tradbigmips --set-section-flags=.foo=large %t %t.mips.large 2>&1 | FileCheck %s --check-prefixes=BAD-LARGE
# BAD-LARGE: error: {{.*}}: section flag SHF_X86_64_LARGE can only be used with x86_64 architecture

## Converting x86_64 to non-x86_64 preserves the flag equivalent to SHF_X86_64_LARGE.
## (This is not a deliberate feature, but it reflects how preservation/setting of flags
## works for arch-specific flags.)
# RUN: llvm-objcopy -O elf64-tradbigmips --set-section-flags=.foo=alloc --set-section-flags=.bar=alloc %t %t.mips
# RUN: llvm-readobj --sections %t.mips | FileCheck %s --check-prefixes=CHECK,REINTERPRET-GPREL

## Converting non-x86_64 to x86_64 clears the flag equivalent to SHF_X86_64_LARGE,
## and SHF_X86_64_LARGE is set according to the presence of the "large" flag,
## as long as --set-section-flags is used. If --set-section-flag is _not_ used, then
## the section flag is retained. (This latter behaviour is also not deliberate.)
# RUN: llvm-objcopy -O elf64-x86-64 --set-section-flags=.foo=alloc --set-section-flags=.bar=alloc %t.mips %t.x86_64.no-large
# RUN: llvm-readobj --sections %t.x86_64.no-large | FileCheck %s --check-prefixes=CHECK,REINTERPRET-LARGE
# 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
# RUN: llvm-readobj --sections %t.x86_64.large | FileCheck %s --check-prefixes=CHECK,LARGE,REINTERPRET-LARGE

!ELF
FileHeader:
  Class:    ELFCLASS64
  Data:     ELFDATA2LSB
  Type:     ET_REL
  Machine:  EM_X86_64
Sections:
  - Name:   .foo
    Type:   SHT_PROGBITS
    Flags:  [ ]
  - Name:   .bar
    Type:   SHT_PROGBITS
    Flags:  [ SHF_X86_64_LARGE ]
  - Name:   .untouched
    Type:   SHT_PROGBITS
    Flags:  [ ]
  - Name:   .untouched_large
    Type:   SHT_PROGBITS
    Flags:  [ SHF_X86_64_LARGE ]

# CHECK:         Name: .foo
# CHECK-NEXT:    Type: SHT_PROGBITS
# CHECK-NEXT:    Flags [
# CHECK-NEXT:      SHF_ALLOC (0x2)
# CHECK-NEXT:      SHF_WRITE (0x1)
# LARGE-NEXT:      SHF_X86_64_LARGE (0x10000000)
# CHECK-NEXT:    ]

# CHECK:         Name: .bar
# CHECK-NEXT:    Type: SHT_PROGBITS
# CHECK-NEXT:    Flags [
# CHECK-NEXT:      SHF_ALLOC (0x2)
# REINTERPRET-GPREL-NEXT: SHF_MIPS_GPREL (0x10000000)
# CHECK-NEXT:      SHF_WRITE (0x1)
# LARGE-NEXT:      SHF_X86_64_LARGE (0x10000000)
# CHECK-NEXT:    ]

# CHECK:         Name: .untouched
# CHECK-NEXT:    Type: SHT_PROGBITS
# CHECK-NEXT:    Flags [
# CHECK-NEXT:    ]

# CHECK:         Name: .untouched_large
# CHECK-NEXT:    Type: SHT_PROGBITS
# CHECK-NEXT:    Flags [
# REINTERPRET-GPREL-NEXT: SHF_MIPS_GPREL (0x10000000)
# REINTERPRET-LARGE-NEXT: SHF_X86_64_LARGE (0x10000000)
# CHECK-NEXT:    ]