From: SL B. <st...@bs...> - 2002-04-24 07:15:45
|
The comments should be self-explanatory. This file implements a sial intrinsic that when given an address, returns an associated symbol name. lookup.c ---------------------- Cut Here -------------------------- /* Copyright(C) 2002 NEC Corporation, All rights reserved This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. Build this file with: gcc -I/usr/include/lkcd -c lookup.c gcc -shared -o lookup.so lookup.o This file implements new SIAL built in function lookup string lookup(long long address); The single argument is treated as an address and is looked up in the symbol table. If there is a match, then the symbol name is returned. */ #include <stdio.h> #include <sial_api.h> #include <klib.h> VALUE_S * ext_lookup(VALUE_S *vs) { kaddr_t kaddr = (kaddr_t)sial_getval(vs); syment_t *st; if ((st = kl_lkup_symaddr(kaddr))) { return sial_makestr(st->s_name); } else { return sial_makestr(""); } } BT_SPEC_TABLE = { { "string lookup(int addr)", (bf_t *)ext_lookup }, { NULL, NULL }, }; BT_INIDSO_FUNC() { return 1; } BT_ENDDSO_FUNC() { return; } |