3
3
This file is part of the UPX executable compressor.
5
Copyright (C) 1996-2007 Markus Franz Xaver Johannes Oberhumer
6
Copyright (C) 1996-2007 Laszlo Molnar
7
Copyright (C) 2001-2007 John F. Reiser
5
Copyright (C) 1996-2008 Markus Franz Xaver Johannes Oberhumer
6
Copyright (C) 1996-2008 Laszlo Molnar
7
Copyright (C) 2001-2008 John F. Reiser
10
10
UPX and the UCL library are free software; you can redistribute them
23
23
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
25
25
Markus F.X.J. Oberhumer Laszlo Molnar
26
<mfx@users.sourceforge.net> <ml1050@users.sourceforge.net>
26
<markus@oberhumer.com> <ml1050@users.sourceforge.net>
29
29
<jreiser@users.sourceforge.net>
526
526
ei_osabi = osabi0; // Proudly declares its osabi in Ehdr.
529
unsigned const e_phnum = get_native16(&ehdr.e_phnum);
529
unsigned const e_phnum = get_te16(&ehdr.e_phnum);
530
530
if (e_phnum<=(512/sizeof(Elf32_Phdr))) {
532
fi->seek(get_native32(&ehdr.e_phoff), SEEK_SET);
532
fi->seek(get_te32(&ehdr.e_phoff), SEEK_SET);
533
533
fi->readx(buf2, sizeof(buf2));
534
534
fi->seek(0, SEEK_SET);
535
535
Elf32_Phdr const *phdr = (Elf32_Phdr const *)buf2;
536
536
for (unsigned j=0; j < e_phnum; ++phdr, ++j) {
537
if (phdr->PT_NOTE == get_native32(&phdr->p_type)) {
538
unsigned const offset = get_native32(&phdr->p_offset);
537
if (phdr->PT_NOTE == get_te32(&phdr->p_type)) {
538
unsigned const offset = get_te32(&phdr->p_offset);
539
539
struct Elf32_Note note; memset(¬e, 0, sizeof(note));
540
540
fi->seek(offset, SEEK_SET);
541
541
fi->readx(¬e, sizeof(note));
542
542
fi->seek(0, SEEK_SET);
543
if (4==get_native32(¬e.descsz)
544
&& 1==get_native32(¬e.type)
543
if (4==get_te32(¬e.descsz)
544
&& 1==get_te32(¬e.type)
545
545
&& 0==note.end ) {
546
546
if (0==strcmp("NetBSD", (char const *)¬e.text)) {
547
547
ei_osabi = Elf32_Ehdr::ELFOSABI_NETBSD;