/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code 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
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*
*/
#include <unistd.h>
#include <search.h>
#include <stdlib.h>
#include <string.h>
#include <db.h>
#include <fcntl.h>
#include "symtab.h"
#include "salibelf.h"
// ----------------------------------------------------
// functions for symbol lookups
// ----------------------------------------------------
struct elf_section {
void *c_data;
};
struct elf_symbol {
char *name;
};
typedef struct symtab {
char *strs;
} symtab_t;
// read symbol table from given fd.
// Reading of elf header
int cnt = 0;
int symtab_found = 0;
int dynsym_found = 0;
// not an elf
return NULL;
}
// read ELF header
goto quit;
}
goto quit;
}
goto quit;
}
}
symtab_found++;
dynsym_found++;
cursct++;
}
if (!symtab_found && dynsym_found)
int j, n;
// FIXME: there could be multiple data buffers associated with the
// same ELF section. Here we can handle only one buffer. See man page
// for elf_getdata on Solaris.
// guarantee(symtab == NULL, "multiple symtab");
goto quit;
}
// the symbol table
// number of symbols
// create hash table, we use berkeley db to
// manipulate the hash table.
// guarantee(symtab->hash_table, "unexpected failure: dbopen");
goto bad;
// shdr->sh_link points to the section that contains the actual strings
// for symbol names. the st_name field in ELF_SYM is just the
// string table index. we make a copy of the string table so the
// strings will not be destroyed by elf_end.
goto bad;
// allocate memory for storing symbol offset and size;
symtab->num_symbols = n;
goto bad;
// copy symbols info our symtab and enter them info the hash table
for (j = 0; j < n; j++, syms++) {
// skip non-object and non-function symbols
continue;
// skip empty strings and undefined symbols
}
}
}
goto quit;
bad:
quit:
if (scn_cache) {
}
}
}
return symtab;
}
if (!symtab) return;
if (symtab->hash_table) {
}
}
int ret;
// library does not have symbol table
return 0;
if (ret == 0) {
return rslt;
}
return 0;
}
int n = 0;
for (; n < symtab->num_symbols; n++) {
}
}
return NULL;
}