1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-04 09:09:56 +00:00

Update elftoolchain to upstream revision 3179

Some notable changes:
- libdwarf: Fixed DWARF4 line section
- elfcopy: Implement --localize-hidden
- nm: handle object name referenced by DW_AT_specification
- elfcopy: Add --strip-dwo and --extract-dwo options for split DWARF
- readelf: add remaining arm64 dynamic relocation names
- nm: Avoid integer overflow in value comparison

Relnotes:	Yes
Sponsored by:	The FreeBSD Foundation
This commit is contained in:
Ed Maste 2015-04-01 01:08:01 +00:00
commit 67d97fe724
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=280932
78 changed files with 255 additions and 240 deletions

View File

@ -24,7 +24,6 @@
* SUCH DAMAGE.
*/
#include <sys/cdefs.h>
#include <sys/param.h>
#include <dwarf.h>
#include <err.h>
@ -40,7 +39,7 @@
#include "_elftc.h"
ELFTC_VCSID("$Id: addr2line.c 3148 2015-02-15 18:47:39Z emaste $");
ELFTC_VCSID("$Id: addr2line.c 3174 2015-03-27 17:13:41Z emaste $");
static struct option longopts[] = {
{"target" , required_argument, NULL, 'b'},

View File

@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: _elftc.h 3139 2015-01-05 03:17:06Z kaiwang27 $
* $Id: _elftc.h 3175 2015-03-27 17:21:24Z emaste $
*/
/**
@ -294,7 +294,8 @@ struct name { \
#define ELFTC_VCSID(ID) __FBSDID(ID)
#endif
#if defined(__linux__) || defined(__GNU__) || defined(__GLIBC__)
#if defined(__APPLE__) || defined(__GLIBC__) || defined(__GNU__) || \
defined(__linux__)
#if defined(__GNUC__)
#define ELFTC_VCSID(ID) __asm__(".ident\t\"" ID "\"")
#else
@ -330,8 +331,8 @@ struct name { \
#ifndef ELFTC_GETPROGNAME
#if defined(__DragonFly__) || defined(__FreeBSD__) || defined(__minix) || \
defined(__NetBSD__)
#if defined(__APPLE__) || defined(__DragonFly__) || defined(__FreeBSD__) || \
defined(__minix) || defined(__NetBSD__)
#include <stdlib.h>
@ -340,7 +341,7 @@ struct name { \
#endif /* __DragonFly__ || __FreeBSD__ || __minix || __NetBSD__ */
#if defined(__GLIBC__)
#if defined(__GLIBC__) || defined(__linux__)
/*
* GLIBC based systems have a global 'char *' pointer referencing
@ -350,7 +351,7 @@ extern const char *program_invocation_short_name;
#define ELFTC_GETPROGNAME() program_invocation_short_name
#endif /* __GLIBC__ */
#endif /* __GLIBC__ || __linux__ */
#if defined(__OpenBSD__)
@ -368,6 +369,21 @@ extern const char *__progname;
** Per-OS configuration.
**/
#if defined(__APPLE__)
#include <machine/endian.h>
#define roundup2 roundup
#define ELFTC_BYTE_ORDER _BYTE_ORDER
#define ELFTC_BYTE_ORDER_LITTLE_ENDIAN _LITTLE_ENDIAN
#define ELFTC_BYTE_ORDER_BIG_ENDIAN _BIG_ENDIAN
#define ELFTC_HAVE_MMAP 1
#define ELFTC_HAVE_STRMODE 1
#endif /* __APPLE__ */
#if defined(__DragonFly__)
#include <osreldate.h>
@ -381,7 +397,7 @@ extern const char *__progname;
#endif
#if defined(__GLIBC__)
#if defined(__GLIBC__) || defined(__linux__)
#include <endian.h>
@ -401,7 +417,7 @@ extern const char *__progname;
#define roundup2 roundup
#endif /* __GLIBC__ */
#endif /* __GLIBC__ || __linux__ */
#if defined(__FreeBSD__)

View File

@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: elfdefinitions.h 3149 2015-02-15 19:00:06Z emaste $
* $Id: elfdefinitions.h 3178 2015-03-30 18:29:13Z emaste $
*/
/*
@ -171,7 +171,7 @@ _ELF_DEFINE_DT(DT_MOVEENT, 0x6FFFFDFAUL, \
"size of DT_MOVETAB entries") \
_ELF_DEFINE_DT(DT_MOVESZ, 0x6FFFFDFBUL, \
"total size of the MOVETAB table") \
_ELF_DEFINE_DT(DT_FEATURE_1, 0x6FFFFDFCUL, "feature values") \
_ELF_DEFINE_DT(DT_FEATURE, 0x6FFFFDFCUL, "feature values") \
_ELF_DEFINE_DT(DT_POSFLAG_1, 0x6FFFFDFDUL, \
"dynamic position flags") \
_ELF_DEFINE_DT(DT_SYMINSZ, 0x6FFFFDFEUL, \

View File

@ -1,6 +1,6 @@
#!/bin/sh
#
# $Id: native-elf-format 2064 2011-10-26 15:12:32Z jkoshy $
# $Id: native-elf-format 3167 2015-02-24 19:10:08Z emaste $
#
# Find the native ELF format for a host platform by compiling a
# test object and examining the resulting object.
@ -19,7 +19,7 @@ touch ${tmp_c}
echo "/* Generated by ${program} on `date` */"
cc -c ${tmp_c} -o ${tmp_o}
readelf -h ${tmp_o} | awk '
LC_ALL=C readelf -h ${tmp_o} | awk '
$1 ~ "Class:" {
sub("ELF","",$2); elfclass = $2;
}

View File

@ -24,7 +24,6 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/cdefs.h>
#include <sys/param.h>
#include <ctype.h>
#include <err.h>
@ -36,7 +35,7 @@
#include "_elftc.h"
ELFTC_VCSID("$Id: cxxfilt.c 2185 2011-11-19 16:07:16Z jkoshy $");
ELFTC_VCSID("$Id: cxxfilt.c 3174 2015-03-27 17:13:41Z emaste $");
#define STRBUFSZ 8192

View File

@ -24,8 +24,6 @@
* SUCH DAMAGE.
*/
#include <sys/cdefs.h>
#include <sys/param.h>
#include <sys/stat.h>
#include <err.h>
@ -40,7 +38,7 @@
#include "elfcopy.h"
ELFTC_VCSID("$Id: archive.c 3102 2014-10-29 21:09:01Z jkoshy $");
ELFTC_VCSID("$Id: archive.c 3174 2015-03-27 17:13:41Z emaste $");
#define _ARMAG_LEN 8 /* length of ar magic string */
#define _ARHDR_LEN 60 /* length of ar header */

View File

@ -24,7 +24,6 @@
* SUCH DAMAGE.
*/
#include <sys/cdefs.h>
#include <sys/param.h>
#include <ctype.h>
#include <err.h>
@ -37,7 +36,7 @@
#include "elfcopy.h"
ELFTC_VCSID("$Id: ascii.c 2358 2011-12-19 18:22:32Z kaiwang27 $");
ELFTC_VCSID("$Id: ascii.c 3177 2015-03-30 18:19:41Z emaste $");
static void append_data(struct section *s, const void *buf, size_t sz);
static char hex_digit(uint8_t n);

View File

@ -24,7 +24,6 @@
* SUCH DAMAGE.
*/
#include <sys/cdefs.h>
#include <sys/param.h>
#include <sys/stat.h>
#include <err.h>
@ -36,7 +35,7 @@
#include "elfcopy.h"
ELFTC_VCSID("$Id: binary.c 2358 2011-12-19 18:22:32Z kaiwang27 $");
ELFTC_VCSID("$Id: binary.c 3174 2015-03-27 17:13:41Z emaste $");
/*
* Convert ELF object to `binary'. Sections with SHF_ALLOC flag set

View File

@ -21,9 +21,9 @@
.\" out of the use of this software, even if advised of the possibility of
.\" such damage.
.\"
.\" $Id: elfcopy.1 2373 2011-12-30 07:13:44Z jkoshy $
.\" $Id: elfcopy.1 3173 2015-03-27 16:46:13Z emaste $
.\"
.Dd October 03, 2011
.Dd March 27, 2015
.Os
.Dt ELFCOPY 1
.Sh NAME
@ -63,7 +63,9 @@
.Op Fl -adjust-warnings | Fl -change-warnings
.Op Fl -change-section-lma Ar section Ns {+|-|=} Ns Ar val
.Op Fl -change-section-vma Ar section Ns {+|-|=} Ns Ar val
.Op Fl -extract-dwo
.Op Fl -gap-fill Ns = Ns Ar val
.Op Fl -localize-hidden
.Op Fl -no-adjust-warnings | Fl -no-change-warnings
.Op Fl -only-keep-debug
.Op Fl -pad-to Ns = Ns Ar address
@ -75,6 +77,7 @@
.Op Fl -set-start Ns = Ns Ar address
.Op Fl -srec-forceS3
.Op Fl -srec-len Ns = Ns Ar val
.Op Fl -strip-dwo
.Op Fl -strip-unneeded
.Ar infile
.Op Ar outfile
@ -220,10 +223,15 @@ Depending on the operator specified, the value in argument
.Ar val
will be used as an increment, a decrement or as the new value
of the virtual memory address.
.It Fl -extract-dwo
Copy only .dwo debug sections to the output file.
.It Fl -gap-fill Ns = Ns Ar val
Fill the gaps between sections with the byte value specified by
the argument
.Ar val .
.It Fl -localize-hidden
Make all hidden symbols local to the output file.
This includes symbols with internal visiblity.
.It Fl -no-adjust-warnings | Fl -no-change-warnings
Do not issue a warning if the section specified by the options
.Fl -change-section-address ,
@ -304,6 +312,8 @@ Set the maximum length of an S-record line to
.Ar val .
This option is only meaningful when the output target is set to
.Dq srec .
.It Fl -strip-dwo
Do not copy .dwo debug sections to the output file.
.It Fl -strip-unneeded
Do not copy symbols that are not needed for relocation processing.
.El

View File

@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: elfcopy.h 3134 2014-12-23 10:43:59Z kaiwang27 $
* $Id: elfcopy.h 3173 2015-03-27 16:46:13Z emaste $
*/
#include <sys/queue.h>
@ -190,7 +190,9 @@ struct elfcopy {
STRIP_NONE = 0,
STRIP_ALL,
STRIP_DEBUG,
STRIP_DWO,
STRIP_NONDEBUG,
STRIP_NONDWO,
STRIP_UNNEEDED
} strip;
@ -216,6 +218,7 @@ struct elfcopy {
#define SEC_REMOVE 0x00800000U
#define SEC_COPY 0x01000000U
#define DISCARD_LLABEL 0x02000000U
#define LOCALIZE_HIDDEN 0x04000000U
int flags; /* elfcopy run control flags. */
int64_t change_addr; /* Section address adjustment. */

View File

@ -24,7 +24,6 @@
* SUCH DAMAGE.
*/
#include <sys/cdefs.h>
#include <sys/param.h>
#include <sys/stat.h>
@ -40,7 +39,7 @@
#include "elfcopy.h"
ELFTC_VCSID("$Id: main.c 3156 2015-02-15 21:40:01Z emaste $");
ELFTC_VCSID("$Id: main.c 3174 2015-03-27 17:13:41Z emaste $");
enum options
{
@ -57,9 +56,11 @@ enum options
ECP_GLOBALIZE_SYMBOLS,
ECP_KEEP_SYMBOLS,
ECP_KEEP_GLOBAL_SYMBOLS,
ECP_LOCALIZE_HIDDEN,
ECP_LOCALIZE_SYMBOLS,
ECP_NO_CHANGE_WARN,
ECP_ONLY_DEBUG,
ECP_ONLY_DWO,
ECP_PAD_TO,
ECP_PREFIX_ALLOC,
ECP_PREFIX_SEC,
@ -72,6 +73,7 @@ enum options
ECP_SET_START,
ECP_SREC_FORCE_S3,
ECP_SREC_LEN,
ECP_STRIP_DWO,
ECP_STRIP_SYMBOLS,
ECP_STRIP_UNNEEDED,
ECP_WEAKEN_ALL,
@ -124,6 +126,7 @@ static struct option elfcopy_longopts[] =
{"change-warnings", no_argument, NULL, ECP_CHANGE_WARN},
{"discard-all", no_argument, NULL, 'x'},
{"discard-locals", no_argument, NULL, 'X'},
{"extract-dwo", no_argument, NULL, ECP_ONLY_DWO},
{"gap-fill", required_argument, NULL, ECP_GAP_FILL},
{"globalize-symbol", required_argument, NULL, ECP_GLOBALIZE_SYMBOL},
{"globalize-symbols", required_argument, NULL, ECP_GLOBALIZE_SYMBOLS},
@ -134,6 +137,7 @@ static struct option elfcopy_longopts[] =
{"keep-global-symbol", required_argument, NULL, 'G'},
{"keep-global-symbols", required_argument, NULL,
ECP_KEEP_GLOBAL_SYMBOLS},
{"localize-hidden", no_argument, NULL, ECP_LOCALIZE_HIDDEN},
{"localize-symbol", required_argument, NULL, 'L'},
{"localize-symbols", required_argument, NULL, ECP_LOCALIZE_SYMBOLS},
{"no-adjust-warnings", no_argument, NULL, ECP_NO_CHANGE_WARN},
@ -157,6 +161,7 @@ static struct option elfcopy_longopts[] =
{"srec-len", required_argument, NULL, ECP_SREC_LEN},
{"strip-all", no_argument, NULL, 'S'},
{"strip-debug", no_argument, 0, 'g'},
{"strip-dwo", no_argument, NULL, ECP_STRIP_DWO},
{"strip-symbol", required_argument, NULL, 'N'},
{"strip-symbols", required_argument, NULL, ECP_STRIP_SYMBOLS},
{"strip-unneeded", no_argument, NULL, ECP_STRIP_UNNEEDED},
@ -348,6 +353,7 @@ create_elf(struct elfcopy *ecp)
if (ecp->strip == STRIP_DEBUG ||
ecp->strip == STRIP_UNNEEDED ||
ecp->flags & WEAKEN_ALL ||
ecp->flags & LOCALIZE_HIDDEN ||
ecp->flags & DISCARD_LOCAL ||
ecp->flags & DISCARD_LLABEL ||
ecp->prefix_sym != NULL ||
@ -870,6 +876,9 @@ elfcopy_main(struct elfcopy *ecp, int argc, char **argv)
case ECP_KEEP_GLOBAL_SYMBOLS:
parse_symlist_file(ecp, optarg, SYMOP_KEEPG);
break;
case ECP_LOCALIZE_HIDDEN:
ecp->flags |= LOCALIZE_HIDDEN;
break;
case ECP_LOCALIZE_SYMBOLS:
parse_symlist_file(ecp, optarg, SYMOP_LOCALIZE);
break;
@ -879,6 +888,9 @@ elfcopy_main(struct elfcopy *ecp, int argc, char **argv)
case ECP_ONLY_DEBUG:
ecp->strip = STRIP_NONDEBUG;
break;
case ECP_ONLY_DWO:
ecp->strip = STRIP_NONDWO;
break;
case ECP_PAD_TO:
ecp->pad_to = (uint64_t) strtoull(optarg, NULL, 0);
break;
@ -939,6 +951,9 @@ elfcopy_main(struct elfcopy *ecp, int argc, char **argv)
ecp->flags |= SREC_FORCE_LEN;
ecp->srec_len = strtoul(optarg, NULL, 0);
break;
case ECP_STRIP_DWO:
ecp->strip = STRIP_DWO;
break;
case ECP_STRIP_SYMBOLS:
parse_symlist_file(ecp, optarg, SYMOP_STRIP);
break;
@ -1379,6 +1394,8 @@ Usage: %s [options] infile [outfile]\n\
section by VAL.\n\
--gap-fill=VAL Fill the gaps between sections with bytes\n\
of value VAL.\n\
--localize-hidden Make all hidden symbols local to the output\n\
file.\n\
--no-adjust-warning| --no-change-warnings\n\
Do not issue warnings for non-existent\n\
sections.\n\

View File

@ -24,7 +24,6 @@
* SUCH DAMAGE.
*/
#include <sys/cdefs.h>
#include <sys/param.h>
#include <sys/stat.h>
#include <err.h>
@ -35,7 +34,7 @@
#include "elfcopy.h"
ELFTC_VCSID("$Id: sections.c 3150 2015-02-15 19:07:46Z emaste $");
ELFTC_VCSID("$Id: sections.c 3174 2015-03-27 17:13:41Z emaste $");
static void add_gnu_debuglink(struct elfcopy *ecp);
static uint32_t calc_crc32(const char *p, size_t len, uint32_t crc);
@ -47,6 +46,7 @@ static void insert_to_strtab(struct section *t, const char *s);
static int is_append_section(struct elfcopy *ecp, const char *name);
static int is_compress_section(struct elfcopy *ecp, const char *name);
static int is_debug_section(const char *name);
static int is_dwo_section(const char *name);
static int is_modify_section(struct elfcopy *ecp, const char *name);
static int is_print_section(struct elfcopy *ecp, const char *name);
static int lookup_string(struct section *t, const char *s);
@ -73,6 +73,11 @@ is_remove_section(struct elfcopy *ecp, const char *name)
return (0);
}
if (ecp->strip == STRIP_DWO && is_dwo_section(name))
return (1);
if (ecp->strip == STRIP_NONDWO && !is_dwo_section(name))
return (1);
if (is_debug_section(name)) {
if (ecp->strip == STRIP_ALL ||
ecp->strip == STRIP_DEBUG ||
@ -233,6 +238,16 @@ is_debug_section(const char *name)
return (0);
}
static int
is_dwo_section(const char *name)
{
size_t len;
if ((len = strlen(name)) > 4 && strcmp(name + len - 4, ".dwo") == 0)
return (1);
return (0);
}
static int
is_print_section(struct elfcopy *ecp, const char *name)
{

View File

@ -24,7 +24,6 @@
* SUCH DAMAGE.
*/
#include <sys/cdefs.h>
#include <sys/queue.h>
#include <err.h>
#include <gelf.h>
@ -35,7 +34,7 @@
#include "elfcopy.h"
ELFTC_VCSID("$Id: segments.c 3134 2014-12-23 10:43:59Z kaiwang27 $");
ELFTC_VCSID("$Id: segments.c 3177 2015-03-30 18:19:41Z emaste $");
static void insert_to_inseg_list(struct segment *seg, struct section *sec);

View File

@ -24,7 +24,6 @@
* SUCH DAMAGE.
*/
#include <sys/cdefs.h>
#include <sys/param.h>
#include <err.h>
#include <fnmatch.h>
@ -34,7 +33,7 @@
#include "elfcopy.h"
ELFTC_VCSID("$Id: symbols.c 3135 2014-12-24 08:22:43Z kaiwang27 $");
ELFTC_VCSID("$Id: symbols.c 3174 2015-03-27 17:13:41Z emaste $");
/* Symbol table buffer structure. */
struct symbuf {
@ -128,6 +127,17 @@ is_local_symbol(unsigned char st_info)
return (0);
}
static int
is_hidden_symbol(unsigned char st_other)
{
if (GELF_ST_VISIBILITY(st_other) == STV_HIDDEN ||
GELF_ST_VISIBILITY(st_other) == STV_INTERNAL)
return (1);
return (0);
}
static int
is_local_label(const char *name)
{
@ -457,6 +467,11 @@ generate_symbols(struct elfcopy *ecp)
lookup_symop_list(ecp, name, SYMOP_KEEPG) == NULL)
sym.st_info = GELF_ST_INFO(STB_LOCAL,
GELF_ST_TYPE(sym.st_info));
if (ecp->flags & LOCALIZE_HIDDEN &&
sym.st_shndx != SHN_UNDEF &&
is_hidden_symbol(sym.st_other))
sym.st_info = GELF_ST_INFO(STB_LOCAL,
GELF_ST_TYPE(sym.st_info));
} else {
/* STB_LOCAL binding. */
if (lookup_symop_list(ecp, name, SYMOP_GLOBALIZE) !=
@ -1036,10 +1051,8 @@ match_wildcard(const char *name, const char *pattern)
}
match = 0;
if (!fnmatch(pattern, name, 0)) {
if (!fnmatch(pattern, name, 0))
match = 1;
printf("string '%s' match to pattern '%s'\n", name, pattern);
}
return (reverse ? !match : match);
}

View File

@ -24,7 +24,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: _libdwarf.h 3161 2015-02-15 21:43:36Z emaste $
* $Id: _libdwarf.h 3164 2015-02-19 01:20:12Z kaiwang27 $
*/
#ifndef __LIBDWARF_H_
@ -190,6 +190,7 @@ struct _Dwarf_LineInfo {
Dwarf_Half li_version; /* Version of line info. */
Dwarf_Unsigned li_hdrlen; /* Length of line info header. */
Dwarf_Small li_minlen; /* Minimum instrutction length. */
Dwarf_Small li_maxop; /* Maximum operations per inst. */
Dwarf_Small li_defstmt; /* Default value of is_stmt. */
int8_t li_lbase; /* Line base for special opcode. */
Dwarf_Small li_lrange; /* Line range for special opcode. */

View File

@ -24,7 +24,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: libdwarf.h 3149 2015-02-15 19:00:06Z emaste $
* $Id: libdwarf.h 3174 2015-03-27 17:13:41Z emaste $
*/
#ifndef _LIBDWARF_H_
@ -444,7 +444,9 @@ enum Dwarf_ISA {
};
/* Function prototype definitions. */
__BEGIN_DECLS
#ifdef __cplusplus
extern "C" {
#endif
Dwarf_P_Attribute dwarf_add_AT_comp_dir(Dwarf_P_Die, char *, Dwarf_Error *);
Dwarf_P_Attribute dwarf_add_AT_const_value_signedint(Dwarf_P_Die, Dwarf_Signed,
Dwarf_Error *);
@ -831,6 +833,8 @@ int dwarf_whatattr(Dwarf_Attribute, Dwarf_Half *, Dwarf_Error *);
int dwarf_whatform(Dwarf_Attribute, Dwarf_Half *, Dwarf_Error *);
int dwarf_whatform_direct(Dwarf_Attribute, Dwarf_Half *,
Dwarf_Error *);
__END_DECLS
#ifdef __cplusplus
}
#endif
#endif /* !_LIBDWARF_H_ */

View File

@ -26,7 +26,7 @@
#include "_libdwarf.h"
ELFTC_VCSID("$Id: libdwarf_lineno.c 3100 2014-10-25 20:34:29Z jkoshy $");
ELFTC_VCSID("$Id: libdwarf_lineno.c 3164 2015-02-19 01:20:12Z kaiwang27 $");
static int
_dwarf_lineno_add_file(Dwarf_LineInfo li, uint8_t **p, const char *compdir,
@ -315,6 +315,8 @@ _dwarf_lineno_init(Dwarf_Die die, uint64_t offset, Dwarf_Error *error)
li->li_hdrlen = dbg->read(ds->ds_data, &offset, dwarf_size);
hdroff = offset;
li->li_minlen = dbg->read(ds->ds_data, &offset, 1);
if (li->li_version == 4)
li->li_maxop = dbg->read(ds->ds_data, &offset, 1);
li->li_defstmt = dbg->read(ds->ds_data, &offset, 1);
li->li_lbase = dbg->read(ds->ds_data, &offset, 1);
li->li_lrange = dbg->read(ds->ds_data, &offset, 1);

View File

@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: _libelf.h 3011 2014-03-23 03:32:42Z jkoshy $
* $Id: _libelf.h 3174 2015-03-27 17:13:41Z emaste $
*/
#ifndef __LIBELF_H_
@ -194,7 +194,9 @@ enum {
* Function Prototypes.
*/
__BEGIN_DECLS
#ifdef __cplusplus
extern "C" {
#endif
struct _Libelf_Data *_libelf_allocate_data(Elf_Scn *_s);
Elf *_libelf_allocate_elf(void);
Elf_Scn *_libelf_allocate_scn(Elf *_e, size_t _ndx);
@ -230,6 +232,8 @@ int _libelf_setshstrndx(Elf *_e, void *_eh, int _elfclass,
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);
__END_DECLS
#ifdef __cplusplus
}
#endif
#endif /* __LIBELF_H_ */

View File

@ -23,10 +23,10 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: _libelf_config.h 3143 2015-02-15 17:57:38Z emaste $
* $Id: _libelf_config.h 3168 2015-02-24 19:17:47Z emaste $
*/
#ifdef __DragonFly__
#if defined(__APPLE__) || defined(__DragonFly__)
#if defined(__amd64__)
#define LIBELF_ARCH EM_X86_64

View File

@ -32,7 +32,7 @@
#include "_libelf.h"
ELFTC_VCSID("$Id: elf_data.c 3009 2014-03-23 01:49:59Z jkoshy $");
ELFTC_VCSID("$Id: elf_data.c 3177 2015-03-30 18:19:41Z emaste $");
Elf_Data *
elf_getdata(Elf_Scn *s, Elf_Data *ed)

View File

@ -24,8 +24,6 @@
* SUCH DAMAGE.
*/
#include <sys/cdefs.h>
#include <assert.h>
#include <libelf.h>
#include <stdlib.h>
@ -36,7 +34,7 @@
#include <sys/mman.h>
#endif
ELFTC_VCSID("$Id: elf_end.c 2240 2011-11-28 06:36:48Z jkoshy $");
ELFTC_VCSID("$Id: elf_end.c 3174 2015-03-27 17:13:41Z emaste $");
int
elf_end(Elf *e)

View File

@ -24,15 +24,13 @@
* SUCH DAMAGE.
*/
#include <sys/cdefs.h>
#include <libelf.h>
#include <stdio.h>
#include <string.h>
#include "_libelf.h"
ELFTC_VCSID("$Id: elf_errmsg.c 3012 2014-03-23 03:41:38Z jkoshy $");
ELFTC_VCSID("$Id: elf_errmsg.c 3174 2015-03-27 17:13:41Z emaste $");
/*
* Retrieve a human readable translation for an error message.

View File

@ -24,13 +24,11 @@
* SUCH DAMAGE.
*/
#include <sys/cdefs.h>
#include <libelf.h>
#include "_libelf.h"
ELFTC_VCSID("$Id: elf_errno.c 2225 2011-11-26 18:55:54Z jkoshy $");
ELFTC_VCSID("$Id: elf_errno.c 3174 2015-03-27 17:13:41Z emaste $");
int
elf_errno(void)

View File

@ -24,13 +24,11 @@
* SUCH DAMAGE.
*/
#include <sys/cdefs.h>
#include <libelf.h>
#include "_libelf.h"
ELFTC_VCSID("$Id: elf_fill.c 2225 2011-11-26 18:55:54Z jkoshy $");
ELFTC_VCSID("$Id: elf_fill.c 3174 2015-03-27 17:13:41Z emaste $");
void
elf_fill(int fill)

View File

@ -24,13 +24,11 @@
* SUCH DAMAGE.
*/
#include <sys/cdefs.h>
#include <libelf.h>
#include "_libelf.h"
ELFTC_VCSID("$Id: elf_flag.c 2988 2014-03-17 08:51:49Z jkoshy $");
ELFTC_VCSID("$Id: elf_flag.c 3174 2015-03-27 17:13:41Z emaste $");
unsigned int
elf_flagarhdr(Elf_Arhdr *a, Elf_Cmd c, unsigned int flags)

View File

@ -24,13 +24,11 @@
* SUCH DAMAGE.
*/
#include <sys/cdefs.h>
#include <libelf.h>
#include "_libelf.h"
ELFTC_VCSID("$Id: elf_getarhdr.c 2225 2011-11-26 18:55:54Z jkoshy $");
ELFTC_VCSID("$Id: elf_getarhdr.c 3174 2015-03-27 17:13:41Z emaste $");
Elf_Arhdr *
elf_getarhdr(Elf *e)

View File

@ -24,13 +24,11 @@
* SUCH DAMAGE.
*/
#include <sys/cdefs.h>
#include <libelf.h>
#include "_libelf.h"
ELFTC_VCSID("$Id: elf_getarsym.c 2225 2011-11-26 18:55:54Z jkoshy $");
ELFTC_VCSID("$Id: elf_getarsym.c 3174 2015-03-27 17:13:41Z emaste $");
Elf_Arsym *
elf_getarsym(Elf *ar, size_t *ptr)

View File

@ -24,13 +24,11 @@
* SUCH DAMAGE.
*/
#include <sys/cdefs.h>
#include <libelf.h>
#include "_libelf.h"
ELFTC_VCSID("$Id: elf_getbase.c 2225 2011-11-26 18:55:54Z jkoshy $");
ELFTC_VCSID("$Id: elf_getbase.c 3174 2015-03-27 17:13:41Z emaste $");
off_t
elf_getbase(Elf *e)

View File

@ -24,15 +24,13 @@
* SUCH DAMAGE.
*/
#include <sys/cdefs.h>
#include <ar.h>
#include <assert.h>
#include <libelf.h>
#include "_libelf.h"
ELFTC_VCSID("$Id: elf_getident.c 2225 2011-11-26 18:55:54Z jkoshy $");
ELFTC_VCSID("$Id: elf_getident.c 3174 2015-03-27 17:13:41Z emaste $");
char *
elf_getident(Elf *e, size_t *sz)

View File

@ -24,13 +24,11 @@
* SUCH DAMAGE.
*/
#include <sys/cdefs.h>
#include <libelf.h>
#include "_libelf.h"
ELFTC_VCSID("$Id: elf_hash.c 2225 2011-11-26 18:55:54Z jkoshy $");
ELFTC_VCSID("$Id: elf_hash.c 3174 2015-03-27 17:13:41Z emaste $");
/*
* This elf_hash function is defined by the System V ABI.

View File

@ -24,13 +24,11 @@
* SUCH DAMAGE.
*/
#include <sys/cdefs.h>
#include <libelf.h>
#include "_libelf.h"
ELFTC_VCSID("$Id: elf_kind.c 2225 2011-11-26 18:55:54Z jkoshy $");
ELFTC_VCSID("$Id: elf_kind.c 3174 2015-03-27 17:13:41Z emaste $");
Elf_Kind
elf_kind(Elf *e)

View File

@ -24,15 +24,13 @@
* SUCH DAMAGE.
*/
#include <sys/cdefs.h>
#include <ar.h>
#include <assert.h>
#include <libelf.h>
#include "_libelf.h"
ELFTC_VCSID("$Id: elf_next.c 2989 2014-03-17 09:56:46Z jkoshy $");
ELFTC_VCSID("$Id: elf_next.c 3174 2015-03-27 17:13:41Z emaste $");
Elf_Cmd
elf_next(Elf *e)

View File

@ -24,14 +24,12 @@
* SUCH DAMAGE.
*/
#include <sys/cdefs.h>
#include <ar.h>
#include <libelf.h>
#include "_libelf.h"
ELFTC_VCSID("$Id: elf_phnum.c 2225 2011-11-26 18:55:54Z jkoshy $");
ELFTC_VCSID("$Id: elf_phnum.c 3174 2015-03-27 17:13:41Z emaste $");
static int
_libelf_getphdrnum(Elf *e, size_t *phnum)

View File

@ -24,14 +24,12 @@
* SUCH DAMAGE.
*/
#include <sys/cdefs.h>
#include <ar.h>
#include <libelf.h>
#include "_libelf.h"
ELFTC_VCSID("$Id: elf_rand.c 2991 2014-03-17 09:57:04Z jkoshy $");
ELFTC_VCSID("$Id: elf_rand.c 3174 2015-03-27 17:13:41Z emaste $");
off_t
elf_rand(Elf *ar, off_t offset)

View File

@ -24,13 +24,11 @@
* SUCH DAMAGE.
*/
#include <sys/cdefs.h>
#include <libelf.h>
#include "_libelf.h"
ELFTC_VCSID("$Id: elf_rawfile.c 3013 2014-03-23 06:16:59Z jkoshy $");
ELFTC_VCSID("$Id: elf_rawfile.c 3174 2015-03-27 17:13:41Z emaste $");
char *
elf_rawfile(Elf *e, size_t *sz)

View File

@ -24,7 +24,6 @@
* SUCH DAMAGE.
*/
#include <sys/cdefs.h>
#include <sys/queue.h>
#include <assert.h>
@ -37,7 +36,7 @@
#include "_libelf.h"
ELFTC_VCSID("$Id: elf_scn.c 3147 2015-02-15 18:45:23Z emaste $");
ELFTC_VCSID("$Id: elf_scn.c 3177 2015-03-30 18:19:41Z emaste $");
/*
* Load an ELF section table and create a list of Elf_Scn structures.

View File

@ -24,14 +24,12 @@
* SUCH DAMAGE.
*/
#include <sys/cdefs.h>
#include <ar.h>
#include <libelf.h>
#include "_libelf.h"
ELFTC_VCSID("$Id: elf_shnum.c 2225 2011-11-26 18:55:54Z jkoshy $");
ELFTC_VCSID("$Id: elf_shnum.c 3174 2015-03-27 17:13:41Z emaste $");
static int
_libelf_getshdrnum(Elf *e, size_t *shnum)

View File

@ -24,14 +24,12 @@
* SUCH DAMAGE.
*/
#include <sys/cdefs.h>
#include <ar.h>
#include <libelf.h>
#include "_libelf.h"
ELFTC_VCSID("$Id: elf_shstrndx.c 2225 2011-11-26 18:55:54Z jkoshy $");
ELFTC_VCSID("$Id: elf_shstrndx.c 3174 2015-03-27 17:13:41Z emaste $");
static int
_libelf_getshdrstrndx(Elf *e, size_t *strndx)

View File

@ -24,13 +24,11 @@
* SUCH DAMAGE.
*/
#include <sys/cdefs.h>
#include <libelf.h>
#include "_libelf.h"
ELFTC_VCSID("$Id: elf_version.c 2225 2011-11-26 18:55:54Z jkoshy $");
ELFTC_VCSID("$Id: elf_version.c 3174 2015-03-27 17:13:41Z emaste $");
unsigned int
elf_version(unsigned int v)

View File

@ -23,14 +23,12 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: gelf.h 1168 2010-09-04 01:03:25Z jkoshy $
* $Id: gelf.h 3174 2015-03-27 17:13:41Z emaste $
*/
#ifndef _GELF_H_
#define _GELF_H_
#include <sys/cdefs.h>
#include <libelf.h>
typedef Elf64_Addr GElf_Addr; /* Addresses */
@ -69,7 +67,9 @@ typedef Elf64_Syminfo GElf_Syminfo; /* Symbol information */
#define GELF_ST_TYPE ELF64_ST_TYPE
#define GELF_ST_VISIBILITY ELF64_ST_VISIBILITY
__BEGIN_DECLS
#ifdef __cplusplus
extern "C" {
#endif
long gelf_checksum(Elf *_elf);
size_t gelf_fsize(Elf *_elf, Elf_Type _type, size_t _count,
unsigned int _version);
@ -103,6 +103,8 @@ GElf_Syminfo *gelf_getsyminfo(Elf_Data *_src, int _index, GElf_Syminfo *_dst);
int gelf_update_cap(Elf_Data *_dst, int _index, GElf_Cap *_src);
int gelf_update_move(Elf_Data *_dst, int _index, GElf_Move *_src);
int gelf_update_syminfo(Elf_Data *_dst, int _index, GElf_Syminfo *_src);
__END_DECLS
#ifdef __cplusplus
}
#endif
#endif /* _GELF_H_ */

View File

@ -24,8 +24,6 @@
* SUCH DAMAGE.
*/
#include <sys/cdefs.h>
#include <assert.h>
#include <gelf.h>
#include <limits.h>
@ -33,7 +31,7 @@
#include "_libelf.h"
ELFTC_VCSID("$Id: gelf_cap.c 2995 2014-03-18 02:16:31Z jkoshy $");
ELFTC_VCSID("$Id: gelf_cap.c 3177 2015-03-30 18:19:41Z emaste $");
GElf_Cap *
gelf_getcap(Elf_Data *ed, int ndx, GElf_Cap *dst)

View File

@ -24,14 +24,12 @@
* SUCH DAMAGE.
*/
#include <sys/cdefs.h>
#include <gelf.h>
#include <libelf.h>
#include "_libelf.h"
ELFTC_VCSID("$Id: gelf_checksum.c 2225 2011-11-26 18:55:54Z jkoshy $");
ELFTC_VCSID("$Id: gelf_checksum.c 3174 2015-03-27 17:13:41Z emaste $");
long
elf32_checksum(Elf *e)

View File

@ -24,8 +24,6 @@
* SUCH DAMAGE.
*/
#include <sys/cdefs.h>
#include <assert.h>
#include <gelf.h>
#include <limits.h>
@ -33,7 +31,7 @@
#include "_libelf.h"
ELFTC_VCSID("$Id: gelf_dyn.c 2998 2014-03-18 17:19:00Z jkoshy $");
ELFTC_VCSID("$Id: gelf_dyn.c 3177 2015-03-30 18:19:41Z emaste $");
GElf_Dyn *
gelf_getdyn(Elf_Data *ed, int ndx, GElf_Dyn *dst)

View File

@ -24,8 +24,6 @@
* SUCH DAMAGE.
*/
#include <sys/cdefs.h>
#include <assert.h>
#include <gelf.h>
#include <libelf.h>
@ -35,7 +33,7 @@
#include "_libelf.h"
ELFTC_VCSID("$Id: gelf_ehdr.c 2268 2011-12-03 17:05:11Z jkoshy $");
ELFTC_VCSID("$Id: gelf_ehdr.c 3177 2015-03-30 18:19:41Z emaste $");
Elf32_Ehdr *
elf32_getehdr(Elf *e)

View File

@ -24,14 +24,12 @@
* SUCH DAMAGE.
*/
#include <sys/cdefs.h>
#include <gelf.h>
#include <libelf.h>
#include "_libelf.h"
ELFTC_VCSID("$Id: gelf_fsize.c 2225 2011-11-26 18:55:54Z jkoshy $");
ELFTC_VCSID("$Id: gelf_fsize.c 3174 2015-03-27 17:13:41Z emaste $");
size_t
elf32_fsize(Elf_Type t, size_t c, unsigned int v)

View File

@ -24,13 +24,11 @@
* SUCH DAMAGE.
*/
#include <sys/cdefs.h>
#include <gelf.h>
#include "_libelf.h"
ELFTC_VCSID("$Id: gelf_getclass.c 2225 2011-11-26 18:55:54Z jkoshy $");
ELFTC_VCSID("$Id: gelf_getclass.c 3174 2015-03-27 17:13:41Z emaste $");
int
gelf_getclass(Elf *e)

View File

@ -24,8 +24,6 @@
* SUCH DAMAGE.
*/
#include <sys/cdefs.h>
#include <assert.h>
#include <gelf.h>
#include <limits.h>
@ -33,7 +31,7 @@
#include "_libelf.h"
ELFTC_VCSID("$Id: gelf_move.c 2998 2014-03-18 17:19:00Z jkoshy $");
ELFTC_VCSID("$Id: gelf_move.c 3177 2015-03-30 18:19:41Z emaste $");
GElf_Move *
gelf_getmove(Elf_Data *ed, int ndx, GElf_Move *dst)

View File

@ -24,8 +24,6 @@
* SUCH DAMAGE.
*/
#include <sys/cdefs.h>
#include <gelf.h>
#include <libelf.h>
#include <limits.h>
@ -33,7 +31,7 @@
#include "_libelf.h"
ELFTC_VCSID("$Id: gelf_phdr.c 2268 2011-12-03 17:05:11Z jkoshy $");
ELFTC_VCSID("$Id: gelf_phdr.c 3177 2015-03-30 18:19:41Z emaste $");
Elf32_Phdr *
elf32_getphdr(Elf *e)

View File

@ -24,8 +24,6 @@
* SUCH DAMAGE.
*/
#include <sys/cdefs.h>
#include <assert.h>
#include <gelf.h>
#include <limits.h>
@ -33,7 +31,7 @@
#include "_libelf.h"
ELFTC_VCSID("$Id: gelf_rel.c 2998 2014-03-18 17:19:00Z jkoshy $");
ELFTC_VCSID("$Id: gelf_rel.c 3177 2015-03-30 18:19:41Z emaste $");
GElf_Rel *
gelf_getrel(Elf_Data *ed, int ndx, GElf_Rel *dst)

View File

@ -24,8 +24,6 @@
* SUCH DAMAGE.
*/
#include <sys/cdefs.h>
#include <assert.h>
#include <gelf.h>
#include <limits.h>
@ -33,7 +31,7 @@
#include "_libelf.h"
ELFTC_VCSID("$Id: gelf_rela.c 2998 2014-03-18 17:19:00Z jkoshy $");
ELFTC_VCSID("$Id: gelf_rela.c 3177 2015-03-30 18:19:41Z emaste $");
GElf_Rela *
gelf_getrela(Elf_Data *ed, int ndx, GElf_Rela *dst)

View File

@ -24,8 +24,6 @@
* SUCH DAMAGE.
*/
#include <sys/cdefs.h>
#include <assert.h>
#include <gelf.h>
#include <libelf.h>
@ -34,7 +32,7 @@
#include "_libelf.h"
ELFTC_VCSID("$Id: gelf_shdr.c 2268 2011-12-03 17:05:11Z jkoshy $");
ELFTC_VCSID("$Id: gelf_shdr.c 3177 2015-03-30 18:19:41Z emaste $");
Elf32_Shdr *
elf32_getshdr(Elf_Scn *s)

View File

@ -24,8 +24,6 @@
* SUCH DAMAGE.
*/
#include <sys/cdefs.h>
#include <assert.h>
#include <gelf.h>
#include <limits.h>
@ -33,7 +31,7 @@
#include "_libelf.h"
ELFTC_VCSID("$Id: gelf_sym.c 2999 2014-03-18 17:19:06Z jkoshy $");
ELFTC_VCSID("$Id: gelf_sym.c 3177 2015-03-30 18:19:41Z emaste $");
GElf_Sym *
gelf_getsym(Elf_Data *ed, int ndx, GElf_Sym *dst)

View File

@ -24,14 +24,12 @@
* SUCH DAMAGE.
*/
#include <sys/cdefs.h>
#include <assert.h>
#include <gelf.h>
#include "_libelf.h"
ELFTC_VCSID("$Id: gelf_syminfo.c 2998 2014-03-18 17:19:00Z jkoshy $");
ELFTC_VCSID("$Id: gelf_syminfo.c 3174 2015-03-27 17:13:41Z emaste $");
GElf_Syminfo *
gelf_getsyminfo(Elf_Data *ed, int ndx, GElf_Syminfo *dst)

View File

@ -24,14 +24,12 @@
* SUCH DAMAGE.
*/
#include <sys/cdefs.h>
#include <assert.h>
#include <gelf.h>
#include "_libelf.h"
ELFTC_VCSID("$Id: gelf_symshndx.c 2998 2014-03-18 17:19:00Z jkoshy $");
ELFTC_VCSID("$Id: gelf_symshndx.c 3174 2015-03-27 17:13:41Z emaste $");
GElf_Sym *
gelf_getsymshndx(Elf_Data *d, Elf_Data *id, int ndx, GElf_Sym *dst,

View File

@ -24,15 +24,13 @@
* SUCH DAMAGE.
*/
#include <sys/cdefs.h>
#include <gelf.h>
#include <libelf.h>
#include <string.h>
#include "_libelf.h"
ELFTC_VCSID("$Id: gelf_xlate.c 2225 2011-11-26 18:55:54Z jkoshy $");
ELFTC_VCSID("$Id: gelf_xlate.c 3174 2015-03-27 17:13:41Z emaste $");
Elf_Data *
elf32_xlatetof(Elf_Data *dst, const Elf_Data *src, unsigned int encoding)

View File

@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: libelf.h 2988 2014-03-17 08:51:49Z jkoshy $
* $Id: libelf.h 3174 2015-03-27 17:13:41Z emaste $
*/
#ifndef _LIBELF_H_
@ -176,7 +176,9 @@ enum Elf_Error {
#define ELF_F_ARCHIVE 0x100U /* archive creation */
#define ELF_F_ARCHIVE_SYSV 0x200U /* SYSV style archive */
__BEGIN_DECLS
#ifdef __cplusplus
extern "C" {
#endif
Elf *elf_begin(int _fd, Elf_Cmd _cmd, Elf *_elf);
int elf_cntl(Elf *_elf, Elf_Cmd _cmd);
int elf_end(Elf *_elf);
@ -247,6 +249,8 @@ Elf_Data *elf64_xlatetof(Elf_Data *_dst, const Elf_Data *_src,
unsigned int _enc);
Elf_Data *elf64_xlatetom(Elf_Data *_dst, const Elf_Data *_src,
unsigned int _enc);
__END_DECLS
#ifdef __cplusplus
}
#endif
#endif /* _LIBELF_H_ */

View File

@ -24,15 +24,13 @@
* SUCH DAMAGE.
*/
#include <sys/cdefs.h>
#include <sys/types.h>
#include <libelf.h>
#include "_libelf.h"
ELFTC_VCSID("$Id: libelf_align.c 3006 2014-03-22 08:10:07Z jkoshy $");
ELFTC_VCSID("$Id: libelf_align.c 3174 2015-03-27 17:13:41Z emaste $");
struct align {
unsigned int a32;

View File

@ -28,8 +28,6 @@
* Internal APIs
*/
#include <sys/cdefs.h>
#include <assert.h>
#include <errno.h>
#include <libelf.h>
@ -38,7 +36,7 @@
#include "_libelf.h"
ELFTC_VCSID("$Id: libelf_allocate.c 2272 2011-12-03 17:07:31Z jkoshy $");
ELFTC_VCSID("$Id: libelf_allocate.c 3174 2015-03-27 17:13:41Z emaste $");
Elf *
_libelf_allocate_elf(void)

View File

@ -24,8 +24,6 @@
* SUCH DAMAGE.
*/
#include <sys/cdefs.h>
#include <assert.h>
#include <ctype.h>
#include <libelf.h>
@ -35,7 +33,7 @@
#include "_libelf.h"
#include "_libelf_ar.h"
ELFTC_VCSID("$Id: libelf_ar.c 3013 2014-03-23 06:16:59Z jkoshy $");
ELFTC_VCSID("$Id: libelf_ar.c 3174 2015-03-27 17:13:41Z emaste $");
#define LIBELF_NALLOC_SIZE 16

View File

@ -24,8 +24,6 @@
* SUCH DAMAGE.
*/
#include <sys/cdefs.h>
#include <assert.h>
#include <libelf.h>
#include <stdlib.h>
@ -34,7 +32,7 @@
#include "_libelf.h"
#include "_libelf_ar.h"
ELFTC_VCSID("$Id: libelf_ar_util.c 3157 2015-02-15 21:42:02Z emaste $");
ELFTC_VCSID("$Id: libelf_ar_util.c 3174 2015-03-27 17:13:41Z emaste $");
/*
* Convert a string bounded by `start' and `start+sz' (exclusive) to a

View File

@ -24,13 +24,11 @@
* SUCH DAMAGE.
*/
#include <sys/cdefs.h>
#include <gelf.h>
#include "_libelf.h"
ELFTC_VCSID("$Id: libelf_checksum.c 3003 2014-03-22 07:43:10Z jkoshy $");
ELFTC_VCSID("$Id: libelf_checksum.c 3174 2015-03-27 17:13:41Z emaste $");
static unsigned long
_libelf_sum(unsigned long c, const unsigned char *s, size_t size)

View File

@ -24,15 +24,13 @@
* SUCH DAMAGE.
*/
#include <sys/cdefs.h>
#include <assert.h>
#include <libelf.h>
#include <string.h>
#include "_libelf.h"
ELFTC_VCSID("$Id: libelf_convert.m4 3158 2015-02-15 21:42:07Z emaste $");
ELFTC_VCSID("$Id: libelf_convert.m4 3174 2015-03-27 17:13:41Z emaste $");
/* WARNING: GENERATED FROM __file__. */

View File

@ -24,13 +24,11 @@
* SUCH DAMAGE.
*/
#include <sys/cdefs.h>
#include <libelf.h>
#include "_libelf.h"
ELFTC_VCSID("$Id: libelf_data.c 3080 2014-07-28 08:46:17Z jkoshy $");
ELFTC_VCSID("$Id: libelf_data.c 3174 2015-03-27 17:13:41Z emaste $");
int
_libelf_xlate_shtype(uint32_t sht)

View File

@ -24,8 +24,6 @@
* SUCH DAMAGE.
*/
#include <sys/cdefs.h>
#include <assert.h>
#include <gelf.h>
#include <libelf.h>
@ -33,7 +31,7 @@
#include "_libelf.h"
ELFTC_VCSID("$Id: libelf_ehdr.c 3009 2014-03-23 01:49:59Z jkoshy $");
ELFTC_VCSID("$Id: libelf_ehdr.c 3174 2015-03-27 17:13:41Z emaste $");
/*
* Retrieve counts for sections, phdrs and the section string table index

View File

@ -24,14 +24,12 @@
* SUCH DAMAGE.
*/
#include <sys/cdefs.h>
#include <assert.h>
#include <libelf.h>
#include "_libelf.h"
ELFTC_VCSID("$Id: libelf_extended.c 3005 2014-03-22 07:43:25Z jkoshy $");
ELFTC_VCSID("$Id: libelf_extended.c 3174 2015-03-27 17:13:41Z emaste $");
/*
* Retrieve section #0, allocating a new section if needed.

View File

@ -24,15 +24,13 @@
* SUCH DAMAGE.
*/
#include <sys/cdefs.h>
#include <assert.h>
#include <libelf.h>
#include <string.h>
#include "_libelf.h"
ELFTC_VCSID("$Id: libelf_msize.m4 2225 2011-11-26 18:55:54Z jkoshy $");
ELFTC_VCSID("$Id: libelf_msize.m4 3174 2015-03-27 17:13:41Z emaste $");
/* WARNING: GENERATED FROM __file__. */

View File

@ -24,8 +24,6 @@
* SUCH DAMAGE.
*/
#include <sys/cdefs.h>
#include <assert.h>
#include <gelf.h>
#include <libelf.h>
@ -33,7 +31,7 @@
#include "_libelf.h"
ELFTC_VCSID("$Id: libelf_phdr.c 3009 2014-03-23 01:49:59Z jkoshy $");
ELFTC_VCSID("$Id: libelf_phdr.c 3174 2015-03-27 17:13:41Z emaste $");
void *
_libelf_getphdr(Elf *e, int ec)

View File

@ -24,14 +24,12 @@
* SUCH DAMAGE.
*/
#include <sys/cdefs.h>
#include <gelf.h>
#include <libelf.h>
#include "_libelf.h"
ELFTC_VCSID("$Id: libelf_shdr.c 2225 2011-11-26 18:55:54Z jkoshy $");
ELFTC_VCSID("$Id: libelf_shdr.c 3174 2015-03-27 17:13:41Z emaste $");
void *
_libelf_getshdr(Elf_Scn *s, int ec)

View File

@ -24,14 +24,12 @@
* SUCH DAMAGE.
*/
#include <sys/cdefs.h>
#include <assert.h>
#include <libelf.h>
#include "_libelf.h"
ELFTC_VCSID("$Id: libelf_xlate.c 3007 2014-03-22 08:10:14Z jkoshy $");
ELFTC_VCSID("$Id: libelf_xlate.c 3174 2015-03-27 17:13:41Z emaste $");
/*
* Translate to/from the file representation of ELF objects.

View File

@ -24,7 +24,7 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* $Id: _libelftc.h 2856 2013-01-04 16:00:26Z jkoshy $
* $Id: _libelftc.h 3174 2015-03-27 17:13:41Z emaste $
*/
#ifndef __LIBELFTC_H_
@ -64,7 +64,9 @@ struct vector_str {
#define VECTOR_DEF_CAPACITY 8
__BEGIN_DECLS
#ifdef __cplusplus
extern "C" {
#endif
char *cpp_demangle_ARM(const char *_org);
char *cpp_demangle_gnu2(const char *_org);
char *cpp_demangle_gnu3(const char *_org);
@ -84,6 +86,8 @@ bool vector_str_push_vector_head(struct vector_str *_dst,
struct vector_str *_org);
char *vector_str_substr(const struct vector_str *_vs, size_t _begin,
size_t _end, size_t *_rlen);
__END_DECLS
#ifdef __cplusplus
}
#endif
#endif /* __LIBELFTC_H */

View File

@ -24,15 +24,13 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/cdefs.h>
#include <sys/param.h>
#include <string.h>
#include <libelftc.h>
#include "_libelftc.h"
ELFTC_VCSID("$Id: elftc_bfdtarget.c 2251 2011-11-30 16:50:06Z jkoshy $");
ELFTC_VCSID("$Id: elftc_bfdtarget.c 3174 2015-03-27 17:13:41Z emaste $");
Elftc_Bfd_Target *
elftc_bfd_find_target(const char *tgt_name)

View File

@ -24,8 +24,6 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/cdefs.h>
#include <sys/param.h>
#include <assert.h>
#include <errno.h>
@ -35,7 +33,7 @@
#include "_libelftc.h"
ELFTC_VCSID("$Id: elftc_demangle.c 3030 2014-05-01 06:30:48Z kaiwang27 $");
ELFTC_VCSID("$Id: elftc_demangle.c 3174 2015-03-27 17:13:41Z emaste $");
static int
is_mangled(const char *s, int style)

View File

@ -24,7 +24,7 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* $FreeBSD: users/kaiwang27/elftc/libelftc.h 392 2009-05-31 19:17:46Z kaiwang27 $
* $Id: libelftc.h 3031 2014-05-01 17:45:41Z jkoshy $
* $Id: libelftc.h 3174 2015-03-27 17:13:41Z emaste $
*/
#ifndef _LIBELFTC_H_
@ -62,7 +62,9 @@ typedef enum {
/* Demangling behaviour control. */
#define ELFTC_DEM_NOPARAM 0x00010000U
__BEGIN_DECLS
#ifdef __cplusplus
extern "C" {
#endif
Elftc_Bfd_Target *elftc_bfd_find_target(const char *_tgt_name);
Elftc_Bfd_Target_Flavor elftc_bfd_target_flavor(Elftc_Bfd_Target *_tgt);
unsigned int elftc_bfd_target_byteorder(Elftc_Bfd_Target *_tgt);
@ -87,6 +89,8 @@ int elftc_string_table_remove(Elftc_String_Table *_table,
const char *elftc_string_table_to_string(Elftc_String_Table *_table,
size_t offset);
const char *elftc_version(void);
__END_DECLS
#ifdef __cplusplus
}
#endif
#endif /* _LIBELFTC_H_ */

View File

@ -24,15 +24,13 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/cdefs.h>
#include <sys/param.h>
#include <libelf.h>
#include <libelftc.h>
#include "_libelftc.h"
ELFTC_VCSID("$Id: libelftc_bfdtarget.c 2251 2011-11-30 16:50:06Z jkoshy $");
ELFTC_VCSID("$Id: libelftc_bfdtarget.c 3174 2015-03-27 17:13:41Z emaste $");
struct _Elftc_Bfd_Target _libelftc_targets[] = {

View File

@ -48,7 +48,7 @@
#include "_elftc.h"
ELFTC_VCSID("$Id: nm.c 3145 2015-02-15 18:04:37Z emaste $");
ELFTC_VCSID("$Id: nm.c 3179 2015-03-31 19:38:56Z emaste $");
/* symbol information list */
STAILQ_HEAD(sym_head, sym_entry);
@ -379,7 +379,7 @@ cmp_value(const void *lp, const void *rp)
/* Both defined */
if (l->sym->st_value == r->sym->st_value)
return (strcmp(l->name, r->name));
return (l->sym->st_value - r->sym->st_value);
return (l->sym->st_value > r->sym->st_value ? 1 : -1);
case 1:
/* One undefined */
return (l_is_undef == 0 ? 1 : -1);
@ -948,6 +948,36 @@ get_block_value(Dwarf_Debug dbg, Dwarf_Block *block)
return (0);
}
static char *
find_object_name(Dwarf_Debug dbg, Dwarf_Die die)
{
Dwarf_Die ret_die;
Dwarf_Attribute at;
Dwarf_Off off;
Dwarf_Error de;
const char *str;
char *name;
if (dwarf_attrval_string(die, DW_AT_name, &str, &de) == DW_DLV_OK) {
if ((name = strdup(str)) == NULL) {
warn("strdup");
return (NULL);
}
return (name);
}
if (dwarf_attr(die, DW_AT_specification, &at, &de) != DW_DLV_OK)
return (NULL);
if (dwarf_global_formref(at, &off, &de) != DW_DLV_OK)
return (NULL);
if (dwarf_offdie(dbg, off, &ret_die, &de) != DW_DLV_OK)
return (NULL);
return (find_object_name(dbg, ret_die));
}
static void
search_line_attr(Dwarf_Debug dbg, struct func_info_head *func_info,
struct var_info_head *var_info, Dwarf_Die die, char **src_files,
@ -962,7 +992,6 @@ search_line_attr(Dwarf_Debug dbg, struct func_info_head *func_info,
Dwarf_Error de;
struct func_info_entry *func;
struct var_info_entry *var;
const char *str;
int ret;
if (dwarf_tag(die, &tag, &de) != DW_DLV_OK) {
@ -1012,16 +1041,12 @@ search_line_attr(Dwarf_Debug dbg, struct func_info_head *func_info,
DW_DLV_OK)
var->line = udata;
if (dwarf_attrval_string(die, DW_AT_name, &str, &de) ==
DW_DLV_OK) {
var->name = strdup(str);
if (var->name == NULL) {
warn("strdup");
if (var->file)
free(var->file);
free(var);
goto cont_search;
}
var->name = find_object_name(dbg, die);
if (var->name == NULL) {
if (var->file)
free(var->file);
free(var);
goto cont_search;
}
if (dwarf_attr(die, DW_AT_location, &at, &de) == DW_DLV_OK &&
@ -1064,16 +1089,12 @@ search_line_attr(Dwarf_Debug dbg, struct func_info_head *func_info,
DW_DLV_OK)
func->line = udata;
if (dwarf_attrval_string(die, DW_AT_name, &str, &de) ==
DW_DLV_OK) {
func->name = strdup(str);
if (func->name == NULL) {
warn("strdup");
if (func->file)
free(func->file);
free(func);
goto cont_search;
}
func->name = find_object_name(dbg, die);
if (func->name == NULL) {
if (func->file)
free(func->file);
free(func);
goto cont_search;
}
if (dwarf_attrval_unsigned(die, DW_AT_low_pc, &udata, &de) ==

View File

@ -24,7 +24,6 @@
* SUCH DAMAGE.
*/
#include <sys/cdefs.h>
#include <sys/param.h>
#include <sys/queue.h>
#include <ar.h>
@ -47,7 +46,7 @@
#include "_elftc.h"
ELFTC_VCSID("$Id: readelf.c 3155 2015-02-15 19:15:57Z emaste $");
ELFTC_VCSID("$Id: readelf.c 3178 2015-03-30 18:29:13Z emaste $");
/*
* readelf(1) options.
@ -1143,7 +1142,11 @@ r_type(unsigned int mach, unsigned int type)
case 1025: return "R_AARCH64_GLOB_DAT";
case 1026: return "R_AARCH64_JUMP_SLOT";
case 1027: return "R_AARCH64_RELATIVE";
case 1028: return "R_AARCH64_TLS_DTPREL64";
case 1029: return "R_AARCH64_TLS_DTPMOD64";
case 1030: return "R_AARCH64_TLS_TPREL64";
case 1031: return "R_AARCH64_TLSDESC";
case 1032: return "R_AARCH64_IRELATIVE";
default: return "";
}
case EM_ARM:

View File

@ -24,7 +24,6 @@
* SUCH DAMAGE.
*/
#include <sys/cdefs.h>
#include <assert.h>
#include <err.h>
#include <fcntl.h>
@ -39,7 +38,7 @@
#include "_elftc.h"
ELFTC_VCSID("$Id: size.c 2350 2011-12-19 10:20:06Z jkoshy $");
ELFTC_VCSID("$Id: size.c 3174 2015-03-27 17:13:41Z emaste $");
#define BUF_SIZE 1024
#define ELF_ALIGN(val,x) (((val)+(x)-1) & ~((x)-1))

View File

@ -24,7 +24,6 @@
* SUCH DAMAGE.
*/
#include <sys/cdefs.h>
#include <sys/stat.h>
#include <sys/types.h>
@ -46,7 +45,7 @@
#include "_elftc.h"
ELFTC_VCSID("$Id: strings.c 3124 2014-12-21 05:46:28Z kaiwang27 $");
ELFTC_VCSID("$Id: strings.c 3174 2015-03-27 17:13:41Z emaste $");
enum return_code {
RETURN_OK,