"elf_begin" returns NULL
Robe
robe at prodal.telemar.cu
Thu Mar 15 19:46:16 UTC 2007
Hi,
I'm trying to create an object file (.o) using the "libelf" library.
Below appear the full source code.
Does any body know why the "elf_begin" statement return NULL?
#include < stdio.h>
#include <stdlib.h>
#include <libelf.h>
int main()
{
int FileDes;
Elf *pElf = elf_begin(FileDes, ELF_C_WRITE, NULL); // 3rd argument
is ignored for "ELF_C_WRITE"
if (!pElf)
printf("elf_begin: error\n");
Elf32_Ehdr *pEhdr = elf32_newehdr(pElf);
if (!pEhdr)
printf("elf32_newehdr: error\n");
elf_end(pElf);
// Free the memory
free(pElf);
free(pEhdr);
return 0;
}
Thanx,
Robe.
More information about the freebsd-questions
mailing list