From 84d41a2986852c0d7d820f95b41c1db1cc818027 Mon Sep 17 00:00:00 2001 From: Ed Maste Date: Tue, 31 Mar 2015 20:01:37 +0000 Subject: [PATCH] Import ELF toolchain rev 3179 From http://svn.code.sf.net/p/elftoolchain/code --- INSTALL | 8 ++- addr2line/addr2line.c | 3 +- ar/acplex.l | 4 +- ar/acpyacc.y | 2 - ar/ar.c | 4 +- ar/read.c | 13 +++- ar/util.c | 3 +- ar/write.c | 3 +- brandelf/brandelf.c | 4 +- common/_elftc.h | 32 ++++++--- common/elfdefinitions.h | 4 +- common/native-elf-format | 4 +- cxxfilt/cxxfilt.c | 3 +- elfcopy/archive.c | 4 +- elfcopy/ascii.c | 4 +- elfcopy/binary.c | 3 +- elfcopy/elfcopy.1 | 14 +++- elfcopy/elfcopy.h | 5 +- elfcopy/main.c | 21 +++++- elfcopy/sections.c | 19 +++++- elfcopy/segments.c | 4 +- elfcopy/symbols.c | 23 +++++-- elfdump/elfdump.c | 3 +- findtextrel/findtextrel.c | 3 +- ld/ld.h | 3 +- libdwarf/_libdwarf.h | 3 +- libdwarf/libdwarf.h | 10 ++- libdwarf/libdwarf_lineno.c | 4 +- libelf/_libelf.h | 10 ++- libelf/_libelf_config.h | 4 +- libelf/elf_data.c | 3 +- libelf/elf_end.c | 4 +- libelf/elf_errmsg.c | 4 +- libelf/elf_errno.c | 4 +- libelf/elf_fill.c | 4 +- libelf/elf_flag.c | 4 +- libelf/elf_getarhdr.c | 4 +- libelf/elf_getarsym.c | 4 +- libelf/elf_getbase.c | 4 +- libelf/elf_getident.c | 4 +- libelf/elf_hash.c | 4 +- libelf/elf_kind.c | 4 +- libelf/elf_next.c | 4 +- libelf/elf_phnum.c | 4 +- libelf/elf_rand.c | 4 +- libelf/elf_rawfile.c | 4 +- libelf/elf_scn.c | 4 +- libelf/elf_shnum.c | 4 +- libelf/elf_shstrndx.c | 4 +- libelf/elf_version.c | 4 +- libelf/gelf.h | 12 ++-- libelf/gelf_cap.c | 5 +- libelf/gelf_checksum.c | 4 +- libelf/gelf_dyn.c | 5 +- libelf/gelf_ehdr.c | 5 +- libelf/gelf_fsize.c | 4 +- libelf/gelf_getclass.c | 4 +- libelf/gelf_move.c | 5 +- libelf/gelf_phdr.c | 5 +- libelf/gelf_rel.c | 5 +- libelf/gelf_rela.c | 5 +- libelf/gelf_shdr.c | 5 +- libelf/gelf_sym.c | 5 +- libelf/gelf_syminfo.c | 4 +- libelf/gelf_symshndx.c | 4 +- libelf/gelf_xlate.c | 4 +- libelf/libelf.h | 10 ++- libelf/libelf_align.c | 4 +- libelf/libelf_allocate.c | 4 +- libelf/libelf_ar.c | 4 +- libelf/libelf_ar_util.c | 4 +- libelf/libelf_checksum.c | 4 +- libelf/libelf_convert.m4 | 4 +- libelf/libelf_data.c | 4 +- libelf/libelf_ehdr.c | 4 +- libelf/libelf_extended.c | 4 +- libelf/libelf_msize.m4 | 4 +- libelf/libelf_phdr.c | 4 +- libelf/libelf_shdr.c | 4 +- libelf/libelf_xlate.c | 4 +- libelftc/_libelftc.h | 10 ++- libelftc/elftc_bfdtarget.c | 4 +- libelftc/elftc_demangle.c | 4 +- libelftc/libelftc.h | 10 ++- libelftc/libelftc_bfdtarget.c | 4 +- nm/nm.c | 70 +++++++++++++------- readelf/readelf.c | 10 ++- size/size.c | 3 +- strings/strings.c | 3 +- test/libelf/tset/common/ehdr_template.m4 | 4 +- test/libelf/tset/common/gelf_ehdr_template.h | 4 +- test/libelf/tset/common/phdr_template.c | 4 +- test/libelf/tset/common/xlate_template.c | 3 +- test/libelf/tset/elf32_getehdr/ehdr.m4 | 4 +- test/libelf/tset/elf32_getphdr/phdr.m4 | 4 +- test/libelf/tset/elf32_newehdr/ehdr.m4 | 4 +- test/libelf/tset/elf64_getehdr/ehdr.m4 | 4 +- test/libelf/tset/elf64_getphdr/phdr.m4 | 4 +- test/libelf/tset/elf64_newehdr/ehdr.m4 | 4 +- test/libelf/tset/gelf_getehdr/ehdr.m4 | 4 +- test/libelf/tset/gelf_newehdr/ehdr.m4 | 4 +- test/libelf/tset/gelf_xlate/xlate.m4 | 4 +- 102 files changed, 308 insertions(+), 307 deletions(-) diff --git a/INSTALL b/INSTALL index 4171ce816f7..ddab88de472 100644 --- a/INSTALL +++ b/INSTALL @@ -171,13 +171,14 @@ Prerequisites ``pmake`` A ``make`` that uses BSD-make syntax. ``python-yaml`` A YAML library for Python. ``sharutils`` For ``uudecode``. + ``zlib1g-dev`` Compression library. =================== ===================================== The following command line may be used to install the necessary pre-requisites:: % sudo apt-get install binutils bison flex gcc libarchive-dev \ - libc6-dev m4 pmake + libc6-dev m4 pmake zlib1g-dev - To build and run the test suite: @@ -211,13 +212,14 @@ Prerequisites ``pmake`` A ``make`` that uses BSD-make syntax. ``python-yaml`` A YAML library for Python. ``sharutils`` For ``uudecode``. + ``zlib1g-dev`` Compression library. =================== ===================================== The following command line may be used to install the necessary pre-requisites:: % sudo apt-get install bison build-essential flex libarchive-dev \ - m4 pmake + m4 pmake zlib1g-dev - To build and run the test suite: @@ -297,7 +299,7 @@ website`_. .. _project website: http://elftoolchain.sourceforge.net/ -.. $Id: INSTALL 3020 2014-04-17 15:52:31Z jkoshy $ +.. $Id: INSTALL 3165 2015-02-20 20:52:18Z emaste $ .. Local Variables: .. mode: rst diff --git a/addr2line/addr2line.c b/addr2line/addr2line.c index 6dcf19ceca4..d6f5d73e8d7 100644 --- a/addr2line/addr2line.c +++ b/addr2line/addr2line.c @@ -24,7 +24,6 @@ * SUCH DAMAGE. */ -#include #include #include #include @@ -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'}, diff --git a/ar/acplex.l b/ar/acplex.l index cde256f9649..6b50fb3b19d 100644 --- a/ar/acplex.l +++ b/ar/acplex.l @@ -25,8 +25,6 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include - #include #include #include @@ -34,7 +32,7 @@ #include "_elftc.h" -ELFTC_VCSID("$Id: acplex.l 3162 2015-02-15 21:43:41Z emaste $"); +ELFTC_VCSID("$Id: acplex.l 3174 2015-03-27 17:13:41Z emaste $"); #include "acpyacc.h" diff --git a/ar/acpyacc.y b/ar/acpyacc.y index e1d02ec8251..84f08e2393a 100644 --- a/ar/acpyacc.y +++ b/ar/acpyacc.y @@ -25,8 +25,6 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include - #include #include #include diff --git a/ar/ar.c b/ar/ar.c index 9cdddb2ca40..05327a2b186 100644 --- a/ar/ar.c +++ b/ar/ar.c @@ -58,8 +58,6 @@ * SUCH DAMAGE. */ -#include - #include #include #include @@ -74,7 +72,7 @@ #include "ar.h" -ELFTC_VCSID("$Id: ar.c 2485 2012-04-07 15:54:59Z kaiwang27 $"); +ELFTC_VCSID("$Id: ar.c 3174 2015-03-27 17:13:41Z emaste $"); enum options { diff --git a/ar/read.c b/ar/read.c index f047a430cae..84bb032231a 100644 --- a/ar/read.c +++ b/ar/read.c @@ -25,7 +25,6 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include #include #include @@ -39,7 +38,7 @@ #include "ar.h" -ELFTC_VCSID("$Id: read.c 3163 2015-02-15 21:43:51Z emaste $"); +ELFTC_VCSID("$Id: read.c 3174 2015-03-27 17:13:41Z emaste $"); /* * Handle read modes: 'x', 't' and 'p'. @@ -175,7 +174,15 @@ ar_read_archive(struct bsdar *bsdar, int mode) if (bsdar->options & AR_V) (void)fprintf(out, "x - %s\n", name); - flags = 0; + /* Disallow absolute paths. */ + if (name[0] == '/') { + bsdar_warnc(bsdar, 0, + "Absolute path '%s'", name); + continue; + } + /* Basic path security flags. */ + flags = ARCHIVE_EXTRACT_SECURE_SYMLINKS | \ + ARCHIVE_EXTRACT_SECURE_NODOTDOT; if (bsdar->options & AR_O) flags |= ARCHIVE_EXTRACT_TIME; diff --git a/ar/util.c b/ar/util.c index 8ed877a6026..f22542e67db 100644 --- a/ar/util.c +++ b/ar/util.c @@ -24,7 +24,6 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include #include #include #include @@ -38,7 +37,7 @@ #include "ar.h" -ELFTC_VCSID("$Id: util.c 2130 2011-11-10 06:56:46Z jkoshy $"); +ELFTC_VCSID("$Id: util.c 3174 2015-03-27 17:13:41Z emaste $"); static void bsdar_vwarnc(struct bsdar *, int code, const char *fmt, va_list ap); diff --git a/ar/write.c b/ar/write.c index 490b22fab07..0b962d22cd8 100644 --- a/ar/write.c +++ b/ar/write.c @@ -24,7 +24,6 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include #include #include @@ -41,7 +40,7 @@ #include "ar.h" -ELFTC_VCSID("$Id: write.c 3102 2014-10-29 21:09:01Z jkoshy $"); +ELFTC_VCSID("$Id: write.c 3174 2015-03-27 17:13:41Z emaste $"); #define _ARMAG_LEN 8 /* length of the magic string */ #define _ARHDR_LEN 60 /* length of the archive header */ diff --git a/brandelf/brandelf.c b/brandelf/brandelf.c index 286b6ab1235..5f5e6317b7b 100644 --- a/brandelf/brandelf.c +++ b/brandelf/brandelf.c @@ -28,8 +28,6 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include - #include #include #include @@ -46,7 +44,7 @@ #include "_elftc.h" -ELFTC_VCSID("$Id: brandelf.c 3101 2014-10-27 22:24:40Z jkoshy $"); +ELFTC_VCSID("$Id: brandelf.c 3174 2015-03-27 17:13:41Z emaste $"); static int elftype(const char *); static const char *iselftype(int); diff --git a/common/_elftc.h b/common/_elftc.h index d6c87840274..45f0abd8077 100644 --- a/common/_elftc.h +++ b/common/_elftc.h @@ -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 @@ -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 +#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 @@ -381,7 +397,7 @@ extern const char *__progname; #endif -#if defined(__GLIBC__) +#if defined(__GLIBC__) || defined(__linux__) #include @@ -401,7 +417,7 @@ extern const char *__progname; #define roundup2 roundup -#endif /* __GLIBC__ */ +#endif /* __GLIBC__ || __linux__ */ #if defined(__FreeBSD__) diff --git a/common/elfdefinitions.h b/common/elfdefinitions.h index f0a2fc2dade..a53acde8b6c 100644 --- a/common/elfdefinitions.h +++ b/common/elfdefinitions.h @@ -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, \ diff --git a/common/native-elf-format b/common/native-elf-format index af707591d19..34d84bf2896 100755 --- a/common/native-elf-format +++ b/common/native-elf-format @@ -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; } diff --git a/cxxfilt/cxxfilt.c b/cxxfilt/cxxfilt.c index d30cfaeffdd..4efa45b33f2 100644 --- a/cxxfilt/cxxfilt.c +++ b/cxxfilt/cxxfilt.c @@ -24,7 +24,6 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include #include #include #include @@ -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 diff --git a/elfcopy/archive.c b/elfcopy/archive.c index 4735f02296e..682a1df66dc 100644 --- a/elfcopy/archive.c +++ b/elfcopy/archive.c @@ -24,8 +24,6 @@ * SUCH DAMAGE. */ -#include - #include #include #include @@ -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 */ diff --git a/elfcopy/ascii.c b/elfcopy/ascii.c index 968e5c667f6..cad4eb8a91e 100644 --- a/elfcopy/ascii.c +++ b/elfcopy/ascii.c @@ -24,11 +24,11 @@ * SUCH DAMAGE. */ -#include #include #include #include #include +#include #include #include #include @@ -36,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); diff --git a/elfcopy/binary.c b/elfcopy/binary.c index 65b49fbe874..23e46e77f39 100644 --- a/elfcopy/binary.c +++ b/elfcopy/binary.c @@ -24,7 +24,6 @@ * SUCH DAMAGE. */ -#include #include #include #include @@ -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 diff --git a/elfcopy/elfcopy.1 b/elfcopy/elfcopy.1 index 2976da377d2..ce8f120196a 100644 --- a/elfcopy/elfcopy.1 +++ b/elfcopy/elfcopy.1 @@ -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 diff --git a/elfcopy/elfcopy.h b/elfcopy/elfcopy.h index 7b3a9b1af9b..b750246d850 100644 --- a/elfcopy/elfcopy.h +++ b/elfcopy/elfcopy.h @@ -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 @@ -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. */ diff --git a/elfcopy/main.c b/elfcopy/main.c index e5bea86fb6f..a48aea58974 100644 --- a/elfcopy/main.c +++ b/elfcopy/main.c @@ -24,7 +24,6 @@ * SUCH DAMAGE. */ -#include #include #include @@ -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\ diff --git a/elfcopy/sections.c b/elfcopy/sections.c index ee6d17278ee..077bb74b0f5 100644 --- a/elfcopy/sections.c +++ b/elfcopy/sections.c @@ -24,7 +24,6 @@ * SUCH DAMAGE. */ -#include #include #include #include @@ -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) { diff --git a/elfcopy/segments.c b/elfcopy/segments.c index 1cdf4664ebe..3ed6d93bbcd 100644 --- a/elfcopy/segments.c +++ b/elfcopy/segments.c @@ -24,17 +24,17 @@ * SUCH DAMAGE. */ -#include #include #include #include +#include #include #include #include #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); diff --git a/elfcopy/symbols.c b/elfcopy/symbols.c index 7fb6ccba7dd..49bb2398865 100644 --- a/elfcopy/symbols.c +++ b/elfcopy/symbols.c @@ -24,7 +24,6 @@ * SUCH DAMAGE. */ -#include #include #include #include @@ -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); } diff --git a/elfdump/elfdump.c b/elfdump/elfdump.c index f7fc4264423..93420fed936 100644 --- a/elfdump/elfdump.c +++ b/elfdump/elfdump.c @@ -26,7 +26,6 @@ * SUCH DAMAGE. */ -#include #include #include #include @@ -51,7 +50,7 @@ #include "_elftc.h" -ELFTC_VCSID("$Id: elfdump.c 3146 2015-02-15 18:20:03Z emaste $"); +ELFTC_VCSID("$Id: elfdump.c 3174 2015-03-27 17:13:41Z emaste $"); #if defined(ELFTC_NEED_ELF_NOTE_DEFINITION) #include "native-elf-format.h" diff --git a/findtextrel/findtextrel.c b/findtextrel/findtextrel.c index a744ca5b0b1..91baa54618c 100644 --- a/findtextrel/findtextrel.c +++ b/findtextrel/findtextrel.c @@ -24,7 +24,6 @@ * SUCH DAMAGE. */ -#include #include #include #include @@ -39,7 +38,7 @@ #include "_elftc.h" -ELFTC_VCSID("$Id: findtextrel.c 2185 2011-11-19 16:07:16Z jkoshy $"); +ELFTC_VCSID("$Id: findtextrel.c 3174 2015-03-27 17:13:41Z emaste $"); static struct option longopts[] = { {"help", no_argument, NULL, 'H'}, diff --git a/ld/ld.h b/ld/ld.h index 624abfcb39e..1de1853b55e 100644 --- a/ld/ld.h +++ b/ld/ld.h @@ -23,10 +23,9 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: ld.h 2940 2013-05-04 22:22:10Z kaiwang27 $ + * $Id: ld.h 3174 2015-03-27 17:13:41Z emaste $ */ -#include #include #include #include diff --git a/libdwarf/_libdwarf.h b/libdwarf/_libdwarf.h index 06413beeb58..e6eb496feed 100644 --- a/libdwarf/_libdwarf.h +++ b/libdwarf/_libdwarf.h @@ -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. */ diff --git a/libdwarf/libdwarf.h b/libdwarf/libdwarf.h index fdbcb4e05b6..0cb8b1ae8cb 100644 --- a/libdwarf/libdwarf.h +++ b/libdwarf/libdwarf.h @@ -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_ */ diff --git a/libdwarf/libdwarf_lineno.c b/libdwarf/libdwarf_lineno.c index 63627f736f7..d0ff5f8e80d 100644 --- a/libdwarf/libdwarf_lineno.c +++ b/libdwarf/libdwarf_lineno.c @@ -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); diff --git a/libelf/_libelf.h b/libelf/_libelf.h index d5803a4e44f..be45335907f 100644 --- a/libelf/_libelf.h +++ b/libelf/_libelf.h @@ -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_ */ diff --git a/libelf/_libelf_config.h b/libelf/_libelf_config.h index 45d8714b2ae..1b8f35b2242 100644 --- a/libelf/_libelf_config.h +++ b/libelf/_libelf_config.h @@ -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 diff --git a/libelf/elf_data.c b/libelf/elf_data.c index 9960b77bea2..ce80e1c94c4 100644 --- a/libelf/elf_data.c +++ b/libelf/elf_data.c @@ -27,11 +27,12 @@ #include #include #include +#include #include #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) diff --git a/libelf/elf_end.c b/libelf/elf_end.c index 097664c1257..3f32ebbee8e 100644 --- a/libelf/elf_end.c +++ b/libelf/elf_end.c @@ -24,8 +24,6 @@ * SUCH DAMAGE. */ -#include - #include #include #include @@ -36,7 +34,7 @@ #include #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) diff --git a/libelf/elf_errmsg.c b/libelf/elf_errmsg.c index 409862cc155..9e5b2e92ee1 100644 --- a/libelf/elf_errmsg.c +++ b/libelf/elf_errmsg.c @@ -24,15 +24,13 @@ * SUCH DAMAGE. */ -#include - #include #include #include #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. diff --git a/libelf/elf_errno.c b/libelf/elf_errno.c index c78d4c7a7ce..10ae69acbe5 100644 --- a/libelf/elf_errno.c +++ b/libelf/elf_errno.c @@ -24,13 +24,11 @@ * SUCH DAMAGE. */ -#include - #include #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) diff --git a/libelf/elf_fill.c b/libelf/elf_fill.c index 4c9facc7827..427d78d5ad6 100644 --- a/libelf/elf_fill.c +++ b/libelf/elf_fill.c @@ -24,13 +24,11 @@ * SUCH DAMAGE. */ -#include - #include #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) diff --git a/libelf/elf_flag.c b/libelf/elf_flag.c index 89af3160da6..73503214a9f 100644 --- a/libelf/elf_flag.c +++ b/libelf/elf_flag.c @@ -24,13 +24,11 @@ * SUCH DAMAGE. */ -#include - #include #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) diff --git a/libelf/elf_getarhdr.c b/libelf/elf_getarhdr.c index 07f6888147b..75e2e86226e 100644 --- a/libelf/elf_getarhdr.c +++ b/libelf/elf_getarhdr.c @@ -24,13 +24,11 @@ * SUCH DAMAGE. */ -#include - #include #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) diff --git a/libelf/elf_getarsym.c b/libelf/elf_getarsym.c index eeb8513aa4e..3679b81e155 100644 --- a/libelf/elf_getarsym.c +++ b/libelf/elf_getarsym.c @@ -24,13 +24,11 @@ * SUCH DAMAGE. */ -#include - #include #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) diff --git a/libelf/elf_getbase.c b/libelf/elf_getbase.c index 417808df360..b038c3ddd26 100644 --- a/libelf/elf_getbase.c +++ b/libelf/elf_getbase.c @@ -24,13 +24,11 @@ * SUCH DAMAGE. */ -#include - #include #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) diff --git a/libelf/elf_getident.c b/libelf/elf_getident.c index aeea996b9fa..a69139c932c 100644 --- a/libelf/elf_getident.c +++ b/libelf/elf_getident.c @@ -24,15 +24,13 @@ * SUCH DAMAGE. */ -#include - #include #include #include #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) diff --git a/libelf/elf_hash.c b/libelf/elf_hash.c index 373523714bc..ef7e44d1afd 100644 --- a/libelf/elf_hash.c +++ b/libelf/elf_hash.c @@ -24,13 +24,11 @@ * SUCH DAMAGE. */ -#include - #include #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. diff --git a/libelf/elf_kind.c b/libelf/elf_kind.c index ba83adce845..f497bd315a8 100644 --- a/libelf/elf_kind.c +++ b/libelf/elf_kind.c @@ -24,13 +24,11 @@ * SUCH DAMAGE. */ -#include - #include #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) diff --git a/libelf/elf_next.c b/libelf/elf_next.c index 7da8ba6fe85..4c33714f291 100644 --- a/libelf/elf_next.c +++ b/libelf/elf_next.c @@ -24,15 +24,13 @@ * SUCH DAMAGE. */ -#include - #include #include #include #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) diff --git a/libelf/elf_phnum.c b/libelf/elf_phnum.c index 59948061b40..4ac665df308 100644 --- a/libelf/elf_phnum.c +++ b/libelf/elf_phnum.c @@ -24,14 +24,12 @@ * SUCH DAMAGE. */ -#include - #include #include #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) diff --git a/libelf/elf_rand.c b/libelf/elf_rand.c index 8c36ff80970..eb2c9eaa2c1 100644 --- a/libelf/elf_rand.c +++ b/libelf/elf_rand.c @@ -24,14 +24,12 @@ * SUCH DAMAGE. */ -#include - #include #include #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) diff --git a/libelf/elf_rawfile.c b/libelf/elf_rawfile.c index a5b5b3ed5f7..f63982fb0b4 100644 --- a/libelf/elf_rawfile.c +++ b/libelf/elf_rawfile.c @@ -24,13 +24,11 @@ * SUCH DAMAGE. */ -#include - #include #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) diff --git a/libelf/elf_scn.c b/libelf/elf_scn.c index f07f6ae9ea1..d3e274715b7 100644 --- a/libelf/elf_scn.c +++ b/libelf/elf_scn.c @@ -24,7 +24,6 @@ * SUCH DAMAGE. */ -#include #include #include @@ -32,11 +31,12 @@ #include #include #include +#include #include #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. diff --git a/libelf/elf_shnum.c b/libelf/elf_shnum.c index a06a9e41131..5c0560fb556 100644 --- a/libelf/elf_shnum.c +++ b/libelf/elf_shnum.c @@ -24,14 +24,12 @@ * SUCH DAMAGE. */ -#include - #include #include #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) diff --git a/libelf/elf_shstrndx.c b/libelf/elf_shstrndx.c index 0a7bab96b1f..dac40c99a0d 100644 --- a/libelf/elf_shstrndx.c +++ b/libelf/elf_shstrndx.c @@ -24,14 +24,12 @@ * SUCH DAMAGE. */ -#include - #include #include #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) diff --git a/libelf/elf_version.c b/libelf/elf_version.c index 3aa466ad3c4..cd25954b44e 100644 --- a/libelf/elf_version.c +++ b/libelf/elf_version.c @@ -24,13 +24,11 @@ * SUCH DAMAGE. */ -#include - #include #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) diff --git a/libelf/gelf.h b/libelf/gelf.h index 0a7dc249402..6eae0a5f27f 100644 --- a/libelf/gelf.h +++ b/libelf/gelf.h @@ -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 - #include 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_ */ diff --git a/libelf/gelf_cap.c b/libelf/gelf_cap.c index 9925d1bd214..f509c69c2ba 100644 --- a/libelf/gelf_cap.c +++ b/libelf/gelf_cap.c @@ -24,15 +24,14 @@ * SUCH DAMAGE. */ -#include - #include #include #include +#include #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) diff --git a/libelf/gelf_checksum.c b/libelf/gelf_checksum.c index af707daeba1..b16272f3961 100644 --- a/libelf/gelf_checksum.c +++ b/libelf/gelf_checksum.c @@ -24,14 +24,12 @@ * SUCH DAMAGE. */ -#include - #include #include #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) diff --git a/libelf/gelf_dyn.c b/libelf/gelf_dyn.c index 4e09afd12ce..74233094bf6 100644 --- a/libelf/gelf_dyn.c +++ b/libelf/gelf_dyn.c @@ -24,15 +24,14 @@ * SUCH DAMAGE. */ -#include - #include #include #include +#include #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) diff --git a/libelf/gelf_ehdr.c b/libelf/gelf_ehdr.c index 1efd8178c56..dcd260e14ba 100644 --- a/libelf/gelf_ehdr.c +++ b/libelf/gelf_ehdr.c @@ -24,17 +24,16 @@ * SUCH DAMAGE. */ -#include - #include #include #include #include +#include #include #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) diff --git a/libelf/gelf_fsize.c b/libelf/gelf_fsize.c index 7eeac69bf8f..afdea7381fc 100644 --- a/libelf/gelf_fsize.c +++ b/libelf/gelf_fsize.c @@ -24,14 +24,12 @@ * SUCH DAMAGE. */ -#include - #include #include #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) diff --git a/libelf/gelf_getclass.c b/libelf/gelf_getclass.c index 214e60282ce..d7f68038207 100644 --- a/libelf/gelf_getclass.c +++ b/libelf/gelf_getclass.c @@ -24,13 +24,11 @@ * SUCH DAMAGE. */ -#include - #include #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) diff --git a/libelf/gelf_move.c b/libelf/gelf_move.c index 2b734eba53b..2ec8f251f8f 100644 --- a/libelf/gelf_move.c +++ b/libelf/gelf_move.c @@ -24,15 +24,14 @@ * SUCH DAMAGE. */ -#include - #include #include #include +#include #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) diff --git a/libelf/gelf_phdr.c b/libelf/gelf_phdr.c index ade82dbdf87..31e20b0680c 100644 --- a/libelf/gelf_phdr.c +++ b/libelf/gelf_phdr.c @@ -24,15 +24,14 @@ * SUCH DAMAGE. */ -#include - #include #include #include +#include #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) diff --git a/libelf/gelf_rel.c b/libelf/gelf_rel.c index 3b798c04220..02a613383df 100644 --- a/libelf/gelf_rel.c +++ b/libelf/gelf_rel.c @@ -24,15 +24,14 @@ * SUCH DAMAGE. */ -#include - #include #include #include +#include #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) diff --git a/libelf/gelf_rela.c b/libelf/gelf_rela.c index ed289a674d1..d485ab90929 100644 --- a/libelf/gelf_rela.c +++ b/libelf/gelf_rela.c @@ -24,15 +24,14 @@ * SUCH DAMAGE. */ -#include - #include #include #include +#include #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) diff --git a/libelf/gelf_shdr.c b/libelf/gelf_shdr.c index d4024895c60..1a9d949e42e 100644 --- a/libelf/gelf_shdr.c +++ b/libelf/gelf_shdr.c @@ -24,16 +24,15 @@ * SUCH DAMAGE. */ -#include - #include #include #include #include +#include #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) diff --git a/libelf/gelf_sym.c b/libelf/gelf_sym.c index e32a1869cea..ecd85fceefb 100644 --- a/libelf/gelf_sym.c +++ b/libelf/gelf_sym.c @@ -24,15 +24,14 @@ * SUCH DAMAGE. */ -#include - #include #include #include +#include #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) diff --git a/libelf/gelf_syminfo.c b/libelf/gelf_syminfo.c index e54258292aa..f6d7b6c367f 100644 --- a/libelf/gelf_syminfo.c +++ b/libelf/gelf_syminfo.c @@ -24,14 +24,12 @@ * SUCH DAMAGE. */ -#include - #include #include #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) diff --git a/libelf/gelf_symshndx.c b/libelf/gelf_symshndx.c index 69fabe55ce0..b490aa2bb11 100644 --- a/libelf/gelf_symshndx.c +++ b/libelf/gelf_symshndx.c @@ -24,14 +24,12 @@ * SUCH DAMAGE. */ -#include - #include #include #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, diff --git a/libelf/gelf_xlate.c b/libelf/gelf_xlate.c index 15f30eebc26..f50181925f2 100644 --- a/libelf/gelf_xlate.c +++ b/libelf/gelf_xlate.c @@ -24,15 +24,13 @@ * SUCH DAMAGE. */ -#include - #include #include #include #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) diff --git a/libelf/libelf.h b/libelf/libelf.h index 41e7224956f..47c11b90158 100644 --- a/libelf/libelf.h +++ b/libelf/libelf.h @@ -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_ */ diff --git a/libelf/libelf_align.c b/libelf/libelf_align.c index 817fd158856..5afb98bb414 100644 --- a/libelf/libelf_align.c +++ b/libelf/libelf_align.c @@ -24,15 +24,13 @@ * SUCH DAMAGE. */ -#include - #include #include #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; diff --git a/libelf/libelf_allocate.c b/libelf/libelf_allocate.c index 9a5df6bb495..0a74facc9fc 100644 --- a/libelf/libelf_allocate.c +++ b/libelf/libelf_allocate.c @@ -28,8 +28,6 @@ * Internal APIs */ -#include - #include #include #include @@ -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) diff --git a/libelf/libelf_ar.c b/libelf/libelf_ar.c index 0830dd6fc06..faeec2c6076 100644 --- a/libelf/libelf_ar.c +++ b/libelf/libelf_ar.c @@ -24,8 +24,6 @@ * SUCH DAMAGE. */ -#include - #include #include #include @@ -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 diff --git a/libelf/libelf_ar_util.c b/libelf/libelf_ar_util.c index 7b824fb579a..239612e7915 100644 --- a/libelf/libelf_ar_util.c +++ b/libelf/libelf_ar_util.c @@ -24,8 +24,6 @@ * SUCH DAMAGE. */ -#include - #include #include #include @@ -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 diff --git a/libelf/libelf_checksum.c b/libelf/libelf_checksum.c index f05f9a93640..ef868773105 100644 --- a/libelf/libelf_checksum.c +++ b/libelf/libelf_checksum.c @@ -24,13 +24,11 @@ * SUCH DAMAGE. */ -#include - #include #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) diff --git a/libelf/libelf_convert.m4 b/libelf/libelf_convert.m4 index f400367c361..9f99f1ead86 100644 --- a/libelf/libelf_convert.m4 +++ b/libelf/libelf_convert.m4 @@ -24,15 +24,13 @@ * SUCH DAMAGE. */ -#include - #include #include #include #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__. */ diff --git a/libelf/libelf_data.c b/libelf/libelf_data.c index f078c36ab75..fcffd8bd9d1 100644 --- a/libelf/libelf_data.c +++ b/libelf/libelf_data.c @@ -24,13 +24,11 @@ * SUCH DAMAGE. */ -#include - #include #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) diff --git a/libelf/libelf_ehdr.c b/libelf/libelf_ehdr.c index d59f61f2ba1..d375fb30028 100644 --- a/libelf/libelf_ehdr.c +++ b/libelf/libelf_ehdr.c @@ -24,8 +24,6 @@ * SUCH DAMAGE. */ -#include - #include #include #include @@ -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 diff --git a/libelf/libelf_extended.c b/libelf/libelf_extended.c index f1a77d17efb..96765a8293e 100644 --- a/libelf/libelf_extended.c +++ b/libelf/libelf_extended.c @@ -24,14 +24,12 @@ * SUCH DAMAGE. */ -#include - #include #include #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. diff --git a/libelf/libelf_msize.m4 b/libelf/libelf_msize.m4 index 411019bd912..179880c4327 100644 --- a/libelf/libelf_msize.m4 +++ b/libelf/libelf_msize.m4 @@ -24,15 +24,13 @@ * SUCH DAMAGE. */ -#include - #include #include #include #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__. */ diff --git a/libelf/libelf_phdr.c b/libelf/libelf_phdr.c index f44c3cd7e44..ba872bbb974 100644 --- a/libelf/libelf_phdr.c +++ b/libelf/libelf_phdr.c @@ -24,8 +24,6 @@ * SUCH DAMAGE. */ -#include - #include #include #include @@ -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) diff --git a/libelf/libelf_shdr.c b/libelf/libelf_shdr.c index fc48423a99d..862264b5043 100644 --- a/libelf/libelf_shdr.c +++ b/libelf/libelf_shdr.c @@ -24,14 +24,12 @@ * SUCH DAMAGE. */ -#include - #include #include #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) diff --git a/libelf/libelf_xlate.c b/libelf/libelf_xlate.c index 4cc6a452e4d..6ee76244b83 100644 --- a/libelf/libelf_xlate.c +++ b/libelf/libelf_xlate.c @@ -24,14 +24,12 @@ * SUCH DAMAGE. */ -#include - #include #include #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. diff --git a/libelftc/_libelftc.h b/libelftc/_libelftc.h index c300f9105ae..ba0b10112a5 100644 --- a/libelftc/_libelftc.h +++ b/libelftc/_libelftc.h @@ -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 */ diff --git a/libelftc/elftc_bfdtarget.c b/libelftc/elftc_bfdtarget.c index 351e5e467e6..a5ae1a67189 100644 --- a/libelftc/elftc_bfdtarget.c +++ b/libelftc/elftc_bfdtarget.c @@ -24,15 +24,13 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include - #include #include #include #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) diff --git a/libelftc/elftc_demangle.c b/libelftc/elftc_demangle.c index 9639d630c6e..ff309550428 100644 --- a/libelftc/elftc_demangle.c +++ b/libelftc/elftc_demangle.c @@ -24,8 +24,6 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include - #include #include #include @@ -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) diff --git a/libelftc/libelftc.h b/libelftc/libelftc.h index 85e4feb3a71..062db318c4d 100644 --- a/libelftc/libelftc.h +++ b/libelftc/libelftc.h @@ -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_ */ diff --git a/libelftc/libelftc_bfdtarget.c b/libelftc/libelftc_bfdtarget.c index 31c89b74f14..00ba2254fc1 100644 --- a/libelftc/libelftc_bfdtarget.c +++ b/libelftc/libelftc_bfdtarget.c @@ -24,15 +24,13 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include - #include #include #include #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[] = { diff --git a/nm/nm.c b/nm/nm.c index f9849660f65..87a456ee97c 100644 --- a/nm/nm.c +++ b/nm/nm.c @@ -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) == @@ -1525,7 +1546,8 @@ print_lineno(struct sym_entry *ep, struct func_info_head *func_info, /* For function symbol, search the function line information list. */ if ((ep->sym->st_info & 0xf) == STT_FUNC && func_info != NULL) { SLIST_FOREACH(func, func_info, entries) { - if (!strcmp(ep->name, func->name) && + if (func->name != NULL && + !strcmp(ep->name, func->name) && ep->sym->st_value >= func->lowpc && ep->sym->st_value < func->highpc) { printf("\t%s:%" PRIu64, func->file, func->line); diff --git a/readelf/readelf.c b/readelf/readelf.c index 775172646ff..bca228cec13 100644 --- a/readelf/readelf.c +++ b/readelf/readelf.c @@ -24,7 +24,6 @@ * SUCH DAMAGE. */ -#include #include #include #include @@ -38,6 +37,7 @@ #include #include #include +#include #include #include #include @@ -46,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. @@ -910,7 +910,7 @@ dt_type(unsigned int mach, unsigned int dtype) case DT_PLTPADSZ: return "PLTPADSZ"; case DT_MOVEENT: return "MOVEENT"; case DT_MOVESZ: return "MOVESZ"; - case DT_FEATURE_1: return "FEATURE_1"; + case DT_FEATURE: return "FEATURE"; case DT_POSFLAG_1: return "POSFLAG_1"; case DT_SYMINSZ: return "SYMINSZ"; case DT_SYMINENT: return "SYMINENT"; @@ -1142,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: diff --git a/size/size.c b/size/size.c index c5c5b64cb0d..8380f750ded 100644 --- a/size/size.c +++ b/size/size.c @@ -24,7 +24,6 @@ * SUCH DAMAGE. */ -#include #include #include #include @@ -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)) diff --git a/strings/strings.c b/strings/strings.c index 5964f64f19d..6eab165e0bf 100644 --- a/strings/strings.c +++ b/strings/strings.c @@ -24,7 +24,6 @@ * SUCH DAMAGE. */ -#include #include #include @@ -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, diff --git a/test/libelf/tset/common/ehdr_template.m4 b/test/libelf/tset/common/ehdr_template.m4 index 4f60fffa1a3..872e0ff3b7c 100644 --- a/test/libelf/tset/common/ehdr_template.m4 +++ b/test/libelf/tset/common/ehdr_template.m4 @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: ehdr_template.m4 2077 2011-10-27 03:59:40Z jkoshy $ + * $Id: ehdr_template.m4 3174 2015-03-27 17:13:41Z emaste $ */ include(`elfts.m4') @@ -42,8 +42,6 @@ ifdef(`TS_EHDRFUNC',`',`errprint(`TS_EHDRFUNC was not defined')m4exit(1)') ifdef(`TS_EHDRSZ',`',`errprint(`TS_EHDRSZ was not defined')m4exit(1)') define(`TS_OTHERSIZE',`ifelse(TS_EHDRSZ,32,64,32)') -#include - define(`TS_ICFUNC',`elf'TS_EHDRSZ`'TS_EHDRFUNC) define(`TS_EHDR',`Elf'TS_EHDRSZ`_Ehdr') define(`TS_ICNAME',TS_ICFUNC) diff --git a/test/libelf/tset/common/gelf_ehdr_template.h b/test/libelf/tset/common/gelf_ehdr_template.h index 741409e28d0..30c7c675a33 100644 --- a/test/libelf/tset/common/gelf_ehdr_template.h +++ b/test/libelf/tset/common/gelf_ehdr_template.h @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: gelf_ehdr_template.h 223 2008-08-10 15:40:06Z jkoshy $ + * $Id: gelf_ehdr_template.h 3174 2015-03-27 17:13:41Z emaste $ */ #include @@ -50,8 +50,6 @@ * #include "gelf_getehdr_template.c" */ -#include - IC_REQUIRES_VERSION_INIT(); /* diff --git a/test/libelf/tset/common/phdr_template.c b/test/libelf/tset/common/phdr_template.c index 808743d9639..3bca4ceca27 100644 --- a/test/libelf/tset/common/phdr_template.c +++ b/test/libelf/tset/common/phdr_template.c @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: phdr_template.c 1074 2010-08-09 11:43:34Z jkoshy $ + * $Id: phdr_template.c 3174 2015-03-27 17:13:41Z emaste $ */ /* @@ -36,8 +36,6 @@ * #include "phdr_template.c" */ -#include - /* Variations of __CONCAT and __STRING which expand their arguments. */ #define __XCONCAT(x,y) __CONCAT(x,y) #ifndef __XSTRING diff --git a/test/libelf/tset/common/xlate_template.c b/test/libelf/tset/common/xlate_template.c index 84bdb4c1b97..b361ab3f7cc 100644 --- a/test/libelf/tset/common/xlate_template.c +++ b/test/libelf/tset/common/xlate_template.c @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: xlate_template.c 2586 2012-09-15 14:32:47Z jkoshy $ + * $Id: xlate_template.c 3174 2015-03-27 17:13:41Z emaste $ */ /* @@ -36,7 +36,6 @@ */ #include -#include #define __XCONCAT(x,y) __CONCAT(x,y) #ifndef __XSTRING diff --git a/test/libelf/tset/elf32_getehdr/ehdr.m4 b/test/libelf/tset/elf32_getehdr/ehdr.m4 index 54f058380bc..bd69b1bf7c2 100644 --- a/test/libelf/tset/elf32_getehdr/ehdr.m4 +++ b/test/libelf/tset/elf32_getehdr/ehdr.m4 @@ -23,11 +23,9 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: ehdr.m4 2054 2011-10-26 12:12:06Z jkoshy $ + * $Id: ehdr.m4 3174 2015-03-27 17:13:41Z emaste $ */ -#include - #include #include #include diff --git a/test/libelf/tset/elf32_getphdr/phdr.m4 b/test/libelf/tset/elf32_getphdr/phdr.m4 index eb27e0ecbb5..ea00caadc33 100644 --- a/test/libelf/tset/elf32_getphdr/phdr.m4 +++ b/test/libelf/tset/elf32_getphdr/phdr.m4 @@ -23,11 +23,9 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: phdr.m4 2054 2011-10-26 12:12:06Z jkoshy $ + * $Id: phdr.m4 3174 2015-03-27 17:13:41Z emaste $ */ -#include - #include #include #include diff --git a/test/libelf/tset/elf32_newehdr/ehdr.m4 b/test/libelf/tset/elf32_newehdr/ehdr.m4 index fb3fbdd5ed8..04577441caf 100644 --- a/test/libelf/tset/elf32_newehdr/ehdr.m4 +++ b/test/libelf/tset/elf32_newehdr/ehdr.m4 @@ -23,11 +23,9 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: ehdr.m4 2054 2011-10-26 12:12:06Z jkoshy $ + * $Id: ehdr.m4 3174 2015-03-27 17:13:41Z emaste $ */ -#include - #include #include #include diff --git a/test/libelf/tset/elf64_getehdr/ehdr.m4 b/test/libelf/tset/elf64_getehdr/ehdr.m4 index 3cda7e22200..ce7774c7c21 100644 --- a/test/libelf/tset/elf64_getehdr/ehdr.m4 +++ b/test/libelf/tset/elf64_getehdr/ehdr.m4 @@ -23,11 +23,9 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: ehdr.m4 2054 2011-10-26 12:12:06Z jkoshy $ + * $Id: ehdr.m4 3174 2015-03-27 17:13:41Z emaste $ */ -#include - #include #include #include diff --git a/test/libelf/tset/elf64_getphdr/phdr.m4 b/test/libelf/tset/elf64_getphdr/phdr.m4 index fbb6154d258..97af5fa1dd7 100644 --- a/test/libelf/tset/elf64_getphdr/phdr.m4 +++ b/test/libelf/tset/elf64_getphdr/phdr.m4 @@ -23,11 +23,9 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: phdr.m4 2054 2011-10-26 12:12:06Z jkoshy $ + * $Id: phdr.m4 3174 2015-03-27 17:13:41Z emaste $ */ -#include - #include #include #include diff --git a/test/libelf/tset/elf64_newehdr/ehdr.m4 b/test/libelf/tset/elf64_newehdr/ehdr.m4 index a1ee794f1fc..36c5d8e38fb 100644 --- a/test/libelf/tset/elf64_newehdr/ehdr.m4 +++ b/test/libelf/tset/elf64_newehdr/ehdr.m4 @@ -23,11 +23,9 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: ehdr.m4 2054 2011-10-26 12:12:06Z jkoshy $ + * $Id: ehdr.m4 3174 2015-03-27 17:13:41Z emaste $ */ -#include - #include #include #include diff --git a/test/libelf/tset/gelf_getehdr/ehdr.m4 b/test/libelf/tset/gelf_getehdr/ehdr.m4 index ba8f948c9e8..29f9960c239 100644 --- a/test/libelf/tset/gelf_getehdr/ehdr.m4 +++ b/test/libelf/tset/gelf_getehdr/ehdr.m4 @@ -23,13 +23,11 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: ehdr.m4 2054 2011-10-26 12:12:06Z jkoshy $ + * $Id: ehdr.m4 3174 2015-03-27 17:13:41Z emaste $ */ include(`elfts.m4') -#include - #include #include #include diff --git a/test/libelf/tset/gelf_newehdr/ehdr.m4 b/test/libelf/tset/gelf_newehdr/ehdr.m4 index 3cf55b66bc9..a22a65bef09 100644 --- a/test/libelf/tset/gelf_newehdr/ehdr.m4 +++ b/test/libelf/tset/gelf_newehdr/ehdr.m4 @@ -23,11 +23,9 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: ehdr.m4 2054 2011-10-26 12:12:06Z jkoshy $ + * $Id: ehdr.m4 3174 2015-03-27 17:13:41Z emaste $ */ -#include - #include #include #include diff --git a/test/libelf/tset/gelf_xlate/xlate.m4 b/test/libelf/tset/gelf_xlate/xlate.m4 index 1b9b447510a..906211c4445 100644 --- a/test/libelf/tset/gelf_xlate/xlate.m4 +++ b/test/libelf/tset/gelf_xlate/xlate.m4 @@ -23,11 +23,9 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: xlate.m4 2586 2012-09-15 14:32:47Z jkoshy $ + * $Id: xlate.m4 3174 2015-03-27 17:13:41Z emaste $ */ -#include - #include #include #include