From owner-p4-projects@FreeBSD.ORG Sat Aug 12 19:07:56 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 402A116A4E1; Sat, 12 Aug 2006 19:07:56 +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 1B76F16A4DA for ; Sat, 12 Aug 2006 19:07:56 +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 B553943D49 for ; Sat, 12 Aug 2006 19:07:55 +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 k7CJ7tHf074255 for ; Sat, 12 Aug 2006 19:07:55 GMT (envelope-from jb@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.6/8.13.4/Submit) id k7CJ7tmP074252 for perforce@freebsd.org; Sat, 12 Aug 2006 19:07:55 GMT (envelope-from jb@freebsd.org) Date: Sat, 12 Aug 2006 19:07:55 GMT Message-Id: <200608121907.k7CJ7tmP074252@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 103728 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: Sat, 12 Aug 2006 19:07:56 -0000 http://perforce.freebsd.org/chv.cgi?CH=103728 Change 103728 by jb@jb_freebsd2 on 2006/08/12 19:07:02 IFlibbsdelf Affected files ... .. //depot/projects/dtrace/src/lib/libelf/Makefile#2 integrate .. //depot/projects/dtrace/src/lib/libelf/elf_cntl.3#1 branch .. //depot/projects/dtrace/src/lib/libelf/elf_cntl.c#1 branch .. //depot/projects/dtrace/src/lib/libelf/elf_errmsg.c#2 integrate .. //depot/projects/dtrace/src/lib/libelf/elf_flagdata.3#1 branch .. //depot/projects/dtrace/src/lib/libelf/elf_getident.3#2 integrate .. //depot/projects/dtrace/src/lib/libelf/elf_getident.c#2 integrate .. //depot/projects/dtrace/src/lib/libelf/libelf.h#2 integrate .. //depot/projects/dtrace/src/lib/libelf/libelf_convert.m4#2 integrate Differences ... ==== //depot/projects/dtrace/src/lib/libelf/Makefile#2 (text+ko) ==== @@ -4,6 +4,7 @@ SRCS= elf_allocate.c \ elf_begin.c \ + elf_cntl.c \ elf_end.c elf_errmsg.c elf_errno.c \ elf_fill.c \ elf_getbase.c \ @@ -28,12 +29,14 @@ OBJS+= libelf_convert.o -WARNS?= 6 +WARNS?= 9 MAN= elf.3 \ elf_begin.3 \ + elf_cntl.3 \ elf_end.3 elf_errmsg.3 \ elf_fill.3 \ + elf_flagdata.3 \ elf_getbase.3 \ elf_getident.3 \ elf_kind.3 \ @@ -73,13 +76,11 @@ gelf_fsize.3 elf64_fsize.3 MLINKS+= \ - elf.3 elf_cntl.3 \ - elf.3 elf_flagdata.3 \ - elf.3 elf_flagehdr.3 \ - elf.3 elf_flagelf.3 \ - elf.3 elf_flagphdr.3 \ - elf.3 elf_flagscn.3 \ - elf.3 elf_flagshdr.3 \ + elf_flagdata.3 elf_flagehdr.3 \ + elf_flagdata.3 elf_flagelf.3 \ + elf_flagdata.3 elf_flagphdr.3 \ + elf_flagdata.3 elf_flagscn.3 \ + elf_flagdata.3 elf_flagshdr.3 \ elf.3 elf_getarhdr.3 \ elf.3 elf_getarsym.3 \ elf.3 elf_getdata.3 \ ==== //depot/projects/dtrace/src/lib/libelf/elf_errmsg.c#2 (text+ko) ==== @@ -43,6 +43,7 @@ DEFINE_ERROR(ARGUMENT, "Invalid argument"), DEFINE_ERROR(HEADER, "Missing ELF header"), DEFINE_ERROR(MMAP, "File mapping failed"), + DEFINE_ERROR(MODE, "Incorrect ELF descriptor mode"), DEFINE_ERROR(RESOURCE, "Resource exhaustion"), DEFINE_ERROR(SEQUENCE, "API calls out of sequence"), DEFINE_ERROR(STAT, "Cannot determine file parameters"), ==== //depot/projects/dtrace/src/lib/libelf/elf_getident.3#2 (text+ko) ==== @@ -60,6 +60,13 @@ .It Bq Er ELF_E_ARGUMENT A NULL value was passed in for argument .Ar elf . +.It Bq Er ELF_E_SEQUENCE +ELF descriptor +.Ar elf +was opened for writing and function +.Fn elf_getident +was called before a call to +.Xr elf_update 3 . .El .Sh SEE ALSO .Xr elf 3 , @@ -67,9 +74,8 @@ .Xr elf_getbase 3 , .Xr elf_getflags 3 , .Xr elf_kind 3 , -.Xr elf_getshnum 3 , -.Xr elf_getshstrndx 3 , .Xr elf_rawfile 3 , +.Xr elf_update 3 , .Xr elf32_getehdr , .Xr elf64_getehdr , .Xr gelf 3 , ==== //depot/projects/dtrace/src/lib/libelf/elf_getident.c#2 (text+ko) ==== @@ -27,6 +27,7 @@ #include __FBSDID("$FreeBSD$"); +#include #include #include @@ -37,13 +38,19 @@ char * elf_getident(Elf *e, size_t *sz) { + if (e == NULL) { LIBELF_SET_ERROR(ARGUMENT, 0); - if (sz) - *sz = 0; - return (NULL); + goto error; + } + + if (e->e_cmd == ELF_C_WRITE && e->e_rawfile == NULL) { + LIBELF_SET_ERROR(SEQUENCE, 0); + goto error; } + assert(e->e_kind != ELF_K_AR || e->e_cmd == ELF_C_READ); + if (sz) { if (e->e_kind == ELF_K_AR) *sz = SARMAG; @@ -53,8 +60,10 @@ *sz = e->e_rawsize; } - /* - * XXX: what do we do for ELF files opened for write? - */ return (e->e_rawfile); + + error: + if (sz) + *sz = 0; + return (NULL); } ==== //depot/projects/dtrace/src/lib/libelf/libelf.h#2 (text+ko) ==== @@ -142,6 +142,7 @@ ELF_E_ARGUMENT, /* Invalid argument */ ELF_E_HEADER, /* Missing ELF header */ ELF_E_MMAP, /* File mapping failed */ + ELF_E_MODE, /* Wrong mode for ELF descriptor */ ELF_E_RESOURCE, /* Resource exhaustion */ ELF_E_SEQUENCE, /* API calls out of sequence */ ELF_E_STAT, /* Cannot determine file parameters */ @@ -177,7 +178,7 @@ Elf_Data *elf_getdata(Elf_Scn *, Elf_Data *); char *elf_getident(Elf *_elf, size_t *_ptr); int elf_getphnum(Elf *_elf, size_t *_dst); -Elf_Scn elf_getscn(Elf *_elf, size_t _index); +Elf_Scn *elf_getscn(Elf *_elf, size_t _index); int elf_getshnum(Elf *_elf, size_t *_dst); int elf_getshstrndx(Elf *_elf, size_t *_dst); unsigned long elf_hash(const char *_name); ==== //depot/projects/dtrace/src/lib/libelf/libelf_convert.m4#2 (text+ko) ==== @@ -387,8 +387,8 @@ size_t fsz; fsz = elf$3_fsize(ELF_T_$1, 1, EV_CURRENT); - d = ((Elf$3_$2 *) dst) + (count - 1); - s = (unsigned char *) src + (count - 1) * fsz; + d = ((Elf$3_$2 *) dst) + (count - 1); + s0 = (unsigned char *) src + (count - 1) * fsz; while (count--) { s = s0;