本文整理汇总了C++中elf_getdata函数的典型用法代码示例。如果您正苦于以下问题:C++ elf_getdata函数的具体用法?C++ elf_getdata怎么用?C++ elf_getdata使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了elf_getdata函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: FindExportTrampolines
static ExportTrampolineVector FindExportTrampolines(Elf *e,
const ElfSectionInfo &xptramp_info) {
auto sym_scn = FindSectionByType(e, SHT_DYNSYM);
auto sym_data = elf_getdata(sym_scn.first, nullptr);
auto syms = reinterpret_cast<Elf_Sym*>(sym_data->d_buf);
ExportTrampolineVector res;
// FIXME: this assumes that the whole section
// is inside a single Elf_Data object
auto xptramp_data = elf_getdata(xptramp_info.first, nullptr);
auto xptramp_start = reinterpret_cast<uint8_t*>(xptramp_data->d_buf);
auto xptramp_end = xptramp_start + xptramp_data->d_size;
for (auto ptr = xptramp_start; ptr < xptramp_end;) {
auto addr = xptramp_info.second.sh_addr + xptramp_data->d_off + (ptr - xptramp_start);
auto ofs = xptramp_info.second.sh_offset + xptramp_data->d_off + (ptr - xptramp_start);
auto arg = *reinterpret_cast<uint32_t*>(ptr + 1);
switch(ptr[0]) {
case 0x01:
res.emplace_back(addr, ofs, syms[arg].st_value);
break;
case 0xE9:
break;
default:
errx(EX_SOFTWARE, ".xptramp section has invalid byte: %hhd\n", ptr[0]);
}
ptr += 5;
}
return res;
}
开发者ID:yurizhykin,项目名称:selfrando,代码行数:29,代码来源:PatchEntry.cpp
示例2: get_data_from_iterator
unsigned char *
get_data_from_iterator (struct data_iterator *it, GElf_Addr size)
{
unsigned char *ptr;
/* If we're at the end of a data block, move onto the next. */
if (it->data && it->data->d_off + it->data->d_size == it->sec_offset)
it->data = elf_getdata (it->dso->scn[it->sec], it->data);
if (it->data == NULL)
{
/* Find out which section contains the next byte. */
it->sec = addr_to_sec (it->dso, it->addr);
if (it->sec < 0)
return NULL;
/* Fast-forward to the block that contains ADDR, if any. */
it->sec_offset = it->addr - it->dso->shdr[it->sec].sh_addr;
do
it->data = elf_getdata (it->dso->scn[it->sec], it->data);
while (it->data && it->data->d_off + it->data->d_size <= it->sec_offset);
}
/* Make sure that all the data we want is included in this block. */
if (it->data == NULL
|| it->data->d_off > it->sec_offset
|| it->data->d_off + it->data->d_size < it->sec_offset + size)
return NULL;
ptr = (unsigned char *) it->data->d_buf + (it->sec_offset - it->data->d_off);
it->sec_offset += size;
it->addr += size;
return ptr;
}
开发者ID:foxsen,项目名称:prelink,代码行数:34,代码来源:data.c
示例3: handle_dynamic_section
static void handle_dynamic_section(elf_info_s *elf, Elf_Scn *scn, GElf_Shdr shdr)
{
Elf_Data *data;
GElf_Addr replt_addr;
size_t replt_count;
/* get data of .dynamic */
data = elf_getdata(scn, NULL);
/* iterate through .dynamic */
for (size_t i = 0; i < shdr.sh_size / shdr.sh_entsize; ++i) {
GElf_Dyn dyn;
// get entries i
gelf_getdyn(data, i, &dyn);
// if replt
if (dyn.d_tag == DT_JMPREL)
replt_addr = dyn.d_un.d_ptr;
// if replt_size
if (dyn.d_tag == DT_PLTRELSZ)
replt_count = dyn.d_un.d_val;
}
LOG(INFO, "Section relplt at 0x%lx (%zu)", replt_addr, replt_count);
for (size_t i = 1; i < elf->hdr.e_shnum; ++i) {
Elf_Scn *scn;
GElf_Shdr shdr;
scn = elf_getscn(elf->elf, i);
gelf_getshdr(scn, &shdr);
if (shdr.sh_addr == replt_addr && shdr.sh_size == replt_count) {
elf->replt = elf_getdata(scn, NULL);
elf->replt_count = shdr.sh_size / shdr.sh_entsize;
break;
}
}
}
开发者ID:schischi,项目名称:my_ltrace,代码行数:35,代码来源:elfd.c
示例4: resolve_relocations
static void resolve_relocations(sym_strtab **list)
{
Elf_Scn *scn;
Elf64_Shdr *shdr;
scn = NULL;
while ((scn = elf_nextscn(e, scn)))
{
if ((shdr = elf64_getshdr(scn)) == NULL)
exit_error("gelf_getshdr() fail");
if (shdr->sh_type == SHT_DYNSYM)
{
Elf_Data *data;
data = elf_getdata(scn, NULL);
dynsym_tab = (Elf64_Sym*)data->d_buf;
}
if (shdr->sh_type == SHT_STRTAB && shdr->sh_flags == SHF_ALLOC)
{
Elf_Data *data;
data = elf_getdata(scn, NULL);
dynsym_strtab = (char*)data->d_buf;
}
}
if (!dynsym_tab)
return;
scn = NULL;
while ((scn = elf_nextscn(e, scn)))
{
if ((shdr = elf64_getshdr(scn)) == NULL)
exit_error("gelf_getshdr() fail");
if (shdr->sh_type == SHT_RELA)
reloc_treatment(scn, shdr, list);
}
}
开发者ID:basticho,项目名称:ftrace,代码行数:34,代码来源:symbolnames.c
示例5: elf_getdata
static Elf_Data *loaddata(Elf_Scn *scn, GElf_Shdr *shdr)
{
Elf_Data *data = elf_getdata(scn, NULL);
if (data == NULL || elf_getdata(scn, data) != NULL
|| data->d_off || data->d_size != shdr->sh_size)
return NULL;
return data;
}
开发者ID:KapJlcoH,项目名称:ltrace,代码行数:8,代码来源:ltrace-elf.c
示例6: radeon_elf_read
void radeon_elf_read(const char *elf_data, unsigned elf_size,
struct radeon_shader_binary *binary,
unsigned debug)
{
char *elf_buffer;
Elf *elf;
Elf_Scn *section = NULL;
size_t section_str_index;
/* One of the libelf implementations
* (http://www.mr511.de/software/english.htm) requires calling
* elf_version() before elf_memory().
*/
elf_version(EV_CURRENT);
elf_buffer = MALLOC(elf_size);
memcpy(elf_buffer, elf_data, elf_size);
elf = elf_memory(elf_buffer, elf_size);
elf_getshdrstrndx(elf, §ion_str_index);
binary->disassembled = 0;
while ((section = elf_nextscn(elf, section))) {
const char *name;
Elf_Data *section_data = NULL;
GElf_Shdr section_header;
if (gelf_getshdr(section, §ion_header) != §ion_header) {
fprintf(stderr, "Failed to read ELF section header\n");
return;
}
name = elf_strptr(elf, section_str_index, section_header.sh_name);
if (!strcmp(name, ".text")) {
section_data = elf_getdata(section, section_data);
binary->code_size = section_data->d_size;
binary->code = MALLOC(binary->code_size * sizeof(unsigned char));
memcpy(binary->code, section_data->d_buf, binary->code_size);
} else if (!strcmp(name, ".AMDGPU.config")) {
section_data = elf_getdata(section, section_data);
binary->config_size = section_data->d_size;
binary->config = MALLOC(binary->config_size * sizeof(unsigned char));
memcpy(binary->config, section_data->d_buf, binary->config_size);
} else if (debug && !strcmp(name, ".AMDGPU.disasm")) {
binary->disassembled = 1;
section_data = elf_getdata(section, section_data);
fprintf(stderr, "\nShader Disassembly:\n\n");
fprintf(stderr, "%.*s\n", (int)section_data->d_size,
(char *)section_data->d_buf);
}
}
if (elf){
elf_end(elf);
}
FREE(elf_buffer);
}
开发者ID:Haifen,项目名称:Mesa-3D,代码行数:55,代码来源:radeon_elf_util.c
示例7: read_trap_data
struct trap_data_t read_trap_data(struct trap_file_t *file) {
struct trap_data_t res = { TRAP_PLATFORM_UNKNOWN, 0, 0, NULL, 0 };
Elf_Scn *txtrp_scn = find_section(file->elf, ".txtrp");
if (txtrp_scn == NULL)
return res;
GElf_Shdr shdr;
if (gelf_getshdr(txtrp_scn, &shdr) == NULL)
errx(EXIT_FAILURE, "Cannot get section header");
res.txtrp_address = shdr.sh_addr;
// Get the platform
GElf_Ehdr ehdr;
if (gelf_getehdr(file->elf, &ehdr) == NULL)
errx(EXIT_FAILURE, "Cannot get ELF header");
switch (ehdr.e_machine) {
case EM_386:
res.trap_platform = TRAP_PLATFORM_POSIX_X86;
break;
case EM_X86_64:
res.trap_platform = TRAP_PLATFORM_POSIX_X86_64;
break;
case EM_ARM:
res.trap_platform = TRAP_PLATFORM_POSIX_ARM;
break;
case 183: // EM_AARCH64
res.trap_platform = TRAP_PLATFORM_POSIX_ARM64;
break;
default:
errx(EXIT_FAILURE, "Unknown ELF machine");
break;
}
Elf_Data *data = elf_getdata(txtrp_scn, NULL);
for (data = elf_getdata(txtrp_scn, NULL);
data != NULL;
data = elf_getdata(txtrp_scn, data))
res.size += data->d_size;
res.data = malloc(res.size);
uint8_t *ptr = res.data;
for (data = elf_getdata(txtrp_scn, NULL);
data != NULL;
data = elf_getdata(txtrp_scn, data)) {
memcpy(ptr, data->d_buf, data->d_size);
ptr += data->d_size;
}
return res;
}
开发者ID:immunant,项目名称:selfrando,代码行数:53,代码来源:ReadTrap.c
示例8: handle_dynsym_section
static void handle_dynsym_section(elf_info_s *elf, Elf_Scn *scn, GElf_Shdr shdr)
{
Elf_Data *data;
/* get .dynsym data and size */
elf->dynsym = elf_getdata(scn, NULL);
elf->dynsym_count = shdr.sh_size / shdr.sh_entsize;
/* retrieve the header table index link which point to .dynstr */
scn = elf_getscn(elf->elf, shdr.sh_link);
gelf_getshdr(scn, &shdr);
/* get the data of .dynstr */
data = elf_getdata(scn, NULL);
elf->dynstr = data->d_buf;
}
开发者ID:schischi,项目名称:my_ltrace,代码行数:14,代码来源:elfd.c
示例9: extract_functions_internal
/* Below code adapted from libelf tutorial example */
static u32 extract_functions_internal (const char *str, func_entry *func_list) {
Elf *e;
Elf_Kind ek;
Elf_Scn *scn;
Elf_Data *edata;
u32 fd, i, symbol_count;
GElf_Sym sym;
GElf_Shdr shdr;
u32 func_count = 0;
if(elf_version(EV_CURRENT) == EV_NONE) {
printf("Error initializing ELF: %s\n", elf_errmsg(-1));
return -1;
}
if ((fd = open(str, O_RDONLY, 0)) < 0) {
printf("Unable to open %s\n", str);
return -1;
}
if ((e = elf_begin(fd, ELF_C_READ, NULL)) == NULL) {
printf("elf_begin failed: %s\n", elf_errmsg(-1));
}
ek = elf_kind(e);
if(ek != ELF_K_ELF) {
printf("not an ELF object");
} else {
scn = NULL;
edata = NULL;
while((scn = elf_nextscn(e, scn)) != NULL) {
gelf_getshdr(scn, &shdr);
if(shdr.sh_type == SHT_SYMTAB) {
edata = elf_getdata(scn, edata);
symbol_count = shdr.sh_size / shdr.sh_entsize;
for(i = 0; i < symbol_count; i++) {
gelf_getsym(edata, i, &sym);
if(ELF32_ST_TYPE(sym.st_info) != STT_FUNC) {
check_for_end_marker(elf_strptr(e, shdr.sh_link, sym.st_name), sym.st_value);
continue;
}
if(sym.st_size == 0) continue;
func_list[func_count].offset = sym.st_value;
func_list[func_count++].func_name = strdup(elf_strptr(e, shdr.sh_link, sym.st_name));
if(func_count >= MAXFNS) {
printf("Func limit (%"PRId32") reached, please increase MAXFNS & rebuild\n", MAXFNS);
raise(SIGABRT);
}
// printf("%08x %08x\t%s\n", sym.st_value, sym.st_size, elf_strptr(e, shdr.sh_link, sym.st_name));
}
}
}
}
elf_end(e);
close(fd);
return func_count;
}
开发者ID:shamouda,项目名称:ocr,代码行数:61,代码来源:elf-utils.c
示例10: exec_getdata
/* if this function encounters an error it never returns */
static Elf_Data *exec_getdata( Elf_Scn *scn, int line )
#define exec_getdata(a) \
exec_getdata(a,__LINE__)
{
Elf_Data *data;
char *location;
location = NULL;
data = elf_getdata(scn, NULL);
if ( data != NULL )
{
if ( data->d_buf != NULL )
{
return data;
}
else
{
location = "d_buf";
}
}
else
{
location = "elf_data";
}
fprintf( stderr, "exec_getdata: %[email protected]%d - %s\n", location, line,
elf_errmsg( -1 ) );
exit( 1 );
}
开发者ID:wodz,项目名称:open21xx,代码行数:29,代码来源:execfile.c
示例11: find_symbol
int find_symbol(char *fn, struct lsym *lsym, unsigned long baseaddr)
{
struct lsym *ls;
int num = 0;
for (ls = lsym; ls->name; ls++)
num++;
elf_version(EV_CURRENT);
int fd = open(fn, O_RDONLY);
if (fd < 0)
return -1;
long ret = -1;
Elf *elf = elf_begin(fd, ELF_C_READ, NULL);
if (elf == NULL)
goto out;
GElf_Ehdr header;
if (!gelf_getehdr(elf, &header))
goto out_elf;
Elf_Scn *section = NULL;
int found = 0;
while (found < num && (section = elf_nextscn(elf, section)) != 0) {
GElf_Shdr shdr, *sh;
sh = gelf_getshdr(section, &shdr);
if (sh->sh_type == SHT_SYMTAB || sh->sh_type == SHT_DYNSYM) {
Elf_Data *data = elf_getdata(section, NULL);
GElf_Sym *sym, symbol;
int j;
unsigned numsym = sh->sh_size / sh->sh_entsize;
for (j = 0; j < numsym; j++) {
sym = gelf_getsymshndx(data, NULL, j, &symbol, NULL);
char *symname = elf_strptr(elf, shdr.sh_link, sym->st_name);
for (ls = lsym; ls->name; ls++) {
if (!strcmp(symname, ls->name)) {
Elf_Scn *oscn = elf_getscn(elf, sym->st_shndx);
GElf_Shdr oshdr, *osh;
osh = gelf_getshdr(oscn, &oshdr);
ls->addr = (sym->st_value - osh->sh_addr) + osh->sh_offset + baseaddr;
found++;
if (found == num)
break;
}
}
}
}
}
if (found == num)
ret = 0;
out_elf:
elf_end(elf);
out:
close(fd);
return ret;
}
开发者ID:gcracker,项目名称:tsx-tools,代码行数:60,代码来源:sym.c
示例12: dump_dynamic
static int dump_dynamic(struct file_state *f, Elf_Scn *scn, GElf_Shdr *shdr)
{
struct dyn_state d;
GElf_Dyn needed_dyn;
char *needed_name;
int i;
d.f = f;
d.dyn_data = elf_getdata(scn, NULL);
if (!d.dyn_data) {
elf_err("elf_getdata failed");
return -1;
}
d.count = shdr->sh_size / shdr->sh_entsize;
for (i = 0; i < d.count; i++) {
if (!gelf_getdyn(d.dyn_data, i, &needed_dyn))
continue;
if (needed_dyn.d_tag != DT_NEEDED)
continue;
needed_name = (char *)f->strtab_data->d_buf
+ needed_dyn.d_un.d_val;
dump_needed(f->t, needed_name);
}
return 0;
}
开发者ID:0omega,项目名称:platform_development,代码行数:30,代码来源:elftree.c
示例13: get_scnbyname
Elf_Scn *
get_scnbyname(Elf *elf, char *name, int *num)
{
Elf32_Ehdr * ehdr;
Elf_Scn * scn;
Elf32_Shdr * shdr;
Elf_Data * data;
int cnt,
tmp;
if (!num)
num = &tmp;
*num = 0;
if ((ehdr = elf32_getehdr(elf))==NULL)
return NULL;
if (((scn = elf_getscn(elf, ehdr->e_shstrndx)) == NULL) ||
((data = elf_getdata(scn, NULL)) == NULL))
return NULL;
for (cnt = 1, scn = NULL; (scn = elf_nextscn(elf, scn)); cnt++) {
if ((shdr = elf32_getshdr(scn)) == NULL)
return NULL;
if (! strcmp(name, (char *)data->d_buf + shdr->sh_name)) {
*num = cnt;
return scn;
}
}
return NULL;
}
开发者ID:akpotter,项目名称:binary-encryption,代码行数:33,代码来源:util.c
示例14: load_script
/**
* Read a script from it's elf section and store it
* @param script In output, contains the lua script loaded
* @param scn section containing the script
* @param shdr section header
* @param name name of the script
*/
static void load_script(struct lua_script *script, Elf_Scn *scn,
GElf_Shdr *shdr, const char *name)
{
unsigned i;
Elf_Data *data;
char *p;
script->name = strdup(name + strlen(LUA_WRAPPER_SECTION_PREFIX));
if (script->name == NULL)
exit(101);
script->code = calloc(shdr->sh_size + 1, 1);
if (script->name == NULL)
exit(102);
script->code[shdr->sh_size] = '\0';
data = NULL;
i = 0;
while (i < shdr->sh_size && (data = elf_getdata(scn, data)) != NULL) {
p = data->d_buf;
while (p < (char *)data->d_buf + data->d_size) {
script->code[i] = *p;
i++;
p++;
}
}
remove_shebang(script->code);
}
开发者ID:csaszitoma,项目名称:configi,代码行数:34,代码来源:luawrapper.c
示例15: ELF_ASSERT
Elf_Scn *elf_utils_new_scn_with_name(Elf *e, const char *scn_name)
{
Elf_Scn *scn;
GElf_Shdr shdr;
size_t shstrndx, index, namelen;
Elf_Data *shstrdata;
void *ptr;
ELF_ASSERT(elf_getshdrstrndx(e, &shstrndx) == 0);
ELF_ASSERT(scn = elf_getscn(e, shstrndx));
ELF_ASSERT(shstrdata = elf_getdata(scn, NULL));
namelen = strlen(scn_name) + 1;
ELF_ASSERT(gelf_getshdr(scn, &shdr));
if (!elf_utils_shift_contents(e, shdr.sh_offset + shdr.sh_size, namelen))
goto failure;
ASSERT(ptr = realloc(shstrdata->d_buf, shstrdata->d_size + namelen));
index = shstrdata->d_size;
strcpy(ptr+index, scn_name);
shstrdata->d_buf = ptr;
shstrdata->d_size += namelen;
shdr.sh_size += namelen;
ELF_ASSERT(gelf_update_shdr(scn, &shdr));
ELF_ASSERT(scn = elf_newscn(e));
ELF_ASSERT(gelf_getshdr(scn, &shdr));
shdr.sh_name = index;
ELF_ASSERT(gelf_update_shdr(scn, &shdr));
return scn;
failure:
return NULL;
}
开发者ID:nterry,项目名称:vita-toolchain,代码行数:34,代码来源:elf-utils.c
示例16: elf_scn_getsymaddr_byname
/**
* @brief Search a single, particular ELF symbol table for a named symbol
*
* @param elf The open ELF object
* @param symtab The ELF symbol table section
* @param name The symbol name to find
*
* @returns The address to which the symbol points, 0 otherwise.
*/
static GElf_Addr elf_scn_getsymaddr_byname(Elf *elf, Elf_Scn *symtab,
const char * name) {
GElf_Shdr shdr;
Elf_Data *data;
uint32_t syms, i;
GElf_Sym sym;
if (gelf_getshdr(symtab, &shdr) == NULL || shdr.sh_type != SHT_SYMTAB) {
return 0;
}
data = elf_getdata(symtab, NULL);
if (data == NULL) {
return 0;
}
syms = shdr.sh_size / shdr.sh_entsize;
for(i=0; i<syms; i++) {
gelf_getsym(data, i, &sym);
if (strcmp(elf_strptr(elf, shdr.sh_link, sym.st_name), name) == 0) {
return sym.st_value;
}
}
return 0;
}
开发者ID:girling-morgan,项目名称:bootrom-tools,代码行数:36,代码来源:tftf_in.c
示例17: extract_section_and_copy
/* Extract section and copy into HsaBrig */
static status_t extract_section_and_copy (Elf *elfP,
Elf_Data *secHdr,
const SectionDesc* desc,
hsa_ext_brig_module_t* brig_module,
hsa_ext_brig_section_id_t section_id) {
Elf_Scn* scn = NULL;
Elf_Data* data = NULL;
void* address_to_copy;
size_t section_size=0;
scn = extract_elf_section(elfP, secHdr, desc);
if (scn) {
if ((data = elf_getdata(scn, NULL)) == NULL) {
return STATUS_UNKNOWN;
}
section_size = data->d_size;
if (section_size > 0) {
address_to_copy = malloc(section_size);
memcpy(address_to_copy, data->d_buf, section_size);
}
}
if ((!scn || section_size == 0)) {
return STATUS_UNKNOWN;
}
/* Create a section header */
brig_module->section[section_id] = (hsa_ext_brig_section_header_t*) address_to_copy;
return STATUS_SUCCESS;
}
开发者ID:ashwinma,项目名称:CLOC,代码行数:33,代码来源:elf_utils.c
示例18: elf_strptr
char*
elf_strptr(Elf *elf, size_t section, size_t offset) {
Elf_Scn *scn;
Elf_Data *sd;
if (!elf) {
return NULL;
}
elf_assert(elf->e_magic == ELF_MAGIC);
if (!(scn = elf_getscn(elf, section))) {
return NULL;
}
if (scn->s_type != SHT_STRTAB) {
seterr(ERROR_NOSTRTAB);
return NULL;
}
if (offset >= 0 && offset < scn->s_size) {
sd = NULL;
while ((sd = elf_getdata(scn, sd))) {
if (sd->d_buf
&& offset >= (size_t)sd->d_off
&& offset < (size_t)sd->d_off + sd->d_size) {
return (char*)sd->d_buf + (offset - sd->d_off);
}
}
}
seterr(ERROR_BADSTROFF);
return NULL;
}
开发者ID:rdeforest,项目名称:ColdStore,代码行数:29,代码来源:strptr.c
示例19: scngrp_read
static Dwarf *
scngrp_read (Dwarf *result, Elf *elf, GElf_Ehdr *ehdr, Dwarf_Cmd cmd,
Elf_Scn *scngrp)
{
/* SCNGRP is the section descriptor for a section group which might
contain debug sections. */
Elf_Data *data = elf_getdata (scngrp, NULL);
if (data == NULL)
{
/* We cannot read the section content. Fail! */
free (result);
return NULL;
}
/* The content of the section is a number of 32-bit words which
represent section indices. The first word is a flag word. */
Elf32_Word *scnidx = (Elf32_Word *) data->d_buf;
size_t cnt;
for (cnt = 1; cnt * sizeof (Elf32_Word) <= data->d_size; ++cnt)
{
Elf_Scn *scn = elf_getscn (elf, scnidx[cnt]);
if (scn == NULL)
{
/* A section group refers to a non-existing section. Should
never happen. */
__libdw_seterrno (DWARF_E_INVALID_ELF);
free (result);
return NULL;
}
check_section (result, ehdr, scn, true);
}
return valid_p (result);
}
开发者ID:325116067,项目名称:semc-qsd8x50,代码行数:35,代码来源:dwarf_begin_elf.c
示例20: lookup_addr
/*
* Look up the symbol at addr, returning a copy of the symbol and its name.
*/
static int
lookup_addr(Elf *e, Elf_Scn *scn, u_long stridx, uintptr_t off, uintptr_t addr,
const char **name, GElf_Sym *symcopy)
{
GElf_Sym sym;
Elf_Data *data;
const char *s;
uint64_t rsym;
int i;
if ((data = elf_getdata(scn, NULL)) == NULL) {
DPRINTFX("ERROR: elf_getdata() failed: %s", elf_errmsg(-1));
return (1);
}
for (i = 0; gelf_getsym(data, i, &sym) != NULL; i++) {
rsym = off + sym.st_value;
if (addr >= rsym && addr < rsym + sym.st_size) {
s = elf_strptr(e, stridx, sym.st_name);
if (s != NULL) {
*name = s;
memcpy(symcopy, &sym, sizeof(*symcopy));
/*
* DTrace expects the st_value to contain
* only the address relative to the start of
* the function.
*/
symcopy->st_value = rsym;
return (0);
}
}
}
return (1);
}
开发者ID:sambuc,项目名称:netbsd,代码行数:36,代码来源:proc_sym.c
注:本文中的elf_getdata函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论