Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 13 Feb 2016 16:02:12 +0000 (UTC)
From:      Dimitry Andric <dim@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-projects@freebsd.org
Subject:   svn commit: r295601 - in projects/clang380-import: . contrib/elftoolchain/addr2line contrib/elftoolchain/ar contrib/elftoolchain/brandelf contrib/elftoolchain/common contrib/elftoolchain/cxxfilt co...
Message-ID:  <201602131602.u1DG2ClQ071331@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: dim
Date: Sat Feb 13 16:02:12 2016
New Revision: 295601
URL: https://svnweb.freebsd.org/changeset/base/295601

Log:
  Merge ^/head r295544 through r295600.

Added:
  projects/clang380-import/contrib/elftoolchain/addr2line/os.NetBSD.mk
     - copied unchanged from r295600, head/contrib/elftoolchain/addr2line/os.NetBSD.mk
  projects/clang380-import/contrib/elftoolchain/elfcopy/pe.c
     - copied unchanged from r295600, head/contrib/elftoolchain/elfcopy/pe.c
  projects/clang380-import/contrib/elftoolchain/elfdump/os.NetBSD.mk
     - copied unchanged from r295600, head/contrib/elftoolchain/elfdump/os.NetBSD.mk
  projects/clang380-import/contrib/elftoolchain/libdwarf/os.NetBSD.mk
     - copied unchanged from r295600, head/contrib/elftoolchain/libdwarf/os.NetBSD.mk
  projects/clang380-import/contrib/elftoolchain/libelftc/os.NetBSD.mk
     - copied unchanged from r295600, head/contrib/elftoolchain/libelftc/os.NetBSD.mk
  projects/clang380-import/contrib/elftoolchain/libpe/
     - copied from r295600, head/contrib/elftoolchain/libpe/
  projects/clang380-import/contrib/elftoolchain/nm/os.NetBSD.mk
     - copied unchanged from r295600, head/contrib/elftoolchain/nm/os.NetBSD.mk
  projects/clang380-import/contrib/elftoolchain/readelf/os.NetBSD.mk
     - copied unchanged from r295600, head/contrib/elftoolchain/readelf/os.NetBSD.mk
  projects/clang380-import/contrib/elftoolchain/size/os.NetBSD.mk
     - copied unchanged from r295600, head/contrib/elftoolchain/size/os.NetBSD.mk
  projects/clang380-import/contrib/elftoolchain/strings/os.NetBSD.mk
     - copied unchanged from r295600, head/contrib/elftoolchain/strings/os.NetBSD.mk
  projects/clang380-import/lib/libpe/
     - copied from r295600, head/lib/libpe/
  projects/clang380-import/sys/sys/_ucontext.h
     - copied unchanged from r295600, head/sys/sys/_ucontext.h
Deleted:
  projects/clang380-import/contrib/elftoolchain/libelftc/elftc_symbol_table_create.3
Modified:
  projects/clang380-import/Makefile.inc1
  projects/clang380-import/contrib/elftoolchain/addr2line/addr2line.c
  projects/clang380-import/contrib/elftoolchain/ar/ar.c
  projects/clang380-import/contrib/elftoolchain/brandelf/brandelf.c
  projects/clang380-import/contrib/elftoolchain/common/elfdefinitions.h
  projects/clang380-import/contrib/elftoolchain/common/native-elf-format
  projects/clang380-import/contrib/elftoolchain/cxxfilt/cxxfilt.c
  projects/clang380-import/contrib/elftoolchain/elfcopy/Makefile
  projects/clang380-import/contrib/elftoolchain/elfcopy/archive.c
  projects/clang380-import/contrib/elftoolchain/elfcopy/elfcopy.1
  projects/clang380-import/contrib/elftoolchain/elfcopy/elfcopy.h
  projects/clang380-import/contrib/elftoolchain/elfcopy/main.c
  projects/clang380-import/contrib/elftoolchain/elfcopy/sections.c
  projects/clang380-import/contrib/elftoolchain/elfcopy/segments.c
  projects/clang380-import/contrib/elftoolchain/elfcopy/symbols.c
  projects/clang380-import/contrib/elftoolchain/elfdump/elfdump.c
  projects/clang380-import/contrib/elftoolchain/libdwarf/_libdwarf.h
  projects/clang380-import/contrib/elftoolchain/libdwarf/dwarf.3
  projects/clang380-import/contrib/elftoolchain/libdwarf/dwarf_str.c
  projects/clang380-import/contrib/elftoolchain/libdwarf/libdwarf.h
  projects/clang380-import/contrib/elftoolchain/libdwarf/libdwarf_rw.c
  projects/clang380-import/contrib/elftoolchain/libelf/_libelf_config.h
  projects/clang380-import/contrib/elftoolchain/libelftc/Makefile
  projects/clang380-import/contrib/elftoolchain/libelftc/elftc_bfd_find_target.3
  projects/clang380-import/contrib/elftoolchain/libelftc/elftc_copyfile.c
  projects/clang380-import/contrib/elftoolchain/libelftc/elftc_demangle.c
  projects/clang380-import/contrib/elftoolchain/libelftc/libelftc.h
  projects/clang380-import/contrib/elftoolchain/libelftc/libelftc_bfdtarget.c
  projects/clang380-import/contrib/elftoolchain/libelftc/libelftc_dem_gnu3.c
  projects/clang380-import/contrib/elftoolchain/libelftc/make-toolchain-version
  projects/clang380-import/contrib/elftoolchain/readelf/readelf.c
  projects/clang380-import/contrib/elftoolchain/strings/strings.1
  projects/clang380-import/contrib/elftoolchain/strings/strings.c
  projects/clang380-import/etc/rc.d/jail
  projects/clang380-import/include/signal.h
  projects/clang380-import/lib/Makefile
  projects/clang380-import/lib/libelftc/elftc_version.c
  projects/clang380-import/share/examples/jails/jib
  projects/clang380-import/share/examples/jails/jng
  projects/clang380-import/share/man/man4/ds3231.4
  projects/clang380-import/share/man/man5/rc.conf.5
  projects/clang380-import/share/mk/src.libnames.mk
  projects/clang380-import/sys/arm/mv/twsi.c
  projects/clang380-import/sys/arm64/arm64/swtch.S
  projects/clang380-import/sys/dev/cxgbe/common/t4_msg.h
  projects/clang380-import/sys/dev/cxgbe/t4_main.c
  projects/clang380-import/sys/dev/hwpmc/hwpmc_core.c
  projects/clang380-import/sys/dev/hwpmc/hwpmc_core.h
  projects/clang380-import/sys/dev/hwpmc/hwpmc_mod.c
  projects/clang380-import/sys/dev/ioat/ioat.c
  projects/clang380-import/sys/dev/uart/uart_dev_lpc.c
  projects/clang380-import/sys/dev/uart/uart_dev_ns8250.c
  projects/clang380-import/sys/fs/cd9660/cd9660_vfsops.c
  projects/clang380-import/sys/fs/tmpfs/tmpfs_vnops.c
  projects/clang380-import/sys/kern/kern_mbuf.c
  projects/clang380-import/sys/kern/uipc_mbuf.c
  projects/clang380-import/sys/mips/include/ucontext.h
  projects/clang380-import/sys/netinet/sctp_constants.h
  projects/clang380-import/sys/netinet6/nd6.c
  projects/clang380-import/sys/netinet6/nd6.h
  projects/clang380-import/sys/netinet6/nd6_nbr.c
  projects/clang380-import/sys/netinet6/nd6_rtr.c
  projects/clang380-import/sys/netinet6/scope6.c
  projects/clang380-import/sys/powerpc/include/ucontext.h
  projects/clang380-import/sys/riscv/include/ucontext.h
  projects/clang380-import/sys/sparc64/include/ucontext.h
  projects/clang380-import/sys/sys/mbuf.h
  projects/clang380-import/sys/sys/pmc.h
  projects/clang380-import/sys/sys/signal.h
  projects/clang380-import/sys/sys/ucontext.h
  projects/clang380-import/sys/x86/include/ucontext.h
  projects/clang380-import/usr.bin/elfcopy/Makefile
  projects/clang380-import/usr.sbin/ctld/login.c
