Tiny binary.

This commit is contained in:
Bartosz Taudul 2019-09-26 23:54:08 +02:00
parent 6f5dd44f1f
commit 9de2d312a3
2 changed files with 7 additions and 4 deletions

3
extra/systrace/build Normal file
View File

@ -0,0 +1,3 @@
clang tracy_systrace.c -s -Os -ffunction-sections -fdata-sections -Wl,--gc-sections -fno-stack-protector -Wl,-z,norelro -Wl,--build-id=none -nostdlib -lc
strip --strip-all -R .note.gnu.gold-version -R .comment -R .note -R .note.gnu.build-id -R .note.ABI-tag -R .eh_frame -R .eh_frame_hdr -R .gnu.hash -R .gnu.version -R .got a.out
sstrip -z a.out (elfkickers)

View File

@ -3,17 +3,18 @@
#include <stdio.h> #include <stdio.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <sys/types.h> #include <sys/types.h>
#include <stdlib.h>
#include <time.h> #include <time.h>
#include <unistd.h> #include <unistd.h>
enum { BufSize = 64*1024 }; enum { BufSize = 64*1024 };
int main() void _start()
{ {
char buf[BufSize]; char buf[BufSize];
int kernelFd = open( "/sys/kernel/debug/tracing/trace_pipe", O_RDONLY ); int kernelFd = open( "/sys/kernel/debug/tracing/trace_pipe", O_RDONLY );
if( kernelFd == -1 ) return -1; if( kernelFd < 0 ) exit( 0 );
struct pollfd pfd; struct pollfd pfd;
pfd.fd = kernelFd; pfd.fd = kernelFd;
@ -31,6 +32,5 @@ int main()
write( STDOUT_FILENO, buf, rd ); write( STDOUT_FILENO, buf, rd );
} }
close( kernelFd ); exit( 0 );
return 0;
} }