Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 30 Nov 2012 16:01:18 -0800
From:      Yuri <yuri@rawbw.com>
To:        hackers@freebsd.org
Subject:   How to overload the system call in the userland program?
Message-ID:  <50B948CE.5080304@rawbw.com>

next in thread | raw e-mail | index | archive | help
I am looking into one library (google-perftools) that attempts to 
overload sbrk(2).
In Linux libc translates calls, ex. sbrk -> __sbrk (in libc), so one can 
define their own version, call extern __sbrk and it works.
FreeBSD programs connect to the symbol sbrk@@FBSD_1.0

So what is the way to overload the system call like this would be in linux?:

extern "C" void* __sbrk(ptrdiff_t increment);
extern "C" void* sbrk(intptr_t increment) {
   return__sbrk(increment);
}

Yuri




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?50B948CE.5080304>