Directory Properties:
  projects/clang380-import/   (props changed)
  projects/clang380-import/contrib/elftoolchain/   (props changed)
  projects/clang380-import/contrib/elftoolchain/ar/   (props changed)
  projects/clang380-import/contrib/elftoolchain/brandelf/   (props changed)
  projects/clang380-import/contrib/elftoolchain/elfdump/   (props changed)
  projects/clang380-import/include/   (props changed)
  projects/clang380-import/share/   (props changed)
  projects/clang380-import/share/man/man4/   (props changed)
  projects/clang380-import/sys/   (props changed)

Modified: projects/clang380-import/Makefile.inc1
==============================================================================
--- projects/clang380-import/Makefile.inc1	Sat Feb 13 15:58:51 2016	(r295600)
+++ projects/clang380-import/Makefile.inc1	Sat Feb 13 16:02:12 2016	(r295601)
@@ -1638,6 +1638,7 @@ _binutils=	gnu/usr.bin/binutils
 .endif
 .if ${MK_ELFTOOLCHAIN_BOOTSTRAP} != "no"
 _elftctools=	lib/libelftc \
+		lib/libpe \
 		usr.bin/elfcopy \
 		usr.bin/nm \
 		usr.bin/size \
@@ -1650,6 +1651,7 @@ _elftctools+=	usr.bin/addr2line
 # If cross-building with an external binutils we still need to build strip for
 # the target (for at least crunchide).
 _elftctools=	lib/libelftc \
+		lib/libpe \
 		usr.bin/elfcopy
 .endif
 

Modified: projects/clang380-import/contrib/elftoolchain/addr2line/addr2line.c
==============================================================================
--- projects/clang380-import/contrib/elftoolchain/addr2line/addr2line.c	Sat Feb 13 15:58:51 2016	(r295600)
+++ projects/clang380-import/contrib/elftoolchain/addr2line/addr2line.c	Sat Feb 13 16:02:12 2016	(r295601)
@@ -40,7 +40,7 @@
 #include "uthash.h"
 #include "_elftc.h"
 
-ELFTC_VCSID("$Id: addr2line.c 3264 2015-11-30 05:38:14Z kaiwang27 $");
+ELFTC_VCSID("$Id: addr2line.c 3273 2015-12-11 21:38:57Z kaiwang27 $");
 
 struct Func {
 	char *name;
@@ -368,7 +368,8 @@ print_inlines(struct CU *cu, struct Func
 				printf("%s\n", f->name);
 		}
 	}
-	(void) printf("%s:%ju\n", base ? basename(file) : file, call_line);
+	(void) printf("%s:%ju\n", base ? basename(file) : file,
+	    (uintmax_t) call_line);
 
 	if (f->inlined_caller != NULL)
 		print_inlines(cu, f->inlined_caller, f->call_file,
@@ -562,7 +563,8 @@ out:
 		}
 	}
 
-	(void) printf("%s:%ju\n", base ? basename(file) : file, lineno);
+	(void) printf("%s:%ju\n", base ? basename(file) : file,
+	    (uintmax_t) lineno);
 
 	if (ret == DW_DLV_OK && inlines && cu != NULL &&
 	    cu->srcfiles != NULL && f != NULL && f->inlined_caller != NULL)

Copied: projects/clang380-import/contrib/elftoolchain/addr2line/os.NetBSD.mk (from r295600, head/contrib/elftoolchain/addr2line/os.NetBSD.mk)
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ projects/clang380-import/contrib/elftoolchain/addr2line/os.NetBSD.mk	Sat Feb 13 16:02:12 2016	(r295601, copy of r295600, head/contrib/elftoolchain/addr2line/os.NetBSD.mk)
@@ -0,0 +1,2 @@
+# TODO(#511): Revert after the source tree is -Wconversion clean.
+WARNS=5

Modified: projects/clang380-import/contrib/elftoolchain/ar/ar.c
==============================================================================
--- projects/clang380-import/contrib/elftoolchain/ar/ar.c	Sat Feb 13 15:58:51 2016	(r295600)
+++ projects/clang380-import/contrib/elftoolchain/ar/ar.c	Sat Feb 13 16:02:12 2016	(r295601)
@@ -72,7 +72,7 @@
 
 #include "ar.h"
 
