svn commit: r261246 - in head: . cddl/contrib/opensolaris/tools/ctf/cvt contrib/elftoolchain lib/libdwarf lib/libelf sys/sys

Kai Wang kaiw at FreeBSD.org
Tue Jan 28 21:38:56 UTC 2014


Author: kaiw
Date: Tue Jan 28 21:38:54 2014
New Revision: 261246
URL: http://svnweb.freebsd.org/changeset/base/261246

Log:
  Merge from projects/elftoolchain: Upgrade libelf and libdwarf to newer
  versions from elftoolchain upstream (r2974).  Convert ctfconvert to
  use the APIs from the new libdwarf and make ctfconvert work with Clang
  3.4.
  
  __FreeBSD_version is bumped to 1100006.
  
  A list of notable changes:
  
  [libelf]
  
  * The old libelf source code in lib/libelf has been removed.
    Instead, the new libelf is built from contrib/elftoolchain/libelf.
  * Manual pages are largely improved.
  * Internal implementation was refactored and improved for better
    correctness and portability.
  * Fixed a few memory leaks.
  * Extended with extension APIs `elf_open()` and `elf_openmemory()`.
    These APIs are similar to `elf_begin()` and `elf_memory()`
    respectively, except that they return an ELF descriptor of kind
    `ELF_K_NONE` instead of an error if the object being opened could
    not be parsed.
  * Implement support for translating sections of type ELF_T_VDEF and
    ELF_T_VNEED.
  * Improve `elf_update()` to check that the executable header, the
    program header table, section contents and the section header table
    do not overlap, and to ensure that gaps between extents are
    filled with the fill character specified by `elf_fill()`.
  * Allow `Elf_Data` descriptors to have types and alignments differing
    from their containing section.
  * Remove functionality controlled by `LIBELF_TEST_HOOKS`.
  * Support processing of BSD-flavor archives.
  * Add knowledge of section types `SHT_GNU_ATTRIBUTES` and
    `SHT_GNU_LIBLIST`.
  * Use elftoolchain style symbol versioning.
  * Shared library version is bumped.
  
  [libdwarf]
  
  * The old libdwarf source code in lib/libdwarf has been removed.
    Instead, the new libdwarf is built from contrib/elftoolchain/libdwarf.
  * Support full DWARF3 and partial DWARF4 parsing.
  * Support DWARF2 generation.
  * Support for DWARF line number, call frame, location expression,
    macro info and address ranges, among other things.
  * The APIs for the new libdwarf are mostly compatible with the widely
    used LGPL libdwarf. Some of the incompatible APIs from the old
    libdwarf are kept as its own extensions. All the APIs are documented.
  * Use elftoolchain style symbol versioning.
  * Shared library version is bumped.
  
  [ctfconvert]
  
  * Switch to the APIs from the new libdwarf.
  * Improve die_mem_offset() so that DW_AT_data_member_location attributes
    generated by Clang 3.4 can be handled properly.
  * Make use of DW_AT_byte_size attribute of the member DIE to calculate
    the bits occupied by the member's type, without actually resolving
    the type. This way ctfconvert can deal with the case that Clang 3.4
    sometimes emits DIE for struct/union member before emitting the DIE
    for the type of that member.
  
  Obtained from:	elftoolchain
  No objection:	-toolchain mailing list

Added:
  head/contrib/elftoolchain/
     - copied from r261245, projects/elftoolchain/contrib/elftoolchain/
Deleted:
  head/lib/libdwarf/_libdwarf.h
  head/lib/libdwarf/dwarf.h
  head/lib/libdwarf/dwarf_abbrev.c
  head/lib/libdwarf/dwarf_attr.c
  head/lib/libdwarf/dwarf_attrval.c
  head/lib/libdwarf/dwarf_cu.c
  head/lib/libdwarf/dwarf_dealloc.c
  head/lib/libdwarf/dwarf_die.c
  head/lib/libdwarf/dwarf_dump.c
  head/lib/libdwarf/dwarf_errmsg.c
  head/lib/libdwarf/dwarf_errno.c
  head/lib/libdwarf/dwarf_finish.c
  head/lib/libdwarf/dwarf_form.c
  head/lib/libdwarf/dwarf_func.c
  head/lib/libdwarf/dwarf_init.c
  head/lib/libdwarf/dwarf_loc.c
  head/lib/libdwarf/libdwarf.h
  head/lib/libelf/README
  head/lib/libelf/Version.map
  head/lib/libelf/_libelf.h
  head/lib/libelf/elf.3
  head/lib/libelf/elf_begin.3
  head/lib/libelf/elf_begin.c
  head/lib/libelf/elf_cntl.3
  head/lib/libelf/elf_cntl.c
  head/lib/libelf/elf_data.c
  head/lib/libelf/elf_end.3
  head/lib/libelf/elf_end.c
  head/lib/libelf/elf_errmsg.3
  head/lib/libelf/elf_errmsg.c
  head/lib/libelf/elf_errno.c
  head/lib/libelf/elf_fill.3
  head/lib/libelf/elf_fill.c
  head/lib/libelf/elf_flag.c
  head/lib/libelf/elf_flagdata.3
  head/lib/libelf/elf_getarhdr.3
  head/lib/libelf/elf_getarhdr.c
  head/lib/libelf/elf_getarsym.3
  head/lib/libelf/elf_getarsym.c
  head/lib/libelf/elf_getbase.3
  head/lib/libelf/elf_getbase.c
  head/lib/libelf/elf_getdata.3
  head/lib/libelf/elf_getident.3
  head/lib/libelf/elf_getident.c
  head/lib/libelf/elf_getphdrnum.3
  head/lib/libelf/elf_getphnum.3
  head/lib/libelf/elf_getscn.3
  head/lib/libelf/elf_getshdrnum.3
  head/lib/libelf/elf_getshdrstrndx.3
  head/lib/libelf/elf_getshnum.3
  head/lib/libelf/elf_getshstrndx.3
  head/lib/libelf/elf_hash.3
  head/lib/libelf/elf_hash.c
  head/lib/libelf/elf_kind.3
  head/lib/libelf/elf_kind.c
  head/lib/libelf/elf_memory.3
  head/lib/libelf/elf_memory.c
  head/lib/libelf/elf_next.3
  head/lib/libelf/elf_next.c
  head/lib/libelf/elf_phnum.c
  head/lib/libelf/elf_rand.3
  head/lib/libelf/elf_rand.c
  head/lib/libelf/elf_rawfile.3
  head/lib/libelf/elf_rawfile.c
  head/lib/libelf/elf_scn.c
  head/lib/libelf/elf_shnum.c
  head/lib/libelf/elf_shstrndx.c
  head/lib/libelf/elf_strptr.3
  head/lib/libelf/elf_strptr.c
  head/lib/libelf/elf_types.m4
  head/lib/libelf/elf_update.3
  head/lib/libelf/elf_update.c
  head/lib/libelf/elf_version.3
  head/lib/libelf/elf_version.c
  head/lib/libelf/gelf.3
  head/lib/libelf/gelf.h
  head/lib/libelf/gelf_cap.c
  head/lib/libelf/gelf_checksum.3
  head/lib/libelf/gelf_checksum.c
  head/lib/libelf/gelf_dyn.c
  head/lib/libelf/gelf_ehdr.c
  head/lib/libelf/gelf_fsize.3
  head/lib/libelf/gelf_fsize.c
  head/lib/libelf/gelf_getcap.3
  head/lib/libelf/gelf_getclass.3
  head/lib/libelf/gelf_getclass.c
  head/lib/libelf/gelf_getdyn.3
  head/lib/libelf/gelf_getehdr.3
  head/lib/libelf/gelf_getmove.3
  head/lib/libelf/gelf_getphdr.3
  head/lib/libelf/gelf_getrel.3
  head/lib/libelf/gelf_getrela.3
  head/lib/libelf/gelf_getshdr.3
  head/lib/libelf/gelf_getsym.3
  head/lib/libelf/gelf_getsyminfo.3
  head/lib/libelf/gelf_getsymshndx.3
  head/lib/libelf/gelf_move.c
  head/lib/libelf/gelf_newehdr.3
  head/lib/libelf/gelf_newphdr.3
  head/lib/libelf/gelf_phdr.c
  head/lib/libelf/gelf_rel.c
  head/lib/libelf/gelf_rela.c
  head/lib/libelf/gelf_shdr.c
  head/lib/libelf/gelf_sym.c
  head/lib/libelf/gelf_syminfo.c
  head/lib/libelf/gelf_symshndx.c
  head/lib/libelf/gelf_update_ehdr.3
  head/lib/libelf/gelf_xlate.c
  head/lib/libelf/gelf_xlatetof.3
  head/lib/libelf/libelf.c
  head/lib/libelf/libelf.h
  head/lib/libelf/libelf_align.c
  head/lib/libelf/libelf_allocate.c
  head/lib/libelf/libelf_ar.c
  head/lib/libelf/libelf_ar_util.c
  head/lib/libelf/libelf_checksum.c
  head/lib/libelf/libelf_convert.m4
  head/lib/libelf/libelf_data.c
  head/lib/libelf/libelf_ehdr.c
  head/lib/libelf/libelf_extended.c
  head/lib/libelf/libelf_fsize.m4
  head/lib/libelf/libelf_msize.m4
  head/lib/libelf/libelf_phdr.c
  head/lib/libelf/libelf_shdr.c
  head/lib/libelf/libelf_xlate.c
