• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# RUN: yaml2obj %s -o %t
2# RUN: llvm-objcopy --add-symbol='abs1=1' \
3# RUN:              --add-symbol='abs2=2,LoCaL,HiDdEn,FuNcTiOn' \
4# RUN:              --add-symbol='abs3=3,global,default,object' \
5# RUN:              --add-symbol='abs4=4,global,protected,object' \
6# RUN:              --add-symbol='foo.cpp=0,file' \
7# RUN:              --add-symbol='=.text:0,section' \
8# RUN:              --add-symbol='data=.data:0x100,weak' \
9# RUN:              --add-symbol='ifunc=.text:0,indirect-function' \
10# RUN:              %t %t2
11# RUN: llvm-readelf -s %t2 | FileCheck %s
12
13# Checked ignored options
14# RUN: llvm-objcopy \
15# RUN:   --add-symbol='dummy1=0,indirect,constructor,debug,synthetic' \
16# RUN:   --add-symbol='dummy2=0,before=foo,unique-object,warning' %t %t3
17# RUN: llvm-readelf -s %t3 | FileCheck %s --check-prefix=IGNORED
18
19# Check errors
20# RUN: not llvm-objcopy --add-symbol='test' %t %t4 2>&1 | FileCheck %s --check-prefix=ERR1
21# RUN: not llvm-objcopy --add-symbol='test=:0' %t %t5 2>&1 | FileCheck %s --check-prefix=ERR2
22# RUN: not llvm-objcopy --add-symbol='test=foo:' %t %t6 2>&1 | FileCheck %s --check-prefix=ERR2
23# RUN: not llvm-objcopy --add-symbol='test=0,cool' %t %t7 2>&1 | FileCheck %s --check-prefix=ERR3
24# RUN: not llvm-objcopy --add-symbol='test=0,foo,bar' %t %t8 2>&1 | FileCheck %s --check-prefix=ERR4
25# RUN: not llvm-objcopy --add-symbol='test=xyz' %t %t9 2>&1 | FileCheck %s --check-prefix=ERR5
26
27!ELF
28FileHeader:
29  Class:           ELFCLASS32
30  Data:            ELFDATA2LSB
31  Type:            ET_EXEC
32  Machine:         EM_ARM
33Sections:
34  - Name:            .text
35    Type:            SHT_PROGBITS
36    Flags:           [ SHF_ALLOC, SHF_EXECINSTR ]
37    Address:         0x1000
38    AddressAlign:    0x0000000000001000
39    Size:            64
40  - Name:            .data
41    Type:            SHT_PROGBITS
42    Flags:           [ SHF_ALLOC ]
43    Address:         0x2000
44    AddressAlign:    0x0000000000001000
45    Size:            64
46ProgramHeaders:
47  - Type:     PT_LOAD
48    Flags:    [ PF_X, PF_R ]
49    VAddr:    0x1000
50    Align:    0x1000
51    FirstSec: .text
52    LastSec:  .text
53  - Type:     PT_LOAD
54    Flags:    [ PF_R, PF_W ]
55    VAddr:    0x2000
56    Align:    0x1000
57    FirstSec: .data
58    LastSec:  .data
59## TODO (grimar): llvm-objcopy seems produce a broken output without
60## the following line, i.e. when there is no symbol table in the input.
61Symbols: []
62
63# CHECK:      0: 00000000 0 NOTYPE LOCAL DEFAULT UND
64# CHECK-NEXT: 1: 00000001 0 NOTYPE GLOBAL DEFAULT ABS abs1
65# CHECK-NEXT: 2: 00000002 0 FUNC LOCAL HIDDEN ABS abs2
66# CHECK-NEXT: 3: 00000003 0 OBJECT GLOBAL DEFAULT ABS abs3
67# CHECK-NEXT: 4: 00000004 0 OBJECT GLOBAL PROTECTED ABS abs4
68# CHECK-NEXT: 5: 00000000 0 FILE GLOBAL DEFAULT ABS foo.cpp
69# CHECK-NEXT: 6: 00001000 0 SECTION GLOBAL DEFAULT 1
70# CHECK-NEXT: 7: 00002100 0 NOTYPE WEAK DEFAULT 2 data
71# CHECK-NEXT: 8: 00001000 0 IFUNC GLOBAL DEFAULT 1 ifunc
72
73# IGNORED:       1: 00000000 0 NOTYPE GLOBAL DEFAULT ABS dummy1
74# IGNORED-NEXT:  2: 00000000 0 NOTYPE GLOBAL DEFAULT ABS dummy2
75
76# ERR1: error: bad format for --add-symbol, missing '=' after 'test'
77# ERR2: error: bad format for --add-symbol, missing section name or symbol value
78# ERR3: error: unsupported flag for --add-symbol: 'cool'
79# ERR4: error: unsupported flags for --add-symbol: 'foo', 'bar'
80# ERR5: error: bad symbol value: 'xyz'
81
82