From owner-svn-src-vendor@freebsd.org Thu May 19 20:06:58 2016 Return-Path: Delivered-To: svn-src-vendor@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 89463B4221D; Thu, 19 May 2016 20:06:58 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 25AC71FCE; Thu, 19 May 2016 20:06:58 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u4JK6vTR090735; Thu, 19 May 2016 20:06:57 GMT (envelope-from emaste@FreeBSD.org) Received: (from emaste@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u4JK6uUN090722; Thu, 19 May 2016 20:06:56 GMT (envelope-from emaste@FreeBSD.org) Message-Id: <201605192006.u4JK6uUN090722@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: emaste set sender to emaste@FreeBSD.org using -f From: Ed Maste Date: Thu, 19 May 2016 20:06:56 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-vendor@freebsd.org Subject: svn commit: r300228 - in vendor/elftoolchain/dist: addr2line brandelf common cxxfilt elfcopy elfdump findtextrel ld libdwarf libelf libelftc libpe nm readelf size strings test/cxxfilt test/cxxfilt/... X-SVN-Group: vendor MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-vendor@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for the vendor work area tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 19 May 2016 20:06:58 -0000 Author: emaste Date: Thu May 19 20:06:56 2016 New Revision: 300228 URL: https://svnweb.freebsd.org/changeset/base/300228 Log: Import ELF Tool Chain snapshot at revision 3475 From http://svn.code.sf.net/p/elftoolchain/code/ Added: vendor/elftoolchain/dist/ld/ld.1 (contents, props changed) vendor/elftoolchain/dist/libelftc/elftc_reloc_type_str.3 (contents, props changed) vendor/elftoolchain/dist/libelftc/elftc_reloc_type_str.c (contents, props changed) vendor/elftoolchain/dist/test/cxxfilt/ vendor/elftoolchain/dist/test/cxxfilt/Makefile (contents, props changed) vendor/elftoolchain/dist/test/cxxfilt/tet_scen vendor/elftoolchain/dist/test/cxxfilt/tetexec.cfg vendor/elftoolchain/dist/test/cxxfilt/ts/ vendor/elftoolchain/dist/test/cxxfilt/ts/Makefile (contents, props changed) vendor/elftoolchain/dist/test/cxxfilt/ts/common/ vendor/elftoolchain/dist/test/cxxfilt/ts/common/func.sh (contents, props changed) vendor/elftoolchain/dist/test/cxxfilt/ts/common/gen.awk (contents, props changed) vendor/elftoolchain/dist/test/cxxfilt/ts/common/ts.mk (contents, props changed) vendor/elftoolchain/dist/test/cxxfilt/ts/misc/ vendor/elftoolchain/dist/test/cxxfilt/ts/misc/Makefile (contents, props changed) vendor/elftoolchain/dist/test/cxxfilt/ts/misc/tclist Modified: vendor/elftoolchain/dist/addr2line/addr2line.c vendor/elftoolchain/dist/brandelf/brandelf.c vendor/elftoolchain/dist/common/_elftc.h vendor/elftoolchain/dist/common/elfdefinitions.h vendor/elftoolchain/dist/cxxfilt/cxxfilt.c vendor/elftoolchain/dist/elfcopy/ascii.c vendor/elftoolchain/dist/elfcopy/binary.c vendor/elftoolchain/dist/elfcopy/elfcopy.1 vendor/elftoolchain/dist/elfcopy/elfcopy.h vendor/elftoolchain/dist/elfcopy/main.c vendor/elftoolchain/dist/elfcopy/sections.c vendor/elftoolchain/dist/elfcopy/segments.c vendor/elftoolchain/dist/elfcopy/symbols.c vendor/elftoolchain/dist/elfdump/elfdump.c vendor/elftoolchain/dist/findtextrel/findtextrel.c vendor/elftoolchain/dist/ld/Makefile vendor/elftoolchain/dist/ld/amd64.c vendor/elftoolchain/dist/ld/i386.c vendor/elftoolchain/dist/ld/ld_options.c vendor/elftoolchain/dist/ld/ld_options.h vendor/elftoolchain/dist/libdwarf/libdwarf_abbrev.c vendor/elftoolchain/dist/libdwarf/libdwarf_elf_init.c vendor/elftoolchain/dist/libelf/_libelf_config.h vendor/elftoolchain/dist/libelf/elf_data.c vendor/elftoolchain/dist/libelf/libelf_ar.c vendor/elftoolchain/dist/libelf/libelf_convert.m4 vendor/elftoolchain/dist/libelftc/Makefile vendor/elftoolchain/dist/libelftc/libelftc.h vendor/elftoolchain/dist/libelftc/libelftc_dem_arm.c vendor/elftoolchain/dist/libelftc/libelftc_dem_gnu2.c vendor/elftoolchain/dist/libelftc/libelftc_dem_gnu3.c vendor/elftoolchain/dist/libelftc/make-toolchain-version vendor/elftoolchain/dist/libpe/libpe_section.c vendor/elftoolchain/dist/libpe/pe.h vendor/elftoolchain/dist/nm/nm.c vendor/elftoolchain/dist/readelf/readelf.c vendor/elftoolchain/dist/size/size.c vendor/elftoolchain/dist/strings/strings.c vendor/elftoolchain/dist/test/elfdump/ts/dso1/@S@p%libelf.so.out vendor/elftoolchain/dist/test/elfdump/ts/dso1/@c@p@n%libelf.so.out vendor/elftoolchain/dist/test/elfdump/ts/dso1/@e@p@c%libelf.so.out vendor/elftoolchain/dist/test/elfdump/ts/dso1/@p%libelf.so.out vendor/elftoolchain/dist/test/elfdump/ts/dso1/@p@s%libelf.so.out vendor/elftoolchain/dist/test/elfdump/ts/dso2/@S@p%test.so.out vendor/elftoolchain/dist/test/elfdump/ts/dso2/@c@p@n%test.so.out vendor/elftoolchain/dist/test/elfdump/ts/dso2/@e@p@c%test.so.out vendor/elftoolchain/dist/test/elfdump/ts/dso2/@p%test.so.out vendor/elftoolchain/dist/test/elfdump/ts/dso2/@p@s%test.so.out vendor/elftoolchain/dist/test/elfdump/ts/exec1/@S@e@p%ls.out vendor/elftoolchain/dist/test/elfdump/ts/exec1/@c@p@n%ls.out vendor/elftoolchain/dist/test/elfdump/ts/exec1/@e@p%ls.out vendor/elftoolchain/dist/test/elfdump/ts/exec1/@e@p@c@d%ls.out vendor/elftoolchain/dist/test/elfdump/ts/exec1/@p@e%ls.out vendor/elftoolchain/dist/test/elfdump/ts/exec1/@p@n%ls.out vendor/elftoolchain/dist/test/elfdump/ts/exec1/@p@s%ls.out vendor/elftoolchain/dist/test/elfdump/ts/exec2/@S@n%cp.out Modified: vendor/elftoolchain/dist/addr2line/addr2line.c ============================================================================== --- vendor/elftoolchain/dist/addr2line/addr2line.c Thu May 19 20:03:01 2016 (r300227) +++ vendor/elftoolchain/dist/addr2line/addr2line.c Thu May 19 20:06:56 2016 (r300228) @@ -40,7 +40,7 @@ #include "uthash.h" #include "_elftc.h" -ELFTC_VCSID("$Id: addr2line.c 3273 2015-12-11 21:38:57Z kaiwang27 $"); +ELFTC_VCSID("$Id: addr2line.c 3446 2016-05-03 01:31:17Z emaste $"); struct Func { char *name; @@ -284,7 +284,7 @@ collect_func(Dwarf_Debug dbg, Dwarf_Die &de) == DW_DLV_OK) goto add_func; - /* Skip if no name assoicated with this DIE. */ + /* Skip if no name associated with this DIE. */ goto cont_search; add_func: Modified: vendor/elftoolchain/dist/brandelf/brandelf.c ============================================================================== --- vendor/elftoolchain/dist/brandelf/brandelf.c Thu May 19 20:03:01 2016 (r300227) +++ vendor/elftoolchain/dist/brandelf/brandelf.c Thu May 19 20:06:56 2016 (r300228) @@ -44,7 +44,7 @@ #include "_elftc.h" -ELFTC_VCSID("$Id: brandelf.c 3354 2016-01-18 21:50:15Z jkoshy $"); +ELFTC_VCSID("$Id: brandelf.c 3440 2016-04-07 14:51:47Z emaste $"); static int elftype(const char *); static const char *iselftype(int); @@ -62,6 +62,7 @@ static struct ELFtypes elftypes[] = { { "AIX", ELFOSABI_AIX }, { "ARM", ELFOSABI_ARM }, { "AROS", ELFOSABI_AROS }, + { "CloudABI", ELFOSABI_CLOUDABI }, { "FreeBSD", ELFOSABI_FREEBSD }, { "GNU", ELFOSABI_GNU }, { "HP/UX", ELFOSABI_HPUX}, Modified: vendor/elftoolchain/dist/common/_elftc.h ============================================================================== --- vendor/elftoolchain/dist/common/_elftc.h Thu May 19 20:03:01 2016 (r300227) +++ vendor/elftoolchain/dist/common/_elftc.h Thu May 19 20:06:56 2016 (r300228) @@ -23,11 +23,11 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: _elftc.h 3244 2015-08-31 19:53:08Z emaste $ + * $Id: _elftc.h 3446 2016-05-03 01:31:17Z emaste $ */ /** - ** Miscellanous definitions needed by multiple components. + ** Miscellaneous definitions needed by multiple components. **/ #ifndef _ELFTC_H Modified: vendor/elftoolchain/dist/common/elfdefinitions.h ============================================================================== --- vendor/elftoolchain/dist/common/elfdefinitions.h Thu May 19 20:03:01 2016 (r300227) +++ vendor/elftoolchain/dist/common/elfdefinitions.h Thu May 19 20:06:56 2016 (r300228) @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: elfdefinitions.h 3392 2016-02-05 19:51:22Z emaste $ + * $Id: elfdefinitions.h 3455 2016-05-09 13:47:29Z emaste $ */ /* @@ -184,6 +184,10 @@ _ELF_DEFINE_DT(DT_ADDRRNGLO, 0x6F "start of range using the d_ptr field") \ _ELF_DEFINE_DT(DT_GNU_HASH, 0x6FFFFEF5UL, \ "GNU style hash tables") \ +_ELF_DEFINE_DT(DT_TLSDESC_PLT, 0x6FFFFEF6UL, \ + "location of PLT entry for TLS descriptor resolver calls") \ +_ELF_DEFINE_DT(DT_TLSDESC_GOT, 0x6FFFFEF7UL, \ + "location of GOT entry used by TLS descriptor resolver PLT entry") \ _ELF_DEFINE_DT(DT_GNU_CONFLICT, 0x6FFFFEF8UL, \ "address of conflict section") \ _ELF_DEFINE_DT(DT_GNU_LIBLIST, 0x6FFFFEF9UL, \ @@ -269,7 +273,7 @@ _ELF_DEFINE_DT(DT_MIPS_DELTA_RELOC, 0x70 _ELF_DEFINE_DT(DT_MIPS_DELTA_RELOC_NO, 0x7000001CUL, \ "number of entries in DT_MIPS_DELTA_RELOC") \ _ELF_DEFINE_DT(DT_MIPS_DELTA_SYM, 0x7000001DUL, \ - "Delta symbols refered by Delta relocations") \ + "Delta symbols referred by Delta relocations") \ _ELF_DEFINE_DT(DT_MIPS_DELTA_SYM_NO, 0x7000001EUL, \ "number of entries in DT_MIPS_DELTA_SYM") \ _ELF_DEFINE_DT(DT_MIPS_DELTA_CLASSSYM, 0x70000020UL, \ @@ -540,6 +544,7 @@ _ELF_DEFINE_EABI(ELFOSABI_NSK, 14 _ELF_DEFINE_EABI(ELFOSABI_AROS, 15, "Amiga Research OS") \ _ELF_DEFINE_EABI(ELFOSABI_FENIXOS, 16, \ "The FenixOS highly scalable multi-core OS") \ +_ELF_DEFINE_EABI(ELFOSABI_CLOUDABI, 17, "Nuxi CloudABI") \ _ELF_DEFINE_EABI(ELFOSABI_ARM_AEABI, 64, \ "ARM specific symbol versioning extensions") \ _ELF_DEFINE_EABI(ELFOSABI_ARM, 97, "ARM ABI") \ @@ -1193,7 +1198,7 @@ _ELF_DEFINE_SHT(SHT_MIPS_ABIFLAGS, 0x7 "ABI flags") \ _ELF_DEFINE_SHT(SHT_SPARC_GOTDATA, 0x70000000UL, \ "SPARC-specific data") \ -_ELF_DEFINE_SHT(SHT_AMD64_UNWIND, 0x70000001UL, \ +_ELF_DEFINE_SHT(SHT_X86_64_UNWIND, 0x70000001UL, \ "unwind tables for the AMD64") \ _ELF_DEFINE_SHT(SHT_ORDERED, 0x7FFFFFFFUL, \ "sort entries in the section") \ @@ -1212,6 +1217,7 @@ enum { }; /* Aliases for section types. */ +#define SHT_AMD64_UNWIND SHT_X86_64_UNWIND #define SHT_GNU_verdef SHT_SUNW_verdef #define SHT_GNU_verneed SHT_SUNW_verneed #define SHT_GNU_versym SHT_SUNW_versym @@ -1255,6 +1261,7 @@ _ELF_DEFINE_STT(STT_FILE, 4, _ELF_DEFINE_STT(STT_COMMON, 5, "uninitialized common block") \ _ELF_DEFINE_STT(STT_TLS, 6, "thread local storage") \ _ELF_DEFINE_STT(STT_LOOS, 10, "start of OS-specific types") \ +_ELF_DEFINE_STT(STT_GNU_IFUNC, 10, "indirect function") \ _ELF_DEFINE_STT(STT_HIOS, 12, "end of OS-specific types") \ _ELF_DEFINE_STT(STT_LOPROC, 13, \ "start of processor-specific types") \ @@ -1402,10 +1409,37 @@ _ELF_DEFINE_RELOC(R_386_RELATIVE, 8) \ _ELF_DEFINE_RELOC(R_386_GOTOFF, 9) \ _ELF_DEFINE_RELOC(R_386_GOTPC, 10) \ _ELF_DEFINE_RELOC(R_386_32PLT, 11) \ +_ELF_DEFINE_RELOC(R_386_TLS_TPOFF, 14) \ +_ELF_DEFINE_RELOC(R_386_TLS_IE, 15) \ +_ELF_DEFINE_RELOC(R_386_TLS_GOTIE, 16) \ +_ELF_DEFINE_RELOC(R_386_TLS_LE, 17) \ +_ELF_DEFINE_RELOC(R_386_TLS_GD, 18) \ +_ELF_DEFINE_RELOC(R_386_TLS_LDM, 19) \ _ELF_DEFINE_RELOC(R_386_16, 20) \ _ELF_DEFINE_RELOC(R_386_PC16, 21) \ _ELF_DEFINE_RELOC(R_386_8, 22) \ -_ELF_DEFINE_RELOC(R_386_PC8, 23) +_ELF_DEFINE_RELOC(R_386_PC8, 23) \ +_ELF_DEFINE_RELOC(R_386_TLS_GD_32, 24) \ +_ELF_DEFINE_RELOC(R_386_TLS_GD_PUSH, 25) \ +_ELF_DEFINE_RELOC(R_386_TLS_GD_CALL, 26) \ +_ELF_DEFINE_RELOC(R_386_TLS_GD_POP, 27) \ +_ELF_DEFINE_RELOC(R_386_TLS_LDM_32, 28) \ +_ELF_DEFINE_RELOC(R_386_TLS_LDM_PUSH, 29) \ +_ELF_DEFINE_RELOC(R_386_TLS_LDM_CALL, 30) \ +_ELF_DEFINE_RELOC(R_386_TLS_LDM_POP, 31) \ +_ELF_DEFINE_RELOC(R_386_TLS_LDO_32, 32) \ +_ELF_DEFINE_RELOC(R_386_TLS_IE_32, 33) \ +_ELF_DEFINE_RELOC(R_386_TLS_LE_32, 34) \ +_ELF_DEFINE_RELOC(R_386_TLS_DTPMOD32, 35) \ +_ELF_DEFINE_RELOC(R_386_TLS_DTPOFF32, 36) \ +_ELF_DEFINE_RELOC(R_386_TLS_TPOFF32, 37) \ +_ELF_DEFINE_RELOC(R_386_SIZE32, 38) \ +_ELF_DEFINE_RELOC(R_386_TLS_GOTDESC, 39) \ +_ELF_DEFINE_RELOC(R_386_TLS_DESC_CALL, 40) \ +_ELF_DEFINE_RELOC(R_386_TLS_DESC, 41) \ +_ELF_DEFINE_RELOC(R_386_IRELATIVE, 42) \ +_ELF_DEFINE_RELOC(R_386_GOT32X, 43) + /* */ @@ -1795,11 +1829,18 @@ _ELF_DEFINE_RELOC(R_MIPS_GOT16, 9) \ _ELF_DEFINE_RELOC(R_MIPS_PC16, 10) \ _ELF_DEFINE_RELOC(R_MIPS_CALL16, 11) \ _ELF_DEFINE_RELOC(R_MIPS_GPREL32, 12) \ +_ELF_DEFINE_RELOC(R_MIPS_SHIFT5, 16) \ +_ELF_DEFINE_RELOC(R_MIPS_SHIFT6, 17) \ _ELF_DEFINE_RELOC(R_MIPS_64, 18) \ -_ELF_DEFINE_RELOC(R_MIPS_GOTHI16, 21) \ -_ELF_DEFINE_RELOC(R_MIPS_GOTLO16, 22) \ +_ELF_DEFINE_RELOC(R_MIPS_GOT_DISP, 19) \ +_ELF_DEFINE_RELOC(R_MIPS_GOT_PAGE, 20) \ +_ELF_DEFINE_RELOC(R_MIPS_GOT_OFST, 21) \ +_ELF_DEFINE_RELOC(R_MIPS_GOT_HI16, 22) \ +_ELF_DEFINE_RELOC(R_MIPS_GOT_LO16, 23) \ +_ELF_DEFINE_RELOC(R_MIPS_SUB, 24) \ _ELF_DEFINE_RELOC(R_MIPS_CALLHI16, 30) \ _ELF_DEFINE_RELOC(R_MIPS_CALLLO16, 31) \ +_ELF_DEFINE_RELOC(R_MIPS_JALR, 37) \ _ELF_DEFINE_RELOC(R_MIPS_TLS_DTPMOD32, 38) \ _ELF_DEFINE_RELOC(R_MIPS_TLS_DTPREL32, 39) \ _ELF_DEFINE_RELOC(R_MIPS_TLS_DTPMOD64, 40) \ @@ -2095,6 +2136,7 @@ _ELF_DEFINE_RELOC(R_SPARC_PC_HM10, 38) \ _ELF_DEFINE_RELOC(R_SPARC_PC_LM22, 39) \ _ELF_DEFINE_RELOC(R_SPARC_WDISP16, 40) \ _ELF_DEFINE_RELOC(R_SPARC_WDISP19, 41) \ +_ELF_DEFINE_RELOC(R_SPARC_GLOB_JMP, 42) \ _ELF_DEFINE_RELOC(R_SPARC_7, 43) \ _ELF_DEFINE_RELOC(R_SPARC_5, 44) \ _ELF_DEFINE_RELOC(R_SPARC_6, 45) \ @@ -2108,6 +2150,30 @@ _ELF_DEFINE_RELOC(R_SPARC_L44, 52) \ _ELF_DEFINE_RELOC(R_SPARC_REGISTER, 53) \ _ELF_DEFINE_RELOC(R_SPARC_UA64, 54) \ _ELF_DEFINE_RELOC(R_SPARC_UA16, 55) \ +_ELF_DEFINE_RELOC(R_SPARC_TLS_GD_HI22, 56) \ +_ELF_DEFINE_RELOC(R_SPARC_TLS_GD_LO10, 57) \ +_ELF_DEFINE_RELOC(R_SPARC_TLS_GD_ADD, 58) \ +_ELF_DEFINE_RELOC(R_SPARC_TLS_GD_CALL, 59) \ +_ELF_DEFINE_RELOC(R_SPARC_TLS_LDM_HI22, 60) \ +_ELF_DEFINE_RELOC(R_SPARC_TLS_LDM_LO10, 61) \ +_ELF_DEFINE_RELOC(R_SPARC_TLS_LDM_ADD, 62) \ +_ELF_DEFINE_RELOC(R_SPARC_TLS_LDM_CALL, 63) \ +_ELF_DEFINE_RELOC(R_SPARC_TLS_LDO_HIX22, 64) \ +_ELF_DEFINE_RELOC(R_SPARC_TLS_LDO_LOX10, 65) \ +_ELF_DEFINE_RELOC(R_SPARC_TLS_LDO_ADD, 66) \ +_ELF_DEFINE_RELOC(R_SPARC_TLS_IE_HI22, 67) \ +_ELF_DEFINE_RELOC(R_SPARC_TLS_IE_LO10, 68) \ +_ELF_DEFINE_RELOC(R_SPARC_TLS_IE_LD, 69) \ +_ELF_DEFINE_RELOC(R_SPARC_TLS_IE_LDX, 70) \ +_ELF_DEFINE_RELOC(R_SPARC_TLS_IE_ADD, 71) \ +_ELF_DEFINE_RELOC(R_SPARC_TLS_LE_HIX22, 72) \ +_ELF_DEFINE_RELOC(R_SPARC_TLS_LE_LOX10, 73) \ +_ELF_DEFINE_RELOC(R_SPARC_TLS_DTPMOD32, 74) \ +_ELF_DEFINE_RELOC(R_SPARC_TLS_DTPMOD64, 75) \ +_ELF_DEFINE_RELOC(R_SPARC_TLS_DTPOFF32, 76) \ +_ELF_DEFINE_RELOC(R_SPARC_TLS_DTPOFF64, 77) \ +_ELF_DEFINE_RELOC(R_SPARC_TLS_TPOFF32, 78) \ +_ELF_DEFINE_RELOC(R_SPARC_TLS_TPOFF64, 79) \ _ELF_DEFINE_RELOC(R_SPARC_GOTDATA_HIX22, 80) \ _ELF_DEFINE_RELOC(R_SPARC_GOTDATA_LOX10, 81) \ _ELF_DEFINE_RELOC(R_SPARC_GOTDATA_OP_HIX22, 82) \ @@ -2153,7 +2219,10 @@ _ELF_DEFINE_RELOC(R_X86_64_SIZE64, 33) \ _ELF_DEFINE_RELOC(R_X86_64_GOTPC32_TLSDESC, 34) \ _ELF_DEFINE_RELOC(R_X86_64_TLSDESC_CALL, 35) \ _ELF_DEFINE_RELOC(R_X86_64_TLSDESC, 36) \ -_ELF_DEFINE_RELOC(R_X86_64_IRELATIVE, 37) +_ELF_DEFINE_RELOC(R_X86_64_IRELATIVE, 37) \ +_ELF_DEFINE_RELOC(R_X86_64_RELATIVE64, 38) \ +_ELF_DEFINE_RELOC(R_X86_64_GOTPCRELX, 41) \ +_ELF_DEFINE_RELOC(R_X86_64_REX_GOTPCRELX, 42) #define _ELF_DEFINE_RELOCATIONS() \ _ELF_DEFINE_386_RELOCATIONS() \ @@ -2424,7 +2493,7 @@ _ELF_DEFINE_ODK(ODK_HWOR, 8, _ELF_DEFINE_ODK(ODK_GP_GROUP, 9, \ "GP group to use for text/data sections") \ _ELF_DEFINE_ODK(ODK_IDENT, 10, "ID information") \ -_ELF_DEFINE_ODK(ODK_PAGESIZE, 11, "page size infomation") +_ELF_DEFINE_ODK(ODK_PAGESIZE, 11, "page size information") #undef _ELF_DEFINE_ODK #define _ELF_DEFINE_ODK(N, V, DESCR) N = V , Modified: vendor/elftoolchain/dist/cxxfilt/cxxfilt.c ============================================================================== --- vendor/elftoolchain/dist/cxxfilt/cxxfilt.c Thu May 19 20:03:01 2016 (r300227) +++ vendor/elftoolchain/dist/cxxfilt/cxxfilt.c Thu May 19 20:06:56 2016 (r300228) @@ -35,7 +35,7 @@ #include "_elftc.h" -ELFTC_VCSID("$Id: cxxfilt.c 3356 2016-01-22 22:31:38Z jkoshy $"); +ELFTC_VCSID("$Id: cxxfilt.c 3454 2016-05-07 17:11:05Z kaiwang27 $"); #define STRBUFSZ 8192 @@ -112,35 +112,18 @@ find_format(const char *fstr) } static char * -demangle(char *name, int strict, size_t *pos) +demangle(char *name) { static char dem[STRBUFSZ]; - char nb[STRBUFSZ]; - size_t p, t; - if (stripus && *name == '_') { - strncpy(nb, name + 1, sizeof(nb) - 1); - t = 1; - } else { - strncpy(nb, name, sizeof(nb) - 1); - t = 0; - } - nb[sizeof(nb) - 1] = '\0'; + if (stripus && *name == '_') + name++; - p = strlen(nb); - if (p == 0) - return NULL; - - while (elftc_demangle(nb, dem, sizeof(dem), (unsigned) format) < 0) { - if (!strict && p > 1) { - nb[--p] = '\0'; - continue; - } else - return (NULL); - } + if (strlen(name) == 0) + return (NULL); - if (pos != NULL) - *pos = t ? p + 1 : p; + if (elftc_demangle(name, dem, sizeof(dem), (unsigned) format) < 0) + return (NULL); return (dem); } @@ -149,7 +132,7 @@ int main(int argc, char **argv) { char *dem, buf[STRBUFSZ]; - size_t i, p, s; + size_t p; int c, n, opt; while ((opt = getopt_long(argc, argv, "_nps:V", longopts, NULL)) != @@ -184,8 +167,8 @@ main(int argc, char **argv) if (*argv != NULL) { for (n = 0; n < argc; n++) { - if ((dem = demangle(argv[n], 1, NULL)) == NULL) - fprintf(stderr, "Failed: %s\n", argv[n]); + if ((dem = demangle(argv[n])) == NULL) + printf("%s\n", argv[n]); else printf("%s\n", dem); } @@ -193,23 +176,18 @@ main(int argc, char **argv) p = 0; for (;;) { c = fgetc(stdin); - if (c == EOF || !isprint(c) || strchr(" \t\n", c)) { + if (c == EOF || !(isalnum(c) || strchr(".$_", c))) { if (p > 0) { buf[p] = '\0'; - if ((dem = demangle(buf, 0, &s)) == - NULL) + if ((dem = demangle(buf)) == NULL) printf("%s", buf); - else { + else printf("%s", dem); - for (i = s; i < p; i++) - putchar(buf[i]); - } p = 0; } if (c == EOF) break; - if (isprint(c) || strchr(" \t\n", c)) - putchar(c); + putchar(c); } else { if ((size_t) p >= sizeof(buf) - 1) warnx("buffer overflowed"); Modified: vendor/elftoolchain/dist/elfcopy/ascii.c ============================================================================== --- vendor/elftoolchain/dist/elfcopy/ascii.c Thu May 19 20:03:01 2016 (r300227) +++ vendor/elftoolchain/dist/elfcopy/ascii.c Thu May 19 20:06:56 2016 (r300228) @@ -36,7 +36,7 @@ #include "elfcopy.h" -ELFTC_VCSID("$Id: ascii.c 3177 2015-03-30 18:19:41Z emaste $"); +ELFTC_VCSID("$Id: ascii.c 3446 2016-05-03 01:31:17Z emaste $"); static void append_data(struct section *s, const void *buf, size_t sz); static char hex_digit(uint8_t n); @@ -187,7 +187,7 @@ create_srec(struct elfcopy *ecp, int ifd if (elferr != 0) warnx("elf_nextscn failed: %s", elf_errmsg(elferr)); - /* Generate S{7,8,9} end of block recrod. */ + /* Generate S{7,8,9} end of block record. */ if (gelf_getehdr(e, &eh) == NULL) errx(EXIT_FAILURE, "gelf_getehdr() failed: %s", elf_errmsg(-1)); Modified: vendor/elftoolchain/dist/elfcopy/binary.c ============================================================================== --- vendor/elftoolchain/dist/elfcopy/binary.c Thu May 19 20:03:01 2016 (r300227) +++ vendor/elftoolchain/dist/elfcopy/binary.c Thu May 19 20:06:56 2016 (r300228) @@ -26,6 +26,7 @@ #include #include +#include #include #include #include @@ -35,7 +36,7 @@ #include "elfcopy.h" -ELFTC_VCSID("$Id: binary.c 3270 2015-12-11 18:48:56Z emaste $"); +ELFTC_VCSID("$Id: binary.c 3445 2016-04-20 19:08:30Z emaste $"); /* * Convert ELF object to `binary'. Sections with SHF_ALLOC flag set @@ -213,9 +214,9 @@ create_elf_from_binary(struct elfcopy *e if ((sym_basename = strdup(ifn)) == NULL) err(1, "strdup"); - p = sym_basename; - while ((p = strchr(p, '.')) != NULL) - *p++ = '_'; + for (p = sym_basename; *p != '\0'; p++) + if (!isalnum(*p)) + *p = '_'; #define _GEN_SYMNAME(S) do { \ snprintf(name, sizeof(name), "%s%s%s", "_binary_", sym_basename, S); \ } while (0) Modified: vendor/elftoolchain/dist/elfcopy/elfcopy.1 ============================================================================== --- vendor/elftoolchain/dist/elfcopy/elfcopy.1 Thu May 19 20:03:01 2016 (r300227) +++ vendor/elftoolchain/dist/elfcopy/elfcopy.1 Thu May 19 20:06:56 2016 (r300228) @@ -21,9 +21,9 @@ .\" out of the use of this software, even if advised of the possibility of .\" such damage. .\" -.\" $Id: elfcopy.1 3381 2016-01-30 19:39:47Z jkoshy $ +.\" $Id: elfcopy.1 3426 2016-03-05 13:32:28Z emaste $ .\" -.Dd January 29, 2016 +.Dd March 5, 2016 .Os .Dt ELFCOPY 1 .Sh NAME @@ -67,7 +67,10 @@ .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 -globalize-symbol Ns = Ns ar symbolname +.Op Fl -globalize-symbols Ns = Ns Ar filename .Op Fl -localize-hidden +.Op Fl -localize-symbols Ns = Ns Ar filename .Op Fl -no-adjust-warnings | Fl -no-change-warnings .Op Fl -only-keep-debug .Op Fl -pad-to Ns = Ns Ar address @@ -239,9 +242,21 @@ Copy only .dwo debug sections to the out Fill the gaps between sections with the byte value specified by the argument .Ar val . +.It Fl -globalize-symbol Ns = Ns Ar symbolname +Make the symbol named by argument +.Ar symbolname +global, so that it is visible outside of the file in which it is defined. +.It Fl -globalize-symbols Ns = Ns Ar filename +Make each symbol listed in the file specified by +.Ar filename +global. .It Fl -localize-hidden Make all hidden symbols local to the output file. This includes symbols with internal visiblity. +.It Fl -localize-symbols Ns = Ns Ar filename +Make each symbol listed in the file specified by +.Ar filename +local to the output file. .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 , Modified: vendor/elftoolchain/dist/elfcopy/elfcopy.h ============================================================================== --- vendor/elftoolchain/dist/elfcopy/elfcopy.h Thu May 19 20:03:01 2016 (r300227) +++ vendor/elftoolchain/dist/elfcopy/elfcopy.h Thu May 19 20:06:56 2016 (r300228) @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: elfcopy.h 3310 2016-01-10 09:10:54Z kaiwang27 $ + * $Id: elfcopy.h 3446 2016-05-03 01:31:17Z emaste $ */ #include @@ -139,7 +139,8 @@ struct section { /* Internal data structure for segments. */ struct segment { - uint64_t addr; /* load addr */ + uint64_t vaddr; /* virtual addr (VMA) */ + uint64_t paddr; /* physical addr (LMA) */ uint64_t off; /* file offset */ uint64_t fsz; /* file size */ uint64_t msz; /* memory size */ @@ -177,7 +178,7 @@ struct elfcopy { Elftc_Bfd_Target_Flavor otf; /* flavour of output object */ const char *otgt; /* output target name */ int oec; /* elfclass of output object */ - unsigned char oed; /* endianess of output object */ + unsigned char oed; /* endianness of output object */ int oem; /* EM_XXX of output object */ int abi; /* OSABI of output object */ Elf *ein; /* ELF descriptor of input object */ @@ -237,7 +238,7 @@ struct elfcopy { uint64_t *secndx; /* section index map. */ uint64_t *symndx; /* symbol index map. */ unsigned char *v_rel; /* symbols needed by relocation. */ - unsigned char *v_grp; /* symbols refered by section group. */ + unsigned char *v_grp; /* symbols referred by section group. */ unsigned char *v_secsym; /* sections with section symbol. */ STAILQ_HEAD(, segment) v_seg; /* list of segments. */ STAILQ_HEAD(, sec_action) v_sac;/* list of section operations. */ Modified: vendor/elftoolchain/dist/elfcopy/main.c ============================================================================== --- vendor/elftoolchain/dist/elfcopy/main.c Thu May 19 20:03:01 2016 (r300227) +++ vendor/elftoolchain/dist/elfcopy/main.c Thu May 19 20:06:56 2016 (r300228) @@ -39,7 +39,7 @@ #include "elfcopy.h" -ELFTC_VCSID("$Id: main.c 3399 2016-02-12 18:07:56Z emaste $"); +ELFTC_VCSID("$Id: main.c 3446 2016-05-03 01:31:17Z emaste $"); enum options { @@ -209,6 +209,7 @@ static struct { {"openbsd", ELFOSABI_OPENBSD}, {"openvms", ELFOSABI_OPENVMS}, {"nsk", ELFOSABI_NSK}, + {"cloudabi", ELFOSABI_CLOUDABI}, {"arm", ELFOSABI_ARM}, {"standalone", ELFOSABI_STANDALONE}, {NULL, 0} @@ -235,7 +236,7 @@ static void strip_main(struct elfcopy *e static void strip_usage(void); /* - * An ELF object usually has a sturcture described by the + * An ELF object usually has a structure described by the * diagram below. * _____________ * | | @@ -641,6 +642,18 @@ create_file(struct elfcopy *ecp, const c * ELF object before processing. */ if (ecp->itf != ETF_ELF) { + /* + * If the output object is not an ELF file, choose an arbitrary + * ELF format for the intermediate file. srec, ihex and binary + * formats are independent of class, endianness and machine + * type so these choices do not affect the output. + */ + if (ecp->otf != ETF_ELF) { + if (ecp->oec == ELFCLASSNONE) + ecp->oec = ELFCLASS64; + if (ecp->oed == ELFDATANONE) + ecp->oed = ELFDATA2LSB; + } create_tempfile(&elftemp, &efd); if ((ecp->eout = elf_begin(efd, ELF_C_WRITE, NULL)) == NULL) errx(EXIT_FAILURE, "elf_begin() failed: %s", @@ -1434,7 +1447,7 @@ Usage: %s [options] infile [outfile]\n\ sections.\n\ --only-keep-debug Copy only debugging information.\n\ --output-target=FORMAT Use the specified format for the output.\n\ - --pad-to=ADDRESS Pad the output object upto the given address.\n\ + --pad-to=ADDRESS Pad the output object up to the given address.\n\ --prefix-alloc-sections=STRING\n\ Prefix the section names of all the allocated\n\ sections with STRING.\n\ Modified: vendor/elftoolchain/dist/elfcopy/sections.c ============================================================================== --- vendor/elftoolchain/dist/elfcopy/sections.c Thu May 19 20:03:01 2016 (r300227) +++ vendor/elftoolchain/dist/elfcopy/sections.c Thu May 19 20:06:56 2016 (r300228) @@ -34,7 +34,7 @@ #include "elfcopy.h" -ELFTC_VCSID("$Id: sections.c 3346 2016-01-17 20:09:15Z kaiwang27 $"); +ELFTC_VCSID("$Id: sections.c 3443 2016-04-15 18:57:54Z kaiwang27 $"); static void add_gnu_debuglink(struct elfcopy *ecp); static uint32_t calc_crc32(const char *p, size_t len, uint32_t crc); @@ -343,7 +343,7 @@ create_scn(struct elfcopy *ecp) GElf_Shdr ish; size_t indx; uint64_t oldndx, newndx; - int elferr, sec_flags; + int elferr, sec_flags, reorder; /* * Insert a pseudo section that contains the ELF header @@ -367,6 +367,7 @@ create_scn(struct elfcopy *ecp) errx(EXIT_FAILURE, "elf_getshstrndx failed: %s", elf_errmsg(-1)); + reorder = 0; is = NULL; while ((is = elf_nextscn(ecp->ein, is)) != NULL) { if (gelf_getshdr(is, &ish) == NULL) @@ -482,8 +483,20 @@ create_scn(struct elfcopy *ecp) /* create section header based on input object. */ if (strcmp(name, ".symtab") != 0 && strcmp(name, ".strtab") != 0 && - strcmp(name, ".shstrtab") != 0) + strcmp(name, ".shstrtab") != 0) { copy_shdr(ecp, s, NULL, 0, sec_flags); + /* + * elfcopy puts .symtab, .strtab and .shstrtab + * sections in the end of the output object. + * If the input objects have more sections + * after any of these 3 sections, the section + * table will be reordered. section symbols + * should be regenerated for relocations. + */ + if (reorder) + ecp->flags &= ~SYMTAB_INTACT; + } else + reorder = 1; if (strcmp(name, ".symtab") == 0) { ecp->flags |= SYMTAB_EXIST; @@ -1519,6 +1532,9 @@ add_gnu_debuglink(struct elfcopy *ecp) err(EXIT_FAILURE, "strdup failed"); if (stat(ecp->debuglink, &sb) == -1) err(EXIT_FAILURE, "stat failed"); + if (sb.st_size == 0) + errx(EXIT_FAILURE, "empty debug link target %s", + ecp->debuglink); if ((buf = malloc(sb.st_size)) == NULL) err(EXIT_FAILURE, "malloc failed"); if ((fp = fopen(ecp->debuglink, "r")) == NULL) Modified: vendor/elftoolchain/dist/elfcopy/segments.c ============================================================================== --- vendor/elftoolchain/dist/elfcopy/segments.c Thu May 19 20:03:01 2016 (r300227) +++ vendor/elftoolchain/dist/elfcopy/segments.c Thu May 19 20:06:56 2016 (r300228) @@ -34,7 +34,7 @@ #include "elfcopy.h" -ELFTC_VCSID("$Id: segments.c 3397 2016-02-12 14:35:19Z emaste $"); +ELFTC_VCSID("$Id: segments.c 3449 2016-05-03 13:59:29Z emaste $"); static void insert_to_inseg_list(struct segment *seg, struct section *sec); @@ -72,12 +72,12 @@ add_to_inseg_list(struct elfcopy *ecp, s */ loadable = 0; STAILQ_FOREACH(seg, &ecp->v_seg, seg_list) { - if (s->off < seg->off || (s->vma < seg->addr && !s->pseudo)) + if (s->off < seg->off || (s->vma < seg->vaddr && !s->pseudo)) continue; if (s->off + s->sz > seg->off + seg->fsz && s->type != SHT_NOBITS) continue; - if (s->vma + s->sz > seg->addr + seg->msz) + if (s->vma + s->sz > seg->vaddr + seg->msz) continue; insert_to_inseg_list(seg, s); @@ -85,7 +85,12 @@ add_to_inseg_list(struct elfcopy *ecp, s s->seg = seg; else if (seg->type == PT_TLS) s->seg_tls = seg; - s->lma = seg->addr + (s->off - seg->off); + if (s->pseudo) + s->vma = seg->vaddr + (s->off - seg->off); + if (seg->paddr > 0) + s->lma = seg->paddr + (s->off - seg->off); + else + s->lma = 0; loadable = 1; } @@ -98,7 +103,7 @@ adjust_addr(struct elfcopy *ecp) struct section *s, *s0; struct segment *seg; struct sec_action *sac; - uint64_t dl, lma, start, end; + uint64_t dl, vma, lma, start, end; int found, i; /* @@ -110,59 +115,52 @@ adjust_addr(struct elfcopy *ecp) if (!s->loadable) continue; + /* Apply global VMA adjustment. */ + if (ecp->change_addr != 0) + s->vma += ecp->change_addr; + /* Apply global LMA adjustment. */ - if (ecp->change_addr != 0 && s->seg != NULL) + if (ecp->change_addr != 0 && s->seg != NULL && + s->seg->paddr > 0) s->lma += ecp->change_addr; - - if (!s->pseudo) { - /* Apply global VMA adjustment. */ - if (ecp->change_addr != 0) - s->vma += ecp->change_addr; - - /* Apply section VMA adjustment. */ - sac = lookup_sec_act(ecp, s->name, 0); - if (sac == NULL) - continue; - if (sac->setvma) - s->vma = sac->vma; - if (sac->vma_adjust != 0) - s->vma += sac->vma_adjust; - } } /* - * Apply sections LMA change in the second iteration. + * Apply sections VMA change in the second iteration. */ TAILQ_FOREACH(s, &ecp->v_sec, sec_list) { - /* - * Only loadable section that's inside a segment can have - * LMA adjusted. - */ - if (!s->loadable || s->seg == NULL) + if (!s->loadable) continue; /* - * Check if there is a LMA change request for this + * Check if there is a VMA change request for this * section. */ sac = lookup_sec_act(ecp, s->name, 0); if (sac == NULL) continue; - if (!sac->setlma && sac->lma_adjust == 0) + vma = s->vma; + if (sac->setvma) + vma = sac->vma; + if (sac->vma_adjust != 0) + vma += sac->vma_adjust; + if (vma == s->vma) continue; - lma = s->lma; - if (sac->setlma) - lma = sac->lma; - if (sac->lma_adjust != 0) - lma += sac->lma_adjust; - if (lma == s->lma) + + /* + * No need to make segment adjustment if the section doesn't + * belong to any segment. + */ + if (s->seg == NULL) { + s->vma = vma; continue; + } /* - * Check if the LMA change is viable. + * Check if the VMA change is viable. * - * 1. Check if the new LMA is properly aligned accroding to + * 1. Check if the new VMA is properly aligned accroding to * section alignment. * * 2. Compute the new extent of segment that contains this @@ -170,37 +168,36 @@ adjust_addr(struct elfcopy *ecp) * segments. */ #ifdef DEBUG - printf("LMA for section %s: %#jx\n", s->name, lma); + printf("VMA for section %s: %#jx\n", s->name, vma); #endif - if (lma % s->align != 0) - errx(EXIT_FAILURE, "The load address %#jx for " + if (vma % s->align != 0) + errx(EXIT_FAILURE, "The VMA %#jx for " "section %s is not aligned to %ju", - (uintmax_t) lma, s->name, (uintmax_t) s->align); + (uintmax_t) vma, s->name, (uintmax_t) s->align); - if (lma < s->lma) { + if (vma < s->vma) { /* Move section to lower address. */ - if (lma < s->lma - s->seg->addr) + if (vma < s->vma - s->seg->vaddr) errx(EXIT_FAILURE, "Not enough space to move " - "section %s load address to %#jx", s->name, - (uintmax_t) lma); - start = lma - (s->lma - s->seg->addr); + "section %s VMA to %#jx", s->name, + (uintmax_t) vma); + start = vma - (s->vma - s->seg->vaddr); if (s == s->seg->v_sec[s->seg->nsec - 1]) end = start + s->seg->msz; else - end = s->seg->addr + s->seg->msz; - + end = s->seg->vaddr + s->seg->msz; } else { /* Move section to upper address. */ if (s == s->seg->v_sec[0]) - start = lma; + start = vma; else - start = s->seg->addr; - end = lma + (s->seg->addr + s->seg->msz - s->lma); + start = s->seg->vaddr; + end = vma + (s->seg->vaddr + s->seg->msz - s->vma); if (end < start) errx(EXIT_FAILURE, "Not enough space to move " - "section %s load address to %#jx", s->name, - (uintmax_t) lma); + "section %s VMA to %#jx", s->name, + (uintmax_t) vma); } #ifdef DEBUG @@ -211,34 +208,34 @@ adjust_addr(struct elfcopy *ecp) STAILQ_FOREACH(seg, &ecp->v_seg, seg_list) { if (seg == s->seg || seg->type != PT_LOAD) continue; - if (start > seg->addr + seg->msz) + if (start > seg->vaddr + seg->msz) continue; - if (end < seg->addr) + if (end < seg->vaddr) continue; errx(EXIT_FAILURE, "The extent of segment containing " "section %s overlaps with segment(%#jx,%#jx)", - s->name, (uintmax_t) seg->addr, - (uintmax_t) (seg->addr + seg->msz)); + s->name, (uintmax_t) seg->vaddr, + (uintmax_t) (seg->vaddr + seg->msz)); } /* - * Update section LMA and file offset. + * Update section VMA and file offset. */ - if (lma < s->lma) { + if (vma < s->vma) { /* - * To move a section to lower load address, we decrease - * the load addresses of the section and all the - * sections that are before it, and we increase the - * file offsets of all the sections that are after it. + * To move a section to lower VMA, we decrease + * the VMA of the section and all the sections that + * are before it, and we increase the file offsets + * of all the sections that are after it. */ - dl = s->lma - lma; + dl = s->vma - vma; for (i = 0; i < s->seg->nsec; i++) { s0 = s->seg->v_sec[i]; - s0->lma -= dl; + s0->vma -= dl; #ifdef DEBUG - printf("section %s LMA set to %#jx\n", - s0->name, (uintmax_t) s0->lma); + printf("section %s VMA set to %#jx\n", + s0->name, (uintmax_t) s0->vma); #endif if (s0 == s) break; @@ -253,13 +250,13 @@ adjust_addr(struct elfcopy *ecp) } } else { /* - * To move a section to upper load address, we increase - * the load addresses of the section and all the - * sections that are after it, and we increase the - * their file offsets too unless the section in question + * To move a section to upper VMA, we increase + * the VMA of the section and all the sections that + * are after it, and we increase the their file + * offsets too unless the section in question * is the first in its containing segment. */ - dl = lma - s->lma; + dl = vma - s->vma; for (i = 0; i < s->seg->nsec; i++) if (s->seg->v_sec[i] == s) break; @@ -269,9 +266,9 @@ adjust_addr(struct elfcopy *ecp) s->name); for (; i < s->seg->nsec; i++) { s0 = s->seg->v_sec[i]; - s0->lma += dl; + s0->vma += dl; #ifdef DEBUG - printf("section %s LMA set to %#jx\n", + printf("section %s VMA set to %#jx\n", s0->name, (uintmax_t) s0->lma); #endif if (s != s->seg->v_sec[0]) { @@ -292,9 +289,8 @@ adjust_addr(struct elfcopy *ecp) if (ecp->pad_to != 0) { /* - * Find the section with highest load address. + * Find the section with highest VMA. */ - s = NULL; STAILQ_FOREACH(seg, &ecp->v_seg, seg_list) { if (seg->type != PT_LOAD) @@ -308,26 +304,113 @@ adjust_addr(struct elfcopy *ecp) s = seg->v_sec[i]; else { s0 = seg->v_sec[i]; - if (s0->lma > s->lma) + if (s0->vma > s->vma) s = s0; } } if (s == NULL) - goto issue_warn; + goto adjust_lma; /* No need to pad if the pad_to address is lower. */ - if (ecp->pad_to <= s->lma + s->sz) - goto issue_warn; + if (ecp->pad_to <= s->vma + s->sz) + goto adjust_lma; - s->pad_sz = ecp->pad_to - (s->lma + s->sz); + s->pad_sz = ecp->pad_to - (s->vma + s->sz); #ifdef DEBUG - printf("pad section %s load to address %#jx by %#jx\n", s->name, + printf("pad section %s VMA to address %#jx by %#jx\n", s->name, (uintmax_t) ecp->pad_to, (uintmax_t) s->pad_sz); #endif } -issue_warn: + +adjust_lma: + + /* + * Apply sections LMA change in the third iteration. + */ + TAILQ_FOREACH(s, &ecp->v_sec, sec_list) { + + /* + * Only loadable section that's inside a segment can have + * LMA adjusted. Also, if LMA of the containing segment is + * set to 0, it probably means we should ignore the LMA. + */ + if (!s->loadable || s->seg == NULL || s->seg->paddr == 0) + continue; + + /* + * Check if there is a LMA change request for this + * section. + */ + sac = lookup_sec_act(ecp, s->name, 0); + if (sac == NULL) + continue; + if (!sac->setlma && sac->lma_adjust == 0) + continue; + lma = s->lma; + if (sac->setlma) + lma = sac->lma; + if (sac->lma_adjust != 0) + lma += sac->lma_adjust; + if (lma == s->lma) + continue; + +#ifdef DEBUG + printf("LMA for section %s: %#jx\n", s->name, lma); +#endif + + /* Check alignment. */ + if (lma % s->align != 0) + errx(EXIT_FAILURE, "The LMA %#jx for " + "section %s is not aligned to %ju", + (uintmax_t) lma, s->name, (uintmax_t) s->align); + + /* + * Update section LMA. + */ + + if (lma < s->lma) { + /* + * To move a section to lower LMA, we decrease + * the LMA of the section and all the sections that + * are before it. + */ + dl = s->lma - lma; + for (i = 0; i < s->seg->nsec; i++) { + s0 = s->seg->v_sec[i]; + s0->lma -= dl; +#ifdef DEBUG + printf("section %s LMA set to %#jx\n", + s0->name, (uintmax_t) s0->lma); +#endif + if (s0 == s) + break; + } + } else { + /* + * To move a section to upper LMA, we increase + * the LMA of the section and all the sections that + * are after it. + */ + dl = lma - s->lma; + for (i = 0; i < s->seg->nsec; i++) + if (s->seg->v_sec[i] == s) + break; + if (i >= s->seg->nsec) + errx(EXIT_FAILURE, "Internal: section `%s' not" + " found in its containing segement", + s->name); + for (; i < s->seg->nsec; i++) { + s0 = s->seg->v_sec[i]; + s0->lma += dl; +#ifdef DEBUG + printf("section %s LMA set to %#jx\n", + s0->name, (uintmax_t) s0->lma); +#endif + } + } + } /* * Issue a warning if there are VMA/LMA adjust requests for @@ -385,8 +468,7 @@ setup_phdr(struct elfcopy *ecp) { struct segment *seg; GElf_Phdr iphdr; - size_t iphnum; - int i; *** DIFF OUTPUT TRUNCATED AT 1000 LINES ***