Changeset View
Changeset View
Standalone View
Standalone View
stand/common/load_elf_obj.c
Show First 20 Lines • Show All 178 Lines • ▼ Show 20 Lines | if (fp == NULL) { | ||||
printf("elf" __XSTRING(__ELF_WORD_SIZE) | printf("elf" __XSTRING(__ELF_WORD_SIZE) | ||||
"_obj_loadfile: cannot allocate module info\n"); | "_obj_loadfile: cannot allocate module info\n"); | ||||
err = EPERM; | err = EPERM; | ||||
goto out; | goto out; | ||||
} | } | ||||
fp->f_name = strdup(filename); | fp->f_name = strdup(filename); | ||||
fp->f_type = strdup(__elfN(obj_moduletype)); | fp->f_type = strdup(__elfN(obj_moduletype)); | ||||
if (module_verbose > MODULE_VERBOSE_SILENT) | |||||
printf("%s ", filename); | printf("%s ", filename); | ||||
fp->f_size = __elfN(obj_loadimage)(fp, &ef, dest); | fp->f_size = __elfN(obj_loadimage)(fp, &ef, dest); | ||||
if (fp->f_size == 0 || fp->f_addr == 0) | if (fp->f_size == 0 || fp->f_addr == 0) | ||||
goto ioerr; | goto ioerr; | ||||
/* save exec header as metadata */ | /* save exec header as metadata */ | ||||
file_addmetadata(fp, MODINFOMD_ELFHDR, sizeof(*hdr), hdr); | file_addmetadata(fp, MODINFOMD_ELFHDR, sizeof(*hdr), hdr); | ||||
▲ Show 20 Lines • Show All 177 Lines • ▼ Show 20 Lines | #endif | ||||
res = __elfN(obj_parse_modmetadata)(fp, ef); | res = __elfN(obj_parse_modmetadata)(fp, ef); | ||||
if (res != 0) | if (res != 0) | ||||
goto out; | goto out; | ||||
ret = lastaddr - firstaddr; | ret = lastaddr - firstaddr; | ||||
fp->f_addr = firstaddr; | fp->f_addr = firstaddr; | ||||
if (module_verbose > MODULE_VERBOSE_SILENT) | |||||
printf("size 0x%lx at 0x%lx", (u_long)ret, (u_long)firstaddr); | printf("size 0x%lx at 0x%lx", (u_long)ret, (u_long)firstaddr); | ||||
out: | out: | ||||
if (module_verbose > MODULE_VERBOSE_SILENT) | |||||
printf("\n"); | printf("\n"); | ||||
return ret; | return ret; | ||||
} | } | ||||
#if defined(__i386__) && __ELF_WORD_SIZE == 64 | #if defined(__i386__) && __ELF_WORD_SIZE == 64 | ||||
struct mod_metadata64 { | struct mod_metadata64 { | ||||
int md_version; /* structure version MDTV_* */ | int md_version; /* structure version MDTV_* */ | ||||
int md_type; /* type of entry MDT_* */ | int md_type; /* type of entry MDT_* */ | ||||
uint64_t md_data; /* specific data */ | uint64_t md_data; /* specific data */ | ||||
▲ Show 20 Lines • Show All 189 Lines • Show Last 20 Lines |