1*e5436d32Slukem /* $NetBSD: nlist.c,v 1.16 1997/10/17 10:15:14 lukem Exp $ */ 263488d73Sthorpej 361f28255Scgd /*- 4c347bc09Scgd * Copyright (c) 1996 Christopher G. Demetriou. All rights reserved. 5ec1b7778Spk * Copyright (c) 1990, 1993 6ec1b7778Spk * The Regents of the University of California. All rights reserved. 761f28255Scgd * 861f28255Scgd * Redistribution and use in source and binary forms, with or without 961f28255Scgd * modification, are permitted provided that the following conditions 1061f28255Scgd * are met: 1161f28255Scgd * 1. Redistributions of source code must retain the above copyright 1261f28255Scgd * notice, this list of conditions and the following disclaimer. 1361f28255Scgd * 2. Redistributions in binary form must reproduce the above copyright 1461f28255Scgd * notice, this list of conditions and the following disclaimer in the 1561f28255Scgd * documentation and/or other materials provided with the distribution. 1661f28255Scgd * 3. All advertising materials mentioning features or use of this software 1761f28255Scgd * must display the following acknowledgement: 1861f28255Scgd * This product includes software developed by the University of 1961f28255Scgd * California, Berkeley and its contributors. 2061f28255Scgd * 4. Neither the name of the University nor the names of its contributors 2161f28255Scgd * may be used to endorse or promote products derived from this software 2261f28255Scgd * without specific prior written permission. 2361f28255Scgd * 2461f28255Scgd * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 2561f28255Scgd * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 2661f28255Scgd * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 2761f28255Scgd * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 2861f28255Scgd * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2961f28255Scgd * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 3061f28255Scgd * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 3161f28255Scgd * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 3261f28255Scgd * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 3361f28255Scgd * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 3461f28255Scgd * SUCH DAMAGE. 3561f28255Scgd */ 3661f28255Scgd 37*e5436d32Slukem #include <sys/cdefs.h> 3861f28255Scgd #ifndef lint 3963488d73Sthorpej #if 0 4063488d73Sthorpej static char sccsid[] = "from: @(#)nlist.c 8.1 (Berkeley) 6/6/93"; 4163488d73Sthorpej #else 42*e5436d32Slukem __RCSID("$NetBSD: nlist.c,v 1.16 1997/10/17 10:15:14 lukem Exp $"); 4363488d73Sthorpej #endif 4461f28255Scgd #endif /* not lint */ 4561f28255Scgd 4661f28255Scgd #include <sys/param.h> 47ec1b7778Spk 4861f28255Scgd #include <a.out.h> 4961f28255Scgd #include <db.h> 50ec1b7778Spk #include <err.h> 5161f28255Scgd #include <errno.h> 52ec1b7778Spk #include <fcntl.h> 5361f28255Scgd #include <kvm.h> 54ec1b7778Spk #include <limits.h> 5561f28255Scgd #include <stdio.h> 5661f28255Scgd #include <stdlib.h> 57ec1b7778Spk #include <string.h> 58ec1b7778Spk #include <unistd.h> 59ec1b7778Spk 60ec1b7778Spk #include "extern.h" 6161f28255Scgd 62c347bc09Scgd static struct { 63c347bc09Scgd int (*knlist) __P((const char *, DB *)); 64c347bc09Scgd } knlist_fmts[] = { 65c347bc09Scgd #ifdef NLIST_AOUT 66c347bc09Scgd { create_knlist_aout }, 67c347bc09Scgd #endif 68c347bc09Scgd #ifdef NLIST_ECOFF 69c347bc09Scgd { create_knlist_ecoff }, 70c347bc09Scgd #endif 71c347bc09Scgd #ifdef NLIST_ELF32 72c347bc09Scgd { create_knlist_elf32 }, 73c347bc09Scgd #endif 74c347bc09Scgd #ifdef NLIST_ELF64 75c347bc09Scgd { create_knlist_elf64 }, 76c347bc09Scgd #endif 77c347bc09Scgd }; 786ff21e94Spk 796ff21e94Spk void 8061f28255Scgd create_knlist(name, db) 81c347bc09Scgd const char *name; 8261f28255Scgd DB *db; 8361f28255Scgd { 84c347bc09Scgd int i; 8561f28255Scgd 86c347bc09Scgd for (i = 0; i < sizeof(knlist_fmts) / sizeof(knlist_fmts[0]); i++) 87c347bc09Scgd if ((*knlist_fmts[i].knlist)(name, db) != -1) 88c347bc09Scgd return; 89c347bc09Scgd warnx("%s: file format not recognized", name); 90c347bc09Scgd punt(); 9161f28255Scgd } 92