aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorKai Wang <kaiw@FreeBSD.org>2010-09-04 13:00:28 +0000
committerKai Wang <kaiw@FreeBSD.org>2010-09-04 13:00:28 +0000
commitd6e055cdf63c5a4a88dae21798aa3f0bb3ef13e1 (patch)
treea11aba39dd1f8ebec9a372866eb299cd3c010bfe /lib
parentaa6412a09bc3cbecd9594863ed8ad1b72d08e862 (diff)
Notes
Diffstat (limited to 'lib')
-rw-r--r--lib/libelf/elf_begin.316
-rw-r--r--lib/libelf/elf_begin.c10
-rw-r--r--lib/libelf/elf_getdata.35
-rw-r--r--lib/libelf/libelf_data.c2
4 files changed, 19 insertions, 14 deletions
diff --git a/lib/libelf/elf_begin.3 b/lib/libelf/elf_begin.3
index c43766f7bcb2..074015a9fa1a 100644
--- a/lib/libelf/elf_begin.3
+++ b/lib/libelf/elf_begin.3
@@ -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 argument
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 ELF descriptor
.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
diff --git a/lib/libelf/elf_begin.c b/lib/libelf/elf_begin.c
index 7879dbefd31c..6e81e32ced6c 100644
--- a/lib/libelf/elf_begin.c
+++ b/lib/libelf/elf_begin.c
@@ -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++;
diff --git a/lib/libelf/elf_getdata.3 b/lib/libelf/elf_getdata.3
index cd02d4c6574b..2460c8cd0e8f 100644
--- a/lib/libelf/elf_getdata.3
+++ b/lib/libelf/elf_getdata.3
@@ -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
diff --git a/lib/libelf/libelf_data.c b/lib/libelf/libelf_data.c
index 77493005bc1f..3b20e1d75ae1 100644
--- a/lib/libelf/libelf_data.c
+++ b/lib/libelf/libelf_data.c
@@ -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);