aboutsummaryrefslogtreecommitdiff
path: root/contrib/elftoolchain
diff options
context:
space:
mode:
authorEd Maste <emaste@FreeBSD.org>2018-01-02 14:07:55 +0000
committerEd Maste <emaste@FreeBSD.org>2018-01-02 14:07:55 +0000
commitaadb68849f9be8db8d20c3dca19f882d0ebc8bca (patch)
tree43720cc9298781edb41402e750796be245f9700e /contrib/elftoolchain
parent7d3df1907a893a5195cfab753ca4233c52827a5c (diff)
downloadsrc-aadb68849f9be8db8d20c3dca19f882d0ebc8bca.tar.gz
src-aadb68849f9be8db8d20c3dca19f882d0ebc8bca.zip
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 <yamori83@yahoo.co.jp>, Bill Yuan MFC after: 1 week Sponsored by: The FreeBSD Foundation
Notes
Notes: svn path=/head/; revision=327489
Diffstat (limited to 'contrib/elftoolchain')
-rw-r--r--contrib/elftoolchain/elfcopy/binary.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/contrib/elftoolchain/elfcopy/binary.c b/contrib/elftoolchain/elfcopy/binary.c
index ad86a6533c55..0b56ae0566cd 100644
--- a/contrib/elftoolchain/elfcopy/binary.c
+++ b/contrib/elftoolchain/elfcopy/binary.c
@@ -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)