Date: Sat, 12 Aug 2006 19:07:55 GMT From: John Birrell <jb@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 103728 for review Message-ID: <200608121907.k7CJ7tmP074252@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
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 <sys/cdefs.h> __FBSDID("$FreeBSD$"); +#include <assert.h> #include <sys/types.h> #include <ar.h> @@ -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;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200608121907.k7CJ7tmP074252>