svn commit: r212207 - stable/7/lib/libelf
Kai Wang
kaiw at FreeBSD.org
Sat Sep 4 13:00:30 UTC 2010
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);
More information about the svn-src-all
mailing list