summaryrefslogtreecommitdiffstats
path: root/lld/test/old-elf/init_array.test
blob: f7f48445621eeea14aa3341d7c9b6e66bec95951 (plain)
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
# Test .init_array.
# Generated from the following C code:
#
# static void
# init () {}
#
# static void (*const init_array []) ()
#  __attribute__ ((used, section (".init_array"), aligned (sizeof (void *))))
#  = { init };
#
# int
# main() { return (0); }
#
# Note: both STT_OBJECT and STT_SECTION for .init_array are commented in yaml
# declaration to check if lld correct adds the object's .init_array when the
# section has no symbol (some compilers may create object with this behavior,
# specially for C++ global constructors).

#RUN: yaml2obj -format=elf %s -o=%t.o
#RUN: lld -flavor old-gnu -target x86_64 %t.o -o %t -e=main
#RUN: llvm-objdump -t -section-headers %t | FileCheck %s

#CHECK: .init_array {{[0-9]+}} [[ADDR:[0-9]+]]
#CHECK: [[ADDR]] l *ABS* {{[0-9]+}} .hidden __init_array_start

---
FileHeader:
  Class:           ELFCLASS64
  Data:            ELFDATA2LSB
  OSABI:           ELFOSABI_FREEBSD
  Type:            ET_REL
  Machine:         EM_X86_64
Sections:
  - Name:            .text
    Type:            SHT_PROGBITS
    Flags:           [ SHF_ALLOC, SHF_EXECINSTR ]
    AddressAlign:    0x0000000000000010
    Content:         554889E5B800000000C745FC000000005DC366666666662E0F1F840000000000554889E55DC3
  - 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
  - Name:            .init_array
    Type:            SHT_INIT_ARRAY
    Flags:           [ SHF_ALLOC ]
    AddressAlign:    0x0000000000000008
    Content:         '0000000000000000'
  - Name:            .rela.init_array
    Type:            SHT_RELA
    Link:            .symtab
    AddressAlign:    0x0000000000000008
    Info:            .init_array
    Relocations:
      - Offset:          0x0000000000000000
        Symbol:          .text
        Type:            R_X86_64_64
        Addend:          32
  - Name:            .comment
    Type:            SHT_PROGBITS
    Flags:           [ SHF_MERGE, SHF_STRINGS ]
    AddressAlign:    0x0000000000000001
    Content:         004672656542534420636C616E672076657273696F6E20332E342E312028746167732F52454C454153455F33342F646F74312D66696E616C203230383033322920323031343035313200
  - Name:            .note.GNU-stack
    Type:            SHT_PROGBITS
    AddressAlign:    0x0000000000000001
    Content:         ''
  - Name:            .eh_frame
    Type:            SHT_PROGBITS
    Flags:           [ SHF_ALLOC ]
    AddressAlign:    0x0000000000000008
    Content:         1400000000000000017A5200017810011B0C070890010000180000001C000000000000001200000000410E108602430D060000001800000038000000000000000600000000410E108602430D06000000
  - Name:            .rela.eh_frame
    Type:            SHT_RELA
    Link:            .symtab
    AddressAlign:    0x0000000000000008
    Info:            .eh_frame
    Relocations:
      - Offset:          0x0000000000000020
        Symbol:          .text
        Type:            R_X86_64_PC32
      - Offset:          0x000000000000003C
        Symbol:          .text
        Type:            R_X86_64_PC32
        Addend:          32
Symbols:
  Local:
    - Name:            init
      Type:            STT_FUNC
      Section:         .text
      Value:           0x0000000000000020
      Size:            0x0000000000000006
#    - Name:            init_array
#      Type:            STT_OBJECT
#      Section:         .init_array
#      Size:            0x0000000000000008
    - Name:            .text
      Type:            STT_SECTION
      Section:         .text
    - Name:            .data
      Type:            STT_SECTION
      Section:         .data
    - Name:            .bss
      Type:            STT_SECTION
      Section:         .bss
#    - Name:            .init_array
#      Type:            STT_SECTION
#      Section:         .init_array
    - Name:            .comment
      Type:            STT_SECTION
      Section:         .comment
    - Name:            .note.GNU-stack
      Type:            STT_SECTION
      Section:         .note.GNU-stack
    - Name:            .eh_frame
      Type:            STT_SECTION
      Section:         .eh_frame
  Global:
    - Name:            main
      Type:            STT_FUNC
      Section:         .text
      Size:            0x0000000000000012
...
OpenPOWER on IntegriCloud