Modified:
  head/ObsoleteFiles.inc
  head/UPDATING
  head/cddl/contrib/opensolaris/tools/ctf/cvt/dwarf.c
  head/lib/libdwarf/Makefile
  head/lib/libelf/Makefile
  head/sys/sys/elf_common.h
  head/sys/sys/param.h
Directory Properties:
  head/   (props changed)

Modified: head/ObsoleteFiles.inc
==============================================================================
--- head/ObsoleteFiles.inc	Tue Jan 28 21:30:05 2014	(r261245)
+++ head/ObsoleteFiles.inc	Tue Jan 28 21:38:54 2014	(r261246)
@@ -38,6 +38,11 @@
 #   xargs -n1 | sort | uniq -d;
 # done
 
+# 20140128: libelf and libdwarf import
+OLD_LIBS+=usr/lib/libelf.so.1
+OLD_LIBS+=usr/lib32/libelf.so.1
+OLD_LIBS+=usr/lib/libdwarf.so.3
+OLD_LIBS+=usr/lib32/libdwarf.so.3
 # 20131215: libcam version bumped
 OLD_LIBS+=lib/libcam.so.6 usr/lib32/libcam.so.6
 # 20131202: libcapsicum and libcasper moved to /lib/

Modified: head/UPDATING
==============================================================================
--- head/UPDATING	Tue Jan 28 21:30:05 2014	(r261245)
+++ head/UPDATING	Tue Jan 28 21:38:54 2014	(r261246)
@@ -31,6 +31,13 @@ NOTE TO PEOPLE WHO THINK THAT FreeBSD 11
 	disable the most expensive debugging functionality run
 	"ln -s 'abort:false,junk:false' /etc/malloc.conf".)
 
+20140128:
+	The libelf and libdwarf libraries have been updated to newer
+	versions from upstream. Shared library version numbers for
+	these two libraries were bumped. Any ports or binaries
+	requiring these two libraries should be recompiled.
+	__FreeBSD_version is bumped to 1100006.
+
 20140110:
 	If a Makefile in a tests/ directory was auto-generating a Kyuafile
 	instead of providing an explicit one, this would prevent such

Modified: head/cddl/contrib/opensolaris/tools/ctf/cvt/dwarf.c
==============================================================================
--- head/cddl/contrib/opensolaris/tools/ctf/cvt/dwarf.c	Tue Jan 28 21:30:05 2014	(r261245)
+++ head/cddl/contrib/opensolaris/tools/ctf/cvt/dwarf.c	Tue Jan 28 21:38:54 2014	(r261246)
@@ -96,9 +96,6 @@
 #include "list.h"
 #include "traverse.h"
 
-/* The version of DWARF which we support. */
-#define	DWARF_VERSION	2
-
 /*
  * We need to define a couple of our own intrinsics, to smooth out some of the
  * differences between the GCC and DevPro DWARF emitters.  See the referenced
@@ -271,7 +268,7 @@ die_off(dwarf_t *dw, Dwarf_Die die)
 		return (off);
 
 	terminate("failed to get offset for die: %s\n",
-	    dwarf_errmsg(&dw->dw_err));
+	    dwarf_errmsg(dw->dw_err));
 	/*NOTREACHED*/
 	return (0);
 }
@@ -289,7 +286,7 @@ die_sibling(dwarf_t *dw, Dwarf_Die die)
 		return (NULL);
 
 	terminate("die %llu: failed to find type sibling: %s\n",
-	    die_off(dw, die), dwarf_errmsg(&dw->dw_err));
+	    die_off(dw, die), dwarf_errmsg(dw->dw_err));
 	/*NOTREACHED*/
 	return (NULL);
 }
@@ -306,7 +303,7 @@ die_child(dwarf_t *dw, Dwarf_Die die)
 		return (NULL);
 
 	terminate("die %llu: failed to find type child: %s\n",
-	    die_off(dw, die), dwarf_errmsg(&dw->dw_err));
+	    die_off(dw, die), dwarf_errmsg(dw->dw_err));
 	/*NOTREACHED*/
 	return (NULL);
 }
