2N/A * The contents of this file are subject to the terms of the 2N/A * Common Development and Distribution License (the "License"). 2N/A * You may not use this file except in compliance with the License. 2N/A * See the License for the specific language governing permissions 2N/A * and limitations under the License. 2N/A * When distributing Covered Code, include this CDDL HEADER in each 2N/A * If applicable, add the following below this CDDL HEADER, with the 2N/A * fields enclosed by brackets "[]" replaced with your own identifying 2N/A * information: Portions Copyright [yyyy] [name of copyright owner] 2N/A * Copyright 2006 Sun Microsystems, Inc. All rights reserved. 2N/A * Use is subject to license terms. 2N/A#
pragma ident "%Z%%M% %I% %E% SMI" 2N/A * Look for a SYSCALL instruction in the process's address space. 2N/A int syspri;
/* priority of SYSCALL instruction */ 2N/A int n2bytes;
/* number of bytes in second buffer */ 2N/A unsigned nmap;
/* number of map descriptors */ 2N/A /* try the most recently-seen syscall address */ 2N/A /* try the previous instruction */ 2N/A /* open the /proc/<pid>/map file */ 2N/A /* allocate a plausible initial buffer size */ 2N/A /* read all the map structures, allocating more space as needed */ 2N/A dprintf(
"Pscantext: failed to allocate buffer\n");
2N/A dprintf(
"Pscantext: failed to read map file: %s\n",
2N/A /* allocate a bigger buffer */ 2N/A * Scan each executable mapping looking for a syscall instruction. 2N/A * In dynamically linked executables, syscall instructions are 2N/A * typically only found in shared libraries. Because shared libraries 2N/A * are most often mapped at the top of the address space, we minimize 2N/A * our expected search time by starting at the last mapping and working 2N/A * our way down to the first mapping. 2N/A /* avoid non-EXEC mappings; avoid the stack and heap */ 2N/A /* search text for a SYSCALL instruction */