@@ -68,7 +68,7 @@ configure_file(package/SPECS.in/spec.in SPECS.spec)
68
68
#
69
69
# external programs used by this build
70
70
#
71
- set (TEXTTRANSFORM "/usr/lib/monodevelop/AddIns/MonoDevelop.TextTemplating/TextTransform.exe " )
71
+ set (TEXTTRANSFORM "/root/.dotnet/tools/t4 " )
72
72
set (ICONV "/usr/bin/iconv" )
73
73
set (LD "/usr/bin/ld" )
74
74
@@ -79,8 +79,9 @@ set(PACKAGE_NAME "sysmonforlinux")
79
79
80
80
#
81
81
# report warnings as errors
82
+ # -g is required for BTF and CO:RE
82
83
#
83
- add_compile_options (-Wall -Werror )
84
+ add_compile_options (-Wall -Werror -g )
84
85
85
86
#
86
87
# support for C++17
@@ -134,6 +135,12 @@ add_executable(sysmon
134
135
sysmonEBPFkern5.2.o.o
135
136
sysmonEBPFkern5.3-5.5.o.o
136
137
sysmonEBPFkern5.6-.o.o
138
+ sysmonEBPFkern4.15_core.o.o
139
+ sysmonEBPFkern4.16_core.o.o
140
+ sysmonEBPFkern4.17-5.1_core.o.o
141
+ sysmonEBPFkern5.2_core.o.o
142
+ sysmonEBPFkern5.3-5.5_core.o.o
143
+ sysmonEBPFkern5.6-_core.o.o
137
144
sysmonLogView.o
138
145
sysmon.d.o
139
146
sysmon.service.o
@@ -143,6 +150,12 @@ add_executable(sysmon
143
150
sysmonEBPFkern5.2.rep
144
151
sysmonEBPFkern5.3-5.5.rep
145
152
sysmonEBPFkern5.6-.rep
153
+ sysmonEBPFkern4.15_core.rep
154
+ sysmonEBPFkern4.16_core.rep
155
+ sysmonEBPFkern4.17-5.1_core.rep
156
+ sysmonEBPFkern5.2_core.rep
157
+ sysmonEBPFkern5.3-5.5_core.rep
158
+ sysmonEBPFkern5.6-_core.rep
146
159
)
147
160
148
161
target_include_directories (sysmon PUBLIC
@@ -153,7 +166,7 @@ target_include_directories(sysmon PUBLIC
153
166
"/usr/local/include"
154
167
"${LIBXML2_INCLUDE_DIR} "
155
168
"/opt/sysinternalsEBPF/ebpfKern"
156
- )
169
+ )
157
170
158
171
159
172
add_custom_target (packages
@@ -181,7 +194,7 @@ add_custom_command(OUTPUT sysmonEBPFkern4.16.rep
181
194
COMMAND "${CMAKE_BINARY_DIR} /checkEBPFsizes" sysmonEBPFkern4.16.o 4096 && touch sysmonEBPFkern4.16.rep
182
195
COMMENT "Checking sysmonEBPFkern4.16.o"
183
196
DEPENDS checkEBPFsizes sysmonEBPFkern4.16.o
184
- )
197
+ )
185
198
186
199
add_custom_command (OUTPUT sysmonEBPFkern4.17-5.1.rep
187
200
COMMAND "${CMAKE_BINARY_DIR} /checkEBPFsizes" sysmonEBPFkern4.17-5.1.o 4096 && touch sysmonEBPFkern4.17-5.1.rep
@@ -207,6 +220,41 @@ add_custom_command(OUTPUT sysmonEBPFkern5.6-.rep
207
220
DEPENDS checkEBPFsizes sysmonEBPFkern5.6-.o
208
221
)
209
222
223
+ add_custom_command (OUTPUT sysmonEBPFkern4.15_core.rep
224
+ COMMAND "${CMAKE_BINARY_DIR} /checkEBPFsizes" sysmonEBPFkern4.15_core.o 4096 touch sysmonEBPFkern4.15_core.rep
225
+ COMMENT "Checking sysmonEBPFkern4.15_core.o"
226
+ DEPENDS checkEBPFsizes sysmonEBPFkern4.15_core.o
227
+ )
228
+
229
+ add_custom_command (OUTPUT sysmonEBPFkern4.16_core.rep
230
+ COMMAND "${CMAKE_BINARY_DIR} /checkEBPFsizes" sysmonEBPFkern4.16_core.o 4096 && touch sysmonEBPFkern4.16_core.rep
231
+ COMMENT "Checking sysmonEBPFkern4.16_core.o"
232
+ DEPENDS checkEBPFsizes sysmonEBPFkern4.16_core.o
233
+ )
234
+
235
+ add_custom_command (OUTPUT sysmonEBPFkern4.17-5.1_core.rep
236
+ COMMAND "${CMAKE_BINARY_DIR} /checkEBPFsizes" sysmonEBPFkern4.17-5.1_core.o 4096 && touch sysmonEBPFkern4.17-5.1_core.rep
237
+ COMMENT "Checking sysmonEBPFkern4.17-5.1_core.o"
238
+ DEPENDS checkEBPFsizes sysmonEBPFkern4.17-5.1_core.o
239
+ )
240
+
241
+ add_custom_command (OUTPUT sysmonEBPFkern5.2_core.rep
242
+ COMMAND "${CMAKE_BINARY_DIR} /checkEBPFsizes" sysmonEBPFkern5.2_core.o 32768 && touch sysmonEBPFkern5.2_core.rep
243
+ COMMENT "Checking sysmonEBPFkern5.2_core.o"
244
+ DEPENDS checkEBPFsizes sysmonEBPFkern5.2_core.o
245
+ )
246
+
247
+ add_custom_command (OUTPUT sysmonEBPFkern5.3-5.5_core.rep
248
+ COMMAND "${CMAKE_BINARY_DIR} /checkEBPFsizes" sysmonEBPFkern5.3-5.5_core.o 32768 && touch sysmonEBPFkern5.3-5.5_core.rep
249
+ COMMENT "Checking sysmonEBPFkern5.3-5.5_core.o"
250
+ DEPENDS checkEBPFsizes sysmonEBPFkern5.3-5.5_core.o
251
+ )
252
+
253
+ add_custom_command (OUTPUT sysmonEBPFkern5.6-_core.rep
254
+ COMMAND "${CMAKE_BINARY_DIR} /checkEBPFsizes" sysmonEBPFkern5.6-_core.o 32768 && touch sysmonEBPFkern5.6-_core.rep
255
+ COMMENT "Checking sysmonEBPFkern5.6-_core.o"
256
+ DEPENDS checkEBPFsizes sysmonEBPFkern5.6-_core.o
257
+ )
210
258
211
259
# list of files the EBPF programs depend upon
212
260
set (EBPF_DEPENDS
@@ -303,8 +351,7 @@ target_include_directories(checkEBPFsizes PUBLIC
303
351
"/usr/include"
304
352
)
305
353
306
- target_link_libraries (checkEBPFsizes elf )
307
-
354
+ target_link_libraries (checkEBPFsizes sysinternalsEBPF )
308
355
309
356
#
310
357
# GTest required for unit tests
@@ -370,25 +417,25 @@ add_custom_command(OUTPUT yoursleep
370
417
# automatically generate sources from manifest.xml and manifest.tt
371
418
#
372
419
add_custom_command (OUTPUT sysmonevents.h.utf16
373
- COMMAND "mono" " ${TEXTTRANSFORM} " "${SYSMON_COMMON_SOURCE_DIR} /manifest.tt" -out sysmonevents.h.utf16 -a '!!type!header'
420
+ COMMAND "${TEXTTRANSFORM} " "${SYSMON_COMMON_SOURCE_DIR} /manifest.tt" -out sysmonevents.h.utf16 -a '!!type!header'
374
421
COMMENT "Extracting sysmonevents.h.utf16"
375
422
DEPENDS "${SYSMON_COMMON_SOURCE_DIR} /manifest.tt"
376
423
)
377
424
378
425
add_custom_command (OUTPUT sysmonevents.h
379
- COMMAND "${ICONV} " -f UTF-16LE -t UTF-8 sysmonevents.h.utf16 -o sysmonevents.h
426
+ COMMAND "${ICONV} " -f ASCII -t UTF-8 sysmonevents.h.utf16 -o sysmonevents.h
380
427
COMMENT "Converting sysmonevents.h.utf16 to UTF8"
381
428
DEPENDS sysmonevents.h.utf16
382
429
)
383
430
384
431
add_custom_command (OUTPUT sysmonmsg.mc.utf16
385
- COMMAND "mono" " ${TEXTTRANSFORM} " "${SYSMON_COMMON_SOURCE_DIR} /manifest.tt" -out sysmonmsg.mc.utf16 -a '!!version!internal' -a '!!type!mc'
432
+ COMMAND "${TEXTTRANSFORM} " "${SYSMON_COMMON_SOURCE_DIR} /manifest.tt" -out sysmonmsg.mc.utf16 -a '!!version!internal' -a '!!type!mc'
386
433
COMMENT "Extracting sysmonmsg.mc.utf16"
387
434
DEPENDS "${SYSMON_COMMON_SOURCE_DIR} /manifest.tt"
388
435
)
389
436
390
437
add_custom_command (OUTPUT sysmonmsg.mc
391
- COMMAND "${ICONV} " -f UTF-16LE -t UTF-8 sysmonmsg.mc.utf16 -o sysmonmsg.mc
438
+ COMMAND "${ICONV} " -f ASCII -t UTF-8 sysmonmsg.mc.utf16 -o sysmonmsg.mc
392
439
COMMENT "Converting sysmonmsg.mc.utf16 to UTF8"
393
440
DEPENDS sysmonmsg.mc.utf16
394
441
)
@@ -400,13 +447,13 @@ add_custom_command(OUTPUT sysmonmsg.h
400
447
)
401
448
402
449
add_custom_command (OUTPUT sysmonmsgop.man.utf16
403
- COMMAND "mono" " ${TEXTTRANSFORM} " "${SYSMON_COMMON_SOURCE_DIR} /manifest.tt" -out sysmonmsgop.man.utf16 -a '!!version!internal' -a '!!type!man'
450
+ COMMAND "${TEXTTRANSFORM} " "${SYSMON_COMMON_SOURCE_DIR} /manifest.tt" -out sysmonmsgop.man.utf16 -a '!!version!internal' -a '!!type!man'
404
451
COMMENT "Extracting sysmonmsgop.man.utf16"
405
452
DEPENDS "${SYSMON_COMMON_SOURCE_DIR} /manifest.tt"
406
453
)
407
454
408
455
add_custom_command (OUTPUT sysmonmsgop.man
409
- COMMAND "${ICONV} " -f UTF-16LE -t UTF-8 sysmonmsgop.man.utf16 -o sysmonmsgop.man
456
+ COMMAND "${ICONV} " -f ASCII -t UTF-8 sysmonmsgop.man.utf16 -o sysmonmsgop.man
410
457
COMMENT "Converting sysmonmsgop.man.utf16 to UTF8"
411
458
DEPENDS sysmonmsgop.man.utf16
412
459
)
@@ -423,7 +470,7 @@ add_custom_command(OUTPUT sysmonmsgop.c
423
470
DEPENDS sysmonmsgop.man
424
471
)
425
472
426
- #
473
+ #
427
474
# convert embedded files to objects for linking with the sysmon binary
428
475
#
429
476
add_custom_command (OUTPUT manifest.xml.o
@@ -439,6 +486,12 @@ set(PACKED_BINARY_FILES
439
486
sysmonEBPFkern5.2.o
440
487
sysmonEBPFkern5.3-5.5.o
441
488
sysmonEBPFkern5.6-.o
489
+ sysmonEBPFkern4.15_core.o
490
+ sysmonEBPFkern4.16_core.o
491
+ sysmonEBPFkern4.17-5.1_core.o
492
+ sysmonEBPFkern5.2_core.o
493
+ sysmonEBPFkern5.3-5.5_core.o
494
+ sysmonEBPFkern5.6-_core.o
442
495
sysmonLogView
443
496
sysmon.service
444
497
sysmon.d
@@ -485,10 +538,12 @@ set(CLANG_OPTIONS -Wno-unused-value
485
538
-Wno-address-of-packed-member
486
539
-Wno-tautological-compare
487
540
-Wno-unknown-warning-option
541
+ -g
488
542
)
489
543
set (CLANG_DEFINES -D __KERNEL__
490
544
-D __BPF_TRACING__
491
545
-D __TARGET_ARCH_x86
546
+ -D __linux__
492
547
)
493
548
if (DEBUG_K )
494
549
message ("Using DEBUG_K Option..." )
@@ -506,35 +561,44 @@ set(CLANG_INCLUDES
506
561
-I "${libbpf_SOURCE_DIR} /src"
507
562
)
508
563
564
+ set (EBPF_CORE_PROG_SUFFIX "_core" )
565
+
509
566
#
510
567
# EBPF
511
568
#
512
569
# This section makes the EBPF programs
513
570
#
514
571
515
572
# function to make ebpf programs
516
- function (build_ebpf ebpfsrc )
517
- add_custom_command (OUTPUT ${ebpfsrc} .o
518
- COMMAND "${CLANG} " -nostdinc -isystem `gcc -print-file-name=include` ${CLANG_INCLUDES} ${CLANG_DEFINES} -O2 ${CLANG_OPTIONS} -emit-llvm -fno-stack-protector -c "${CMAKE_SOURCE_DIR} /ebpfKern/${ebpfsrc} .c" -o -| "${LLC} " -march=bpf -filetype=obj -o " ${ebpfsrc } .o"
519
- COMMENT "Building EBPF object ${ebpfsrc} .o"
573
+ function (build_ebpf ebpfsrc suffix )
574
+ add_custom_command (OUTPUT ${ebpfsrc}${suffix} .o
575
+ COMMAND "${CLANG} " -nostdinc -isystem `gcc -print-file-name=include` ${CLANG_INCLUDES} ${CLANG_DEFINES} -O2 ${CLANG_OPTIONS} -target bpf -fno-stack-protector -c "${CMAKE_SOURCE_DIR} /ebpfKern/${ebpfsrc} .c" -o "${ebpfsrc}${suffix } .o"
576
+ COMMENT "Building EBPF object ${ebpfsrc}${suffix} .o"
520
577
DEPENDS ebpfKern/${ebpfsrc}.c ${EBPF_DEPENDS}
521
578
)
522
579
endfunction ()
523
580
524
- # loop for all ebpf programs
581
+ # Loop for all ebpf programs
525
582
foreach (EBPF_PROG IN LISTS EBPF_PROGS )
526
583
527
584
# add custom target to build all ebpf programs with 'all'
528
585
add_custom_target (${EBPF_PROG} ALL
529
586
DEPENDS "${CMAKE_SOURCE_DIR} /ebpfKern/${EBPF_PROG} .c"
530
- )
587
+ )
531
588
532
589
# test to only build ebpf programs when they have changed
533
590
if (${CMAKE_SOURCE_DIR} /ebpfKern/${EBPF_PROG}.c IS_NEWER_THAN ${CMAKE_BINARY_DIR} /${EBPF_PROG}.o )
534
- build_ebpf (${EBPF_PROG} )
591
+ # first build NON CORE program
592
+ list (REMOVE_ITEM CLANG_DEFINES -DEBPF_CO_RE )
593
+ build_ebpf (${EBPF_PROG} "" )
594
+ set_directory_properties (PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES ${EBPF_PROG} .o )
535
595
endif ()
536
596
537
- # add ebpf programs to clean
538
- set_directory_properties (PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES ${EBPF_PROG} .o )
539
- endforeach (EBPF_PROG )
597
+ if (${CMAKE_SOURCE_DIR} /ebpfKern/${EBPF_PROG}.c IS_NEWER_THAN ${CMAKE_BINARY_DIR} /${EBPF_PROG}${EBPF_CORE_PROG_SUFFIX}.o )
598
+ # next build CORE program
599
+ list (APPEND CLANG_DEFINES -DEBPF_CO_RE )
600
+ build_ebpf (${EBPF_PROG} ${EBPF_CORE_PROG_SUFFIX} )
601
+ set_directory_properties (PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES ${EBPF_PROG}${EBPF_CORE_PROG_SUFFIX} .o )
602
+ endif ()
540
603
604
+ endforeach (EBPF_PROG )
0 commit comments