@@ -320,7 +317,7 @@ die_tag(dwarf_t *dw, Dwarf_Die die)
 		return (tag);
 
 	terminate("die %llu: failed to get tag for type: %s\n",
-	    die_off(dw, die), dwarf_errmsg(&dw->dw_err));
+	    die_off(dw, die), dwarf_errmsg(dw->dw_err));
 	/*NOTREACHED*/
 	return (0);
 }
@@ -343,7 +340,7 @@ die_attr(dwarf_t *dw, Dwarf_Die die, Dwa
 	}
 
 	terminate("die %llu: failed to get attribute for type: %s\n",
-	    die_off(dw, die), dwarf_errmsg(&dw->dw_err));
+	    die_off(dw, die), dwarf_errmsg(dw->dw_err));
 	/*NOTREACHED*/
 	return (NULL);
 }
@@ -353,10 +350,10 @@ die_signed(dwarf_t *dw, Dwarf_Die die, D
     int req)
 {
 	*valp = 0;
-	if (dwarf_attrval_signed(die, name, valp, &dw->dw_err) != DWARF_E_NONE) {
+	if (dwarf_attrval_signed(die, name, valp, &dw->dw_err) != DW_DLV_OK) {
 		if (req) 
 			terminate("die %llu: failed to get signed: %s\n",
-			    die_off(dw, die), dwarf_errmsg(&dw->dw_err));
+			    die_off(dw, die), dwarf_errmsg(dw->dw_err));
 		return (0);
 	}
 
@@ -368,10 +365,10 @@ die_unsigned(dwarf_t *dw, Dwarf_Die die,
     int req)
 {
 	*valp = 0;
-	if (dwarf_attrval_unsigned(die, name, valp, &dw->dw_err) != DWARF_E_NONE) {
+	if (dwarf_attrval_unsigned(die, name, valp, &dw->dw_err) != DW_DLV_OK) {
 		if (req) 
 			terminate("die %llu: failed to get unsigned: %s\n",
-			    die_off(dw, die), dwarf_errmsg(&dw->dw_err));
+			    die_off(dw, die), dwarf_errmsg(dw->dw_err));
 		return (0);
 	}
 
@@ -383,10 +380,10 @@ die_bool(dwarf_t *dw, Dwarf_Die die, Dwa
 {
 	*valp = 0;
 
-	if (dwarf_attrval_flag(die, name, valp, &dw->dw_err) != DWARF_E_NONE) {
+	if (dwarf_attrval_flag(die, name, valp, &dw->dw_err) != DW_DLV_OK) {
 		if (req) 
 			terminate("die %llu: failed to get flag: %s\n",
-			    die_off(dw, die), dwarf_errmsg(&dw->dw_err));
+			    die_off(dw, die), dwarf_errmsg(dw->dw_err));
 		return (0);
 	}
 
@@ -398,11 +395,11 @@ die_string(dwarf_t *dw, Dwarf_Die die, D
 {
 	const char *str = NULL;
 
-	if (dwarf_attrval_string(die, name, &str, &dw->dw_err) != DWARF_E_NONE ||
+	if (dwarf_attrval_string(die, name, &str, &dw->dw_err) != DW_DLV_OK ||
 	    str == NULL) {
 		if (req) 
 			terminate("die %llu: failed to get string: %s\n",
-			    die_off(dw, die), dwarf_errmsg(&dw->dw_err));
+			    die_off(dw, die), dwarf_errmsg(dw->dw_err));
 		else
 			*strp = NULL;
 		return (0);
@@ -417,9 +414,9 @@ die_attr_ref(dwarf_t *dw, Dwarf_Die die,
 {
 	Dwarf_Off off;
 
-	if (dwarf_attrval_unsigned(die, name, &off, &dw->dw_err) != DWARF_E_NONE) {
+	if (dwarf_attrval_unsigned(die, name, &off, &dw->dw_err) != DW_DLV_OK) {
 		terminate("die %llu: failed to get ref: %s\n",
-		    die_off(dw, die), dwarf_errmsg(&dw->dw_err));
+		    die_off(dw, die), dwarf_errmsg(dw->dw_err));
 	}
 
 	return (off);
@@ -431,6 +428,8 @@ die_name(dwarf_t *dw, Dwarf_Die die)
 	char *str = NULL;
 
 	(void) die_string(dw, die, DW_AT_name, &str, 0);
+	if (str == NULL)
+		str = xstrdup("");
 
 	return (str);
 }
@@ -489,21 +488,73 @@ die_mem_offset(dwarf_t *dw, Dwarf_Die di
 {
 	Dwarf_Locdesc *loc = NULL;
 	Dwarf_Signed locnum = 0;
+	Dwarf_Attribute at;
+	Dwarf_Half form;
+
+	if (name != DW_AT_data_member_location)
+		terminate("die %llu: can only process attribute "
+		    "DW_AT_data_member_location\n", die_off(dw, die));
 
-	if (dwarf_locdesc(die, name, &loc, &locnum, &dw->dw_err) != DW_DLV_OK)
+	if ((at = die_attr(dw, die, name, 0)) == NULL)
 		return (0);
 
-	if (locnum != 1 || loc->ld_s->lr_atom != DW_OP_plus_uconst) {
-		terminate("die %llu: cannot parse member offset\n",
-		    die_off(dw, die));
-	}
+	if (dwarf_whatform(at, &form, &dw->dw_err) != DW_DLV_OK)
+		return (0);
+
+	switch (form) {
+	case DW_FORM_sec_offset:
+	case DW_FORM_block:
+	case DW_FORM_block1:
+	case DW_FORM_block2:
+	case DW_FORM_block4:
+		/*
+		 * GCC in base and Clang (3.3 or below) generates
+		 * DW_AT_data_member_location attribute with DW_FORM_block*
+		 * form. The attribute contains one DW_OP_plus_uconst
+		 * operator. The member offset stores in the operand.
+		 */
+		if (dwarf_loclist(at, &loc, &locnum, &dw->dw_err) != DW_DLV_OK)
+			return (0);
+		if (locnum != 1 || loc->ld_s->lr_atom != DW_OP_plus_uconst) {
+			terminate("die %llu: cannot parse member offset with "
+			    "operator other than DW_OP_plus_uconst\n",
+			    die_off(dw, die));
+		}
+		*valp = loc->ld_s->lr_number;
+		if (loc != NULL) {
+			dwarf_dealloc(dw->dw_dw, loc->ld_s, DW_DLA_LOC_BLOCK);
+			dwarf_dealloc(dw->dw_dw, loc, DW_DLA_LOCDESC);
+		}
+		break;
 
-	*valp = loc->ld_s->lr_number;
+	case DW_FORM_data1:
+	case DW_FORM_data2:
+	case DW_FORM_data4:
+	case DW_FORM_data8:
+	case DW_FORM_udata:
+		/*
+		 * Clang 3.4 generates DW_AT_data_member_location attribute
+		 * with DW_FORM_data* form (constant class). The attribute
+		 * stores a contant value which is the member offset.
+		 *
+		 * However, note that DW_FORM_data[48] in DWARF version 2 or 3
+		 * could be used as a section offset (offset into .debug_loc in
+		 * this case). Here we assume the attribute always stores a
+		 * constant because we know Clang 3.4 does this and GCC in
+		 * base won't emit DW_FORM_data[48] for this attribute. This
+		 * code will remain correct if future vesrions of Clang and
+		 * GCC conform to DWARF4 standard and only use the form
+		 * DW_FORM_sec_offset for section offset.
+		 */
+		if (dwarf_attrval_unsigned(die, name, valp, &dw->dw_err) !=
+		    DW_DLV_OK)
+			return (0);
+		break;
 
-	if (loc != NULL)
-		if (dwarf_locdesc_free(loc, &dw->dw_err) != DW_DLV_OK)
-			terminate("die %llu: cannot free location descriptor: %s\n",
-			    die_off(dw, die), dwarf_errmsg(&dw->dw_err));
+	default:
+		terminate("die %llu: cannot parse member offset with form "
+		    "%u\n", die_off(dw, die), form);
+	}
 
 	return (1);
 }
@@ -884,7 +935,7 @@ static void
 die_sou_create(dwarf_t *dw, Dwarf_Die str, Dwarf_Off off, tdesc_t *tdp,
     int type, const char *typename)
 {
-	Dwarf_Unsigned sz, bitsz, bitoff, maxsz=0;
+	Dwarf_Unsigned sz, bysz, bitsz, bitoff, maxsz=0;
 	Dwarf_Die mem;
 	mlist_t *ml, **mlastp;
 	iidesc_t *ii;
@@ -959,8 +1010,26 @@ die_sou_create(dwarf_t *dw, Dwarf_Die st
 #if BYTE_ORDER == _BIG_ENDIAN
 			ml->ml_offset += bitoff;
 #else
-			ml->ml_offset += tdesc_bitsize(ml->ml_type) - bitoff -
-			    ml->ml_size;
+			/*
+			 * Note that Clang 3.4 will sometimes generate
+			 * member DIE before generating the DIE for the
+			 * member's type. The code can not handle this
+			 * properly so that tdesc_bitsize(ml->ml_type) will
+			 * return 0 because ml->ml_type is unknown. As a
+			 * result, a wrong member offset will be calculated.
+			 * To workaround this, we can instead try to
+			 * retrieve the value of DW_AT_byte_size attribute
+			 * which stores the byte size of the space occupied
+			 * by the type. If this attribute exists, its value
+			 * should equal to tdesc_bitsize(ml->ml_type)/NBBY.
+			 */
+			if (die_unsigned(dw, mem, DW_AT_byte_size, &bysz, 0) &&
+			    bysz > 0)
+				ml->ml_offset += bysz * NBBY - bitoff -
+				    ml->ml_size;
+			else
+				ml->ml_offset += tdesc_bitsize(ml->ml_type) -
+				    bitoff - ml->ml_size;
 #endif
 		}
 
@@ -1852,7 +1921,7 @@ int
 dw_read(tdata_t *td, Elf *elf, char *filename __unused)
 {
 	Dwarf_Unsigned abboff, hdrlen, nxthdr;
-	Dwarf_Half vers, addrsz;
+	Dwarf_Half vers, addrsz, offsz;
 	Dwarf_Die cu = 0;
 	Dwarf_Die child = 0;
 	dwarf_t dw;
@@ -1869,7 +1938,7 @@ dw_read(tdata_t *td, Elf *elf, char *fil
 	dw.dw_enumhash = hash_new(TDESC_HASH_BUCKETS, tdesc_namehash,
 	    tdesc_namecmp);
 
-	if ((rc = dwarf_elf_init(elf, DW_DLC_READ, &dw.dw_dw,
+	if ((rc = dwarf_elf_init(elf, DW_DLC_READ, NULL, NULL, &dw.dw_dw,
 	    &dw.dw_err)) == DW_DLV_NO_ENTRY) {
 		if (should_have_dwarf(elf)) {
 			errno = ENOENT;
@@ -1878,7 +1947,7 @@ dw_read(tdata_t *td, Elf *elf, char *fil
 			return (0);
 		}
 	} else if (rc != DW_DLV_OK) {
-		if (dwarf_errno(&dw.dw_err) == DW_DLE_DEBUG_INFO_NULL) {
+		if (dwarf_errno(dw.dw_err) == DW_DLE_DEBUG_INFO_NULL) {
 			/*
 			 * There's no type data in the DWARF section, but
 			 * libdwarf is too clever to handle that properly.
@@ -1887,12 +1956,12 @@ dw_read(tdata_t *td, Elf *elf, char *fil
 		}
 
 		terminate("failed to initialize DWARF: %s\n",
-		    dwarf_errmsg(&dw.dw_err));
+		    dwarf_errmsg(dw.dw_err));
 	}
 
-	if ((rc = dwarf_next_cu_header(dw.dw_dw, &hdrlen, &vers, &abboff,
-	    &addrsz, &nxthdr, &dw.dw_err)) != DW_DLV_OK)
-		terminate("rc = %d %s\n", rc, dwarf_errmsg(&dw.dw_err));
+	if ((rc = dwarf_next_cu_header_b(dw.dw_dw, &hdrlen, &vers, &abboff,
+	    &addrsz, &offsz, NULL, &nxthdr, &dw.dw_err)) != DW_DLV_OK)
+		terminate("rc = %d %s\n", rc, dwarf_errmsg(dw.dw_err));
 
 	if ((cu = die_sibling(&dw, NULL)) == NULL ||
 	    (((child = die_child(&dw, cu)) == NULL) &&
@@ -1909,9 +1978,9 @@ dw_read(tdata_t *td, Elf *elf, char *fil
 		terminate("file contains too many types\n");
 
 	debug(1, "DWARF version: %d\n", vers);
-	if (vers != DWARF_VERSION) {
+	if (vers < 2 || vers > 4) {
 		terminate("file contains incompatible version %d DWARF code "
-		    "(version 2 required)\n", vers);
+		    "(version 2, 3 or 4 required)\n", vers);
 	}
 
 	if (die_string(&dw, cu, DW_AT_producer, &prod, 0)) {
@@ -1930,11 +1999,11 @@ dw_read(tdata_t *td, Elf *elf, char *fil
 	if ((child = die_child(&dw, cu)) != NULL)
 		die_create(&dw, child);
 
-	if ((rc = dwarf_next_cu_header(dw.dw_dw, &hdrlen, &vers, &abboff,
-	    &addrsz, &nxthdr, &dw.dw_err)) != DW_DLV_NO_ENTRY)
+	if ((rc = dwarf_next_cu_header_b(dw.dw_dw, &hdrlen, &vers, &abboff,
+	    &addrsz, &offsz, NULL, &nxthdr, &dw.dw_err)) != DW_DLV_NO_ENTRY)
 		terminate("multiple compilation units not supported\n");
 
-	(void) dwarf_finish(&dw.dw_dw, &dw.dw_err);
+	(void) dwarf_finish(dw.dw_dw, &dw.dw_err);
 
 	die_resolve(&dw);
 

Modified: head/lib/libdwarf/Makefile
==============================================================================
--- head/lib/libdwarf/Makefile	Tue Jan 28 21:30:05 2014	(r261245)
+++ head/lib/libdwarf/Makefile	Tue Jan 28 21:38:54 2014	(r261246)
@@ -1,9 +1,16 @@
 # $FreeBSD$
+.include <bsd.own.mk>
+
+TOP=	${.CURDIR}/../../contrib/elftoolchain
+SRCDIR=	${TOP}/libdwarf
+
+.PATH:	${SRCDIR}
 
 LIB=	dwarf
 
 SRCS=	\
 	dwarf_abbrev.c		\
+	dwarf_arange.c		\
 	dwarf_attr.c		\
 	dwarf_attrval.c		\
 	dwarf_cu.c		\
@@ -11,19 +18,329 @@ SRCS=	\
 	dwarf_die.c		\
 	dwarf_dump.c		\
 	dwarf_errmsg.c		\
-	dwarf_errno.c		\
 	dwarf_finish.c		\
 	dwarf_form.c		\
-	dwarf_func.c		\
+	dwarf_frame.c		\
+	dwarf_funcs.c		\
 	dwarf_init.c		\
-	dwarf_loc.c
+	dwarf_lineno.c		\
+	dwarf_loclist.c		\
+	dwarf_macinfo.c		\
+	dwarf_pro_arange.c	\
+	dwarf_pro_attr.c	\
+	dwarf_pro_die.c		\
+	dwarf_pro_expr.c	\
+	dwarf_pro_finish.c	\
+	dwarf_pro_frame.c	\
+	dwarf_pro_funcs.c	\
+	dwarf_pro_init.c	\
+	dwarf_pro_lineno.c	\
+	dwarf_pro_macinfo.c	\
+	dwarf_pro_pubnames.c	\
+	dwarf_pro_reloc.c	\
+	dwarf_pro_sections.c	\
+	dwarf_pro_types.c	\
+	dwarf_pro_vars.c	\
+	dwarf_pro_weaks.c	\
+	dwarf_pubnames.c	\
+	dwarf_pubtypes.c	\
+	dwarf_ranges.c		\
+	dwarf_reloc.c		\
+	dwarf_seterror.c	\
+	dwarf_str.c		\
+	dwarf_types.c		\
+	dwarf_vars.c		\
+	dwarf_weaks.c		\
+	libdwarf.c		\
+	libdwarf_abbrev.c	\
+	libdwarf_arange.c	\
+	libdwarf_attr.c		\
+	libdwarf_die.c		\
+	libdwarf_error.c	\
+	libdwarf_elf_access.c	\
+	libdwarf_elf_init.c	\
+	libdwarf_frame.c	\
+	libdwarf_info.c		\
+	libdwarf_init.c		\
+	libdwarf_lineno.c	\
+	libdwarf_loc.c		\
+	libdwarf_loclist.c	\
+	libdwarf_macinfo.c	\
+	libdwarf_nametbl.c	\
+	libdwarf_ranges.c	\
+	libdwarf_reloc.c	\
+	libdwarf_rw.c		\
+	libdwarf_sections.c	\
+	libdwarf_str.c
+
+INCS=		dwarf.h libdwarf.h
+
+#
+# We need to link against the correct version of these files. One
+# solution is to include ../../sys in the include path. This causes
+# problems when a header file in sys depends on a file in another
+# part of the tree, e.g. a machine dependent header.
+#
+SRCS+=	sys/elf32.h sys/elf64.h sys/elf_common.h
+
+GENSRCS=	dwarf_pubnames.c dwarf_pubtypes.c dwarf_weaks.c \
+		dwarf_funcs.c dwarf_vars.c dwarf_types.c	\
+		dwarf_pro_pubnames.c dwarf_pro_weaks.c		\
+		dwarf_pro_funcs.c dwarf_pro_types.c		\
+		dwarf_pro_vars.c
+CLEANFILES=	${GENSRCS}
+CLEANDIRS=	sys
+CFLAGS+=	-I. -I${SRCDIR} -I${TOP}/common -I${TOP}/libelf
 
-INCS=	dwarf.h libdwarf.h
+sys/elf32.h sys/elf64.h sys/elf_common.h: ${.CURDIR}/../../sys/${.TARGET}
+	mkdir -p ${.OBJDIR}/sys
+	ln -sf ${.CURDIR}/../../sys/${.TARGET} ${.TARGET}
 
-CFLAGS+=	-I${.CURDIR}
+LDADD+=		-lelf
+DPADD+=		${LIBELF}
 
-SHLIB_MAJOR=	3
+SHLIB_MAJOR=	4
 
-WITHOUT_MAN=
+MAN=	dwarf.3                                         \
+	dwarf_add_arange.3				\
+	dwarf_add_AT_comp_dir.3				\
+	dwarf_add_AT_const_value_string.3		\
+	dwarf_add_AT_dataref.3				\
+	dwarf_add_AT_flag.3				\
+	dwarf_add_AT_location_expr.3			\
+	dwarf_add_AT_name.3				\
+	dwarf_add_AT_producer.3				\
+	dwarf_add_AT_ref_address.3			\
+	dwarf_add_AT_reference.3			\
+	dwarf_add_AT_signed_const.3			\
+	dwarf_add_AT_string.3				\
+	dwarf_add_AT_targ_address.3			\
+	dwarf_add_die_to_debug.3			\
+	dwarf_add_directory_decl.3			\
+	dwarf_add_expr_addr.3				\
+	dwarf_add_expr_gen.3				\
+	dwarf_add_fde_inst.3				\
+	dwarf_add_file_decl.3				\
+	dwarf_add_frame_cie.3				\
+	dwarf_add_frame_fde.3				\
+	dwarf_add_funcname.3				\
+	dwarf_add_line_entry.3				\
+	dwarf_add_pubname.3				\
+	dwarf_add_typename.3				\
+	dwarf_add_varname.3				\
+	dwarf_add_weakname.3				\
+	dwarf_attr.3					\
+	dwarf_attrlist.3				\
+	dwarf_attrval_signed.3				\
+	dwarf_child.3					\
+	dwarf_dealloc.3					\
+	dwarf_def_macro.3				\
+	dwarf_die_abbrev_code.3				\
+	dwarf_die_link.3				\
+	dwarf_diename.3					\
+	dwarf_dieoffset.3				\
+	dwarf_end_macro_file.3				\
+	dwarf_errmsg.3					\
+	dwarf_errno.3					\
+	dwarf_expand_frame_instructions.3		\
+	dwarf_expr_current_offset.3			\
+	dwarf_expr_into_block.3				\
+	dwarf_fde_cfa_offset.3				\
+	dwarf_find_macro_value_start.3			\
+	dwarf_finish.3					\
+	dwarf_formaddr.3				\
+	dwarf_formblock.3				\
+	dwarf_formexprloc.3				\
+	dwarf_formflag.3				\
+	dwarf_formref.3					\
+	dwarf_formsig8.3				\
+	dwarf_formstring.3				\
+	dwarf_formudata.3				\
+	dwarf_get_abbrev.3				\
+	dwarf_get_abbrev_children_flag.3		\
+	dwarf_get_abbrev_code.3				\
+	dwarf_get_abbrev_entry.3			\
+	dwarf_get_abbrev_tag.3				\
+	dwarf_get_address_size.3			\
+	dwarf_get_arange.3				\
+	dwarf_get_arange_info.3				\
+	dwarf_get_aranges.3				\
+	dwarf_get_AT_name.3				\
+	dwarf_get_cie_index.3				\
+	dwarf_get_cie_info.3				\
+	dwarf_get_cie_of_fde.3				\
+	dwarf_get_cu_die_offset.3			\
+	dwarf_get_elf.3					\
+	dwarf_get_fde_at_pc.3				\
+	dwarf_get_fde_info_for_all_regs.3		\
+	dwarf_get_fde_info_for_all_regs3.3		\
+	dwarf_get_fde_info_for_cfa_reg3.3		\
+	dwarf_get_fde_info_for_reg.3			\
+	dwarf_get_fde_info_for_reg3.3			\
+	dwarf_get_fde_instr_bytes.3			\
+	dwarf_get_fde_list.3				\
+	dwarf_get_fde_n.3				\
+	dwarf_get_fde_range.3				\
+	dwarf_get_form_class.3				\
+	dwarf_get_funcs.3				\
+	dwarf_get_globals.3				\
+	dwarf_get_loclist_entry.3			\
+	dwarf_get_macro_details.3			\
+	dwarf_get_pubtypes.3				\
+	dwarf_get_ranges.3				\
+	dwarf_get_relocation_info.3			\
+	dwarf_get_relocation_info_count.3		\
+	dwarf_get_section_bytes.3			\
+	dwarf_get_str.3					\
+	dwarf_get_types.3				\
+	dwarf_get_vars.3				\
+	dwarf_get_weaks.3				\
+	dwarf_hasattr.3					\
+	dwarf_hasform.3					\
+	dwarf_highpc.3					\
+	dwarf_init.3					\
+	dwarf_lineno.3					\
+	dwarf_lne_end_sequence.3			\
+	dwarf_lne_set_address.3				\
+	dwarf_loclist.3					\
+	dwarf_loclist_from_expr.3			\
+	dwarf_new_die.3					\
+	dwarf_new_expr.3				\
+	dwarf_new_fde.3					\
+	dwarf_next_cu_header.3				\
+	dwarf_object_init.3				\
+	dwarf_producer_init.3				\
+	dwarf_producer_set_isa.3			\
+	dwarf_reset_section_bytes.3			\
+	dwarf_seterrarg.3				\
+	dwarf_set_frame_cfa_value.3			\
+	dwarf_set_reloc_application.3			\
+	dwarf_srcfiles.3				\
+	dwarf_srclines.3				\
+	dwarf_start_macro_file.3			\
+	dwarf_tag.3					\
+	dwarf_transform_to_disk_form.3			\
+	dwarf_undef_macro.3				\
+	dwarf_vendor_ext.3				\
+	dwarf_whatattr.3
+
+MLINKS+= \
+	dwarf_add_AT_const_value_string.3 dwarf_add_AT_const_value_signedint.3 \
+	dwarf_add_AT_const_value_string.3 dwarf_add_AT_const_value_unsignedint.3 \
+	dwarf_add_AT_signed_const.3 dwarf_add_AT_unsigned_const.3 \
+	dwarf_add_AT_targ_address.3 dwarf_add_AT_targ_address_b.3 \
+	dwarf_add_arange.3	dwarf_add_arange_b.3	\
+	dwarf_add_expr_addr.3	dwarf_add_expr_addr_b.3	\
+	dwarf_add_frame_fde.3	dwarf_add_frame_fde_b.3	\
+	dwarf_attrval_signed.3	dwarf_attrval_flag.3	\
+	dwarf_attrval_signed.3	dwarf_attrval_string.3	\
+	dwarf_attrval_signed.3	dwarf_attrval_unsigned.3 \
+	dwarf_child.3	dwarf_offdie.3			\
+	dwarf_child.3	dwarf_siblingof.3		\
+	dwarf_dealloc.3	dwarf_fde_cie_list_dealloc.3	\
+	dwarf_dealloc.3	dwarf_funcs_dealloc.3		\
+	dwarf_dealloc.3	dwarf_globals_dealloc.3		\
+	dwarf_dealloc.3	dwarf_pubtypes_dealloc.3	\
+	dwarf_dealloc.3	dwarf_types_dealloc.3		\
+	dwarf_dealloc.3	dwarf_vars_dealloc.3		\
+	dwarf_dealloc.3	dwarf_weaks_dealloc.3		\
+	dwarf_dealloc.3	dwarf_ranges_dealloc.3		\
+	dwarf_dealloc.3	dwarf_srclines_dealloc.3	\
+	dwarf_init.3	dwarf_elf_init.3		\
+	dwarf_dieoffset.3	dwarf_die_CU_offset.3	\
+	dwarf_dieoffset.3	dwarf_die_CU_offset_range.3 \
+	dwarf_dieoffset.3	dwarf_get_cu_die_offset_given_cu_header_offset.3 \
+	dwarf_finish.3		dwarf_object_finish.3	\
+	dwarf_formref.3	dwarf_global_formref.3		\
+	dwarf_formudata.3	dwarf_formsdata.3	\
+	dwarf_get_AT_name.3	dwarf_get_ACCESS_name.3	\
+	dwarf_get_AT_name.3	dwarf_get_ATE_name.3	\
+	dwarf_get_AT_name.3	dwarf_get_CC_name.3	\
+	dwarf_get_AT_name.3	dwarf_get_CFA_name.3	\
+	dwarf_get_AT_name.3	dwarf_get_CHILDREN_name.3 \
+	dwarf_get_AT_name.3	dwarf_get_DS_name.3	\
+	dwarf_get_AT_name.3	dwarf_get_DSC_name.3	\
+	dwarf_get_AT_name.3	dwarf_get_EH_name.3	\
+	dwarf_get_AT_name.3	dwarf_get_END_name.3	\
+	dwarf_get_AT_name.3	dwarf_get_FORM_name.3	\
+	dwarf_get_AT_name.3	dwarf_get_ID_name.3	\
+	dwarf_get_AT_name.3	dwarf_get_INL_name.3	\
+	dwarf_get_AT_name.3	dwarf_get_LANG_name.3	\
+	dwarf_get_AT_name.3	dwarf_get_LNE_name.3	\
+	dwarf_get_AT_name.3	dwarf_get_LNS_name.3	\
+	dwarf_get_AT_name.3	dwarf_get_MACINFO_name.3 \
+	dwarf_get_AT_name.3	dwarf_get_OP_name.3	\
+	dwarf_get_AT_name.3	dwarf_get_ORD_name.3	\
+	dwarf_get_AT_name.3	dwarf_get_TAG_name.3	\
+	dwarf_get_AT_name.3	dwarf_get_VIRTUALITY_name.3 \
+	dwarf_get_AT_name.3	dwarf_get_VIS_name.3	\
+	dwarf_get_cu_die_offset.3 dwarf_get_arange_cu_header_offset.3 \
+	dwarf_get_fde_list.3	dwarf_get_fde_list_eh.3	\
+	dwarf_get_funcs.3	dwarf_func_die_offset.3	\
+	dwarf_get_funcs.3	dwarf_func_cu_offset.3	\
+	dwarf_get_funcs.3	dwarf_func_name_offsets.3 \
+	dwarf_get_funcs.3	dwarf_funcname.3	\
+	dwarf_get_globals.3	dwarf_global_die_offset.3 \
+	dwarf_get_globals.3	dwarf_global_cu_offset.3 \
+	dwarf_get_globals.3	dwarf_global_name_offsets.3 \
+	dwarf_get_globals.3	dwarf_globname.3	\
+	dwarf_get_pubtypes.3	dwarf_pubtype_die_offset.3 \
+	dwarf_get_pubtypes.3	dwarf_pubtype_cu_offset.3 \
+	dwarf_get_pubtypes.3	dwarf_pubtype_name_offsets.3 \
+	dwarf_get_pubtypes.3	dwarf_pubtypename.3	\
+	dwarf_get_ranges.3	dwarf_get_ranges_a.3	\
+	dwarf_get_types.3	dwarf_type_die_offset.3	\
+	dwarf_get_types.3	dwarf_type_cu_offset.3	\
+	dwarf_get_types.3	dwarf_type_name_offsets.3 \
+	dwarf_get_types.3	dwarf_typename.3	\
+	dwarf_get_vars.3	dwarf_var_die_offset.3	\
+	dwarf_get_vars.3	dwarf_var_cu_offset.3	\
+	dwarf_get_vars.3	dwarf_var_name_offsets.3 \
+	dwarf_get_vars.3	dwarf_varname.3		\
+	dwarf_get_weaks.3	dwarf_weak_die_offset.3	\
+	dwarf_get_weaks.3	dwarf_weak_cu_offset.3	\
+	dwarf_get_weaks.3	dwarf_weak_name_offsets.3 \
+	dwarf_get_weaks.3	dwarf_weakname.3	\
+	dwarf_hasform.3	dwarf_whatform.3		\
+	dwarf_hasform.3	dwarf_whatform_direct.3		\
+	dwarf_highpc.3	dwarf_arrayorder.3		\
+	dwarf_highpc.3	dwarf_bitoffset.3		\
+	dwarf_highpc.3	dwarf_bitsize.3			\
+	dwarf_highpc.3	dwarf_bytesize.3		\
+	dwarf_highpc.3	dwarf_lowpc.3			\
+	dwarf_highpc.3	dwarf_srclang.3			\
+	dwarf_lineno.3	dwarf_lineaddr.3		\
+	dwarf_lineno.3	dwarf_linebeginstatement.3	\
+	dwarf_lineno.3	dwarf_lineblock.3		\
+	dwarf_lineno.3	dwarf_lineendsequence.3		\
+	dwarf_lineno.3	dwarf_lineoff.3			\
+	dwarf_lineno.3	dwarf_linesrc.3			\
+	dwarf_lineno.3	dwarf_line_srcfileno.3		\
+	dwarf_loclist.3	dwarf_loclist_n.3		\
+	dwarf_loclist_from_expr.3 dwarf_loclist_from_expr_a.3 \
+	dwarf_producer_init.3 dwarf_producer_init_b.3	\
+	dwarf_seterrarg.3	dwarf_seterrhand.3	\
+	dwarf_set_frame_cfa_value.3 dwarf_set_frame_rule_initial_value.3 \
+	dwarf_set_frame_cfa_value.3 dwarf_set_frame_rule_table_size.3 \
+	dwarf_set_frame_cfa_value.3 dwarf_set_frame_same_value.3 \
+	dwarf_set_frame_cfa_value.3 dwarf_set_frame_undefined_value.3
+
+dwarf_pubnames.c:	dwarf_nametbl.m4 dwarf_pubnames.m4
+dwarf_pubtypes.c:	dwarf_nametbl.m4 dwarf_pubtypes.m4
+dwarf_weaks.c:		dwarf_nametbl.m4 dwarf_weaks.m4
+dwarf_funcs.c:		dwarf_nametbl.m4 dwarf_funcs.m4
+dwarf_vars.c:		dwarf_nametbl.m4 dwarf_vars.m4
+dwarf_types.c:		dwarf_nametbl.m4 dwarf_types.m4
+dwarf_pro_pubnames.c:	dwarf_pro_nametbl.m4 dwarf_pro_pubnames.m4
+dwarf_pro_weaks.c:	dwarf_pro_nametbl.m4 dwarf_pro_weaks.m4
+dwarf_pro_funcs.c:	dwarf_pro_nametbl.m4 dwarf_pro_funcs.m4
+dwarf_pro_types.c:	dwarf_pro_nametbl.m4 dwarf_pro_types.m4
+dwarf_pro_vars.c:	dwarf_pro_nametbl.m4 dwarf_pro_vars.m4
 
 .include <bsd.lib.mk>
+
+# Keep the .SUFFIXES line after the include of bsd.lib.mk
+.SUFFIXES:	.m4 .c
+.m4.c:
+	m4 -D SRCDIR=${SRCDIR} ${M4FLAGS} ${.IMPSRC} > ${.TARGET}
+

Modified: head/lib/libelf/Makefile
==============================================================================
--- head/lib/libelf/Makefile	Tue Jan 28 21:30:05 2014	(r261245)
+++ head/lib/libelf/Makefile	Tue Jan 28 21:38:54 2014	(r261246)
@@ -1,8 +1,15 @@
 # $FreeBSD$
+.include <bsd.own.mk>
+
+TOP=	${.CURDIR}/../../contrib/elftoolchain
+SRCDIR=	${TOP}/libelf
+
+.PATH:	${SRCDIR}
 
 LIB=	elf
 
-SRCS=	elf_begin.c						\
+SRCS=	elf.c							\
+	elf_begin.c						\
 	elf_cntl.c						\
 	elf_end.c elf_errmsg.c elf_errno.c			\
 	elf_data.c						\
@@ -16,6 +23,7 @@ SRCS=	elf_begin.c						\
 	elf_kind.c						\
 	elf_memory.c						\
 	elf_next.c						\
+	elf_open.c						\
 	elf_rand.c						\
 	elf_rawfile.c						\
 	elf_phnum.c						\
@@ -40,7 +48,6 @@ SRCS=	elf_begin.c						\
 	gelf_syminfo.c						\
 	gelf_symshndx.c						\
 	gelf_xlate.c						\
-	libelf.c						\
 	libelf_align.c						\
 	libelf_allocate.c					\
 	libelf_ar.c						\
@@ -49,11 +56,14 @@ SRCS=	elf_begin.c						\
 	libelf_data.c						\
 	libelf_ehdr.c						\
 	libelf_extended.c					\
+	libelf_memory.c						\
+	libelf_open.c						\
 	libelf_phdr.c						\
 	libelf_shdr.c						\
 	libelf_xlate.c						\
 	${GENSRCS}
-INCS=	libelf.h gelf.h
+
+INCS=		libelf.h gelf.h
 
 #
 # We need to link against the correct version of these files. One
@@ -66,13 +76,13 @@ SRCS+=	sys/elf32.h sys/elf64.h sys/elf_c
 GENSRCS=	libelf_fsize.c libelf_msize.c libelf_convert.c
 CLEANFILES=	${GENSRCS}
 CLEANDIRS=	sys
-CFLAGS+=	-I${.CURDIR} -I.
+CFLAGS+=	-I. -I${SRCDIR} -I${TOP}/common
 
 sys/elf32.h sys/elf64.h sys/elf_common.h: ${.CURDIR}/../../sys/${.TARGET}
 	mkdir -p ${.OBJDIR}/sys
 	ln -sf ${.CURDIR}/../../sys/${.TARGET} ${.TARGET}
 
-SHLIB_MAJOR=	1
+SHLIB_MAJOR=	2
 
 MAN=	elf.3							\
 	elf_begin.3						\
@@ -97,6 +107,7 @@ MAN=	elf.3							\
 	elf_kind.3						\
 	elf_memory.3						\
 	elf_next.3						\
+	elf_open.3						\
 	elf_rawfile.3						\
 	elf_rand.3						\
 	elf_strptr.3						\
@@ -124,6 +135,7 @@ MAN=	elf.3							\
 
 MLINKS+= \
 	elf_errmsg.3 elf_errno.3		\
+	elf_flagdata.3 elf_flagarhdr.3		\
 	elf_flagdata.3 elf_flagehdr.3		\
 	elf_flagdata.3 elf_flagelf.3		\
 	elf_flagdata.3 elf_flagphdr.3		\
@@ -135,6 +147,7 @@ MLINKS+= \
 	elf_getscn.3 elf_newscn.3		\
 	elf_getscn.3 elf_nextscn.3		\
 	elf_getshstrndx.3 elf_setshstrndx.3	\
+	elf_open.3 elf_openmemory.3             \
 	gelf_getcap.3 gelf_update_cap.3		\
 	gelf_getdyn.3 gelf_update_dyn.3		\
 	gelf_getmove.3 gelf_update_move.3	\
@@ -160,12 +173,7 @@ MLINKS+= \
 	gelf_xlatetof.3	elf${E}_xlatetom.3
 .endfor
 
-VERSION_MAP=		${.CURDIR}/Version.map
-
-LIBELF_TEST_HOOKS?=	1
-.if defined(LIBELF_TEST_HOOKS) && (${LIBELF_TEST_HOOKS} > 0)
-CFLAGS+= -DLIBELF_TEST_HOOKS
-.endif
+VERSION_MAP=           ${SRCDIR}/Version.map
 
 libelf_convert.c:	elf_types.m4 libelf_convert.m4
 libelf_fsize.c:		elf_types.m4 libelf_fsize.m4
@@ -176,4 +184,5 @@ libelf_msize.c:		elf_types.m4 libelf_msi
 # Keep the .SUFFIXES line after the include of bsd.lib.mk
 .SUFFIXES:	.m4 .c
 .m4.c:
-	m4 -D SRCDIR=${.CURDIR} ${.IMPSRC} > ${.TARGET}
+	m4 -D SRCDIR=${SRCDIR} ${M4FLAGS} ${.IMPSRC} > ${.TARGET}
+

Modified: head/sys/sys/elf_common.h
==============================================================================
--- head/sys/sys/elf_common.h	Tue Jan 28 21:30:05 2014	(r261245)
+++ head/sys/sys/elf_common.h	Tue Jan 28 21:38:54 2014	(r261246)
@@ -280,6 +280,7 @@ typedef struct {
 #define	SHT_SUNW_cap		0x6ffffff5
 #define	SHT_SUNW_SIGNATURE	0x6ffffff6
 #define	SHT_GNU_HASH		0x6ffffff6
+#define	SHT_GNU_LIBLIST		0x6ffffff7
 #define	SHT_SUNW_ANNOTATE	0x6ffffff7
 #define	SHT_SUNW_DEBUGSTR	0x6ffffff8
 #define	SHT_SUNW_DEBUG		0x6ffffff9
@@ -769,6 +770,7 @@ typedef struct {
 #define	R_MIPS_PC16	10	/* PC relative 16 bit */
 #define	R_MIPS_CALL16	11	/* 16 bit GOT entry for function */
 #define	R_MIPS_GPREL32	12	/* GP relative 32 bit */
+#define	R_MIPS_64	18	/* Direct 64 bit */
 #define	R_MIPS_GOTHI16	21	/* GOT HI 16 bit */
 #define	R_MIPS_GOTLO16	22	/* GOT LO 16 bit */
 #define	R_MIPS_CALLHI16 30	/* upper 16 bit GOT entry for function */

Modified: head/sys/sys/param.h
==============================================================================
--- head/sys/sys/param.h	Tue Jan 28 21:30:05 2014	(r261245)
+++ head/sys/sys/param.h	Tue Jan 28 21:38:54 2014	(r261246)
@@ -58,7 +58,7 @@
  *		in the range 5 to 9.
  */
 #undef __FreeBSD_version
-#define __FreeBSD_version 1100005	/* Master, propagated to newvers */
+#define __FreeBSD_version 1100006	/* Master, propagated to newvers */
 
 /*
  * __FreeBSD_kernel__ indicates that this system uses the kernel of FreeBSD,


More information about the svn-src-head mailing list