mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-05-23 05:42:29 +00:00
Validate privileged code relationships
- Work towards improving non-optimized build support - Introduce MODE=zero which is -O0 without ASAN/UBSAN - Use system GCC when ~/.cosmo.mk has USE_SYSTEM_TOOLCHAIN=1 - Have package.com check .privileged code doesn't call non-privileged
This commit is contained in:
parent
01fd655097
commit
daf4454a06
82 changed files with 808 additions and 850 deletions
|
@ -27,7 +27,6 @@
|
|||
#include "libc/runtime/internal.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
#include "libc/runtime/stack.h"
|
||||
#include "libc/runtime/symbols.internal.h"
|
||||
#include "libc/thread/tls.h"
|
||||
#include "libc/thread/tls2.h"
|
||||
|
||||
|
@ -47,9 +46,7 @@
|
|||
#define DETOUR_SKEW 8
|
||||
#endif
|
||||
|
||||
void ftrace_hook(void);
|
||||
|
||||
static int g_stackdigs;
|
||||
extern _Hide int ftrace_stackdigs;
|
||||
static struct CosmoFtrace g_ftrace;
|
||||
|
||||
static privileged inline int GetNestingLevelImpl(struct StackFrame *frame) {
|
||||
|
@ -73,9 +70,11 @@ static privileged inline int GetNestingLevel(struct CosmoFtrace *ft,
|
|||
/**
|
||||
* Prints name of function being called.
|
||||
*
|
||||
* We insert CALL instructions that point to this function, in the
|
||||
* prologues of other functions. We assume those functions behave
|
||||
* according to the System Five NexGen32e ABI.
|
||||
* Whenever a function is called, ftrace_hook() will be called from the
|
||||
* function prologue which saves the parameter registers and calls this
|
||||
* function, which is responsible for logging the function call.
|
||||
*
|
||||
* @see ftrace_install()
|
||||
*/
|
||||
privileged void ftracer(void) {
|
||||
uintptr_t fn;
|
||||
|
@ -101,20 +100,10 @@ privileged void ftracer(void) {
|
|||
fn = sf->addr + DETOUR_SKEW;
|
||||
if (fn != ft->ft_lastaddr) {
|
||||
stackuse = GetStackAddr() + GetStackSize() - (intptr_t)sf;
|
||||
kprintf("%rFUN %6P %'13T %'*ld %*s%t\n", g_stackdigs, stackuse,
|
||||
kprintf("%rFUN %6P %'13T %'*ld %*s%t\n", ftrace_stackdigs, stackuse,
|
||||
GetNestingLevel(ft, sf) * 2, "", fn);
|
||||
ft->ft_lastaddr = fn;
|
||||
}
|
||||
ft->ft_noreentry = false;
|
||||
}
|
||||
}
|
||||
|
||||
textstartup int ftrace_install(void) {
|
||||
if (GetSymbolTable()) {
|
||||
g_stackdigs = LengthInt64Thousands(GetStackSize());
|
||||
return __hook(ftrace_hook, GetSymbolTable());
|
||||
} else {
|
||||
kprintf("error: --ftrace failed to open symbol table\n");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue