elf_begin return NULL

Robe vcrobe at gmail.com
Thu Mar 15 19:04:03 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.

Lo que más necesitamos es una persona que nos obligue a hacer lo que
sabemos.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ubuntu.com/archives/ubuntu-users/attachments/20070315/d5b9d7b7/attachment.html>


More information about the ubuntu-users mailing list