From owner-p4-projects@FreeBSD.ORG Wed Aug 16 02:09:08 2006 Return-Path: X-Original-To: p4-projects@freebsd.org Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 35E2B16A4E1; Wed, 16 Aug 2006 02:09:08 +0000 (UTC) X-Original-To: perforce@freebsd.org Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 127E716A4DF for ; Wed, 16 Aug 2006 02:09:08 +0000 (UTC) (envelope-from jb@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id CEE1543D49 for ; Wed, 16 Aug 2006 02:09:07 +0000 (GMT) (envelope-from jb@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.6/8.13.6) with ESMTP id k7G297MF098146 for ; Wed, 16 Aug 2006 02:09:07 GMT (envelope-from jb@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.6/8.13.4/Submit) id k7G297G8098143 for perforce@freebsd.org; Wed, 16 Aug 2006 02:09:07 GMT (envelope-from jb@freebsd.org) Date: Wed, 16 Aug 2006 02:09:07 GMT Message-Id: <200608160209.k7G297G8098143@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to jb@freebsd.org using -f From: John Birrell To: Perforce Change Reviews Cc: Subject: PERFORCE change 104171 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 16 Aug 2006 02:09:08 -0000 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 #include #include +#include #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); }