From owner-p4-projects@FreeBSD.ORG Wed Nov 1 22:00:38 2006 Return-Path: X-Original-To: p4-projects@freebsd.org Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 5ACC816A4A0; Wed, 1 Nov 2006 22:00:38 +0000 (UTC) X-Original-To: perforce@freebsd.org Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 0DC4E16A47E for ; Wed, 1 Nov 2006 22:00:38 +0000 (UTC) (envelope-from jb@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id 0CDFA43D64 for ; Wed, 1 Nov 2006 22:00:37 +0000 (GMT) (envelope-from jb@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.6/8.13.6) with ESMTP id kA1M0bZ9055741 for ; Wed, 1 Nov 2006 22:00:37 GMT (envelope-from jb@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.6/8.13.4/Submit) id kA1M0aNM055712 for perforce@freebsd.org; Wed, 1 Nov 2006 22:00:36 GMT (envelope-from jb@freebsd.org) Date: Wed, 1 Nov 2006 22:00:36 GMT Message-Id: <200611012200.kA1M0aNM055712@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to jb@freebsd.org using -f From: John Birrell To: Perforce Change Reviews Cc: Subject: PERFORCE change 108967 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 01 Nov 2006 22:00:38 -0000 http://perforce.freebsd.org/chv.cgi?CH=108967 Change 108967 by jb@jb_freebsd8 on 2006/11/01 22:00:19 IFlibbsdelf and drop some of my changes for the time being. Affected files ... .. //depot/projects/dtrace/src/lib/libelf/_libelf.h#10 integrate .. //depot/projects/dtrace/src/lib/libelf/elf_begin.c#6 integrate .. //depot/projects/dtrace/src/lib/libelf/elf_data.c#3 integrate .. //depot/projects/dtrace/src/lib/libelf/elf_flag.c#3 integrate .. //depot/projects/dtrace/src/lib/libelf/elf_getshstrndx.3#2 integrate .. //depot/projects/dtrace/src/lib/libelf/elf_memory.c#7 integrate .. //depot/projects/dtrace/src/lib/libelf/elf_scn.c#4 integrate .. //depot/projects/dtrace/src/lib/libelf/elf_update.c#5 integrate .. //depot/projects/dtrace/src/lib/libelf/gelf_dyn.c#2 integrate .. //depot/projects/dtrace/src/lib/libelf/gelf_rel.c#3 integrate .. //depot/projects/dtrace/src/lib/libelf/gelf_rela.c#3 integrate .. //depot/projects/dtrace/src/lib/libelf/gelf_sym.c#2 integrate .. //depot/projects/dtrace/src/lib/libelf/gelf_update.c#4 integrate .. //depot/projects/dtrace/src/lib/libelf/libelf.h#11 integrate .. //depot/projects/dtrace/src/lib/libelf/libelf_allocate.c#6 integrate .. //depot/projects/dtrace/src/lib/libelf/libelf_ar.c#2 integrate .. //depot/projects/dtrace/src/lib/libelf/libelf_convert.m4#11 integrate .. //depot/projects/dtrace/src/lib/libelf/libelf_data.c#3 integrate .. //depot/projects/dtrace/src/lib/libelf/libelf_ehdr.c#7 integrate .. //depot/projects/dtrace/src/lib/libelf/libelf_phdr.c#4 integrate .. //depot/projects/dtrace/src/lib/libelf/libelf_xlate.c#2 integrate Differences ... ==== //depot/projects/dtrace/src/lib/libelf/_libelf.h#10 (text+ko) ==== @@ -63,7 +63,7 @@ ((O) << LIBELF_OS_ERROR_SHIFT)); \ } while (0) -#define LIBELF_ADJUST_AR_SIZE(S) (((S) + 1) & ~1) +#define LIBELF_ADJUST_AR_SIZE(S) (((S) + 1U) & ~1U) /* * Flags for library internal use. These use the upper 16 bits of a @@ -141,16 +141,12 @@ Elf_Scn *_libelf_allocate_scn(Elf *_e, size_t _ndx); Elf *_libelf_ar_open(Elf *_e); unsigned long _libelf_checksum(Elf *_e, int _elfclass); -int _libelf_dump32(Elf *_elf, const char *_name, const char *_outfile, - unsigned int _flags); -int _libelf_dump64(Elf *_elf, const char *_name, const char *_outfile, - unsigned int _flags); void *_libelf_ehdr(Elf *_e, int _elfclass, int _allocate); int _libelf_falign(Elf_Type _t, int _elfclass); size_t _libelf_fsize(Elf_Type _t, int _elfclass, unsigned int _version, size_t count); void (*_libelf_get_translator(Elf_Type _t, int _direction, int _elfclass)) - (char *_dst, char *_src, int _cnt, int _byteswap); + (char *_dst, char *_src, size_t _cnt, int _byteswap); void *_libelf_getphdr(Elf *_e, int _elfclass); int _libelf_getshnum(void *_eh, int _elfclass, size_t *_shnum); int _libelf_getshstrndx(void *_eh, int _elfclass, size_t *_shstrndx); @@ -165,6 +161,6 @@ int _libelf_setshstrndx(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(size_t _sht); +int _libelf_xlate_shtype(uint32_t _sht); #endif /* __LIBELF_H_ */ ==== //depot/projects/dtrace/src/lib/libelf/elf_begin.c#6 (text+ko) ==== @@ -58,14 +58,14 @@ } m = NULL; - if ((m = mmap(NULL, sb.st_size, PROT_READ, MAP_PRIVATE, fd, + if ((m = mmap(NULL, (size_t) sb.st_size, PROT_READ, MAP_PRIVATE, fd, (off_t) 0)) == MAP_FAILED) { LIBELF_SET_ERROR(IO, errno); return (NULL); } - if ((e = elf_memory(m, sb.st_size)) == NULL) { - (void) munmap(m, sb.st_size); + if ((e = elf_memory(m, (size_t) sb.st_size)) == NULL) { + (void) munmap(m, (size_t) sb.st_size); return (NULL); } @@ -87,7 +87,8 @@ { Elf *e; struct ar_hdr *arh; - int i, ch, sz; + int i, ch; + size_t sz; assert(elf->e_kind == ELF_K_AR); ==== //depot/projects/dtrace/src/lib/libelf/elf_data.c#3 (text+ko) ==== @@ -41,9 +41,10 @@ Elf *e; char *dst; size_t fsz, msz, count; - int elfclass, elftype, sh_type; + int elfclass, elftype; + unsigned int sh_type; uint64_t sh_align, sh_offset, sh_size; - void (*xlate)(char *_d, char *_s, int _c, int _swap); + void (*xlate)(char *_d, char *_s, size_t _c, int _swap); if (s == NULL || (e = s->s_elf) == NULL || e->e_kind != ELF_K_ELF || (d != NULL && s != d->d_scn)) { @@ -86,7 +87,7 @@ } if ((fsz = (elfclass == ELFCLASS32 ? elf32_fsize : elf64_fsize)(elftype, - 1, e->e_version)) == 0) { + (size_t) 1, e->e_version)) == 0) { LIBELF_SET_ERROR(UNIMPL, 0); return (NULL); } @@ -151,7 +152,7 @@ d->d_align = 1; d->d_buf = NULL; - d->d_off = (off_t) -1; + d->d_off = (uint64_t) ~0; d->d_size = 0; d->d_type = ELF_T_BYTE; d->d_version = LIBELF_PRIVATE(version); ==== //depot/projects/dtrace/src/lib/libelf/elf_flag.c#3 (text+ko) ==== ==== //depot/projects/dtrace/src/lib/libelf/elf_getshstrndx.3#2 (text+ko) ==== @@ -27,9 +27,9 @@ .Os .Dt ELF 3 .Sh NAME -.Nm elf_getshstrndx +.Nm elf_getshstrndx , .Nm elf_setshstrndx -.Nd read/write the number of sections in an ELF file +.Nd retrieve/update the index of the section name string table .Sh LIBRARY .Lb libelf .Sh SYNOPSIS ==== //depot/projects/dtrace/src/lib/libelf/elf_memory.c#7 (text+ko) ==== @@ -28,7 +28,6 @@ __FBSDID("$FreeBSD$"); #include -#include #include #include @@ -81,7 +80,8 @@ return (NULL); } - } else if (sz >= SARMAG && strncmp(image, ARMAG, SARMAG) == 0) { + } else if (sz >= SARMAG && + strncmp(image, ARMAG, (size_t) SARMAG) == 0) { _libelf_init_elf(e, ELF_K_AR); e = _libelf_ar_open(e); } else ==== //depot/projects/dtrace/src/lib/libelf/elf_scn.c#4 (text+ko) ==== @@ -48,7 +48,7 @@ Elf32_Ehdr *eh32; Elf64_Ehdr *eh64; Elf_Scn *scn; - void (*xlator)(char *_d, char *_s, int _c, int _swap); + void (*xlator)(char *_d, char *_s, size_t _c, int _swap); assert(e != NULL); assert(ehdr != NULL); @@ -61,7 +61,7 @@ } \ } while (0) - fsz = gelf_fsize(e, ELF_T_SHDR, 1, e->e_version); + fsz = gelf_fsize(e, ELF_T_SHDR, (size_t) 1, e->e_version); assert(fsz > 0); ec = e->e_class; @@ -90,7 +90,7 @@ else dst = (char *) &scn->s_shdr.s_shdr64; - (*xlator)(dst, src, 1, + (*xlator)(dst, src, (size_t) 1, e->e_byteorder != LIBELF_PRIVATE(byteorder)); if (ec == ELFCLASS32) { @@ -160,7 +160,7 @@ { int ec; void *ehdr; - uint16_t *pshnum; + size_t shnum; Elf_Scn *scn; if (e == NULL || e->e_kind != ELF_K_ELF) { @@ -190,22 +190,26 @@ _libelf_load_scn(e, ehdr) == 0) return (NULL); - if (ec == ELFCLASS32) - pshnum = &((Elf32_Ehdr *) ehdr)->e_shnum; - else - pshnum = &((Elf64_Ehdr *) ehdr)->e_shnum; + if (_libelf_getshnum(ehdr, ec, &shnum) == 0) + return (NULL); if (STAILQ_EMPTY(&e->e_u.e_elf.e_scn)) { - assert(*pshnum == 0); - if ((scn = _libelf_allocate_scn(e, SHN_UNDEF)) == NULL) + assert(shnum == 0); + if ((scn = _libelf_allocate_scn(e, (size_t) SHN_UNDEF)) == + NULL) return (NULL); - (*pshnum)++; + shnum++; } - if ((scn = _libelf_allocate_scn(e, *pshnum)) == NULL) + assert(shnum > 0); + + if ((scn = _libelf_allocate_scn(e, shnum)) == NULL) return (NULL); - (*pshnum)++; + shnum++; + + if (_libelf_setshnum(ehdr, ec, shnum) == 0) + return (NULL); (void) elf_flagscn(scn, ELF_C_SET, ELF_F_DIRTY); ==== //depot/projects/dtrace/src/lib/libelf/elf_update.c#5 (text+ko) ==== @@ -175,7 +175,7 @@ */ if (sh_entsize == 0 && (sh_entsize = _libelf_fsize(elftype, ec, e->e_version, - 1)) == 1) + (size_t) 1)) == 1) sh_entsize = 0; sh_size = scn_size; @@ -299,7 +299,7 @@ int ec, eh_class, eh_type; unsigned int eh_byteorder, eh_version; size_t align, fsz; - uint16_t phnum, shnum; + size_t phnum, shnum; off_t rc, phoff, shoff; void *ehdr; Elf32_Ehdr *eh32; @@ -325,7 +325,6 @@ eh_class = eh32->e_ident[EI_CLASS]; phnum = eh32->e_phnum; phoff = (uint64_t) eh32->e_phoff; - shnum = eh32->e_shnum; shoff = (uint64_t) eh32->e_shoff; eh_type = eh32->e_type; eh_version = eh32->e_version; @@ -334,7 +333,6 @@ eh_class = eh64->e_ident[EI_CLASS]; phnum = eh64->e_phnum; phoff = eh64->e_phoff; - shnum = eh64->e_shnum; shoff = eh64->e_shoff; eh_type = eh64->e_type; eh_version = eh64->e_version; @@ -358,6 +356,9 @@ return ((off_t) -1); } + if (_libelf_getshnum(ehdr, ec, &shnum) == 0) + return ((off_t) -1); + e->e_byteorder = eh_byteorder; #define INITIALIZE_EHDR(E,EC,V) do { \ @@ -367,11 +368,12 @@ (E)->e_ident[EI_MAG3] = ELFMAG3; \ (E)->e_ident[EI_CLASS] = (EC); \ (E)->e_ident[EI_VERSION] = (V); \ - (E)->e_ehsize = _libelf_fsize(ELF_T_EHDR, (EC), (V), 1);\ + (E)->e_ehsize = _libelf_fsize(ELF_T_EHDR, (EC), (V), \ + (size_t) 1); \ (E)->e_phentsize = _libelf_fsize(ELF_T_PHDR, (EC), (V), \ - 1); \ + (size_t) 1); \ (E)->e_shentsize = _libelf_fsize(ELF_T_SHDR, (EC), (V), \ - 1); \ + (size_t) 1); \ } while (0) if (ec == ELFCLASS32) @@ -381,7 +383,7 @@ (void) elf_flagehdr(e, ELF_C_SET, ELF_F_DIRTY); - rc += _libelf_fsize(ELF_T_EHDR, ec, eh_version, 1); + rc += _libelf_fsize(ELF_T_EHDR, ec, eh_version, (size_t) 1); /* * Compute the layout the program header table, if one is @@ -426,7 +428,7 @@ * one is needed. */ if (shnum) { - fsz = _libelf_fsize(ELF_T_SHDR, ec, eh_version, 1); + fsz = _libelf_fsize(ELF_T_SHDR, ec, eh_version, (size_t) 1); align = _libelf_falign(ELF_T_SHDR, ec); if (e->e_flags & ELF_F_LAYOUT) { @@ -471,7 +473,8 @@ _libelf_write_scn(Elf *e, char *nf, Elf_Scn *s, off_t rc) { int ec; - size_t fsz, msz, nobjects, sh_type; + size_t fsz, msz, nobjects; + uint32_t sh_type; uint64_t sh_off; int elftype; Elf_Data *d, dst; @@ -602,7 +605,7 @@ assert(e->e_cmd != ELF_C_READ); assert(e->e_fd >= 0); - if ((newfile = malloc(newsize)) == NULL) { + if ((newfile = malloc((size_t) newsize)) == NULL) { LIBELF_SET_ERROR(RESOURCE, errno); return ((off_t) -1); } @@ -629,7 +632,7 @@ shoff = eh64->e_shoff; } - fsz = _libelf_fsize(ELF_T_EHDR, ec, e->e_version, 1); + fsz = _libelf_fsize(ELF_T_EHDR, ec, e->e_version, (size_t) 1); msz = _libelf_msize(ELF_T_EHDR, ec, e->e_version); (void) memset(&dst, 0, sizeof(dst)); @@ -716,7 +719,7 @@ src.d_size = _libelf_msize(ELF_T_SHDR, ec, e->e_version); src.d_version = dst.d_version = e->e_version; - fsz = _libelf_fsize(ELF_T_SHDR, ec, e->e_version, 1); + fsz = _libelf_fsize(ELF_T_SHDR, ec, e->e_version, (size_t) 1); STAILQ_FOREACH(scn, &e->e_u.e_elf.e_scn, s_next) { if (ec == ELFCLASS32) @@ -750,15 +753,15 @@ goto error; } - if (write(e->e_fd, newfile, newsize) != newsize || - lseek(e->e_fd, 0, SEEK_SET) < 0) { + if (write(e->e_fd, newfile, (size_t) newsize) != newsize || + lseek(e->e_fd, (off_t) 0, SEEK_SET) < 0) { LIBELF_SET_ERROR(IO, errno); goto error; } if (e->e_cmd != ELF_C_WRITE) { - if ((e->e_rawfile = mmap(NULL, newsize, PROT_READ, MAP_PRIVATE, - e->e_fd, (off_t) 0)) == MAP_FAILED) { + if ((e->e_rawfile = mmap(NULL, (size_t) newsize, PROT_READ, + MAP_PRIVATE, e->e_fd, (off_t) 0)) == MAP_FAILED) { LIBELF_SET_ERROR(IO, errno); goto error; } ==== //depot/projects/dtrace/src/lib/libelf/gelf_dyn.c#2 (text+ko) ==== @@ -40,7 +40,8 @@ Elf_Scn *scn; Elf32_Dyn *dyn32; Elf64_Dyn *dyn64; - size_t msz, sh_type; + size_t msz; + uint32_t sh_type; if (d == NULL || ndx < 0 || dst == NULL || (scn = d->d_scn) == NULL || ==== //depot/projects/dtrace/src/lib/libelf/gelf_rel.c#3 (text+ko) ==== @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2006 John Birrell jb@freebsd.org + * Copyright (c) 2006 Joseph Koshy * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -27,15 +27,64 @@ #include __FBSDID("$FreeBSD$"); +#include #include -#include -#include #include "_libelf.h" GElf_Rel * -gelf_getrel(__unused Elf_Data *src, __unused int indx, __unused GElf_Rel *dst) +gelf_getrel(Elf_Data *d, int ndx, GElf_Rel *dst) { - printf("%s: not implemented\n", __FUNCTION__); - return (0); + int ec; + Elf *e; + Elf_Scn *scn; + Elf32_Rel *rel32; + Elf64_Rel *rel64; + size_t msz; + uint32_t sh_type; + + if (d == NULL || ndx < 0 || dst == NULL || + (scn = d->d_scn) == NULL || + (e = scn->s_elf) == NULL) { + LIBELF_SET_ERROR(ARGUMENT, 0); + return (NULL); + } + + ec = e->e_class; + assert(ec == ELFCLASS32 || ec == ELFCLASS64); + + if (ec == ELFCLASS32) + sh_type = scn->s_shdr.s_shdr32.sh_type; + else + sh_type = scn->s_shdr.s_shdr64.sh_type; + + if (_libelf_xlate_shtype(sh_type) != ELF_T_REL) { + LIBELF_SET_ERROR(ARGUMENT, 0); + return (NULL); + } + + msz = _libelf_msize(ELF_T_REL, ec, e->e_version); + + assert(msz > 0); + + if (msz * ndx >= d->d_size) { + LIBELF_SET_ERROR(ARGUMENT, 0); + return (NULL); + } + + if (ec == ELFCLASS32) { + rel32 = (Elf32_Rel *) d->d_buf + ndx; + + dst->r_offset = (Elf64_Addr) rel32->r_offset; + dst->r_info = (Elf64_Xword) rel32->r_info; + + } else { + + rel64 = (Elf64_Rel *) d->d_buf + ndx; + + *dst = *rel64; + } + + return (dst); } + ==== //depot/projects/dtrace/src/lib/libelf/gelf_rela.c#3 (text+ko) ==== @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2006 John Birrell jb@freebsd.org + * Copyright (c) 2006 Joseph Koshy * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -27,15 +27,65 @@ #include __FBSDID("$FreeBSD$"); +#include #include -#include -#include #include "_libelf.h" GElf_Rela * -gelf_getrela(__unused Elf_Data *src, __unused int indx, __unused GElf_Rela *dst) +gelf_getrela(Elf_Data *d, int ndx, GElf_Rela *dst) { - printf("%s: not implemented\n", __FUNCTION__); - return (0); + int ec; + Elf *e; + Elf_Scn *scn; + Elf32_Rela *rela32; + Elf64_Rela *rela64; + size_t msz; + uint32_t sh_type; + + if (d == NULL || ndx < 0 || dst == NULL || + (scn = d->d_scn) == NULL || + (e = scn->s_elf) == NULL) { + LIBELF_SET_ERROR(ARGUMENT, 0); + return (NULL); + } + + ec = e->e_class; + assert(ec == ELFCLASS32 || ec == ELFCLASS64); + + if (ec == ELFCLASS32) + sh_type = scn->s_shdr.s_shdr32.sh_type; + else + sh_type = scn->s_shdr.s_shdr64.sh_type; + + if (_libelf_xlate_shtype(sh_type) != ELF_T_RELA) { + LIBELF_SET_ERROR(ARGUMENT, 0); + return (NULL); + } + + msz = _libelf_msize(ELF_T_RELA, ec, e->e_version); + + assert(msz > 0); + + if (msz * ndx >= d->d_size) { + LIBELF_SET_ERROR(ARGUMENT, 0); + return (NULL); + } + + if (ec == ELFCLASS32) { + rela32 = (Elf32_Rela *) d->d_buf + ndx; + + dst->r_offset = (Elf64_Addr) rela32->r_offset; + dst->r_info = (Elf64_Xword) rela32->r_info; + dst->r_addend = (Elf64_Sxword) rela32->r_addend; + + } else { + + rela64 = (Elf64_Rela *) d->d_buf + ndx; + + *dst = *rela64; + } + + return (dst); } + ==== //depot/projects/dtrace/src/lib/libelf/gelf_sym.c#2 (text+ko) ==== @@ -40,7 +40,8 @@ Elf_Scn *scn; Elf32_Sym *sym32; Elf64_Sym *sym64; - size_t msz, sh_type; + size_t msz; + uint32_t sh_type; if (d == NULL || ndx < 0 || dst == NULL || (scn = d->d_scn) == NULL || ==== //depot/projects/dtrace/src/lib/libelf/gelf_update.c#4 (text+ko) ==== @@ -209,7 +209,8 @@ Elf_Scn *scn; Elf32_Sym *sym32; Elf64_Sym *sym64; - size_t msz, sh_type; + size_t msz; + uint32_t sh_type; if (d == NULL || ndx < 0 || gs == NULL || (scn = d->d_scn) == NULL || @@ -266,7 +267,8 @@ Elf_Scn *scn; Elf32_Dyn *dyn32; Elf64_Dyn *dyn64; - size_t msz, sh_type; + size_t msz; + uint32_t sh_type; if (d == NULL || ndx < 0 || ds == NULL || (scn = d->d_scn) == NULL || @@ -318,7 +320,8 @@ Elf_Scn *scn; Elf32_Rel *rel32; Elf64_Rel *rel64; - size_t msz, sh_type; + size_t msz; + uint32_t sh_type; if (d == NULL || ndx < 0 || dr == NULL || (scn = d->d_scn) == NULL || @@ -370,7 +373,8 @@ Elf_Scn *scn; Elf32_Rela *rela32; Elf64_Rela *rela64; - size_t msz, sh_type; + size_t msz; + uint32_t sh_type; if (d == NULL || ndx < 0 || dr == NULL || (scn = d->d_scn) == NULL || @@ -414,5 +418,3 @@ return (1); } - - ==== //depot/projects/dtrace/src/lib/libelf/libelf.h#11 (text+ko) ==== @@ -171,38 +171,12 @@ * Flags defined by the API. */ -#define ELF_F_LAYOUT 0x001 /* application will layout the file */ -#define ELF_F_DIRTY 0x002 /* a section or ELF file is dirty */ - -/* - * Flags passed to elf_dump(). - */ -#define ELF_DUMP_CAP (1 << 0) -#define ELF_DUMP_CHECKSUM (1 << 1) -#define ELF_DUMP_DEMANGLE (1 << 2) -#define ELF_DUMP_DYN (1 << 3) -#define ELF_DUMP_EHDR (1 << 4) -#define ELF_DUMP_GOT (1 << 5) -#define ELF_DUMP_GROUP (1 << 6) -#define ELF_DUMP_HASH (1 << 7) -#define ELF_DUMP_INTERP (1 << 8) -#define ELF_DUMP_LONGNAME (1 << 9) -#define ELF_DUMP_MOVE (1 << 10) -#define ELF_DUMP_NOTE (1 << 11) -#define ELF_DUMP_PHDR (1 << 12) -#define ELF_DUMP_RELOC (1 << 13) -#define ELF_DUMP_SHDR (1 << 14) -#define ELF_DUMP_SYMBOLS (1 << 15) -#define ELF_DUMP_SYMINFO (1 << 16) -#define ELF_DUMP_UNWIND (1 << 17) -#define ELF_DUMP_VERSIONS (1 << 18) +#define ELF_F_LAYOUT 0x001U /* application will layout the file */ +#define ELF_F_DIRTY 0x002U /* a section or ELF file is dirty */ __BEGIN_DECLS Elf *elf_begin(int _fd, Elf_Cmd _cmd, Elf *_elf); int elf_cntl(Elf *_elf, Elf_Cmd _cmd); -int elf_dump(const char *_elf_file, const char *name, - const char *_outfile, unsigned int _flags); -int elf_dump_argv(int _argc, char **_argv); int elf_end(Elf *_elf); const char *elf_errmsg(int _error); int elf_errno(void); ==== //depot/projects/dtrace/src/lib/libelf/libelf_allocate.c#6 (text+ko) ==== @@ -127,7 +127,7 @@ { Elf_Data *d; - if ((d = calloc(1, sizeof(Elf_Data))) == NULL) { + if ((d = calloc((size_t) 1, sizeof(Elf_Data))) == NULL) { LIBELF_SET_ERROR(RESOURCE, 0); return (NULL); } @@ -154,7 +154,7 @@ { Elf_Scn *s; - if ((s = calloc(1, sizeof(Elf_Scn))) == NULL) { + if ((s = calloc((size_t) 1, sizeof(Elf_Scn))) == NULL) { LIBELF_SET_ERROR(RESOURCE, errno); return (NULL); } ==== //depot/projects/dtrace/src/lib/libelf/libelf_ar.c#2 (text+ko) ==== ==== //depot/projects/dtrace/src/lib/libelf/libelf_convert.m4#11 (text+ko) ==== @@ -1,4 +1,3 @@ -//depot/user/jkoshy/projects/libbsdelf/src/libelf_convert.m4#10 - edit change 104937 (text+ko) /*- * Copyright (c) 2006 Joseph Koshy * All rights reserved. @@ -280,10 +279,10 @@ */ define(`MAKEPRIM_TO_F',` static void -libelf_cvt_$1$3_tof(char *dst, char *src, int count, int byteswap) +libelf_cvt_$1$3_tof(char *dst, char *src, size_t count, int byteswap) { Elf$4_$2 t, *s = (Elf$4_$2 *) (uintptr_t) src; - int c; + size_t c; if (dst == src && !byteswap) return; @@ -303,10 +302,10 @@ define(`MAKEPRIM_TO_M',` static void -libelf_cvt_$1$3_tom(char *dst, char *src, int count, int byteswap) +libelf_cvt_$1$3_tom(char *dst, char *src, size_t count, int byteswap) { Elf$4_$2 t, *d = (Elf$4_$2 *) (uintptr_t) dst; - int c; + size_t c; if (dst == src && !byteswap) return; @@ -398,10 +397,10 @@ define(`MAKE_TO_F', `ifdef(`IGNORE_'$1$3,`',` static void -libelf_cvt$3_$1_tof(char *dst, char *src, int count, int byteswap) +libelf_cvt$3_$1_tof(char *dst, char *src, size_t count, int byteswap) { Elf$3_$2 t, *s; - int c; + size_t c; s = (Elf$3_$2 *) (uintptr_t) src; for (c = 0; c < count; c++) { @@ -417,13 +416,13 @@ define(`MAKE_TO_M', `ifdef(`IGNORE_'$1$3,`',` static void -libelf_cvt$3_$1_tom(char *dst, char *src, int count, int byteswap) +libelf_cvt$3_$1_tom(char *dst, char *src, size_t count, int byteswap) { Elf$3_$2 t, *d; unsigned char *s,*s0; size_t fsz; - fsz = elf$3_fsize(ELF_T_$1, 1, EV_CURRENT); + fsz = elf$3_fsize(ELF_T_$1, (size_t) 1, EV_CURRENT); d = ((Elf$3_$2 *) (uintptr_t) dst) + (count - 1); s0 = (unsigned char *) src + (count - 1) * fsz; @@ -478,7 +477,7 @@ */ static void -libelf_cvt_BYTE_tox(char *dst, char *src, int count, int byteswap) +libelf_cvt_BYTE_tox(char *dst, char *src, size_t count, int byteswap) { (void) byteswap; if (dst != src) @@ -488,10 +487,10 @@ MAKE_TYPE_CONVERTERS(ELF_TYPE_LIST) struct converters { - void (*tof32)(char *dst, char *src, int cnt, int byteswap); - void (*tom32)(char *dst, char *src, int cnt, int byteswap); - void (*tof64)(char *dst, char *src, int cnt, int byteswap); - void (*tom64)(char *dst, char *src, int cnt, int byteswap); + void (*tof32)(char *dst, char *src, size_t cnt, int byteswap); + void (*tom32)(char *dst, char *src, size_t cnt, int byteswap); + void (*tof64)(char *dst, char *src, size_t cnt, int byteswap); + void (*tom64)(char *dst, char *src, size_t cnt, int byteswap); }; divert(-1) @@ -531,7 +530,7 @@ }; void (*_libelf_get_translator(Elf_Type t, int direction, int elfclass)) - (char *_dst, char *_src, int _cnt, int _byteswap) + (char *_dst, char *_src, size_t _cnt, int _byteswap) { assert(elfclass == ELFCLASS32 || elfclass == ELFCLASS64); assert(direction == ELF_TOFILE || direction == ELF_TOMEMORY); ==== //depot/projects/dtrace/src/lib/libelf/libelf_data.c#3 (text+ko) ==== @@ -34,7 +34,7 @@ #include "_libelf.h" int -_libelf_xlate_shtype(size_t sht) +_libelf_xlate_shtype(uint32_t sht) { switch (sht) { case SHT_DYNAMIC: ==== //depot/projects/dtrace/src/lib/libelf/libelf_ehdr.c#7 (text+ko) ==== @@ -55,7 +55,7 @@ { size_t fsz, msz; void *ehdr; - void (*xlator)(char *_d, char *_s, int _c, int _swap); + void (*xlator)(char *_d, char *_s, size_t _c, int _swap); assert(ec == ELFCLASS32 || ec == ELFCLASS64); @@ -85,7 +85,7 @@ if (ehdr != NULL) /* already have a translated ehdr */ return (ehdr); - fsz = gelf_fsize(e, ELF_T_EHDR, 1, e->e_version); + fsz = gelf_fsize(e, ELF_T_EHDR, (size_t) 1, e->e_version); assert(fsz > 0); @@ -98,7 +98,7 @@ assert(msz > 0); - if ((ehdr = calloc(1, msz)) == NULL) { + if ((ehdr = calloc((size_t) 1, msz)) == NULL) { LIBELF_SET_ERROR(RESOURCE, 0); return (NULL); } @@ -118,7 +118,8 @@ return (ehdr); xlator = _libelf_get_translator(ELF_T_EHDR, ELF_TOMEMORY, ec); - (*xlator)(ehdr, e->e_rawfile, 1, e->e_byteorder != LIBELF_PRIVATE(byteorder)); + (*xlator)(ehdr, e->e_rawfile, (size_t) 1, + e->e_byteorder != LIBELF_PRIVATE(byteorder)); return (ehdr); } ==== //depot/projects/dtrace/src/lib/libelf/libelf_phdr.c#4 (text+ko) ==== @@ -45,7 +45,7 @@ Elf32_Ehdr *eh32; Elf64_Ehdr *eh64; void *ehdr, *phdr; - void (*xlator)(char *_d, char *_s, int _c, int _swap); + void (*xlator)(char *_d, char *_s, size_t _c, int _swap); assert(ec == ELFCLASS32 || ec == ELFCLASS64); ==== //depot/projects/dtrace/src/lib/libelf/libelf_xlate.c#2 (text+ko) ==== @@ -80,7 +80,7 @@ } if ((fsz = (elfclass == ELFCLASS32 ? elf32_fsize : elf64_fsize)(src->d_type, - 1, src->d_version)) == 0) + (size_t) 1, src->d_version)) == 0) return (NULL); msz = _libelf_msize(src->d_type, elfclass, src->d_version);