]> gitweb.factorcode.org Git - factor.git/blob - extra/elf/elf-tests.factor
4d1bb5be061e3eb8bf4215048c13685224a50acc
[factor.git] / extra / elf / elf-tests.factor
1 ! Copyright (C) 2010 Erik Charlebois.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: accessors byte-arrays elf kernel sequences system tools.test ;
4 IN: elf.tests
5
6 cpu ppc? [
7 {
8     {
9         ""
10         ".interp"
11         ".note.ABI-tag"
12         ".note.gnu.build-id"
13         ".hash"
14         ".gnu.hash"
15         ".dynsym"
16         ".dynstr"
17         ".gnu.version"
18         ".gnu.version_r"
19         ".rela.dyn"
20         ".rela.plt"
21         ".init"
22         ".plt"
23         ".text"
24         ".fini"
25         ".rodata"
26         ".eh_frame_hdr"
27         ".eh_frame"
28         ".ctors"
29         ".dtors"
30         ".jcr"
31         ".dynamic"
32         ".got"
33         ".got.plt"
34         ".data"
35         ".bss"
36         ".comment"
37         ".debug_aranges"
38         ".debug_pubnames"
39         ".debug_info"
40         ".debug_abbrev"
41         ".debug_line"
42         ".debug_str"
43         ".shstrtab"
44         ".symtab"
45         ".strtab"
46     }
47 }
48 [
49     "resource:extra/elf/a.elf" [
50         sections [ name>> ] map
51     ] with-mapped-elf
52 ]
53 unit-test
54
55 {
56     {
57         ".interp"
58         ".note.ABI-tag"
59         ".note.gnu.build-id"
60         ".hash"
61         ".gnu.hash"
62         ".dynsym"
63         ".dynstr"
64         ".gnu.version"
65         ".gnu.version_r"
66         ".rela.dyn"
67         ".rela.plt"
68         ".init"
69         ".plt"
70         ".text"
71         ".fini"
72         ".rodata"
73         ".eh_frame_hdr"
74         ".eh_frame"
75     }
76 }
77 [
78     "resource:extra/elf/a.elf" [
79         segments [ program-header>> p_type>> PT_LOAD = ] find nip
80         sections [ name>> ] map
81     ] with-mapped-elf
82 ]
83 unit-test
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         "init.c"
122         "call_gmon_start"
123         "crtstuff.c"
124         "__CTOR_LIST__"
125         "__DTOR_LIST__"
126         "__JCR_LIST__"
127         "__do_global_dtors_aux"
128         "completed.7342"
129         "dtor_idx.7344"
130         "frame_dummy"
131         "crtstuff.c"
132         "__CTOR_END__"
133         "__FRAME_END__"
134         "__JCR_END__"
135         "__do_global_ctors_aux"
136         "test.c"
137         "_GLOBAL_OFFSET_TABLE_"
138         "__init_array_end"
139         "__init_array_start"
140         "_DYNAMIC"
141         "data_start"
142         "printf@@GLIBC_2.2.5"
143         "__libc_csu_fini"
144         "_start"
145         "__gmon_start__"
146         "_Jv_RegisterClasses"
147         "_fini"
148         "__libc_start_main@@GLIBC_2.2.5"
149         "_IO_stdin_used"
150         "__data_start"
151         "__dso_handle"
152         "__DTOR_END__"
153         "__libc_csu_init"
154         "__bss_start"
155         "_end"
156         "_edata"
157         "main"
158         "_init"
159     }
160 }
161 [
162     "resource:extra/elf/a.elf" [
163         sections ".symtab" find-section symbols
164         [ name>> ] map
165     ] with-mapped-elf
166 ]
167 unit-test
168
169 {
170     B{
171         85 72 137 229 184 44 6 64 0 72 137 199 184 0 0 0 0 232 222
172         254 255 255 201 195
173     }
174 }
175 [
176     "resource:extra/elf/a.elf" [
177         sections ".symtab" "main" find-section-symbol
178         symbol-data >byte-array
179     ] with-mapped-elf
180 ]
181 unit-test
182 ] unless