Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 4 Sep 2010 13:00:22 +0000 (UTC)
From:      Kai Wang <kaiw@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org
Subject:   svn commit: r212206 - stable/8/lib/libelf
Message-ID:  <201009041300.o84D0Ms7009603@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: kaiw
Date: Sat Sep  4 13:00:22 2010
New Revision: 212206
URL: http://svn.freebsd.org/changeset/base/212206

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/8/lib/libelf/elf_begin.3
  stable/8/lib/libelf/elf_begin.c
  stable/8/lib/libelf/elf_getdata.3
  stable/8/lib/libelf/libelf_data.c
Directory Properties:
  stable/8/lib/libelf/   (props changed)

Modified: stable/8/lib/libelf/elf_begin.3
==============================================================================
--- stable/8/lib/libelf/elf_begin.3	Sat Sep  4 12:52:51 2010	(r212205)
+++ stable/8/lib/libelf/elf_begin.3	Sat Sep  4 13:00:22 2010	(r212206)
@@ -23,7 +23,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd June 21, 2006
+.Dd June 20, 2010
 .Dt ELF_BEGIN 3
 .Os
 .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/8/lib/libelf/elf_begin.c
==============================================================================
--- stable/8/lib/libelf/elf_begin.c	Sat Sep  4 12:52:51 2010	(r212205)
+++ stable/8/lib/libelf/elf_begin.c	Sat Sep  4 13:00:22 2010	(r212206)
@@ -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/8/lib/libelf/elf_getdata.3
==============================================================================
--- stable/8/lib/libelf/elf_getdata.3	Sat Sep  4 12:52:51 2010	(r212205)
+++ stable/8/lib/libelf/elf_getdata.3	Sat Sep  4 13:00:22 2010	(r212206)
@@ -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
 .Dt ELF_GETDATA 3
 .Os
 .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/8/lib/libelf/libelf_data.c
==============================================================================
--- stable/8/lib/libelf/libelf_data.c	Sat Sep  4 12:52:51 2010	(r212205)
+++ stable/8/lib/libelf/libelf_data.c	Sat Sep  4 13:00:22 2010	(r212206)
@@ -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);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201009041300.o84D0Ms7009603>