11import (" core.project.project" )
2+ import (" lib.detect.check_cxsnippets" )
23
34-- get sourcefiles
45function _get_programs (target_name )
@@ -17,6 +18,10 @@ function gen(target, source_target)
1718 if not target then
1819 raise (" could not configure target" )
1920 end
21+ local source_gendir = path .absolute (project .target (source_target ):autogendir ())
22+ if not source_gendir then
23+ raise (" could not obtain the autogendir of the source target" )
24+ end
2025
2126 target :set (" configdir" , target :autogendir ())
2227
@@ -30,7 +35,22 @@ function gen(target, source_target)
3035 local tempconf = path .join (os .tmpdir (), confname )
3136 os .tryrm (tempconf )
3237 os .cp (configfile_template_path , tempconf )
33- target :add (" configfiles" , tempconf , { variables = { PROGNAME = progname , OPERATION = " attach__" } })
38+
39+ local skelpath = path .join (source_gendir , progname .. " .skel.h" )
40+ local has_rodata = check_cxsnippets (" void test() {&((struct " .. progname .. " _bpf*)0)->rodata;}" , {includes = skelpath }) and 1 or 0
41+ if has_rodata == 1 then
42+ utils .dump (
43+ check_cxsnippets (' void test() {printf("%ld", sizeof(&((struct ' .. progname .. ' _bpf*)0)->rodata));}' , {includes = skelpath })
44+ )
45+ end
46+
47+ target :add (" configfiles" , tempconf , {
48+ variables = {
49+ PROGNAME = progname ,
50+ OPERATION = " attach__" ,
51+ PROGNAME_WITH_RODATA = has_rodata
52+ }
53+ })
3454 end
3555end
3656
@@ -51,18 +71,23 @@ function main(target, components_target, banner)
5171
5272 local op = vars [1 ].variables .OPERATION
5373 v [" OPERATION" ] = op
54-
74+
75+ local descr = ' " - '
5576 local programs = {}
5677 table.insert (programs , " 0" )
57- for _ , v in ipairs (vars ) do
78+ for i , v in ipairs (vars ) do
5879 table.insert (programs , v .variables .PROGNAME )
80+ descr = descr .. v .variables .PROGNAME .. (v .variables .PROGNAME_WITH_RODATA == 1 and ' [input]' or ' ' )
81+ if i ~= # vars then
82+ descr = descr .. ' \\ n - '
83+ end
5984 end
6085 table.sort (programs )
6186 v [" PROGRAMS_AS_SYMBOLS" ] = ' program_' .. table.concat (programs , " , program_" )
6287 v [" PROGRAMS_AS_STRINGS" ] = ' "' .. table.concat (programs , ' ", "' ) .. ' "'
6388 v [" PROGRAMS_OPS_AS_SYMBOLS" ] = op .. table.concat (programs , ' , ' .. op )
6489 table.remove (programs , 1 )
65- v [" PROGRAMS_DESCRIPTION" ] = ' " - ' .. table.concat ( programs , ' \\ n - ' ) .. ' "'
90+ v [" PROGRAMS_DESCRIPTION" ] = descr .. ' "'
6691
6792 local content = " "
6893 for i , c in ipairs (components ) do
0 commit comments