CRiSP Blog

elf_cntl(ELF_C_FDREAD) is broken


#include
#include
#include
#include

int main(int argc, char **argv)
{ int fd;
Elf *elf;
int err;

elf_version(EV_CURRENT);
fd = open(argv[1], O_RDONLY);
elf = elf_begin(fd, ELF_C_READ, NULL);
err = elf_cntl(elf, ELF_C_FDREAD);

printf("elf=%p err=%d\n", elf, err);
}


Interestingly, the elf_cntl tries to do a malloc(-1) but fails.
Seems to be a buggy libelf.a on Ubuntu 10.04 - it forgets to fstat()
the original file and ends up thinking the size of the file is ~0.

Annoying, valgrind catches this (complains of a silly malloc(-1)), but doesnt
tell you where this happens, despite it being ever so important.



Post created by CRiSP v10.0.2a-b5887


Read more http://crtags.blogspot.com/2010/09/elfcntlelfcfdread-is-broken.html

Testimonials

"After looking for a good text editor for UNIX for several years I finally found one that met my needs in CRiSP. I have used vi, emacs, xcoral (not to mention edt, teco, brief, tpu, etc, etc.) but prefer using CRiSP for two main (but not exclusive) reasons. First is the language sensitive syntax colorization and second for it's ease of use (brief editor like functionality)."

paypal_horiz