本文整理汇总了C++中LIBELF_SET_ERROR函数的典型用法代码示例。如果您正苦于以下问题:C++ LIBELF_SET_ERROR函数的具体用法?C++ LIBELF_SET_ERROR怎么用?C++ LIBELF_SET_ERROR使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了LIBELF_SET_ERROR函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: _libelf_getshdr
void *
_libelf_getshdr(Elf_Scn *s, int ec)
{
Elf *e;
if (s == NULL || (e = s->s_elf) == NULL ||
e->e_kind != ELF_K_ELF) {
LIBELF_SET_ERROR(ARGUMENT, 0);
return (NULL);
}
if (ec == ELFCLASSNONE)
ec = e->e_class;
if (ec != e->e_class) {
LIBELF_SET_ERROR(CLASS, 0);
return (NULL);
}
return ((void *) &s->s_shdr);
}
示例2: elf_getarhdr
Elf_Arhdr *
elf_getarhdr(Elf *e)
{
if (e == NULL) {
LIBELF_SET_ERROR(ARGUMENT, 0);
return (NULL);
}
if (e->e_flags & LIBELF_F_AR_HEADER)
return (e->e_hdr.e_arhdr);
return (_libelf_ar_gethdr(e));
}
示例3: elf_getarsym
Elf_Arsym *
elf_getarsym(Elf *ar, size_t *ptr)
{
size_t n;
Elf_Arsym *symtab;
n = 0;
symtab = NULL;
if (ar == NULL || ar->e_kind != ELF_K_AR)
LIBELF_SET_ERROR(ARGUMENT, 0);
else if ((symtab = ar->e_u.e_ar.e_symtab) != NULL)
n = ar->e_u.e_ar.e_symtabsz;
else if (ar->e_u.e_ar.e_rawsymtab)
symtab = _libelf_ar_process_symtab(ar, &n);
else
LIBELF_SET_ERROR(ARCHIVE, 0);
if (ptr)
*ptr = n;
return (symtab);
}
示例4: elf_getbase
off_t
elf_getbase(Elf *e)
{
if (e == NULL) {
LIBELF_SET_ERROR(ARGUMENT, 0);
return ((off_t) -1);
}
if (e->e_parent == NULL)
return ((off_t) 0);
return ((off_t) ((uintptr_t) e->e_rawfile -
(uintptr_t) e->e_parent->e_rawfile));
}
示例5: elf_setshstrndx
int
elf_setshstrndx(Elf *e, size_t strndx)
{
void *eh;
int ec;
if (e == NULL || e->e_kind != ELF_K_ELF ||
((ec = e->e_class) != ELFCLASS32 && ec != ELFCLASS64) ||
((eh = _libelf_ehdr(e, ec, 0)) == NULL)) {
LIBELF_SET_ERROR(ARGUMENT, 0);
return (0);
}
return (_libelf_setshstrndx(e, eh, ec, strndx));
}
示例6: elf_getarhdr
Elf_Arhdr *
elf_getarhdr(Elf *e)
{
Elf_Arhdr *arh;
if (e == NULL) {
LIBELF_SET_ERROR(ARGUMENT, 0);
return (NULL);
}
if ((arh = e->e_arhdr) != NULL)
return (arh);
return (_libelf_ar_gethdr(e));
}
示例7: _libelf_ar_get_string
/*
* Retrieve a string from a name field. If `rawname' is set, leave
* ar(1) control characters in.
*/
char *
_libelf_ar_get_string(const char *buf, size_t bufsize, int rawname)
{
const char *q;
char *r;
size_t sz;
if (rawname)
sz = bufsize + 1;
else {
/* Skip back over trailing blanks. */
for (q = buf + bufsize - 1; q >= buf && *q == ' '; --q)
;
if (q < buf) {
/*
* If the input buffer only had blanks in it,
* return a zero-length string.
*/
buf = "";
sz = 1;
} else {
/*
* Remove the trailing '/' character, but only
* if the name isn't one of the special names
* "/" and "//".
*/
if (q > buf + 1 ||
(q == (buf + 1) && *buf != '/'))
q--;
sz = q - buf + 2; /* Space for a trailing NUL. */
}
}
if ((r = malloc(sz)) == NULL) {
LIBELF_SET_ERROR(RESOURCE, 0);
return (NULL);
}
(void) strncpy(r, buf, sz);
r[sz - 1] = '\0';
return (r);
}
示例8: elf_version
unsigned int
elf_version(unsigned int v)
{
unsigned int old;
if ((old = LIBELF_PRIVATE(version)) == EV_NONE)
old = EV_CURRENT;
if (v == EV_NONE)
return old;
if (v > EV_CURRENT) {
LIBELF_SET_ERROR(VERSION, 0);
return EV_NONE;
}
LIBELF_PRIVATE(version) = v;
return (old);
}
示例9: gelf_getehdr
GElf_Ehdr *
gelf_getehdr(Elf *e, GElf_Ehdr *d)
{
int ec;
Elf32_Ehdr *eh32;
Elf64_Ehdr *eh64;
if (d == NULL || e == NULL ||
((ec = e->e_class) != ELFCLASS32 && ec != ELFCLASS64)) {
LIBELF_SET_ERROR(ARGUMENT, 0);
return (NULL);
}
if (ec == ELFCLASS32) {
if ((eh32 = _libelf_ehdr(e, ELFCLASS32, 0)) == NULL)
return (NULL);
(void) memcpy(d->e_ident, eh32->e_ident,
sizeof(eh32->e_ident));
d->e_type = eh32->e_type;
d->e_machine = eh32->e_machine;
d->e_version = eh32->e_version;
d->e_entry = eh32->e_entry;
d->e_phoff = eh32->e_phoff;
d->e_shoff = eh32->e_shoff;
d->e_flags = eh32->e_flags;
d->e_ehsize = eh32->e_ehsize;
d->e_phentsize = eh32->e_phentsize;
d->e_phnum = eh32->e_phnum;
d->e_shentsize = eh32->e_shentsize;
d->e_shnum = eh32->e_shnum;
d->e_shstrndx = eh32->e_shstrndx;
return (d);
}
assert(ec == ELFCLASS64);
if ((eh64 = _libelf_ehdr(e, ELFCLASS64, 0)) == NULL)
return (NULL);
*d = *eh64;
return (d);
}
示例10: _libelf_getshdrnum
static int
_libelf_getshdrnum(Elf *e, size_t *shnum)
{
void *eh;
int ec;
if (e == NULL || e->e_kind != ELF_K_ELF ||
((ec = e->e_class) != ELFCLASS32 && ec != ELFCLASS64)) {
LIBELF_SET_ERROR(ARGUMENT, 0);
return (-1);
}
if ((eh = _libelf_ehdr(e, ec, 0)) == NULL)
return (-1);
*shnum = e->e_u.e_elf.e_nscn;
return (0);
}
示例11: _libelf_ar_open_member
Elf *
_libelf_ar_open_member(int fd, Elf_Cmd c, Elf *elf)
{
Elf *e;
off_t next;
struct ar_hdr *arh;
size_t sz;
assert(elf->e_kind == ELF_K_AR);
next = elf->e_u.e_ar.e_next;
/*
* `next' is only set to zero by elf_next() when the last
* member of an archive is processed.
*/
if (next == (off_t) 0)
return (NULL);
assert((next & 1) == 0);
arh = (struct ar_hdr *) (elf->e_rawfile + next);
if (_libelf_ar_get_number(arh->ar_size, sizeof(arh->ar_size), 10, &sz) == 0) {
LIBELF_SET_ERROR(ARCHIVE, 0);
return (NULL);
}
assert(sz > 0);
arh++; /* skip over archive member header */
if ((e = elf_memory((char *) arh, sz)) == NULL)
return (NULL);
e->e_fd = fd;
e->e_cmd = c;
elf->e_u.e_ar.e_nchildren++;
e->e_parent = elf;
return (e);
}
示例12: elf_flagarhdr
unsigned int
elf_flagarhdr(Elf_Arhdr *a, Elf_Cmd c, unsigned int flags)
{
unsigned int r;
if (a == NULL)
return (0);
if ((c != ELF_C_SET && c != ELF_C_CLR) ||
(flags & ~ELF_F_DIRTY) != 0) {
LIBELF_SET_ERROR(ARGUMENT, 0);
return (0);
}
if (c == ELF_C_SET)
r = a->ar_flags |= flags;
else
r = a->ar_flags &= ~flags;
return (r & LIBELF_F_API_MASK);
}
示例13: gelf_getshdr
GElf_Shdr *
gelf_getshdr(Elf_Scn *s, GElf_Shdr *d)
{
int ec;
void *sh;
Elf32_Shdr *sh32;
Elf64_Shdr *sh64;
if (d == NULL) {
LIBELF_SET_ERROR(ARGUMENT, 0);
return (NULL);
}
if ((sh = _libelf_getshdr(s, ELFCLASSNONE)) == NULL)
return (NULL);
ec = s->s_elf->e_class;
assert(ec == ELFCLASS32 || ec == ELFCLASS64);
if (ec == ELFCLASS32) {
sh32 = (Elf32_Shdr *) sh;
d->sh_name = sh32->sh_name;
d->sh_type = sh32->sh_type;
d->sh_flags = (Elf64_Xword) sh32->sh_flags;
d->sh_addr = (Elf64_Addr) sh32->sh_addr;
d->sh_offset = (Elf64_Off) sh32->sh_offset;
d->sh_size = (Elf64_Xword) sh32->sh_size;
d->sh_link = sh32->sh_link;
d->sh_info = sh32->sh_info;
d->sh_addralign = (Elf64_Xword) sh32->sh_addralign;
d->sh_entsize = (Elf64_Xword) sh32->sh_entsize;
} else {
sh64 = (Elf64_Shdr *) sh;
*d = *sh64;
}
return (d);
}
示例14: elf_newdata
Elf_Data *
elf_newdata(Elf_Scn *s)
{
Elf *e;
struct _Libelf_Data *d;
if (s == NULL || (e = s->s_elf) == NULL) {
LIBELF_SET_ERROR(ARGUMENT, 0);
return (NULL);
}
assert(e->e_kind == ELF_K_ELF);
/*
* elf_newdata() has to append a data descriptor, so
* bring in existing section data if not already present.
*/
if (e->e_rawfile && s->s_size > 0 && STAILQ_EMPTY(&s->s_data))
if (elf_getdata(s, NULL) == NULL)
return (NULL);
if ((d = _libelf_allocate_data(s)) == NULL)
return (NULL);
STAILQ_INSERT_TAIL(&s->s_data, d, d_next);
d->d_data.d_align = 1;
d->d_data.d_buf = NULL;
d->d_data.d_off = (uint64_t) ~0;
d->d_data.d_size = 0;
d->d_data.d_type = ELF_T_BYTE;
d->d_data.d_version = LIBELF_PRIVATE(version);
(void) elf_flagscn(s, ELF_C_SET, ELF_F_DIRTY);
return (&d->d_data);
}
示例15: elf_flagdata
unsigned int
elf_flagdata(Elf_Data *d, Elf_Cmd c, unsigned int flags)
{
unsigned int r;
struct _Libelf_Data *ld;
if (d == NULL)
return (0);
if ((c != ELF_C_SET && c != ELF_C_CLR) ||
(flags & ~ELF_F_DIRTY) != 0) {
LIBELF_SET_ERROR(ARGUMENT, 0);
return (0);
}
ld = (struct _Libelf_Data *) d;
if (c == ELF_C_SET)
r = ld->d_flags |= flags;
else
r = ld->d_flags &= ~flags;
return (r & LIBELF_F_API_MASK);
}