1## Test how yaml2obj sets the value of a symbol's st_other fields.
2
3## Show that yaml2obj reports an error when using an STO_* flag that belongs
4## to a different machine type to what is specified by the YAML.
5
6# RUN: not yaml2obj --docnum=1 2>&1 %s | FileCheck %s --check-prefix=ERR
7# ERR: error: an unknown value is used for symbol's 'Other' field: STO_MIPS_OPTIONAL
8
9--- !ELF
10FileHeader:
11  Class:   ELFCLASS32
12  Data:    ELFDATA2LSB
13  Type:    ET_REL
14  Machine: EM_386
15Symbols:
16  - Name:  foo
17    Other: [ STO_MIPS_OPTIONAL ]
18
19## Test that STO_* can be used with their correct machine type.
20## We use the same YAML as above, but with a change of machine type.
21
22# RUN: yaml2obj --docnum=2 %s -o %t2
23# RUN: llvm-readobj --symbols %t2 | FileCheck %s --check-prefix=USE-OTHER
24
25# USE-OTHER:      Name: foo
26# USE-OTHER:      Other [ (0x4)
27# USE-OTHER-NEXT:   STO_MIPS_OPTIONAL (0x4)
28# USE-OTHER-NEXT: ]
29
30--- !ELF
31FileHeader:
32  Class:   ELFCLASS32
33  Data:    ELFDATA2LSB
34  Type:    ET_REL
35  Machine: EM_MIPS
36Symbols:
37  - Name:  foo
38    Other: [ STO_MIPS_OPTIONAL ]
39
40## Test that we can mix named and unnamed constants and set
41## st_other to any arbitrary value.
42
43# RUN: yaml2obj --docnum=3 %s -o %t3
44# RUN: llvm-readobj --symbols %t3 | FileCheck %s --check-prefix=VALUE
45
46# VALUE:      Name: foo
47# VALUE:      Other [
48# VALUE-SAME: (0x4)
49
50# VALUE:      Name: bar
51# VALUE:      Other [
52# VALUE-SAME: (0x7)
53
54# VALUE:      Name: zed
55# VALUE:      Other [
56# VALUE-SAME: (0xFF)
57
58--- !ELF
59FileHeader:
60  Class:   ELFCLASS32
61  Data:    ELFDATA2LSB
62  Type:    ET_REL
63  Machine: EM_MIPS
64Symbols:
65  - Name:  foo
66    Other: [ 0x4 ]
67  - Name:  bar
68    Other: [ STV_PROTECTED, 4 ]
69  - Name:  zed
70    Other: [ STV_PROTECTED, STO_MIPS_OPTIONAL, 0xf8 ]
71