// Entry points; funcs reachable by definition (call-graph roots)
.decl entry_point(func:FunctionDecl)

// The main func and any other funcs called automatically at
// startup, are our program's entry points

entry_point(Func) :-
   main_func(Func)
 ; called_at_startup(Func).

//-----------------------------------------------------------------------
// Main func
//-----------------------------------------------------------------------

.decl main_func(func:Function)

main_func(MainFn) :-
   func_name(MainFn, "@main"),
   func(MainFn).

//-----------------------------------------------------------------------
// C Runtime performs initializations before running main() by calling
// funcs (e.g., global constructors) insided special sections.
//-----------------------------------------------------------------------

.decl called_at_startup(func:FunctionDecl)

called_at_startup(StartupFn) :-
   func_section(StartupFn, ".text.startup").
