Date: Wed, 14 Mar 2007 11:37:02 -0500 From: Robe <robe@prodal.telemar.cu> To: freebsd-questions@freebsd.org Subject: "elf_begin" returns NULL Message-ID: <1173890222.15236.2.camel@robe-ubuntu>
next in thread | raw e-mail | index | archive | help
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.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?1173890222.15236.2.camel>
