aboutsummaryrefslogtreecommitdiff
path: root/test/elf/X86_64/weaksym.test
blob: d44ca8a369683d5d7c115545cac951abd821c68f (plain) (blame)
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
70
71
72
73
74
75
76
77
78
# Tests that an executable with a weak undefine will put this symbol in the
# dynamic symbol table if the executable has a dynamic relocation against this
# symbol.

#RUN: yaml2obj --format elf %s -o %t.o
#RUN: lld -flavor gnu  -target x86_64 -e main %t.o -o %t1
#RUN: llvm-readobj -dt %t1 | FileCheck -check-prefix CHECKSYMS %s

#CHECKSYMS:        Name: x@
#CHECKSYMS-NEXT:   Value: 0x0
#CHECKSYMS-NEXT:   Size: 0
#CHECKSYMS-NEXT:   Binding: Weak (0x2)
#CHECKSYMS-NEXT:   Type: None (0x0)
#CHECKSYMS-NEXT:   Other: 0
#CHECKSYMS-NEXT:   Section: Undefined (0x0)

# The object file above corresponds to the following C program compiled with
# -fPIC:
# extern int *x __attribute__((weak));
#
# int main() {
#     if (x)
#         return 1;
#     return 0;
# }

---
FileHeader:
  Class:           ELFCLASS64
  Data:            ELFDATA2LSB
  OSABI:           ELFOSABI_GNU
  Type:            ET_REL
  Machine:         EM_X86_64
Sections:
  - Name:            .text
    Type:            SHT_PROGBITS
    Flags:           [ SHF_ALLOC, SHF_EXECINSTR ]
    AddressAlign:    0x0000000000000010
    Content:         554889E5488B0500000000C745FC00000000488138000000000F840C000000C745FC01000000E907000000C745FC000000008B45FC5DC3
  - Name:            .rela.text
    Type:            SHT_RELA
    Link:            .symtab
    AddressAlign:    0x0000000000000008
    Info:            .text
    Relocations:
      - Offset:          0x0000000000000007
        Symbol:          x
        Type:            R_X86_64_GOTPCREL
        Addend:          -4
  - Name:            .data
    Type:            SHT_PROGBITS
    Flags:           [ SHF_WRITE, SHF_ALLOC ]
    AddressAlign:    0x0000000000000004
    Content:         ''
  - Name:            .bss
    Type:            SHT_NOBITS
    Flags:           [ SHF_WRITE, SHF_ALLOC ]
    AddressAlign:    0x0000000000000004
    Content:         ''
Symbols:
  Local:
    - Name:            .text
      Type:            STT_SECTION
      Section:         .text
    - Name:            .data
      Type:            STT_SECTION
      Section:         .data
    - Name:            .bss
      Type:            STT_SECTION
      Section:         .bss
  Global:
    - Name:            main
      Type:            STT_FUNC
      Section:         .text
      Size:            0x0000000000000037
    - Name:            _GLOBAL_OFFSET_TABLE_
  Weak:
    - Name:            x