xref: /llvm-project/llvm/test/tools/llvm-objcopy/ELF/add-symbol-many-sections.test (revision 1562e4552cd1b3d2eadd956c966f8a60e928b8ca)
1## Show that when adding a symbol defined in a section with section index >=
2## SHN_LORESERVE, the symbol's st_shndx value is set correctly, and the
3## SHT_SYMTAB_SHNDX is properly updated.
4## We don't bother to check the actual details of SHT_SYMTAB_SHNDX, because
5## llvm-readobj wouldn't be able to produce the right section indexes if it were
6## incorrect.
7
8## newsym1 = is in a section with index < SHN_LORESERVE.
9## newsym2 = is in a section with index == SHN_LORESERVE.
10## newsym3 = is in a section with index == SHN_ABS.
11## newsym4 = is in a section with index == SHN_COMMON.
12## newsym5 = is in a section with index == SHN_XINDEX.
13## newsym6 = is in a section with index > SHN_XINDEX.
14
15# RUN: %python %p/../Inputs/ungzip.py %p/Inputs/many-sections.o.gz > %t
16# RUN: llvm-objcopy %t %t2 --add-symbol=newsym1=s1:0 --add-symbol=newsym2=s65280:0 \
17# RUN:                     --add-symbol=newsym3=s65521:0 --add-symbol=newsym4=s65522:0 \
18# RUN:                     --add-symbol=newsym5=s65535:0 --add-symbol=newsym6=s65536:0
19# RUN: llvm-readobj --symbols %t2 | FileCheck %s
20
21# CHECK:         Name: newsym1
22# CHECK-NEXT:    Value: 0x0
23# CHECK-NEXT:    Size: 0
24# CHECK-NEXT:    Binding: Global (0x1)
25# CHECK-NEXT:    Type: None (0x0)
26# CHECK-NEXT:    Other: 0
27# CHECK-NEXT:    Section: s1 (0x1)
28# CHECK-NEXT:  }
29# CHECK-NEXT:  Symbol {
30# CHECK-NEXT:    Name: newsym2
31# CHECK-NEXT:    Value: 0x0
32# CHECK-NEXT:    Size: 0
33# CHECK-NEXT:    Binding: Global (0x1)
34# CHECK-NEXT:    Type: None (0x0)
35# CHECK-NEXT:    Other: 0
36# CHECK-NEXT:    Section: s65280 (0xFF00)
37# CHECK-NEXT:  }
38# CHECK-NEXT:  Symbol {
39# CHECK-NEXT:    Name: newsym3
40# CHECK-NEXT:    Value: 0x0
41# CHECK-NEXT:    Size: 0
42# CHECK-NEXT:    Binding: Global (0x1)
43# CHECK-NEXT:    Type: None (0x0)
44# CHECK-NEXT:    Other: 0
45# CHECK-NEXT:    Section: s65521 (0xFFF1)
46# CHECK-NEXT:  }
47# CHECK-NEXT:  Symbol {
48# CHECK-NEXT:    Name: newsym4
49# CHECK-NEXT:    Value: 0x0
50# CHECK-NEXT:    Size: 0
51# CHECK-NEXT:    Binding: Global (0x1)
52# CHECK-NEXT:    Type: None (0x0)
53# CHECK-NEXT:    Other: 0
54# CHECK-NEXT:    Section: s65522 (0xFFF2)
55# CHECK-NEXT:  }
56# CHECK-NEXT:  Symbol {
57# CHECK-NEXT:    Name: newsym5
58# CHECK-NEXT:    Value: 0x0
59# CHECK-NEXT:    Size: 0
60# CHECK-NEXT:    Binding: Global (0x1)
61# CHECK-NEXT:    Type: None (0x0)
62# CHECK-NEXT:    Other: 0
63# CHECK-NEXT:    Section: s65535 (0xFFFF)
64# CHECK-NEXT:  }
65# CHECK-NEXT:  Symbol {
66# CHECK-NEXT:    Name: newsym6
67# CHECK-NEXT:    Value: 0x0
68# CHECK-NEXT:    Size: 0
69# CHECK-NEXT:    Binding: Global (0x1)
70# CHECK-NEXT:    Type: None (0x0)
71# CHECK-NEXT:    Other: 0
72# CHECK-NEXT:    Section: s65536 (0x10000)
73# CHECK-NEXT:  }
74