From owner-freebsd-hackers@FreeBSD.ORG Sat Dec 1 00:01:19 2012 Return-Path: Delivered-To: hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id A1DB9BBF for ; Sat, 1 Dec 2012 00:01:19 +0000 (UTC) (envelope-from yuri@rawbw.com) Received: from shell0.rawbw.com (shell0.rawbw.com [198.144.192.45]) by mx1.freebsd.org (Postfix) with ESMTP id 710818FC08 for ; Sat, 1 Dec 2012 00:01:19 +0000 (UTC) Received: from eagle.yuri.org (stunnel@localhost [127.0.0.1]) (authenticated bits=0) by shell0.rawbw.com (8.14.4/8.14.4) with ESMTP id qB101IKH094574 for ; Fri, 30 Nov 2012 16:01:18 -0800 (PST) (envelope-from yuri@rawbw.com) Message-ID: <50B948CE.5080304@rawbw.com> Date: Fri, 30 Nov 2012 16:01:18 -0800 From: Yuri User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:17.0) Gecko/17.0 Thunderbird/17.0 MIME-Version: 1.0 To: hackers@freebsd.org Subject: How to overload the system call in the userland program? Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 01 Dec 2012 00:01:19 -0000 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