Date: Wed, 16 Aug 2006 02:09:07 GMT From: John Birrell <jb@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 104171 for review Message-ID: <200608160209.k7G297G8098143@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=104171 Change 104171 by jb@jb_freebsd2 on 2006/08/16 02:08:07 Add pointers for a place to hang copies of the program and section header arrays cached in host endian format. Note that the host ELF format may differ from the target one, so the choice of the 32- or 64-bit versions depends on the target data type. However the variables in the cached arrays are in host endian order so that they can be accessed directly. Free allocated memory when freeing the allocated ELF structure. Affected files ... .. //depot/projects/dtrace/src/lib/libelf/_libelf.h#3 edit .. //depot/projects/dtrace/src/lib/libelf/elf_allocate.c#4 edit Differences ... ==== //depot/projects/dtrace/src/lib/libelf/_libelf.h#3 (text+ko) ==== @@ -83,8 +83,17 @@ size_t e_rawsize; /* size of uninterpreted bytes */ unsigned int e_version; /* file version */ + /* + * Cached data in host byte order. Pointers are to malloc'ed + * memory and the dimensions of the arrays are in the relevant + * header. + */ Elf32_Ehdr e_eh32; /* 32-bit ELF header */ Elf64_Ehdr e_eh64; /* 64-bit ELF header */ + Elf32_Phdr *e_ph32; /* Ptr to the 32-bit program header array */ + Elf64_Phdr *e_ph64; /* Ptr to the 64-bit program header array */ + Elf32_Shdr *e_sh32; /* Ptr to the 32-bit section header array */ + Elf64_Shdr *e_sh64; /* Ptr to the 64-bit section header array */ union { struct { /* ar(1) archives */ ==== //depot/projects/dtrace/src/lib/libelf/elf_allocate.c#4 (text+ko) ==== @@ -36,6 +36,7 @@ #include <assert.h> #include <libelf.h> #include <stdlib.h> +#include <string.h> #include "_libelf.h" @@ -69,5 +70,13 @@ void _libelf_release_elf(Elf *e) { + if (e->e_ph32 != NULL) + free(e->e_ph32); + if (e->e_ph64 != NULL) + free(e->e_ph64); + if (e->e_sh32 != NULL) + free(e->e_sh32); + if (e->e_sh64 != NULL) + free(e->e_sh64); free(e); }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200608160209.k7G297G8098143>