-ELFTC_VCSID("$Id: ar.c 3243 2015-08-31 19:28:45Z emaste $");
+ELFTC_VCSID("$Id: ar.c 3319 2016-01-13 21:37:53Z jkoshy $");
 
 enum options
 {
@@ -407,7 +407,7 @@ Usage: %s <command> [options] archive fi
   -F FORMAT | --flavor=FORMAT\n\
                 Create archives with the specified format.\n\
   -S            Do not generate an archive symbol table.\n\
-  -U            Use original metadata, for unique archive checksums.\n"
+  -U            Use original metadata for archive members.\n"
 
 static void
 bsdar_usage(void)

Modified: projects/clang380-import/contrib/elftoolchain/brandelf/brandelf.c
==============================================================================
--- projects/clang380-import/contrib/elftoolchain/brandelf/brandelf.c	Sat Feb 13 15:58:51 2016	(r295600)
+++ projects/clang380-import/contrib/elftoolchain/brandelf/brandelf.c	Sat Feb 13 16:02:12 2016	(r295601)
@@ -44,7 +44,7 @@
 
 #include "_elftc.h"
 
-ELFTC_VCSID("$Id: brandelf.c 3234 2015-07-31 12:35:09Z emaste $");
+ELFTC_VCSID("$Id: brandelf.c 3354 2016-01-18 21:50:15Z jkoshy $");
 
 static int elftype(const char *);
 static const char *iselftype(int);
@@ -212,7 +212,7 @@ main(int argc, char **argv)
 			/*
 			 * Update the ABI type.
 			 */
-			ehdr.e_ident[EI_OSABI] = type;
+			ehdr.e_ident[EI_OSABI] = (unsigned char) type;
 			if (gelf_update_ehdr(elf, &ehdr) == 0) {
 				warnx("gelf_update_ehdr error: %s",
 				    elf_errmsg(-1));

Modified: projects/clang380-import/contrib/elftoolchain/common/elfdefinitions.h
==============================================================================
--- projects/clang380-import/contrib/elftoolchain/common/elfdefinitions.h	Sat Feb 13 15:58:51 2016	(r295600)
+++ projects/clang380-import/contrib/elftoolchain/common/elfdefinitions.h	Sat Feb 13 16:02:12 2016	(r295601)
@@ -23,7 +23,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $Id: elfdefinitions.h 3253 2015-10-10 18:31:33Z kaiwang27 $
+ * $Id: elfdefinitions.h 3392 2016-02-05 19:51:22Z emaste $
  */
 
 /*
@@ -1228,6 +1228,7 @@ _ELF_DEFINE_STB(STB_GLOBAL,          1,	
 _ELF_DEFINE_STB(STB_WEAK,            2,					\
 	"visible across all object files but with low precedence")	\
 _ELF_DEFINE_STB(STB_LOOS,            10, "start of OS-specific range")	\
+_ELF_DEFINE_STB(STB_GNU_UNIQUE,      10, "unique symbol (GNU)")		\
 _ELF_DEFINE_STB(STB_HIOS,            12, "end of OS-specific range")	\
 _ELF_DEFINE_STB(STB_LOPROC,          13,				\
 	"start of processor-specific range")				\
@@ -1259,6 +1260,7 @@ _ELF_DEFINE_STT(STT_LOPROC,          13,
 	"start of processor-specific types")				\
 _ELF_DEFINE_STT(STT_ARM_TFUNC,       13, "Thumb function (GNU)")	\
 _ELF_DEFINE_STT(STT_ARM_16BIT,       15, "Thumb label (GNU)")		\
+_ELF_DEFINE_STT(STT_SPARC_REGISTER,  13, "SPARC register information")	\
 _ELF_DEFINE_STT(STT_HIPROC,          15,				\
 	"end of processor-specific types")
 
@@ -1395,7 +1397,7 @@ _ELF_DEFINE_RELOC(R_386_GOT32,		3)	\
 _ELF_DEFINE_RELOC(R_386_PLT32,		4)	\
 _ELF_DEFINE_RELOC(R_386_COPY,		5)	\
 _ELF_DEFINE_RELOC(R_386_GLOB_DAT,	6)	\
-_ELF_DEFINE_RELOC(R_386_JMP_SLOT,	7)	\
+_ELF_DEFINE_RELOC(R_386_JUMP_SLOT,	7)	\
 _ELF_DEFINE_RELOC(R_386_RELATIVE,	8)	\
 _ELF_DEFINE_RELOC(R_386_GOTOFF,		9)	\
 _ELF_DEFINE_RELOC(R_386_GOTPC,		10)	\
@@ -1407,9 +1409,129 @@ _ELF_DEFINE_RELOC(R_386_PC8,		23)
 
 /*
  */
-#define	_ELF_DEFINE_AARCH64_RELOCATIONS()		\
-_ELF_DEFINE_RELOC(R_AARCH64_ABS64,		257)	\
-_ELF_DEFINE_RELOC(R_AARCH64_ABS32,		258)	\
+#define	_ELF_DEFINE_AARCH64_RELOCATIONS()				\
+_ELF_DEFINE_RELOC(R_AARCH64_NONE,				0)	\
+_ELF_DEFINE_RELOC(R_AARCH64_ABS64,				257)	\
+_ELF_DEFINE_RELOC(R_AARCH64_ABS32,				258)	\
+_ELF_DEFINE_RELOC(R_AARCH64_ABS16,				259)	\
+_ELF_DEFINE_RELOC(R_AARCH64_PREL64,				260)	\
+_ELF_DEFINE_RELOC(R_AARCH64_PREL32,				261)	\
+_ELF_DEFINE_RELOC(R_AARCH64_PREL16,				262)	\
+_ELF_DEFINE_RELOC(R_AARCH64_MOVW_UABS_G0,			263)	\
+_ELF_DEFINE_RELOC(R_AARCH64_MOVW_UABS_G0_NC,			264)	\
+_ELF_DEFINE_RELOC(R_AARCH64_MOVW_UABS_G1,			265)	\
+_ELF_DEFINE_RELOC(R_AARCH64_MOVW_UABS_G1_NC,			266)	\
+_ELF_DEFINE_RELOC(R_AARCH64_MOVW_UABS_G2,			267)	\
+_ELF_DEFINE_RELOC(R_AARCH64_MOVW_UABS_G2_NC,			268)	\
+_ELF_DEFINE_RELOC(R_AARCH64_MOVW_UABS_G3,			269)	\
+_ELF_DEFINE_RELOC(R_AARCH64_MOVW_SABS_G0,			270)	\
+_ELF_DEFINE_RELOC(R_AARCH64_MOVW_SABS_G1,			271)	\
+_ELF_DEFINE_RELOC(R_AARCH64_MOVW_SABS_G2,			272)	\
+_ELF_DEFINE_RELOC(R_AARCH64_LD_PREL_LO19,			273)	\
+_ELF_DEFINE_RELOC(R_AARCH64_ADR_PREL_LO21,			274)	\
+_ELF_DEFINE_RELOC(R_AARCH64_ADR_PREL_PG_HI21,			275)	\
+_ELF_DEFINE_RELOC(R_AARCH64_ADR_PREL_PG_HI21_NC,		276)	\
+_ELF_DEFINE_RELOC(R_AARCH64_ADD_ABS_LO12_NC,			277)	\
+_ELF_DEFINE_RELOC(R_AARCH64_LDST8_ABS_LO12_NC,			278)	\
+_ELF_DEFINE_RELOC(R_AARCH64_TSTBR14,				279)	\
+_ELF_DEFINE_RELOC(R_AARCH64_CONDBR19,				280)	\
+_ELF_DEFINE_RELOC(R_AARCH64_JUMP26,				282)	\
+_ELF_DEFINE_RELOC(R_AARCH64_CALL26,				283)	\
+_ELF_DEFINE_RELOC(R_AARCH64_LDST16_ABS_LO12_NC,			284)	\
+_ELF_DEFINE_RELOC(R_AARCH64_LDST32_ABS_LO12_NC,			285)	\
+_ELF_DEFINE_RELOC(R_AARCH64_LDST64_ABS_LO12_NC,			286)	\
+_ELF_DEFINE_RELOC(R_AARCH64_MOVW_PREL_G0,			287)	\
+_ELF_DEFINE_RELOC(R_AARCH64_MOVW_PREL_G0_NC,			288)	\
+_ELF_DEFINE_RELOC(R_AARCH64_MOVW_PREL_G1,			289)	\
+_ELF_DEFINE_RELOC(R_AARCH64_MOVW_PREL_G1_NC,			290)	\
+_ELF_DEFINE_RELOC(R_AARCH64_MOVW_PREL_G2,			291)	\
+_ELF_DEFINE_RELOC(R_AARCH64_MOVW_PREL_G2_NC,			292)	\
+_ELF_DEFINE_RELOC(R_AARCH64_MOVW_PREL_G3,			293)	\
+_ELF_DEFINE_RELOC(R_AARCH64_LDST128_ABS_LO12_NC,		299)	\
+_ELF_DEFINE_RELOC(R_AARCH64_MOVW_GOTOFF_G0,			300)	\
+_ELF_DEFINE_RELOC(R_AARCH64_MOVW_GOTOFF_G0_NC,			301)	\
+_ELF_DEFINE_RELOC(R_AARCH64_MOVW_GOTOFF_G1,			302)	\
+_ELF_DEFINE_RELOC(R_AARCH64_MOVW_GOTOFF_G1_NC,			303)	\
+_ELF_DEFINE_RELOC(R_AARCH64_MOVW_GOTOFF_G2,			304)	\
+_ELF_DEFINE_RELOC(R_AARCH64_MOVW_GOTOFF_G2_NC,			305)	\
+_ELF_DEFINE_RELOC(R_AARCH64_MOVW_GOTOFF_G3,			306)	\
+_ELF_DEFINE_RELOC(R_AARCH64_GOTREL64,				307)	\
+_ELF_DEFINE_RELOC(R_AARCH64_GOTREL32,				308)	\
+_ELF_DEFINE_RELOC(R_AARCH64_GOT_LD_PREL19,			309)	\
+_ELF_DEFINE_RELOC(R_AARCH64_LD64_GOTOFF_LO15,			310)	\
+_ELF_DEFINE_RELOC(R_AARCH64_ADR_GOT_PAGE,			311)	\
+_ELF_DEFINE_RELOC(R_AARCH64_LD64_GOT_LO12_NC,			312)	\
+_ELF_DEFINE_RELOC(R_AARCH64_LD64_GOTPAGE_LO15,			313)	\
+_ELF_DEFINE_RELOC(R_AARCH64_TLSGD_ADR_PREL21,			512)	\
+_ELF_DEFINE_RELOC(R_AARCH64_TLSGD_ADR_PAGE21,			513)	\
+_ELF_DEFINE_RELOC(R_AARCH64_TLSGD_ADD_LO12_NC,			514)	\
+_ELF_DEFINE_RELOC(R_AARCH64_TLSGD_MOVW_G1,			515)	\
+_ELF_DEFINE_RELOC(R_AARCH64_TLSGD_MOVW_G0_NC,			516)	\
+_ELF_DEFINE_RELOC(R_AARCH64_TLSLD_ADR_PREL21,			517)	\
+_ELF_DEFINE_RELOC(R_AARCH64_TLSLD_ADR_PAGE21,			518)	\
+_ELF_DEFINE_RELOC(R_AARCH64_TLSLD_ADD_LO12_NC,			519)	\
+_ELF_DEFINE_RELOC(R_AARCH64_TLSLD_MOVW_G1,			520)	\
+_ELF_DEFINE_RELOC(R_AARCH64_TLSLD_MOVW_G0_NC,			521)	\
+_ELF_DEFINE_RELOC(R_AARCH64_TLSLD_LD_PREL19,			522)	\
+_ELF_DEFINE_RELOC(R_AARCH64_TLSLD_MOVW_DTPREL_G2,		523)	\
+_ELF_DEFINE_RELOC(R_AARCH64_TLSLD_MOVW_DTPREL_G1,		524)	\
+_ELF_DEFINE_RELOC(R_AARCH64_TLSLD_MOVW_DTPREL_G1_NC,		525)	\
+_ELF_DEFINE_RELOC(R_AARCH64_TLSLD_MOVW_DTPREL_G0,		526)	\
+_ELF_DEFINE_RELOC(R_AARCH64_TLSLD_MOVW_DTPREL_G0_NC,		527)	\
+_ELF_DEFINE_RELOC(R_AARCH64_TLSLD_ADD_DTPREL_HI12,		529)	\
+_ELF_DEFINE_RELOC(R_AARCH64_TLSLD_ADD_DTPREL_LO12_NC,		530)	\
+_ELF_DEFINE_RELOC(R_AARCH64_TLSLD_LDST8_DTPREL_LO12,		531)	\
+_ELF_DEFINE_RELOC(R_AARCH64_TLSLD_LDST8_DTPREL_LO12_NC,		532)	\
+_ELF_DEFINE_RELOC(R_AARCH64_TLSLD_LDST16_DTPREL_LO12,		533)	\
+_ELF_DEFINE_RELOC(R_AARCH64_TLSLD_LDST16_DTPREL_LO12_NC,	534)	\
+_ELF_DEFINE_RELOC(R_AARCH64_TLSLD_LDST32_DTPREL_LO12,		535)	\
+_ELF_DEFINE_RELOC(R_AARCH64_TLSLD_LDST32_DTPREL_LO12_NC,	536)	\
+_ELF_DEFINE_RELOC(R_AARCH64_TLSLD_LDST64_DTPREL_LO12,		537)	\
+_ELF_DEFINE_RELOC(R_AARCH64_TLSLD_LDST64_DTPREL_LO12_NC,	538)	\
+_ELF_DEFINE_RELOC(R_AARCH64_TLSIE_MOVW_GOTTPREL_G1,		539)	\
+_ELF_DEFINE_RELOC(R_AARCH64_TLSIE_MOVW_GOTTPREL_G0_NC,		540)	\
+_ELF_DEFINE_RELOC(R_AARCH64_TLSIE_ADR_GOTTPREL_PAGE21,		541)	\
+_ELF_DEFINE_RELOC(R_AARCH64_TLSIE_LD64_GOTTPREL_LO12_NC,	542)	\
+_ELF_DEFINE_RELOC(R_AARCH64_TLSIE_LD_GOTTPREL_PREL19,		543)	\
+_ELF_DEFINE_RELOC(R_AARCH64_TLSLE_MOVW_TPREL_G2,		544)	\
+_ELF_DEFINE_RELOC(R_AARCH64_TLSLE_MOVW_TPREL_G1,		545)	\
+_ELF_DEFINE_RELOC(R_AARCH64_TLSLE_MOVW_TPREL_G1_NC,		546)	\
+_ELF_DEFINE_RELOC(R_AARCH64_TLSLE_MOVW_TPREL_G0,		547)	\
+_ELF_DEFINE_RELOC(R_AARCH64_TLSLE_MOVW_TPREL_G0_NC,		548)	\
+_ELF_DEFINE_RELOC(R_AARCH64_TLSLE_ADD_TPREL_HI12,		549)	\
+_ELF_DEFINE_RELOC(R_AARCH64_TLSLE_ADD_TPREL_LO12,		550)	\
+_ELF_DEFINE_RELOC(R_AARCH64_TLSLE_ADD_TPREL_LO12_NC,		551)	\
+_ELF_DEFINE_RELOC(R_AARCH64_TLSLE_LDST8_TPREL_LO12,		552)	\
+_ELF_DEFINE_RELOC(R_AARCH64_TLSLE_LDST8_TPREL_LO12_NC,		553)	\
+_ELF_DEFINE_RELOC(R_AARCH64_TLSLE_LDST16_TPREL_LO12,		554)	\
+_ELF_DEFINE_RELOC(R_AARCH64_TLSLE_LDST16_TPREL_LO12_NC,		555)	\
+_ELF_DEFINE_RELOC(R_AARCH64_TLSLE_LDST32_TPREL_LO12,		556)	\
+_ELF_DEFINE_RELOC(R_AARCH64_TLSLE_LDST32_TPREL_LO12_NC,		557)	\
+_ELF_DEFINE_RELOC(R_AARCH64_TLSLE_LDST64_TPREL_LO12,		558)	\
+_ELF_DEFINE_RELOC(R_AARCH64_TLSLE_LDST64_TPREL_LO12_NC,		559)	\
+_ELF_DEFINE_RELOC(R_AARCH64_TLSDESC_LD_PREL19,			560)	\
+_ELF_DEFINE_RELOC(R_AARCH64_TLSDESC_ADR_PREL21,			561)	\
+_ELF_DEFINE_RELOC(R_AARCH64_TLSDESC_ADR_PAGE21,			562)	\
+_ELF_DEFINE_RELOC(R_AARCH64_TLSDESC_LD64_LO12,			563)	\
+_ELF_DEFINE_RELOC(R_AARCH64_TLSDESC_ADD_LO12,			564)	\
+_ELF_DEFINE_RELOC(R_AARCH64_TLSDESC_OFF_G1,			565)	\
+_ELF_DEFINE_RELOC(R_AARCH64_TLSDESC_OFF_G0_NC,			566)	\
+_ELF_DEFINE_RELOC(R_AARCH64_TLSDESC_LDR,			567)	\
+_ELF_DEFINE_RELOC(R_AARCH64_TLSDESC_ADD,			568)	\
+_ELF_DEFINE_RELOC(R_AARCH64_TLSDESC_CALL,			569)	\
+_ELF_DEFINE_RELOC(R_AARCH64_TLSLE_LDST128_TPREL_LO12,		570)	\
+_ELF_DEFINE_RELOC(R_AARCH64_TLSLE_LDST128_TPREL_LO12_NC,	571)	\
+_ELF_DEFINE_RELOC(R_AARCH64_TLSLD_LDST128_DTPREL_LO12,		572)	\
+_ELF_DEFINE_RELOC(R_AARCH64_TLSLD_LDST128_DTPREL_LO12_NC,	573)	\
+_ELF_DEFINE_RELOC(R_AARCH64_COPY,				1024)	\
+_ELF_DEFINE_RELOC(R_AARCH64_GLOB_DAT,				1025)	\
+_ELF_DEFINE_RELOC(R_AARCH64_JUMP_SLOT,				1026)	\
+_ELF_DEFINE_RELOC(R_AARCH64_RELATIVE,				1027)	\
+_ELF_DEFINE_RELOC(R_AARCH64_TLS_DTPREL64,			1028)	\
+_ELF_DEFINE_RELOC(R_AARCH64_TLS_DTPMOD64,			1029)	\
+_ELF_DEFINE_RELOC(R_AARCH64_TLS_TPREL64,			1030)	\
+_ELF_DEFINE_RELOC(R_AARCH64_TLSDESC,				1031)	\
+_ELF_DEFINE_RELOC(R_AARCH64_IRELATIVE,				1032)
 
 /*
  * These are the symbols used in the Sun ``Linkers and Loaders
@@ -1633,7 +1755,7 @@ _ELF_DEFINE_RELOC(R_IA_64_LTV32MSB,		0x7
 _ELF_DEFINE_RELOC(R_IA_64_LTV32LSB,		0x75)	\
 _ELF_DEFINE_RELOC(R_IA_64_LTV64MSB,		0x76)	\
 _ELF_DEFINE_RELOC(R_IA_64_LTV64LSB,		0x77)	\
-_ELF_DEFINE_RELOC(R_IA_64_PCREL21BIa,		0x79)	\
+_ELF_DEFINE_RELOC(R_IA_64_PCREL21BI,		0x79)	\
 _ELF_DEFINE_RELOC(R_IA_64_PCREL22,		0x7A)	\
 _ELF_DEFINE_RELOC(R_IA_64_PCREL64I,		0x7B)	\
 _ELF_DEFINE_RELOC(R_IA_64_IPLTMSB,		0x80)	\
@@ -1723,7 +1845,7 @@ _ELF_DEFINE_RELOC(R_PPC_REL32,		26)	\
 _ELF_DEFINE_RELOC(R_PPC_PLT32,		27)	\
 _ELF_DEFINE_RELOC(R_PPC_PLTREL32,	28)	\
 _ELF_DEFINE_RELOC(R_PPC_PLT16_LO,	29)	\
-_ELF_DEFINE_RELOC(R_PPL_PLT16_HI,	30)	\
+_ELF_DEFINE_RELOC(R_PPC_PLT16_HI,	30)	\
 _ELF_DEFINE_RELOC(R_PPC_PLT16_HA,	31)	\
 _ELF_DEFINE_RELOC(R_PPC_SDAREL16,	32)	\
 _ELF_DEFINE_RELOC(R_PPC_SECTOFF,	33)	\
@@ -1926,7 +2048,7 @@ _ELF_DEFINE_RELOC(R_RISCV_SUB32,		39)	\
 _ELF_DEFINE_RELOC(R_RISCV_SUB64,		40)	\
 _ELF_DEFINE_RELOC(R_RISCV_GNU_VTINHERIT,	41)	\
 _ELF_DEFINE_RELOC(R_RISCV_GNU_VTENTRY,		42)	\
-_ELF_DEFINE_RELOC(R_RISCV_ALIGN			43)	\
+_ELF_DEFINE_RELOC(R_RISCV_ALIGN,		43)	\
 _ELF_DEFINE_RELOC(R_RISCV_RVC_BRANCH,		44)	\
 _ELF_DEFINE_RELOC(R_RISCV_RVC_JUMP,		45)
 
@@ -2042,6 +2164,7 @@ _ELF_DEFINE_IA64_RELOCATIONS()			\
 _ELF_DEFINE_MIPS_RELOCATIONS()			\
 _ELF_DEFINE_PPC32_RELOCATIONS()			\
 _ELF_DEFINE_PPC64_RELOCATIONS()			\
+_ELF_DEFINE_RISCV_RELOCATIONS()			\
 _ELF_DEFINE_SPARC_RELOCATIONS()			\
 _ELF_DEFINE_X86_64_RELOCATIONS()
 

Modified: projects/clang380-import/contrib/elftoolchain/common/native-elf-format
==============================================================================
--- projects/clang380-import/contrib/elftoolchain/common/native-elf-format	Sat Feb 13 15:58:51 2016	(r295600)
+++ projects/clang380-import/contrib/elftoolchain/common/native-elf-format	Sat Feb 13 16:02:12 2016	(r295601)
@@ -1,6 +1,6 @@
 #!/bin/sh
 #
-# $Id: native-elf-format 3186 2015-04-16 22:16:40Z emaste $
+# $Id: native-elf-format 3293 2016-01-07 19:26:27Z emaste $
 #
 # Find the native ELF format for a host platform by compiling a
 # test object and examining the resulting object.
@@ -33,6 +33,8 @@ $1 ~ "Data:"  {
 $1 ~ "Machine:" {
         if (match($0, "Intel.*386")) {
             elfarch = "EM_386";
+        } else if (match($0, "MIPS")) {
+            elfarch = "EM_MIPS";
         } else if (match($0, ".*[xX]86-64")) {
             elfarch = "EM_X86_64";
         } else {

Modified: projects/clang380-import/contrib/elftoolchain/cxxfilt/cxxfilt.c
==============================================================================
--- projects/clang380-import/contrib/elftoolchain/cxxfilt/cxxfilt.c	Sat Feb 13 15:58:51 2016	(r295600)
+++ projects/clang380-import/contrib/elftoolchain/cxxfilt/cxxfilt.c	Sat Feb 13 16:02:12 2016	(r295601)
@@ -35,7 +35,7 @@
 
 #include "_elftc.h"
 
-ELFTC_VCSID("$Id: cxxfilt.c 3174 2015-03-27 17:13:41Z emaste $");
+ELFTC_VCSID("$Id: cxxfilt.c 3356 2016-01-22 22:31:38Z jkoshy $");
 
 #define	STRBUFSZ	8192
 
@@ -112,11 +112,11 @@ find_format(const char *fstr)
 }
 
 static char *
-demangle(char *name, int strict, int *pos)
+demangle(char *name, int strict, size_t *pos)
 {
 	static char dem[STRBUFSZ];
 	char nb[STRBUFSZ];
-	int p, t;
+	size_t p, t;
 
 	if (stripus && *name == '_') {
 		strncpy(nb, name + 1, sizeof(nb) - 1);
@@ -128,10 +128,10 @@ demangle(char *name, int strict, int *po
 	nb[sizeof(nb) - 1] = '\0';
 
 	p = strlen(nb);
-	if (p <= 0)
+	if (p == 0)
 		return NULL;
 
-	while (elftc_demangle(nb, dem, sizeof(dem), format) < 0) {
+	while (elftc_demangle(nb, dem, sizeof(dem), (unsigned) format) < 0) {
 		if (!strict && p > 1) {
 			nb[--p] = '\0';
 			continue;
@@ -149,7 +149,8 @@ int
 main(int argc, char **argv)
 {
 	char *dem, buf[STRBUFSZ];
-	int c, i, p, s, opt;
+	size_t i, p, s;
+	int c, n, opt;
 
 	while ((opt = getopt_long(argc, argv, "_nps:V", longopts, NULL)) !=
 	    -1) {
@@ -182,9 +183,9 @@ main(int argc, char **argv)
 	argc -= optind;
 
 	if (*argv != NULL) {
-		for (i = 0; i < argc; i++) {
-			if ((dem = demangle(argv[i], 1, NULL)) == NULL)
-				fprintf(stderr, "Failed: %s\n", argv[i]);
+		for (n = 0; n < argc; n++) {
+			if ((dem = demangle(argv[n], 1, NULL)) == NULL)
+				fprintf(stderr, "Failed: %s\n", argv[n]);
 			else
 				printf("%s\n", dem);
 		}
@@ -213,7 +214,7 @@ main(int argc, char **argv)
 				if ((size_t) p >= sizeof(buf) - 1)
 					warnx("buffer overflowed");
 				else
-					buf[p++] = c;
+					buf[p++] = (char) c;
 			}
 
 		}

Modified: projects/clang380-import/contrib/elftoolchain/elfcopy/Makefile
==============================================================================
--- projects/clang380-import/contrib/elftoolchain/elfcopy/Makefile	Sat Feb 13 15:58:51 2016	(r295600)
+++ projects/clang380-import/contrib/elftoolchain/elfcopy/Makefile	Sat Feb 13 16:02:12 2016	(r295601)
@@ -1,10 +1,13 @@
-# $Id: Makefile 2290 2011-12-04 07:20:46Z jkoshy $
+# $Id: Makefile 3381 2016-01-30 19:39:47Z jkoshy $
 
 TOP=	..
 
+.include "${TOP}/mk/elftoolchain.components.mk"
+
 PROG=	elfcopy
 
-SRCS=	archive.c ascii.c binary.c main.c sections.c segments.c symbols.c
+SRCS=	archive.c ascii.c binary.c main.c sections.c segments.c \
+	symbols.c
 
 WARNS?=	5
 
@@ -15,14 +18,24 @@ LDADD=	-lelf -lelftc
 LDADD+= -larchive
 .endif
 
+.if defined(WITH_PE) && ${WITH_PE:tl} == "yes"
+SRCS+=	pe.c
+CFLAGS+= -DWITH_PE=1
+
+DPADD+=	${LIBPE}
+LDADD+=	-lpe
+.endif
+
 MAN=	elfcopy.1 mcs.1 strip.1
+MLINKS=	elfcopy.1 objcopy.1
 
 NO_SHARED?=	yes
 
-LINKS=	${BINDIR}/elfcopy ${BINDIR}/strip 	\
-	${BINDIR}/elfcopy ${BINDIR}/mcs
+LINKS=	${BINDIR}/elfcopy ${BINDIR}/mcs		\
+	${BINDIR}/elfcopy ${BINDIR}/objcopy 	\
+	${BINDIR}/elfcopy ${BINDIR}/strip
 
-EXTRA_TARGETS=	strip mcs
+EXTRA_TARGETS=	mcs strip objcopy
 
 CLEANFILES+=	${EXTRA_TARGETS}
 

Modified: projects/clang380-import/contrib/elftoolchain/elfcopy/archive.c
==============================================================================
--- projects/clang380-import/contrib/elftoolchain/elfcopy/archive.c	Sat Feb 13 15:58:51 2016	(r295600)
+++ projects/clang380-import/contrib/elftoolchain/elfcopy/archive.c	Sat Feb 13 16:02:12 2016	(r295601)
@@ -38,7 +38,7 @@
 
 #include "elfcopy.h"
 
-ELFTC_VCSID("$Id: archive.c 3174 2015-03-27 17:13:41Z emaste $");
+ELFTC_VCSID("$Id: archive.c 3287 2015-12-31 16:58:48Z emaste $");
 
 #define _ARMAG_LEN 8		/* length of ar magic string */
 #define _ARHDR_LEN 60		/* length of ar header */
@@ -382,7 +382,7 @@ ac_read_objs(struct elfcopy *ecp, int if
 	if (lseek(ifd, 0, SEEK_SET) == -1)
 		err(EXIT_FAILURE, "lseek failed");
 	if ((a = archive_read_new()) == NULL)
-		errx(EXIT_FAILURE, "%s", archive_error_string(a));
+		errx(EXIT_FAILURE, "archive_read_new failed");
 	archive_read_support_format_ar(a);
 	AC(archive_read_open_fd(a, ifd, 10240));
 	for(;;) {
@@ -443,7 +443,7 @@ ac_write_objs(struct elfcopy *ecp, int o
 	int			 nr;
 
 	if ((a = archive_write_new()) == NULL)
-		errx(EXIT_FAILURE, "%s", archive_error_string(a));
+		errx(EXIT_FAILURE, "archive_write_new failed");
 	archive_write_set_format_ar_svr4(a);
 	AC(archive_write_open_fd(a, ofd));
 

Modified: projects/clang380-import/contrib/elftoolchain/elfcopy/elfcopy.1
==============================================================================
--- projects/clang380-import/contrib/elftoolchain/elfcopy/elfcopy.1	Sat Feb 13 15:58:51 2016	(r295600)
+++ projects/clang380-import/contrib/elftoolchain/elfcopy/elfcopy.1	Sat Feb 13 16:02:12 2016	(r295601)
@@ -21,13 +21,14 @@
 .\" out of the use of this software, even if advised of the possibility of
 .\" such damage.
 .\"
-.\" $Id: elfcopy.1 3266 2015-12-07 15:38:26Z emaste $
+.\" $Id: elfcopy.1 3381 2016-01-30 19:39:47Z jkoshy $
 .\"
-.Dd December 7, 2015
+.Dd January 29, 2016
 .Os
 .Dt ELFCOPY 1
 .Sh NAME
-.Nm elfcopy
+.Nm elfcopy ,
+.Nm objcopy
 .Nd copy and translate object files
 .Sh SYNOPSIS
 .Nm
@@ -85,7 +86,7 @@
 .Sh DESCRIPTION
 The
 .Nm
-utility copies the content of the ELF object named by argument
+utility copies the content of the binary object named by argument
 .Ar infile
 to that named by argument
 .Ar outfile ,
@@ -121,6 +122,10 @@ to the output.
 .It Fl O Ar objformat | Fl -output-target= Ns Ar objformat
 Write the output file using the object format specified in argument
 .Ar objformat .
+The argument
+.Ar objformat
+should be one of the target names recognized by
+.Xr elftc_bfd_find_target 3 .
 .It Fl R Ar sectionname | Fl -remove-section= Ns Ar sectionname
 Remove any section with name
 .Ar sectionname
@@ -330,8 +335,14 @@ Do not copy symbols that are not needed 
 .Xr mcs 1 ,
 .Xr strip 1 ,
 .Xr elf 3 ,
+.Xr elftc_bfd_find_target 3 ,
 .Xr ar 5 ,
 .Xr elf 5
+.Sh COMPATIBILITY
+The
+.Nm
+utility is expected to be option compatible with GNU
+.Nm objcopy .
 .Sh HISTORY
 .Nm
 has been implemented by

Modified: projects/clang380-import/contrib/elftoolchain/elfcopy/elfcopy.h
==============================================================================
--- projects/clang380-import/contrib/elftoolchain/elfcopy/elfcopy.h	Sat Feb 13 15:58:51 2016	(r295600)
+++ projects/clang380-import/contrib/elftoolchain/elfcopy/elfcopy.h	Sat Feb 13 16:02:12 2016	(r295601)
@@ -23,7 +23,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $Id: elfcopy.h 3221 2015-05-24 23:42:43Z kaiwang27 $
+ * $Id: elfcopy.h 3310 2016-01-10 09:10:54Z kaiwang27 $
  */
 
 #include <sys/queue.h>
@@ -287,6 +287,7 @@ struct section *create_external_section(
     int _loadable);
 void	create_external_symtab(struct elfcopy *_ecp);
 void	create_ihex(int _ifd, int _ofd);
+void	create_pe(struct elfcopy *_ecp, int _ifd, int _ofd);
 void	create_scn(struct elfcopy *_ecp);
 void	create_srec(struct elfcopy *_ecp, int _ifd, int _ofd, const char *_ofn);
 void	create_symtab(struct elfcopy *_ecp);

Modified: projects/clang380-import/contrib/elftoolchain/elfcopy/main.c
==============================================================================
--- projects/clang380-import/contrib/elftoolchain/elfcopy/main.c	Sat Feb 13 15:58:51 2016	(r295600)
+++ projects/clang380-import/contrib/elftoolchain/elfcopy/main.c	Sat Feb 13 16:02:12 2016	(r295601)
@@ -39,7 +39,7 @@
 
 #include "elfcopy.h"
 
-ELFTC_VCSID("$Id: main.c 3268 2015-12-07 20:30:55Z emaste $");
+ELFTC_VCSID("$Id: main.c 3399 2016-02-12 18:07:56Z emaste $");
 
 enum options
 {
@@ -316,6 +316,7 @@ create_elf(struct elfcopy *ecp)
 	oeh.e_entry	      = ieh.e_entry;
 	oeh.e_version	      = ieh.e_version;
 
+	ecp->flags &= ~(EXECUTABLE | DYNAMIC | RELOCATABLE);
 	if (ieh.e_type == ET_EXEC)
 		ecp->flags |= EXECUTABLE;
 	else if (ieh.e_type == ET_DYN)
@@ -722,6 +723,15 @@ create_file(struct elfcopy *ecp, const c
 				create_srec(ecp, ofd, ofd0,
 				    dst != NULL ? dst : src);
 				break;
+			case ETF_PE:
+			case ETF_EFI:
+#if	WITH_PE
+				create_pe(ecp, ofd, ofd0);
+#else
+				errx(EXIT_FAILURE, "PE/EFI support not enabled"
+				    " at compile time");
+#endif
+				break;
 			default:
 				errx(EXIT_FAILURE, "Internal: unsupported"
 				    " output flavour %d", ecp->oec);
@@ -1345,6 +1355,9 @@ set_output_target(struct elfcopy *ecp, c
 		ecp->oed = elftc_bfd_target_byteorder(tgt);
 		ecp->oem = elftc_bfd_target_machine(tgt);
 	}
+	if (ecp->otf == ETF_EFI || ecp->otf == ETF_PE)
+		ecp->oem = elftc_bfd_target_machine(tgt);
+
 	ecp->otgt = target_name;
 }
 
@@ -1366,7 +1379,7 @@ set_osabi(struct elfcopy *ecp, const cha
 
 #define	ELFCOPY_USAGE_MESSAGE	"\
 Usage: %s [options] infile [outfile]\n\
-  Transform an ELF object.\n\n\
+  Transform object files.\n\n\
   Options:\n\
   -d | -g | --strip-debug      Remove debugging information from the output.\n\
   -j SECTION | --only-section=SECTION\n\
@@ -1382,6 +1395,8 @@ Usage: %s [options] infile [outfile]\n\
   -N SYM | --strip-symbol=SYM  Do not copy symbol SYM to the output.\n\
   -O FORMAT | --output-target=FORMAT\n\
                                Specify object format for the output file.\n\
+                               FORMAT should be a target name understood by\n\
+                               elftc_bfd_find_target(3).\n\
   -R NAME | --remove-section=NAME\n\
                                Remove the named section.\n\
   -S | --strip-all             Remove all symbol and relocation information\n\
@@ -1471,6 +1486,7 @@ Usage: %s [options] file...\n\
   Options:\n\
   -d | -g | -S | --strip-debug    Remove debugging symbols.\n\
   -h | --help                     Print a help message.\n\
+  -o FILE | --output-file FILE    Write output to FILE.\n\
   --only-keep-debug               Keep debugging information only.\n\
   -p | --preserve-dates           Preserve access and modification times.\n\
   -s | --strip-all                Remove all symbols.\n\

Copied: projects/clang380-import/contrib/elftoolchain/elfcopy/pe.c (from r295600, head/contrib/elftoolchain/elfcopy/pe.c)
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ projects/clang380-import/contrib/elftoolchain/elfcopy/pe.c	Sat Feb 13 16:02:12 2016	(r295601, copy of r295600, head/contrib/elftoolchain/elfcopy/pe.c)
@@ -0,0 +1,233 @@
+/*-
+ * Copyright (c) 2016 Kai Wang
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/param.h>
+#include <err.h>
+#include <gelf.h>
+#include <libpe.h>
+#include <stdlib.h>
+#include <string.h>
+#include <time.h>
+
+#include "elfcopy.h"
+
+ELFTC_VCSID("$Id: pe.c 3312 2016-01-10 09:23:51Z kaiwang27 $");
+
+/* Convert ELF object to Portable Executable (PE). */
+void
+create_pe(struct elfcopy *ecp, int ifd, int ofd)
+{
+	Elf *e;
+	Elf_Scn *scn;
+	Elf_Data *d;
+	GElf_Ehdr eh;
+	GElf_Shdr sh;
+	PE *pe;
+	PE_Scn *ps;
+	PE_SecHdr psh;
+	PE_CoffHdr pch;
+	PE_OptHdr poh;
+	PE_Object po;
+	PE_Buffer *pb;
+	const char *name;
+	size_t indx;
+	int elferr, i;
+
+	if (ecp->otf == ETF_EFI || ecp->oem == EM_X86_64)
+		po = PE_O_PE32P;
+	else
+		po = PE_O_PE32;
+
+	if ((e = elf_begin(ifd, ELF_C_READ, NULL)) == NULL)
+		errx(EXIT_FAILURE, "elf_begin() failed: %s",
+		    elf_errmsg(-1));
+
+	if (gelf_getehdr(e, &eh) == NULL)
+		errx(EXIT_FAILURE, "gelf_getehdr() failed: %s",
+		    elf_errmsg(-1));
+
+	if (elf_getshstrndx(ecp->ein, &indx) == 0)
+		errx(EXIT_FAILURE, "elf_getshstrndx() failed: %s",
+		    elf_errmsg(-1));
+
+	if ((pe = pe_init(ofd, PE_C_WRITE, po)) == NULL)
+		err(EXIT_FAILURE, "pe_init() failed");
+
+	/* Setup PE COFF header. */
+	memset(&pch, 0, sizeof(pch));
+	switch (ecp->oem) {
+	case EM_386:
+		pch.ch_machine = IMAGE_FILE_MACHINE_I386;
+		break;
+	case EM_X86_64:
+		pch.ch_machine = IMAGE_FILE_MACHINE_AMD64;
+		break;
+	default:
+		pch.ch_machine = IMAGE_FILE_MACHINE_UNKNOWN;
+		break;
+	}
+	pch.ch_timestamp = (uint32_t) time(NULL);
+	if (pe_update_coff_header(pe, &pch) < 0)
+		err(EXIT_FAILURE, "pe_update_coff_header() failed");
+
+	/* Setup PE optional header. */
+	memset(&poh, 0, sizeof(poh));
+	if (ecp->otf == ETF_EFI)
+		poh.oh_subsystem = IMAGE_SUBSYSTEM_EFI_APPLICATION;
+	poh.oh_entry = (uint32_t) eh.e_entry;
+
+	/*
+	 * Default section alignment and file alignment. (Here the
+	 * section alignment is set to the default page size of the
+	 * archs supported. We should use different section alignment
+	 * for some arch. (e.g. IA64)
+	 */
+	poh.oh_secalign = 0x1000;
+	poh.oh_filealign = 0x200;
+
+	/* Copy sections. */
+	scn = NULL;
+	while ((scn = elf_nextscn(e, scn)) != NULL) {
+
+		/*
+		 * Read in ELF section.
+		 */
+
+		if (gelf_getshdr(scn, &sh) == NULL) {
+			warnx("gelf_getshdr() failed: %s", elf_errmsg(-1));
+			(void) elf_errno();
+			continue;
+		}
+		if ((name = elf_strptr(ecp->ein, indx, sh.sh_name)) ==
+		    NULL) {
+			warnx("elf_strptr() failed: %s", elf_errmsg(-1));
+			(void) elf_errno();
+			continue;
+		}
+
+		/* Skip sections unneeded. */
+		if (strcmp(name, ".shstrtab") == 0 ||
+		    strcmp(name, ".symtab") == 0 ||
+		    strcmp(name, ".strtab") == 0)
+			continue;
+
+		if ((d = elf_getdata(scn, NULL)) == NULL) {
+			warnx("elf_getdata() failed: %s", elf_errmsg(-1));
+			(void) elf_errno();
+			continue;
+		}
+
+		if (strcmp(name, ".text") == 0) {
+			poh.oh_textbase = (uint32_t) sh.sh_addr;
+			poh.oh_textsize = (uint32_t) roundup(sh.sh_size,
+			    poh.oh_filealign);
+		} else {
+			if (po == PE_O_PE32 && strcmp(name, ".data") == 0)
+				poh.oh_database = sh.sh_addr;
+			if (sh.sh_type == SHT_NOBITS)
+				poh.oh_bsssize += (uint32_t)
+				    roundup(sh.sh_size, poh.oh_filealign);
+			else if (sh.sh_flags & SHF_ALLOC)
+				poh.oh_datasize += (uint32_t)
+				    roundup(sh.sh_size, poh.oh_filealign);
+		}
+
+		/*
+		 * Create PE/COFF section.
+		 */
+
+		if ((ps = pe_newscn(pe)) == NULL) {
+			warn("pe_newscn() failed");
+			continue;
+		}
+
+		/*
+		 * Setup PE/COFF section header. The section name is not
+		 * NUL-terminated if its length happens to be 8. Long
+		 * section name should be truncated for PE image according
+		 * to the PE/COFF specification.
+		 */
+		memset(&psh, 0, sizeof(psh));
+		strncpy(psh.sh_name, name, sizeof(psh.sh_name));
+		psh.sh_addr = sh.sh_addr;
+		psh.sh_virtsize = sh.sh_size;
+		if (sh.sh_type != SHT_NOBITS)
+			psh.sh_rawsize = sh.sh_size;
+		else
+			psh.sh_char |= IMAGE_SCN_CNT_UNINITIALIZED_DATA;
+
+		/*
+		 * Translate ELF section flags to PE/COFF section flags.
+		 */
+		psh.sh_char |= IMAGE_SCN_MEM_READ;
+		if (sh.sh_flags & SHF_WRITE)
+			psh.sh_char |= IMAGE_SCN_MEM_WRITE;
+		if (sh.sh_flags & SHF_EXECINSTR)
+			psh.sh_char |= IMAGE_SCN_MEM_EXECUTE |
+			    IMAGE_SCN_CNT_CODE;
+		if ((sh.sh_flags & SHF_ALLOC) && (psh.sh_char & 0xF0) == 0)
+			psh.sh_char |= IMAGE_SCN_CNT_INITIALIZED_DATA;
+		for (i = 0xE; i > 0; i--) {
+			if (sh.sh_addralign & (1U << (i - 1))) {
+				psh.sh_char |= i << 20;
+				break;
+			}
+		}
+
+		/* Mark relocation section "discardable". */
+		if (strcmp(name, ".reloc") == 0)
+			psh.sh_char |= IMAGE_SCN_MEM_DISCARDABLE;
+
+		if (pe_update_section_header(ps, &psh) < 0) {
+			warn("pe_update_section_header() failed");
+			continue;
+		}
+
+		/* Copy section content. */
+		if ((pb = pe_newbuffer(ps)) == NULL) {
+			warn("pe_newbuffer() failed");
+			continue;
+		}
+		pb->pb_align = 1;
+		pb->pb_off = 0;
+		pb->pb_size = sh.sh_size;
+		pb->pb_buf = d->d_buf;
+	}
+	elferr = elf_errno();
+	if (elferr != 0)
+		warnx("elf_nextscn() failed: %s", elf_errmsg(elferr));
+
+	/* Update PE optional header. */
+	if (pe_update_opt_header(pe, &poh) < 0)
+		err(EXIT_FAILURE, "pe_update_opt_header() failed");
+
+	/* Write out PE/COFF object. */
+	if (pe_update(pe) < 0)
+		err(EXIT_FAILURE, "pe_update() failed");
+
+	pe_finish(pe);
+	elf_end(e);
+}

Modified: projects/clang380-import/contrib/elftoolchain/elfcopy/sections.c
==============================================================================
--- projects/clang380-import/contrib/elftoolchain/elfcopy/sections.c	Sat Feb 13 15:58:51 2016	(r295600)
+++ projects/clang380-import/contrib/elftoolchain/elfcopy/sections.c	Sat Feb 13 16:02:12 2016	(r295601)
@@ -34,7 +34,7 @@
 
 #include "elfcopy.h"
 
-ELFTC_VCSID("$Id: sections.c 3272 2015-12-11 20:00:54Z kaiwang27 $");
+ELFTC_VCSID("$Id: sections.c 3346 2016-01-17 20:09:15Z kaiwang27 $");
 
 static void	add_gnu_debuglink(struct elfcopy *ecp);
 static uint32_t calc_crc32(const char *p, size_t len, uint32_t crc);
@@ -223,6 +223,7 @@ static int
 is_debug_section(const char *name)
 {
 	const char *dbg_sec[] = {
+		".apple_",
 		".debug",
 		".gnu.linkonce.wi.",
 		".line",
@@ -369,7 +370,7 @@ create_scn(struct elfcopy *ecp)
 	is = NULL;
 	while ((is = elf_nextscn(ecp->ein, is)) != NULL) {
 		if (gelf_getshdr(is, &ish) == NULL)
-			errx(EXIT_FAILURE, "219 gelf_getshdr failed: %s",
+			errx(EXIT_FAILURE, "gelf_getshdr failed: %s",
 			    elf_errmsg(-1));
 		if ((name = elf_strptr(ecp->ein, indx, ish.sh_name)) == NULL)
 			errx(EXIT_FAILURE, "elf_strptr failed: %s",
@@ -416,12 +417,19 @@ create_scn(struct elfcopy *ecp)
 			 * is loadable, but if user explicitly set section flags
 			 * while neither "load" nor "alloc" is set, we make the
 			 * section unloadable.
+			 *
+			 * Sections in relocatable object is loadable if
+			 * section flag SHF_ALLOC is set.
 			 */
 			if (sec_flags &&
 			    (sec_flags & (SF_LOAD | SF_ALLOC)) == 0)
 				s->loadable = 0;
-			else
+			else {
 				s->loadable = add_to_inseg_list(ecp, s);
+				if ((ecp->flags & RELOCATABLE) &&
+				    (ish.sh_flags & SHF_ALLOC))
+					s->loadable = 1;
+			}
 		} else {
 			/* Assuming .shstrtab is "unloadable". */
 			s		= ecp->shstrtab;
@@ -875,10 +883,10 @@ resync_sections(struct elfcopy *ecp)
 		if (s->align == 0)
 			s->align = 1;
 		if (off <= s->off) {
-			if (!s->loadable)
+			if (!s->loadable || (ecp->flags & RELOCATABLE))
 				s->off = roundup(off, s->align);
 		} else {
-			if (s->loadable)
+			if (s->loadable && (ecp->flags & RELOCATABLE) == 0)
 				warnx("moving loadable section %s, "
 				    "is this intentional?", s->name);
 			s->off = roundup(off, s->align);
@@ -1028,8 +1036,11 @@ print_section(struct section *s)
 		print_data(s->buf, s->sz);
 	} else {
 		id = NULL;
-		while ((id = elf_getdata(s->is, id)) != NULL)
+		while ((id = elf_getdata(s->is, id)) != NULL ||
+		    (id = elf_rawdata(s->is, id)) != NULL) {
+			(void) elf_errno();
 			print_data(id->d_buf, id->d_size);
+		}
 		elferr = elf_errno();
 		if (elferr != 0)
 			errx(EXIT_FAILURE, "elf_getdata() failed: %s",
@@ -1049,7 +1060,9 @@ read_section(struct section *s, size_t *
 	sz = 0;
 	b = NULL;
 	id = NULL;
-	while ((id = elf_getdata(s->is, id)) != NULL) {
+	while ((id = elf_getdata(s->is, id)) != NULL ||
+	    (id = elf_rawdata(s->is, id)) != NULL) {
+		(void) elf_errno();
 		if (b == NULL)
 			b = malloc(id->d_size);
 		else
@@ -1077,10 +1090,10 @@ copy_shdr(struct elfcopy *ecp, struct se
 	GElf_Shdr ish, osh;
 
 	if (gelf_getshdr(s->is, &ish) == NULL)
-		errx(EXIT_FAILURE, "526 gelf_getshdr() failed: %s",
+		errx(EXIT_FAILURE, "gelf_getshdr() failed: %s",
 		    elf_errmsg(-1));
 	if (gelf_getshdr(s->os, &osh) == NULL)
-		errx(EXIT_FAILURE, "529 gelf_getshdr() failed: %s",
+		errx(EXIT_FAILURE, "gelf_getshdr() failed: %s",
 		    elf_errmsg(-1));
 
 	if (copy)
@@ -1097,19 +1110,32 @@ copy_shdr(struct elfcopy *ecp, struct se
 
 		if (sec_flags) {
 			osh.sh_flags = 0;
-			if (sec_flags & SF_ALLOC) {
+			if (sec_flags & SF_ALLOC)
 				osh.sh_flags |= SHF_ALLOC;
-				if (!s->loadable)
-					warnx("set SHF_ALLOC flag for "
-					    "unloadable section %s",
-					    s->name);
-			}
 			if ((sec_flags & SF_READONLY) == 0)
 				osh.sh_flags |= SHF_WRITE;
 			if (sec_flags & SF_CODE)
 				osh.sh_flags |= SHF_EXECINSTR;
+			if ((sec_flags & SF_CONTENTS) &&
+			    s->type == SHT_NOBITS && s->sz > 0) {
+				/*
+				 * Convert SHT_NOBITS section to section with
+				 * (zero'ed) content on file.
+				 */
+				osh.sh_type = s->type = SHT_PROGBITS;
+				if ((s->buf = calloc(1, s->sz)) == NULL)
+					err(EXIT_FAILURE, "malloc failed");
+				s->nocopy = 1;
+			}
 		} else {
 			osh.sh_flags = ish.sh_flags;
+			/*
+			 * Newer binutils as(1) emits the section flag
+			 * SHF_INFO_LINK for relocation sections. elfcopy
+			 * emits this flag in the output section if it's
+			 * missing in the input section, to remain compatible
+			 * with binutils.
+			 */
 			if (ish.sh_type == SHT_REL || ish.sh_type == SHT_RELA)
 				osh.sh_flags |= SHF_INFO_LINK;
 		}
@@ -1135,11 +1161,14 @@ copy_data(struct section *s)
 		return;
 
 	if ((id = elf_getdata(s->is, NULL)) == NULL) {
-		elferr = elf_errno();
-		if (elferr != 0)
-			errx(EXIT_FAILURE, "elf_getdata() failed: %s",
-			    elf_errmsg(elferr));
-		return;
+		(void) elf_errno();
+		if ((id = elf_rawdata(s->is, NULL)) == NULL) {
+			elferr = elf_errno();
+			if (elferr != 0)
+				errx(EXIT_FAILURE, "failed to read section:"
+				    " %s", s->name);
+			return;
+		}
 	}
 

*** DIFF OUTPUT TRUNCATED AT 1000 LINES ***



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201602131602.u1DG2ClQ071331>