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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
|
project('pax-utils', 'c',
version : '1.3.7',
license : 'GPL-2.0-only',
default_options : [
'warning_level=2',
'c_std=gnu11',
],
)
cc = meson.get_compiler('c')
libcap = dependency('libcap', required : get_option('use_libcap'))
if libcap.found()
add_project_arguments('-DWANT_SYSCAP', language : 'c')
endif
if get_option('use_seccomp')
add_project_arguments('-DWANT_SECCOMP', language : 'c')
endif
if get_option('buildtype') in ['debug', 'debugoptimized']
add_project_arguments('-DEBUG', language : 'c')
endif
# generate VCSID
version_h = vcs_tag(input : 'version.h.in', output : 'pax_utils_version.h')
# tell paxinc.h to use it
add_project_arguments('-DINCLUDE_GENERATE_VERSION_H', language : 'c')
add_project_arguments('-DVERSION="' + meson.project_version() + '"', language : 'c')
add_project_arguments('-D_GNU_SOURCE', language : 'c')
add_project_arguments('-D_FILE_OFFSET_BITS=64', language : 'c')
# probe the platform...
probe_results = configuration_data()
## first, we check a bunch of headers
foreach x : [
'endian.h', 'byteswap.h', # GNU-likes
'sys/endian.h', # BSDs,
'sys/isa_defs.h', # Sun/Illumios
'machine/endian.h', # Mach
'linux/seccomp.h',
'linux/securebits.h',
'sys/prctl.h',
'alloca.h',
'elf-hints.h',
'glob.h',
]
x_exists = 0
if cc.has_header(x)
x_exists = 1
endif
probe_results.set('HAS_' + x.to_upper().underscorify(), x_exists)
endforeach
configure_file(
output : 'probes.h',
configuration : probe_results,
)
# common code
common_src = [
'paxinc.c',
'security.c',
'xfuncs.c',
version_h,
]
common = static_library('common',
common_src,
install : false
)
if cc.get_define('__svr4__') == ''
executable('pspax',
'paxelf.c',
'paxldso.c',
'pspax.c',
version_h,
dependencies : [libcap],
link_with : common,
install : true
)
endif
executable('scanelf',
'paxelf.c',
'paxldso.c',
'scanelf.c',
version_h,
dependencies : [libcap],
link_with : common,
install : true
)
# dumpelf code (without the common code above)
dumpelf_src = [
'paxelf.c',
'paxldso.c',
'dumpelf.c',
version_h,
]
executable('dumpelf',
dumpelf_src,
dependencies : [libcap],
link_with : common,
install : true
)
executable('scanmacho',
'paxmacho.c',
'scanmacho.c',
version_h,
dependencies : [libcap],
link_with : common,
install : true
)
lddtree_impl = get_option('lddtree_implementation')
if lddtree_impl != 'none'
if lddtree_impl == 'python'
suffix = '.py'
else
suffix = '.sh'
endif
install_data('lddtree' + suffix,
rename : 'lddtree',
install_dir : get_option('bindir')
)
endif
install_data('symtree.sh',
rename : 'symtree',
install_dir : get_option('bindir')
)
subdir('man')
meson.add_dist_script('meson-build-dist-man.sh')
do_tests = get_option('tests')
if do_tests
subdir('tests/lddtree')
subdir('tests/scanelf')
subdir('tests/source')
endif
if do_tests and get_option('use_fuzzing')
ncc = meson.get_compiler('c', native : true)
fuzz_flags = [
'-g3', '-ggdb',
'-fsanitize=fuzzer', '-fsanitize-coverage=edge',
'-DPAX_UTILS_LIBFUZZ=1',
]
if ncc.get_id() != 'clang'
warning('use_fuzzing requires Clang, due to LibFuzzer. Not building fuzzers')
else
dumpelf_fuzzer = executable('dumpelf.fuzz',
common_src + dumpelf_src,
override_options : [
'buildtype=debug',
],
c_args : fuzz_flags,
link_args : fuzz_flags,
install : false
)
test('fuzz-dumpelf', dumpelf_fuzzer)
endif
endif
|