From owner-svn-src-stable-7@FreeBSD.ORG Sat Sep 4 13:00:29 2010 Return-Path: Delivered-To: svn-src-stable-7@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id BF32510657AE; Sat, 4 Sep 2010 13:00:28 +0000 (UTC) (envelope-from kaiw@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id C82098FC19; Sat, 4 Sep 2010 13:00:28 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o84D0SLt009656; Sat, 4 Sep 2010 13:00:28 GMT (envelope-from kaiw@svn.freebsd.org) Received: (from kaiw@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o84D0SlL009651; Sat, 4 Sep 2010 13:00:28 GMT (envelope-from kaiw@svn.freebsd.org) Message-Id: <201009041300.o84D0SlL009651@svn.freebsd.org> From: Kai Wang Date: Sat, 4 Sep 2010 13:00:28 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r212207 - stable/7/lib/libelf X-BeenThere: svn-src-stable-7@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 7-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 04 Sep 2010 13:00:30 -0000 Author: kaiw Date: Sat Sep 4 13:00:28 2010 New Revision: 212207 URL: http://svn.freebsd.org/changeset/base/212207 Log: MFC r210351-r210353,r211192. r210351: * Note that ar(1) archives may also be opened using `elf_memory(3)`. * Ignore the passed in value of the `fd` argument for ar(1) archives opened with elf_memory(3). r210352: Add a cross-reference to `elf_rawfile(3)`. r210353: * Remove a superfluous error description. * Document an additional error that may be returned: `ELF_E_ARCHIVE`. r211192: Add translation support for section type SHT_SUNW_dof. Modified: stable/7/lib/libelf/elf_begin.3 stable/7/lib/libelf/elf_begin.c stable/7/lib/libelf/elf_getdata.3 stable/7/lib/libelf/libelf_data.c Directory Properties: stable/7/lib/libelf/ (props changed) Modified: stable/7/lib/libelf/elf_begin.3 ============================================================================== --- stable/7/lib/libelf/elf_begin.3 Sat Sep 4 13:00:22 2010 (r212206) +++ stable/7/lib/libelf/elf_begin.3 Sat Sep 4 13:00:28 2010 (r212207) @@ -23,7 +23,7 @@ .\" .\" $FreeBSD$ .\" -.Dd June 21, 2006 +.Dd June 20, 2010 .Os .Dt ELF_BEGIN 3 .Sh NAME @@ -163,7 +163,9 @@ archive may be opened in read mode (with set to .Dv ELF_C_READ ) using -.Fn elf_begin . +.Fn elf_begin +or +.Fn elf_memory . The returned ELF descriptor can be passed into to subsequent calls to .Fn elf_begin @@ -222,6 +224,10 @@ Function can fail with the following errors: .Pp .Bl -tag -width "[ELF_E_RESOURCE]" +.It Bq Er ELF_E_ARCHIVE +The archive denoted by argument +.Ar elf +could not be parsed. .It Bq Er ELF_E_ARGUMENT An unrecognized value was specified in argument .Ar cmd . @@ -245,12 +251,6 @@ differs from the value specified when EL .Ar elf was created. .It Bq Er ELF_E_ARGUMENT -Argument -.Ar elf -was not a descriptor for an -.Xr ar 1 -archive. -.It Bq Er ELF_E_ARGUMENT An .Xr ar 1 archive was opened with with Modified: stable/7/lib/libelf/elf_begin.c ============================================================================== --- stable/7/lib/libelf/elf_begin.c Sat Sep 4 13:00:22 2010 (r212206) +++ stable/7/lib/libelf/elf_begin.c Sat Sep 4 13:00:28 2010 (r212207) @@ -131,13 +131,15 @@ elf_begin(int fd, Elf_Cmd c, Elf *a) case ELF_C_READ: /* * Descriptor `a' could be for a regular ELF file, or - * for an ar(1) archive. + * for an ar(1) archive. If descriptor `a' was opened + * using a valid file descriptor, we need to check if + * the passed in `fd' value matches the original one. */ - if (a && (a->e_fd != fd || c != a->e_cmd)) { + if (a && + ((a->e_fd != -1 && a->e_fd != fd) || c != a->e_cmd)) { LIBELF_SET_ERROR(ARGUMENT, 0); return (NULL); } - break; default: @@ -149,7 +151,7 @@ elf_begin(int fd, Elf_Cmd c, Elf *a) if (a == NULL) e = _libelf_open_object(fd, c); else if (a->e_kind == ELF_K_AR) - e = _libelf_ar_open_member(fd, c, a); + e = _libelf_ar_open_member(a->e_fd, c, a); else (e = a)->e_activations++; Modified: stable/7/lib/libelf/elf_getdata.3 ============================================================================== --- stable/7/lib/libelf/elf_getdata.3 Sat Sep 4 13:00:22 2010 (r212206) +++ stable/7/lib/libelf/elf_getdata.3 Sat Sep 4 13:00:28 2010 (r212207) @@ -1,4 +1,4 @@ -.\" Copyright (c) 2006,2008 Joseph Koshy. All rights reserved. +.\" Copyright (c) 2006,2008,2010 Joseph Koshy. All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions @@ -23,7 +23,7 @@ .\" .\" $FreeBSD$ .\" -.Dd August 26, 2006 +.Dd April 30, 2010 .Os .Dt ELF_GETDATA 3 .Sh NAME @@ -193,6 +193,7 @@ An out of memory condition was detected. .Xr elf_getscn 3 , .Xr elf_getshdr 3 , .Xr elf_newscn 3 , +.Xr elf_rawfile 3 , .Xr elf_update 3 , .Xr elf_version 3 , .Xr gelf 3 Modified: stable/7/lib/libelf/libelf_data.c ============================================================================== --- stable/7/lib/libelf/libelf_data.c Sat Sep 4 13:00:22 2010 (r212206) +++ stable/7/lib/libelf/libelf_data.c Sat Sep 4 13:00:28 2010 (r212207) @@ -77,6 +77,8 @@ _libelf_xlate_shtype(uint32_t sht) return (ELF_T_MOVE); case SHT_SUNW_syminfo: return (ELF_T_SYMINFO); + case SHT_SUNW_dof: + return (ELF_T_BYTE); #endif case SHT_AMD64_UNWIND: /* == SHT_IA_64_UNWIND */ return (ELF_T_BYTE);