From owner-svn-src-head@freebsd.org Tue Jan 2 14:07:56 2018 Return-Path: Delivered-To: svn-src-head@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 CE7F6EA7491; Tue, 2 Jan 2018 14:07:56 +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 925E780441; Tue, 2 Jan 2018 14:07:56 +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 w02E7tIE077774; Tue, 2 Jan 2018 14:07:55 GMT (envelope-from emaste@FreeBSD.org) Received: (from emaste@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w02E7tOp077773; Tue, 2 Jan 2018 14:07:55 GMT (envelope-from emaste@FreeBSD.org) Message-Id: <201801021407.w02E7tOp077773@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: emaste set sender to emaste@FreeBSD.org using -f From: Ed Maste Date: Tue, 2 Jan 2018 14:07:55 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r327489 - head/contrib/elftoolchain/elfcopy X-SVN-Group: head X-SVN-Commit-Author: emaste X-SVN-Commit-Paths: head/contrib/elftoolchain/elfcopy X-SVN-Commit-Revision: 327489 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 02 Jan 2018 14:07:56 -0000 Author: emaste Date: Tue Jan 2 14:07:55 2018 New Revision: 327489 URL: https://svnweb.freebsd.org/changeset/base/327489 Log: elfcopy: copy raw (untranslated) contents to binary output Previously elfcopy used elf_getdata to obtain data from ELF sections being copied to binary output, but elf_getdata returns data that has been translated - that is, data is in host byte order. When the host and target differ in endianness (e.g., converting a big-endian MIPS ELF object to binary on an x86 host) this resulted in byte-swapped data in certain sections such as .dynamic. Instead use elf_rawdata to keep data in the original, target endianness. Reported by: Hiroki Mori , Bill Yuan MFC after: 1 week Sponsored by: The FreeBSD Foundation Modified: head/contrib/elftoolchain/elfcopy/binary.c Modified: head/contrib/elftoolchain/elfcopy/binary.c ============================================================================== --- head/contrib/elftoolchain/elfcopy/binary.c Tue Jan 2 09:02:42 2018 (r327488) +++ head/contrib/elftoolchain/elfcopy/binary.c Tue Jan 2 14:07:55 2018 (r327489) @@ -101,10 +101,10 @@ create_binary(int ifd, int ofd) sh.sh_size == 0) continue; (void) elf_errno(); - if ((d = elf_getdata(scn, NULL)) == NULL) { + if ((d = elf_rawdata(scn, NULL)) == NULL) { elferr = elf_errno(); if (elferr != 0) - warnx("elf_getdata failed: %s", elf_errmsg(-1)); + warnx("elf_rawdata failed: %s", elf_errmsg(-1)); continue; } if (d->d_buf == NULL || d->d_size == 0)