PERFORCE change 111117 for review
John Birrell
jb at FreeBSD.org
Mon Dec 4 21:54:43 PST 2006
http://perforce.freebsd.org/chv.cgi?CH=111117
Change 111117 by jb at jb_freebsd8 on 2006/12/05 05:54:38
Brick batts for p4. pffff.
Even a force integration wasn't enough to get it to use the
files in current.
Affected files ...
.. //depot/projects/dtrace/src/lib/libelf/_libelf.h#14 edit
.. //depot/projects/dtrace/src/lib/libelf/elf.3#6 edit
.. //depot/projects/dtrace/src/lib/libelf/elf_begin.3#5 edit
.. //depot/projects/dtrace/src/lib/libelf/elf_begin.c#8 edit
.. //depot/projects/dtrace/src/lib/libelf/elf_cntl.3#3 edit
.. //depot/projects/dtrace/src/lib/libelf/elf_cntl.c#3 edit
.. //depot/projects/dtrace/src/lib/libelf/elf_data.c#5 edit
.. //depot/projects/dtrace/src/lib/libelf/elf_end.3#4 edit
.. //depot/projects/dtrace/src/lib/libelf/elf_end.c#5 edit
.. //depot/projects/dtrace/src/lib/libelf/elf_errmsg.3#4 edit
.. //depot/projects/dtrace/src/lib/libelf/elf_errmsg.c#11 edit
.. //depot/projects/dtrace/src/lib/libelf/elf_errno.c#3 edit
.. //depot/projects/dtrace/src/lib/libelf/elf_fill.3#3 edit
.. //depot/projects/dtrace/src/lib/libelf/elf_fill.c#3 edit
.. //depot/projects/dtrace/src/lib/libelf/elf_flag.c#5 edit
.. //depot/projects/dtrace/src/lib/libelf/elf_flagdata.3#5 edit
.. //depot/projects/dtrace/src/lib/libelf/elf_getarhdr.3#3 edit
.. //depot/projects/dtrace/src/lib/libelf/elf_getarhdr.c#3 edit
.. //depot/projects/dtrace/src/lib/libelf/elf_getarsym.3#3 edit
.. //depot/projects/dtrace/src/lib/libelf/elf_getbase.3#3 edit
.. //depot/projects/dtrace/src/lib/libelf/elf_getbase.c#3 edit
.. //depot/projects/dtrace/src/lib/libelf/elf_getdata.3#5 edit
.. //depot/projects/dtrace/src/lib/libelf/elf_getident.3#4 edit
.. //depot/projects/dtrace/src/lib/libelf/elf_getident.c#4 edit
.. //depot/projects/dtrace/src/lib/libelf/elf_getscn.3#5 edit
.. //depot/projects/dtrace/src/lib/libelf/elf_getshnum.3#3 edit
.. //depot/projects/dtrace/src/lib/libelf/elf_getshstrndx.3#4 edit
.. //depot/projects/dtrace/src/lib/libelf/elf_hash.3#3 edit
.. //depot/projects/dtrace/src/lib/libelf/elf_hash.c#3 edit
.. //depot/projects/dtrace/src/lib/libelf/elf_kind.3#3 edit
.. //depot/projects/dtrace/src/lib/libelf/elf_kind.c#3 edit
.. //depot/projects/dtrace/src/lib/libelf/elf_memory.3#4 edit
.. //depot/projects/dtrace/src/lib/libelf/elf_memory.c#9 edit
.. //depot/projects/dtrace/src/lib/libelf/elf_next.3#4 edit
.. //depot/projects/dtrace/src/lib/libelf/elf_next.c#7 edit
.. //depot/projects/dtrace/src/lib/libelf/elf_rand.3#3 edit
.. //depot/projects/dtrace/src/lib/libelf/elf_rand.c#4 edit
.. //depot/projects/dtrace/src/lib/libelf/elf_rawfile.3#3 edit
.. //depot/projects/dtrace/src/lib/libelf/elf_rawfile.c#3 edit
.. //depot/projects/dtrace/src/lib/libelf/elf_scn.c#8 edit
.. //depot/projects/dtrace/src/lib/libelf/elf_shnum.c#4 edit
.. //depot/projects/dtrace/src/lib/libelf/elf_shstrndx.c#3 edit
.. //depot/projects/dtrace/src/lib/libelf/elf_strptr.3#3 edit
.. //depot/projects/dtrace/src/lib/libelf/elf_strptr.c#5 edit
.. //depot/projects/dtrace/src/lib/libelf/elf_types.m4#5 edit
.. //depot/projects/dtrace/src/lib/libelf/elf_update.3#6 edit
.. //depot/projects/dtrace/src/lib/libelf/elf_update.c#8 edit
.. //depot/projects/dtrace/src/lib/libelf/elf_version.3#3 edit
.. //depot/projects/dtrace/src/lib/libelf/elf_version.c#3 edit
.. //depot/projects/dtrace/src/lib/libelf/gelf.3#4 edit
.. //depot/projects/dtrace/src/lib/libelf/gelf.h#4 edit
.. //depot/projects/dtrace/src/lib/libelf/gelf_checksum.3#3 edit
.. //depot/projects/dtrace/src/lib/libelf/gelf_checksum.c#3 edit
.. //depot/projects/dtrace/src/lib/libelf/gelf_dyn.c#4 edit
.. //depot/projects/dtrace/src/lib/libelf/gelf_ehdr.c#3 edit
.. //depot/projects/dtrace/src/lib/libelf/gelf_fsize.3#3 edit
.. //depot/projects/dtrace/src/lib/libelf/gelf_fsize.c#4 edit
.. //depot/projects/dtrace/src/lib/libelf/gelf_getclass.3#3 edit
.. //depot/projects/dtrace/src/lib/libelf/gelf_getclass.c#3 edit
.. //depot/projects/dtrace/src/lib/libelf/gelf_getdyn.3#3 edit
.. //depot/projects/dtrace/src/lib/libelf/gelf_getehdr.3#7 edit
.. //depot/projects/dtrace/src/lib/libelf/gelf_getmove.3#3 edit
.. //depot/projects/dtrace/src/lib/libelf/gelf_getphdr.3#4 edit
.. //depot/projects/dtrace/src/lib/libelf/gelf_getrel.3#3 edit
.. //depot/projects/dtrace/src/lib/libelf/gelf_getrela.3#3 edit
.. //depot/projects/dtrace/src/lib/libelf/gelf_getshdr.3#3 edit
.. //depot/projects/dtrace/src/lib/libelf/gelf_getsym.3#3 edit
.. //depot/projects/dtrace/src/lib/libelf/gelf_getsyminfo.3#3 edit
.. //depot/projects/dtrace/src/lib/libelf/gelf_newehdr.3#9 edit
.. //depot/projects/dtrace/src/lib/libelf/gelf_newphdr.3#5 edit
.. //depot/projects/dtrace/src/lib/libelf/gelf_phdr.c#3 edit
.. //depot/projects/dtrace/src/lib/libelf/gelf_rel.c#5 edit
.. //depot/projects/dtrace/src/lib/libelf/gelf_rela.c#5 edit
.. //depot/projects/dtrace/src/lib/libelf/gelf_sym.c#4 edit
.. //depot/projects/dtrace/src/lib/libelf/gelf_update_ehdr.3#3 edit
.. //depot/projects/dtrace/src/lib/libelf/gelf_xlate.c#6 edit
.. //depot/projects/dtrace/src/lib/libelf/gelf_xlatetof.3#5 edit
.. //depot/projects/dtrace/src/lib/libelf/libelf.c#7 edit
.. //depot/projects/dtrace/src/lib/libelf/libelf.h#13 edit
.. //depot/projects/dtrace/src/lib/libelf/libelf_align.c#3 edit
.. //depot/projects/dtrace/src/lib/libelf/libelf_allocate.c#8 edit
.. //depot/projects/dtrace/src/lib/libelf/libelf_ar.c#4 edit
.. //depot/projects/dtrace/src/lib/libelf/libelf_checksum.c#3 edit
.. //depot/projects/dtrace/src/lib/libelf/libelf_convert.m4#13 edit
.. //depot/projects/dtrace/src/lib/libelf/libelf_data.c#5 edit
.. //depot/projects/dtrace/src/lib/libelf/libelf_ehdr.c#9 edit
.. //depot/projects/dtrace/src/lib/libelf/libelf_fsize.m4#7 edit
.. //depot/projects/dtrace/src/lib/libelf/libelf_msize.m4#6 edit
.. //depot/projects/dtrace/src/lib/libelf/libelf_phdr.c#6 edit
.. //depot/projects/dtrace/src/lib/libelf/libelf_shdr.c#3 edit
.. //depot/projects/dtrace/src/lib/libelf/libelf_xlate.c#4 edit
Differences ...
==== //depot/projects/dtrace/src/lib/libelf/_libelf.h#14 (text+ko) ====
@@ -23,14 +23,13 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $FreeBSD$
+ * $FreeBSD: src/lib/libelf/_libelf.h,v 1.1 2006/11/11 17:16:33 jkoshy Exp $
*/
#ifndef __LIBELF_H_
#define __LIBELF_H_
#include <sys/queue.h>
-#include <stdio.h>
#ifndef NULL
#define NULL ((void *) 0)
@@ -62,7 +61,6 @@
#define LIBELF_SET_ERROR(E, O) do { \
LIBELF_PRIVATE(error) = ((ELF_E_##E & LIBELF_ELF_ERROR_MASK)| \
((O) << LIBELF_OS_ERROR_SHIFT)); \
- printf("Error %d in function %s line %d\n", ELF_E_##E, __FUNCTION__, __LINE__); \
} while (0)
#define LIBELF_ADJUST_AR_SIZE(S) (((S) + 1U) & ~1U)
@@ -76,6 +74,7 @@
struct _Elf {
int e_activations; /* activation count */
+ Elf_Arhdr *e_arhdr; /* header for archive members */
unsigned int e_byteorder; /* ELFDATA* */
int e_class; /* ELFCLASS* */
Elf_Cmd e_cmd; /* ELF_C_* used at creation time */
@@ -89,14 +88,14 @@
union {
struct { /* ar(1) archives */
- off_t e_next;
+ off_t e_next; /* set by elf_rand()/elf_next() */
int e_nchildren;
char *e_rawstrtab; /* file name strings */
size_t e_rawstrtabsz;
char *e_rawsymtab; /* symbol table */
size_t e_rawsymtabsz;
- Elf_Arhdr *e_hdrtab;
Elf_Arsym *e_symtab;
+ size_t e_symtabsz;
} e_ar;
struct { /* regular ELF files */
union {
@@ -134,6 +133,24 @@
ELF_TOMEMORY
};
+#define LIBELF_COPY_U32(DST,SRC,NAME) do { \
+ if ((SRC)->NAME > UINT_MAX) { \
+ LIBELF_SET_ERROR(RANGE, 0); \
+ return (0); \
+ } \
+ (DST)->NAME = (SRC)->NAME; \
+ } while (0)
+
+#define LIBELF_COPY_S32(DST,SRC,NAME) do { \
+ if ((SRC)->NAME > INT_MAX || \
+ (SRC)->NAME < INT_MIN) { \
+ LIBELF_SET_ERROR(RANGE, 0); \
+ return (0); \
+ } \
+ (DST)->NAME = (SRC)->NAME; \
+ } while (0)
+
+
/*
* Prototypes
*/
@@ -141,7 +158,10 @@
Elf_Data *_libelf_allocate_data(Elf_Scn *_s);
Elf *_libelf_allocate_elf(void);
Elf_Scn *_libelf_allocate_scn(Elf *_e, size_t _ndx);
+Elf_Arhdr *_libelf_ar_gethdr(Elf *_e);
Elf *_libelf_ar_open(Elf *_e);
+Elf *_libelf_ar_open_member(int _fd, Elf_Cmd _c, Elf *_ar);
+Elf_Arsym *_libelf_ar_process_symtab(Elf *_ar, size_t *_dst);
unsigned long _libelf_checksum(Elf *_e, int _elfclass);
void *_libelf_ehdr(Elf *_e, int _elfclass, int _allocate);
int _libelf_falign(Elf_Type _t, int _elfclass);
@@ -152,7 +172,8 @@
void *_libelf_getphdr(Elf *_e, int _elfclass);
void *_libelf_getshdr(Elf_Scn *_scn, int _elfclass);
int _libelf_getshnum(Elf *_e, void *_eh, int _elfclass, size_t *_shnum);
-int _libelf_getshstrndx(void *_eh, int _elfclass, size_t *_shstrndx);
+int _libelf_getshstrndx(Elf *_e, void *_eh, int _elfclass,
+ size_t *_shstrndx);
void _libelf_init_elf(Elf *_e, Elf_Kind _kind);
int _libelf_malign(Elf_Type _t, int _elfclass);
size_t _libelf_msize(Elf_Type _t, int _elfclass, unsigned int _version);
@@ -161,7 +182,8 @@
Elf *_libelf_release_elf(Elf *_e);
Elf_Scn *_libelf_release_scn(Elf_Scn *_s);
int _libelf_setshnum(Elf *_e, void *_eh, int _elfclass, size_t _shnum);
-int _libelf_setshstrndx(void *_eh, int _elfclass, size_t _shstrndx);
+int _libelf_setshstrndx(Elf *_e, void *_eh, int _elfclass,
+ size_t _shstrndx);
Elf_Data *_libelf_xlate(Elf_Data *_d, const Elf_Data *_s,
unsigned int _encoding, int _elfclass, int _direction);
int _libelf_xlate_shtype(uint32_t _sht);
==== //depot/projects/dtrace/src/lib/libelf/elf.3#6 (text+ko) ====
@@ -21,7 +21,7 @@
.\" out of the use of this software, even if advised of the possibility of
.\" such damage.
.\"
-.\" $FreeBSD$
+.\" $FreeBSD: src/lib/libelf/elf.3,v 1.2 2006/11/13 09:46:15 ru Exp $
.\"
.Dd September 1, 2006
.Os
@@ -44,6 +44,8 @@
and word-size independent way, allowing an application to read and
create ELF objects for 32 and 64 bit architectures and for little-
and big-endian machines.
+The library is capable of processing ELF objects that use extended
+section numbering.
.Pp
This manual page serves to provide an overview of the functionality in
the ELF library.
@@ -236,12 +238,15 @@
data structure describes an individual chunk of a ELF file as
represented in memory.
It has the following application visible members:
-.Bl -tag -width ".Vt unsigned int d_version"
+.Bl -tag -width ".Vt unsigned int d_version" -compact
.It Vt "uint64_t d_align"
-The alignment of the data buffer within its containing ELF section.
+The in-file alignment of the data buffer within its containing ELF section.
+This value must be a power of two.
.It Vt "uint64_t d_off"
The offset with the containing section where this descriptors data
would be placed.
+This field will be computed by the library unless the application
+requests full control of the ELF object's layout.
.It Vt "uint64_t d_size"
The number of bytes of data in this descriptor.
.It Vt "void *d_buf"
@@ -369,7 +374,7 @@
Sets the operating version.
.El
.It "IO Control"
-.Bl -tag -compact
+.Bl -tag -width ".Fn elf_setshstrndx" -compact
.It Fn elf_cntl
Manage the association between and ELF descriptor and its underlying file.
.It Fn elf_flagdata
@@ -386,16 +391,23 @@
descriptor as dirty.
.It Fn elf_flagshdr
Mark an ELF Section Header as dirty.
+.It Fn elf_setshstrndx
+Set the index of the section name string table for the ELF object.
.It Fn elf_update
Recompute ELF object layout and optionally write the modified object
back to the underlying file.
.El
.It "Queries"
-.Bl -tag -compact
+.Bl -tag -width ".Fn elf_getshstrndx" -compact
.It Fn elf32_checksum , Fn elf64_checkum
Compute checksum of an ELF object.
.It Fn elf_getident
Retrieve the identification bytes for an ELF object.
+.It Fn elf_getshnum
+Retrieve the number of sections in an ELF object.
+.It Fn elf_getshstrndx
+Retrieve the section index of the section name string table in
+an ELF object.
.It Fn elf_hash
Compute the ELF hash value of a string.
.It Fn elf_kind
@@ -413,9 +425,10 @@
However, if the application wishes to take complete charge of the
layout of the ELF file, it may set the
.Dv ELF_F_LAYOUT
-flag on an ELF descriptor, following which the library will use the
-section offsets and alignments specified by the application when
-laying out the file.
+flag on an ELF descriptor using
+.Xr elf_flagelf 3 ,
+following which the library will use the data offsets and alignments
+specified by the application when laying out the file.
.Pp
Gaps in between sections will be filled with the fill character
set by function
@@ -423,7 +436,8 @@
.Ss Error Handling
In case an error is encountered, these library functions set an
internal error number and signal the presence of the error by
-returning an special return value. The application can check the
+returning an special return value.
+The application can check the
current error number by calling
.Xr elf_errno 3 .
A human readable description of the recorded error is available by
==== //depot/projects/dtrace/src/lib/libelf/elf_begin.3#5 (text+ko) ====
@@ -21,11 +21,11 @@
.\" out of the use of this software, even if advised of the possibility of
.\" such damage.
.\"
-.\" $FreeBSD$
+.\" $FreeBSD: src/lib/libelf/elf_begin.3,v 1.2 2006/11/13 09:46:15 ru Exp $
.\"
.Dd June 21, 2006
.Os
-.Dt ELF 3
+.Dt ELF_BEGIN 3
.Sh NAME
.Nm elf_begin
.Nd open an ELF file or ar(1) archive
==== //depot/projects/dtrace/src/lib/libelf/elf_begin.c#8 (text+ko) ====
@@ -25,7 +25,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+__FBSDID("$FreeBSD: src/lib/libelf/elf_begin.c,v 1.1 2006/11/11 17:16:33 jkoshy Exp $");
#include <sys/types.h>
#include <sys/errno.h>
@@ -33,14 +33,13 @@
#include <sys/stat.h>
#include <ar.h>
-#include <assert.h>
#include <ctype.h>
#include <libelf.h>
#include "_libelf.h"
static Elf *
-libelf_open_object(int fd, Elf_Cmd c)
+_libelf_open_object(int fd, Elf_Cmd c)
{
Elf *e;
void *m;
@@ -82,52 +81,8 @@
return (e);
}
-static Elf *
-libelf_open_member(int fd, Elf_Cmd c, Elf *elf)
-{
- Elf *e;
- struct ar_hdr *arh;
- int i, ch;
- size_t sz;
-
- assert(elf->e_kind == ELF_K_AR);
-
- /*
- * TODO: The following code is incorrect for archives using
- * the new extended header scheme.
- */
- arh = (struct ar_hdr *) (elf->e_rawfile + elf->e_u.e_ar.e_next);
- for (i = sz = 0; i < 10; i++) {
- ch = arh->ar_size[i];
- if (isdigit(ch)) {
- sz *= 10;
- sz += ch;
- } else {
- LIBELF_SET_ERROR(ARCHIVE, 0);
- return (NULL);
- }
- }
-
- assert(sz > 0);
-
- arh++; /* skip over archive member header */
-
- if ((e = elf_memory((char *) arh, sz)) == NULL) {
- LIBELF_SET_ERROR(RESOURCE, 0);
- return (NULL);
- }
-
- e->e_fd = fd;
- e->e_cmd = c;
-
- elf->e_u.e_ar.e_nchildren++;
- e->e_parent = elf;
-
- return (e);
-}
-
Elf *
-elf_begin(int fd, Elf_Cmd c, Elf *elf)
+elf_begin(int fd, Elf_Cmd c, Elf *a)
{
Elf *e;
@@ -144,6 +99,11 @@
case ELF_C_WRITE:
+ if (a != NULL) { /* not allowed for ar(1) archives. */
+ LIBELF_SET_ERROR(ARGUMENT, 0);
+ return (NULL);
+ }
+
/*
* Check writeability of `fd' immediately and fail if
* not writeable.
@@ -162,13 +122,17 @@
return (e);
case ELF_C_RDWR:
- if (elf != NULL) {
+ if (a != NULL) { /* not allowed for ar(1) archives. */
LIBELF_SET_ERROR(ARGUMENT, 0);
return (NULL);
}
/*FALLTHROUGH*/
case ELF_C_READ:
- if (elf && (elf->e_fd != fd || c != elf->e_cmd)) {
+ /*
+ * Descriptor `a' could be for a regular ELF file, or
+ * for an ar(1) archive.
+ */
+ if (a && (a->e_fd != fd || c != a->e_cmd)) {
LIBELF_SET_ERROR(ARGUMENT, 0);
return (NULL);
}
@@ -181,12 +145,12 @@
}
- if (elf == NULL)
- e = libelf_open_object(fd, c);
- else if (elf->e_kind == ELF_K_AR)
- e = libelf_open_member(fd, c, elf);
+ 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);
else
- (e = elf)->e_activations++;
+ (e = a)->e_activations++;
return (e);
}
==== //depot/projects/dtrace/src/lib/libelf/elf_cntl.3#3 (text+ko) ====
@@ -21,11 +21,11 @@
.\" out of the use of this software, even if advised of the possibility of
.\" such damage.
.\"
-.\" $FreeBSD$
+.\" $FreeBSD: src/lib/libelf/elf_cntl.3,v 1.2 2006/11/13 09:46:15 ru Exp $
.\"
.Dd August 9, 2006
.Os
-.Dt ELF 3
+.Dt ELF_CNTL 3
.Sh NAME
.Nm elf_cntl
.Nd control an elf file descriptor
==== //depot/projects/dtrace/src/lib/libelf/elf_cntl.c#3 (text+ko) ====
@@ -25,7 +25,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+__FBSDID("$FreeBSD: src/lib/libelf/elf_cntl.c,v 1.1 2006/11/11 17:16:33 jkoshy Exp $");
#include <libelf.h>
==== //depot/projects/dtrace/src/lib/libelf/elf_data.c#5 (text+ko) ====
@@ -25,7 +25,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+__FBSDID("$FreeBSD: src/lib/libelf/elf_data.c,v 1.1 2006/11/11 17:16:33 jkoshy Exp $");
#include <assert.h>
#include <errno.h>
@@ -141,6 +141,14 @@
return (NULL);
}
+ /*
+ * elf_newdata() has to append a data descriptor, so
+ * bring in existing section data if not already present.
+ */
+ if (e->e_rawfile && s->s_size > 0 && STAILQ_EMPTY(&s->s_data))
+ if (elf_getdata(s, NULL) == NULL)
+ return (NULL);
+
if ((d = malloc(sizeof(Elf_Data))) == NULL) {
LIBELF_SET_ERROR(RESOURCE, errno);
return (NULL);
==== //depot/projects/dtrace/src/lib/libelf/elf_end.3#4 (text+ko) ====
@@ -21,11 +21,11 @@
.\" out of the use of this software, even if advised of the possibility of
.\" such damage.
.\"
-.\" $FreeBSD$
+.\" $FreeBSD: src/lib/libelf/elf_end.3,v 1.2 2006/11/13 09:46:15 ru Exp $
.\"
.Dd June 29, 2006
.Os
-.Dt ELF 3
+.Dt ELF_END 3
.Sh NAME
.Nm elf_end
.Nd release an ELF descriptor
==== //depot/projects/dtrace/src/lib/libelf/elf_end.c#5 (text+ko) ====
@@ -25,7 +25,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+__FBSDID("$FreeBSD: src/lib/libelf/elf_end.c,v 1.1 2006/11/11 17:16:33 jkoshy Exp $");
#include <sys/mman.h>
==== //depot/projects/dtrace/src/lib/libelf/elf_errmsg.3#4 (text+ko) ====
@@ -21,11 +21,11 @@
.\" out of the use of this software, even if advised of the possibility of
.\" such damage.
.\"
-.\" $FreeBSD$
+.\" $FreeBSD: src/lib/libelf/elf_errmsg.3,v 1.2 2006/11/13 09:46:15 ru Exp $
.\"
.Dd June 11, 2006
.Os
-.Dt ELF 3
+.Dt ELF_ERRMSG 3
.Sh NAME
.Nm elf_errmsg ,
.Nm elf_errno
==== //depot/projects/dtrace/src/lib/libelf/elf_errmsg.c#11 (text+ko) ====
@@ -25,7 +25,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+__FBSDID("$FreeBSD: src/lib/libelf/elf_errmsg.c,v 1.1 2006/11/11 17:16:33 jkoshy Exp $");
#include <libelf.h>
#include <string.h>
==== //depot/projects/dtrace/src/lib/libelf/elf_errno.c#3 (text+ko) ====
@@ -25,7 +25,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+__FBSDID("$FreeBSD: src/lib/libelf/elf_errno.c,v 1.1 2006/11/11 17:16:33 jkoshy Exp $");
#include <libelf.h>
==== //depot/projects/dtrace/src/lib/libelf/elf_fill.3#3 (text+ko) ====
@@ -21,11 +21,11 @@
.\" out of the use of this software, even if advised of the possibility of
.\" such damage.
.\"
-.\" $FreeBSD$
+.\" $FreeBSD: src/lib/libelf/elf_fill.3,v 1.2 2006/11/13 09:46:15 ru Exp $
.\"
.Dd June 11, 2006
.Os
-.Dt ELF 3
+.Dt ELF_FILL 3
.Sh NAME
.Nm elf_fill
.Nd set fill byte for inter-section padding
@@ -49,4 +49,4 @@
.Sh SEE ALSO
.Xr elf 3 ,
.Xr elf_flagelf 3 ,
-.Xr gelf 3+.Xr gelf 3
==== //depot/projects/dtrace/src/lib/libelf/elf_fill.c#3 (text+ko) ====
@@ -25,7 +25,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+__FBSDID("$FreeBSD: src/lib/libelf/elf_fill.c,v 1.1 2006/11/11 17:16:33 jkoshy Exp $");
#include <libelf.h>
@@ -36,4 +36,3 @@
{
LIBELF_PRIVATE(fillchar) = fill;
}
-
==== //depot/projects/dtrace/src/lib/libelf/elf_flag.c#5 (text+ko) ====
@@ -25,9 +25,8 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+__FBSDID("$FreeBSD: src/lib/libelf/elf_flag.c,v 1.1 2006/11/11 17:16:33 jkoshy Exp $");
-#include <assert.h>
#include <libelf.h>
#include "_libelf.h"
==== //depot/projects/dtrace/src/lib/libelf/elf_flagdata.3#5 (text+ko) ====
@@ -21,11 +21,11 @@
.\" out of the use of this software, even if advised of the possibility of
.\" such damage.
.\"
-.\" $FreeBSD$
+.\" $FreeBSD: src/lib/libelf/elf_flagdata.3,v 1.2 2006/11/13 09:46:15 ru Exp $
.\"
.Dd August 10, 2006
.Os
-.Dt ELF 3
+.Dt ELF_FLAGDATA 3
.Sh NAME
.Nm elf_flagdata ,
.Nm elf_flagehdr ,
@@ -139,14 +139,14 @@
.El
.Sh SEE ALSO
.Xr elf 3 ,
-.Xr elf_newdata 3 ,
-.Xr elf_update 3 ,
.Xr elf32_newehdr 3 ,
.Xr elf32_newphdr 3 ,
.Xr elf32_newshdr 3 ,
.Xr elf64_newehdr 3 ,
.Xr elf64_newphdr 3 ,
.Xr elf64_newshdr 3 ,
+.Xr elf_newdata 3 ,
+.Xr elf_update 3 ,
.Xr gelf 3 ,
.Xr gelf_newehdr 3 ,
.Xr gelf_newphdr 3 ,
==== //depot/projects/dtrace/src/lib/libelf/elf_getarhdr.3#3 (text+ko) ====
@@ -21,11 +21,11 @@
.\" out of the use of this software, even if advised of the possibility of
.\" such damage.
.\"
-.\" $FreeBSD$
+.\" $FreeBSD: src/lib/libelf/elf_getarhdr.3,v 1.2 2006/11/13 09:46:15 ru Exp $
.\"
.Dd August 15, 2006
.Os
-.Dt ELF 3
+.Dt ELF_GETARHDR 3
.Sh NAME
.Nm elf_getarhdr
.Nd retrieve ar(1) header for an archive member
@@ -94,4 +94,4 @@
.Xr elf 3 ,
.Xr elf_begin 3 ,
.Xr elf_getarsym 3 ,
-.Xr elf_memory 3+.Xr elf_memory 3
==== //depot/projects/dtrace/src/lib/libelf/elf_getarhdr.c#3 (text+ko) ====
@@ -1,5 +1,5 @@
/*-
- * Copyright (c) 2006 John Birrell jb at freebsd.org
+ * Copyright (c) 2006 Joseph Koshy
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -25,16 +25,24 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+__FBSDID("$FreeBSD: src/lib/libelf/elf_getarhdr.c,v 1.1 2006/11/11 17:16:33 jkoshy Exp $");
#include <libelf.h>
-#include <stdio.h>
#include "_libelf.h"
Elf_Arhdr *
-elf_getarhdr(__unused Elf *elf)
+elf_getarhdr(Elf *e)
{
- printf("%s: not implemented\n", __FUNCTION__);
- return (0);
+ Elf_Arhdr *arh;
+
+ if (e == NULL) {
+ LIBELF_SET_ERROR(ARGUMENT, 0);
+ return (NULL);
+ }
+
+ if ((arh = e->e_arhdr) != NULL)
+ return (arh);
+
+ return (_libelf_ar_gethdr(e));
}
==== //depot/projects/dtrace/src/lib/libelf/elf_getarsym.3#3 (text+ko) ====
@@ -21,11 +21,11 @@
.\" out of the use of this software, even if advised of the possibility of
.\" such damage.
.\"
-.\" $FreeBSD$
+.\" $FreeBSD: src/lib/libelf/elf_getarsym.3,v 1.2 2006/11/13 09:46:15 ru Exp $
.\"
.Dd August 15, 2006
.Os
-.Dt ELF 3
+.Dt ELF_GETARSYM 3
.Sh NAME
.Nm elf_getarsym
.Nd retrieve the symbol table of an archive
@@ -60,7 +60,7 @@
An
.Vt Elf_Arsym
structure has the following elements:
-.Bl -tag -width indent
+.Bl -tag -width indent -compact
.It Vt "char *" Va as_name
This structure member is a pointer to a null-terminated symbol name.
.It Vt "off_t" Va as_off
@@ -85,8 +85,8 @@
.Ar ptr
is non-null, the
.Fn elf_getarsym
-function will store the number of table entries into the location it
-points to, including the last entry in the count.
+function will store the number of table entries returned (including the
+sentinel entry at the end) into the location it points to.
.Sh RETURN VALUES
Function
.Fn elf_getarsym
@@ -97,9 +97,13 @@
.Pp
If argument
.Ar ptr
-is non-null, the library will store the number of archive
-symbol entries into the location it points to if successful,
-or will store zero to the location in case of an error.
+is non-null and there was no error, the library will store the
+number of archive symbol entries returned into the location it
+points to.
+If argument
+.Ar ptr
+is non-null and an error was encountered, the library will
+set the location pointed to by it to zero.
.Sh ERRORS
Function
.Fn elf_getarsym
@@ -123,4 +127,4 @@
.Xr elf_hash 3 ,
.Xr elf_memory 3 ,
.Xr elf_next 3 ,
-.Xr elf_rand 3+.Xr elf_rand 3
==== //depot/projects/dtrace/src/lib/libelf/elf_getbase.3#3 (text+ko) ====
@@ -21,11 +21,11 @@
.\" out of the use of this software, even if advised of the possibility of
.\" such damage.
.\"
-.\" $FreeBSD$
+.\" $FreeBSD: src/lib/libelf/elf_getbase.3,v 1.2 2006/11/13 09:46:15 ru Exp $
.\"
.Dd June 11, 2006
.Os
-.Dt ELF 3
+.Dt ELF_GETBASE 3
.Sh NAME
.Nm elf_getbase
.Nd get the base offset for an object file
@@ -64,4 +64,4 @@
.Xr elf_getarhdr 3 ,
.Xr elf_getident 3 ,
.Xr elf_rawfile 3 ,
-.Xr gelf 3+.Xr gelf 3
==== //depot/projects/dtrace/src/lib/libelf/elf_getbase.c#3 (text+ko) ====
@@ -25,7 +25,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+__FBSDID("$FreeBSD: src/lib/libelf/elf_getbase.c,v 1.1 2006/11/11 17:16:33 jkoshy Exp $");
#include <libelf.h>
@@ -43,4 +43,3 @@
return ((off_t) ((uintptr_t) e->e_rawfile -
(uintptr_t) e->e_parent->e_rawfile));
}
-
==== //depot/projects/dtrace/src/lib/libelf/elf_getdata.3#5 (text+ko) ====
@@ -21,11 +21,11 @@
.\" out of the use of this software, even if advised of the possibility of
.\" such damage.
.\"
-.\" $FreeBSD$
+.\" $FreeBSD: src/lib/libelf/elf_getdata.3,v 1.2 2006/11/13 09:46:15 ru Exp $
.\"
.Dd August 26, 2006
.Os
-.Dt ELF 3
+.Dt ELF_GETDATA 3
.Sh NAME
.Nm elf_getdata ,
.Nm elf_newdata ,
@@ -80,6 +80,9 @@
Initialized to NULL.
.It Va d_off
Set to (off_t) -1.
+This field is under application control if the
+.Dv ELF_F_LAYOUT
+flag was set on the ELF descriptor.
.It Va d_size
Set to zero.
.It Va d_type
@@ -95,6 +98,15 @@
Section
.Ar scn
must be associated with an ELF file opened for writing.
+If the application has not requested full control of layout by
+setting the
+.Dv ELF_F_LAYOUT
+flag on descriptor
+.Ar elf ,
+then the data referenced by the returned descriptor will be positioned
+after the existing content of the section, honoring the file alignment
+specified in member
+.Va d_align .
On successful completion of a call to
.Fn elf_newdata ,
the ELF library will mark the section
==== //depot/projects/dtrace/src/lib/libelf/elf_getident.3#4 (text+ko) ====
@@ -21,11 +21,11 @@
.\" out of the use of this software, even if advised of the possibility of
.\" such damage.
.\"
-.\" $FreeBSD$
+.\" $FreeBSD: src/lib/libelf/elf_getident.3,v 1.2 2006/11/13 09:46:15 ru Exp $
.\"
.Dd July 3, 2006
.Os
-.Dt ELF 3
+.Dt ELF_GETIDENT 3
.Sh NAME
.Nm elf_getident
.Nd return the initial bytes of a file
@@ -70,14 +70,14 @@
.El
.Sh SEE ALSO
.Xr elf 3 ,
+.Xr elf32_getehdr 3 ,
+.Xr elf64_getehdr 3 ,
.Xr elf_getarhdr 3 ,
.Xr elf_getbase 3 ,
.Xr elf_getflags 3 ,
.Xr elf_kind 3 ,
.Xr elf_rawfile 3 ,
.Xr elf_update 3 ,
-.Xr elf32_getehdr ,
-.Xr elf64_getehdr ,
.Xr gelf 3 ,
.Xr gelf_getclass 3 ,
.Xr gelf_getehdr 3
==== //depot/projects/dtrace/src/lib/libelf/elf_getident.c#4 (text+ko) ====
@@ -25,12 +25,10 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+__FBSDID("$FreeBSD: src/lib/libelf/elf_getident.c,v 1.1 2006/11/11 17:16:33 jkoshy Exp $");
+#include <ar.h>
#include <assert.h>
-#include <sys/types.h>
-
-#include <ar.h>
#include <libelf.h>
#include "_libelf.h"
==== //depot/projects/dtrace/src/lib/libelf/elf_getscn.3#5 (text+ko) ====
@@ -21,11 +21,11 @@
.\" out of the use of this software, even if advised of the possibility of
.\" such damage.
.\"
-.\" $FreeBSD$
+.\" $FreeBSD: src/lib/libelf/elf_getscn.3,v 1.2 2006/11/13 09:46:15 ru Exp $
.\"
.Dd August 26, 2006
.Os
-.Dt ELF 3
+.Dt ELF_GETSCN 3
.Sh NAME
.Nm elf_getscn ,
.Nm elf_ndxscn ,
==== //depot/projects/dtrace/src/lib/libelf/elf_getshnum.3#3 (text+ko) ====
@@ -21,11 +21,11 @@
.\" out of the use of this software, even if advised of the possibility of
.\" such damage.
.\"
-.\" $FreeBSD$
+.\" $FreeBSD: src/lib/libelf/elf_getshnum.3,v 1.2 2006/11/13 09:46:15 ru Exp $
.\"
.Dd October 31, 2006
.Os
-.Dt ELF 3
+.Dt ELF_GETSHNUM 3
.Sh NAME
.Nm elf_getshnum
.Nd return the number of sections in an ELF file
@@ -46,8 +46,6 @@
This routine allows applications to uniformly process both normal ELF
objects, and ELF objects that use extended section numbering.
.Pp
-.Sh IMPLEMENTATION NOTES
-Support for extended section numbering is currently unimplemented.
.Sh RETURN VALUES
Function
.Fn elf_getshnum
@@ -69,18 +67,12 @@
Argument
.Ar elf
lacks an ELF Executable header.
-.It Bq Er ELF_E_UNIMPL
-Argument
-.Ar elf
-had more than
-.Dv SHN_XINDEX
-sections.
.El
.Sh SEE ALSO
.Xr elf 3 ,
+.Xr elf32_getehdr 3 ,
+.Xr elf64_getehdr 3 ,
.Xr elf_getident 3 ,
.Xr elf_getshstrndx 3 ,
-.Xr elf32_getehdr ,
-.Xr elf64_getehdr ,
.Xr gelf 3 ,
.Xr gelf_getehdr 3
==== //depot/projects/dtrace/src/lib/libelf/elf_getshstrndx.3#4 (text+ko) ====
@@ -21,11 +21,11 @@
.\" out of the use of this software, even if advised of the possibility of
.\" such damage.
.\"
-.\" $FreeBSD$
+.\" $FreeBSD: src/lib/libelf/elf_getshstrndx.3,v 1.2 2006/11/13 09:46:15 ru Exp $
.\"
.Dd October 31, 2006
.Os
>>> TRUNCATED FOR MAIL (1000 lines) <<<
More information about the p4-projects
mailing list