From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) by finch.gentoo.org (Postfix) with ESMTP id 88D19138A1A for ; Sat, 3 Jan 2015 23:49:21 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 2274DE0794; Sat, 3 Jan 2015 23:49:21 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id AA881E0794 for ; Sat, 3 Jan 2015 23:49:20 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id B93A234039E for ; Sat, 3 Jan 2015 23:49:19 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 67F7EECDC for ; Sat, 3 Jan 2015 23:49:18 +0000 (UTC) From: "Anthony G. Basile" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Anthony G. Basile" Message-ID: <1420329011.244969d6eaa011c87bcba5d1f982d546de715f08.blueness@gentoo> Subject: [gentoo-commits] proj/elfix:master commit in: misc/elf-abi/ X-VCS-Repository: proj/elfix X-VCS-Files: misc/elf-abi/elf-abi.c X-VCS-Directories: misc/elf-abi/ X-VCS-Committer: blueness X-VCS-Committer-Name: Anthony G. Basile X-VCS-Revision: 244969d6eaa011c87bcba5d1f982d546de715f08 X-VCS-Branch: master Date: Sat, 3 Jan 2015 23:49:18 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Archives-Salt: b7de9e68-a350-4ba1-a833-03f5c64ba7e0 X-Archives-Hash: 39be8e551f213cac8df1c7d25955cb62 commit: 244969d6eaa011c87bcba5d1f982d546de715f08 Author: Anthony G. Basile gentoo org> AuthorDate: Sat Jan 3 23:50:11 2015 +0000 Commit: Anthony G. Basile gentoo org> CommitDate: Sat Jan 3 23:50:11 2015 +0000 URL: http://sources.gentoo.org/gitweb/?p=proj/elfix.git;a=commit;h=244969d6 misc/elf-abi: read() gets the correct endian order --- misc/elf-abi/elf-abi.c | 37 ++++++++++--------------------------- 1 file changed, 10 insertions(+), 27 deletions(-) diff --git a/misc/elf-abi/elf-abi.c b/misc/elf-abi/elf-abi.c index 589d458..32e3851 100644 --- a/misc/elf-abi/elf-abi.c +++ b/misc/elf-abi/elf-abi.c @@ -103,7 +103,6 @@ E_MIPS_ABI_EABI64 = 0x00004000 #define EF_ARM_NEW_ABI 0x80 #define EF_ARM_OLD_ABI 0x100 - /* def compute_suffix_mips(elf_header): name = None @@ -147,15 +146,6 @@ def compute_multilib_id(elf_header): return multilib_id */ - -#define bswap_16(x) ((uint16_t)((((x) >> 8) & 0xff) | (((x) & 0xff) << 8))) - -/* -#define bswap_32(x) \ - ((((x) & 0xff000000) >> 24) | (((x) & 0x00ff0000) >> 8) | \ - (((x) & 0x0000ff00) << 8) | (((x) & 0x000000ff) << 24)) -*/ - #define MAX_IDENT 32 int @@ -206,7 +196,7 @@ main(int argc, char* argv[]) printf("Unknown bit\n"); } - /* Little or Big Endian */ + /* Little or Big Endian? */ if (read(fd, &ei_data, 1) == -1) err(1, "read() ei_data failed"); switch (ei_data) { @@ -223,17 +213,13 @@ main(int argc, char* argv[]) printf("Unknown Endian\n"); } - /* seek to e_macine = 16 bytes (e_ident[])) + 2 bytes (e_type which is Elf32_Half/Elf64_Half) */ + /* Seek to e_macine = 16 bytes (e_ident[])) + 2 bytes (e_type which is Elf32_Half/Elf64_Half) */ if (lseek(fd, 18, SEEK_SET) == -1) err(1, "lseek() e_machine failed"); /* What is the arch? */ if (read(fd, &e_machine, 2) == -1) err(1, "read() e_machine failed"); - //if (endian == 0) - // e_machine = bswap_16(e_machine); - printf("Machine =%d\n", e_machine); - switch(e_machine) { case EM_ALPHA: case EM_FAKE_ALPHA: @@ -284,10 +270,8 @@ main(int argc, char* argv[]) default: arch = "unknown"; } - printf("%s\n", arch); - /* e_data_offset = if (lseek(fd, 18, SEEK_SET) == -1) @@ -295,14 +279,7 @@ main(int argc, char* argv[]) if (read(fd, &e_flags, 2) == -1) err(1, "read() e_machine failed"); */ - - memset(ident, 0, MAX_IDENT); - - close(fd); - exit(EXIT_SUCCESS); -} - -/* + /* # E_ENTRY + 3 * sizeof(uintN) e_flags_offset = E_ENTRY + 3 * width // 8 f.seek(e_flags_offset) @@ -311,4 +288,10 @@ main(int argc, char* argv[]) return _elf_header(ei_class, ei_data, e_machine, e_flags) multilib_id = compute_multilib_id(elf_header) -*/ + */ + + memset(ident, 0, MAX_IDENT); + + close(fd); + exit(EXIT_SUCCESS); +}