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 (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved. 2N/A#
error "STT_NUM has grown. update dt_module_syminit32()" 2N/A for (i = 0; i < n; i++,
sym++) {
2N/A continue;
/* skip sections and unknown types */ 2N/A continue;
/* skip null or invalid names */ 2N/A asrsv++;
/* reserve space in the address map */ 2N/A#
error "STT_NUM has grown. update dt_module_syminit64()" 2N/A for (i = 0; i < n; i++,
sym++) {
2N/A continue;
/* skip sections and unknown types */ 2N/A continue;
/* skip null or invalid names */ 2N/A asrsv++;
/* reserve space in the address map */ 2N/A * Sort comparison function for 32-bit symbol address-to-name lookups. We sort 2N/A * symbols by value. If values are equal, we prefer the symbol that is 2N/A * non-zero sized, typed, not weak, or lexically first, in that order. 2N/A * Sort comparison function for 64-bit symbol address-to-name lookups. We sort 2N/A * symbols by value. If values are equal, we prefer the symbol that is 2N/A * non-zero sized, typed, not weak, or lexically first, in that order. 2N/A for (i =
1; i < n; i++,
dsp++) {
2N/A for (i =
1; i < n; i++,
dsp++) {
2N/A * If the previous entry has the same value, improve our choice. The 2N/A * order of equal-valued symbols is determined by the comparison func. 2N/A * If the previous entry has the same value, improve our choice. The 2N/A * order of equal-valued symbols is determined by the comparison func. 2N/A return (
NULL);
/* caller must handle allocation failure */ 2N/A continue;
/* skip any malformed sections */ 2N/A break;
/* section matches specification */ 2N/A * If the section isn't found, return success but leave cts_data set 2N/A * to NULL and cts_size set to zero for our caller. 2N/A return (0);
/* module is already loaded */ 2N/A * Attempt to load the module's CTF section, symbol table section, and 2N/A * string table section. Note that modules may not contain CTF data: 2N/A * this will result in a successful load_sect but data of size zero. 2N/A * We will then fail if dt_module_getctf() is called, as shown below. 2N/A return (-
1);
/* dt_errno is set for us */ 2N/A * Allocate the hash chains and hash buckets for symbol name lookup. 2N/A * This is relatively simple since the symbol table is of fixed size 2N/A * and is known in advance. We allocate one extra element since we 2N/A * use element indices instead of pointers and zero is our sentinel. 2N/A * Iterate over the symbol table data buffer and insert each symbol 2N/A * name into the name hash if the name and type are valid. Then 2N/A * allocate the address map, fill it in, and sort it. 2N/A * If the data model of the module does not match our program data 2N/A * model, then do not permit CTF from this module to be opened and 2N/A * returned to the compiler. If we support mixed data models in the 2N/A * Now remove this module from its hash chain. We expect to always 2N/A * find the module on its hash chain, so in this loop we assert that 2N/A * we don't run off the end of the list. 2N/A * Insert a new external symbol reference into the specified module. The new 2N/A * symbol will be marked as undefined and is assigned a symbol index beyond 2N/A * any existing cached symbols from this module. We use the ident's di_data 2N/A * field to store a pointer to a copy of the dtrace_syminfo_t for this symbol. 2N/A * Update our module cache by adding an entry for the specified module 'name'. 2N/A * will return ENOENT), tell libelf to cook the entire file now and 2N/A * then close the underlying file descriptor immediately. If this 2N/A * succeeds, we know that we can continue safely using dmp->dm_elf. 2N/A * Iterate over the section headers locating various sections of 2N/A * interest and use their attributes to flesh out the dt_module_t. 2N/A continue;
/* skip any malformed sections */ 2N/A * Unload all the loaded modules and then refresh the module cache with the 2N/A * latest list of loaded modules and their address ranges. 2N/A * each kernel module that is loaded on the current system. 2N/A * Look up all the macro identifiers and set di_id to the latest value. 2N/A * This code collaborates with dt_lex.l on the use of di_id. We will 2N/A * need to implement something fancier if we need to support non-ints. 2N/A * Cache the pointers to the modules representing the base executable 2N/A * and the run-time linker in the dtrace client handle. Note that on 2N/A * x86 krtld is folded into unix, so if we don't find it, use unix 2N/A * If this is the first time we are initializing the module list, 2N/A * remove the module for genunix from the module list and then move it 2N/A * to the front of the module list. We do this so that type and symbol 2N/A * queries encounter genunix and thereby optimize for the common case 2N/A * in dtrace_lookup_by_name() and dtrace_lookup_by_type(), below. 2N/A * Exported interface to look up a symbol by name. We return the GElf_Sym and 2N/A * complete symbol information for the matching symbol. 2N/A return (-
1);
/* dt_errno is set for us */ 2N/A return (-
1);
/* dt_errno is set for us */ 2N/A continue;
/* failed to match required attributes */ 2N/A continue;
/* failed to load symbol table */ 2N/A * Exported interface to look up a symbol by address. We return the GElf_Sym 2N/A * and complete symbol information for the matching symbol. 2N/A return (-
1);
/* dt_errno is set for us */ 2N/A return (-
1);
/* dt_errno is set for us */ 2N/A return (-
1);
/* dt_errno is set for us */ 2N/A continue;
/* failed to match required attributes */ 2N/A * If we can't load the CTF container, continue on to the next 2N/A * module. If our search was scoped to only one module then 2N/A * return immediately leaving dt_errno unmodified. 2N/A * Look up the type in the module's CTF container. If our 2N/A * match is a forward declaration tag, save this choice in 2N/A * 'tip' and keep going in the hope that we will locate the 2N/A * underlying structure definition. Otherwise just return. 2N/A return (-
1);
/* errno is set for us */ 2N/A return (-
1);
/* dt_errno is set for us */ 2N/A return (-
1);
/* dt_errno is set for us */