From: "Anthony G. Basile" <blueness@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/elfix:master commit in: misc/elf-abi/
Date: Sat, 3 Jan 2015 23:49:18 +0000 (UTC) [thread overview]
Message-ID: <1420329011.244969d6eaa011c87bcba5d1f982d546de715f08.blueness@gentoo> (raw)
commit: 244969d6eaa011c87bcba5d1f982d546de715f08
Author: Anthony G. Basile <blueness <AT> gentoo <DOT> org>
AuthorDate: Sat Jan 3 23:50:11 2015 +0000
Commit: Anthony G. Basile <blueness <AT> gentoo <DOT> 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);
+}
next reply other threads:[~2015-01-03 23:49 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-01-03 23:49 Anthony G. Basile [this message]
-- strict thread matches above, loose matches on Subject: below --
2015-01-06 21:43 [gentoo-commits] proj/elfix:master commit in: misc/elf-abi/ Anthony G. Basile
2015-01-06 21:34 Anthony G. Basile
2015-01-06 20:47 Anthony G. Basile
2015-01-06 18:22 Anthony G. Basile
2015-01-06 17:26 Anthony G. Basile
2015-01-06 15:13 Anthony G. Basile
2015-01-05 16:26 Anthony G. Basile
2015-01-05 16:23 Anthony G. Basile
2015-01-03 23:53 Anthony G. Basile
2015-01-03 23:19 Anthony G. Basile
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1420329011.244969d6eaa011c87bcba5d1f982d546de715f08.blueness@gentoo \
--to=blueness@gentoo.org \
--cc=gentoo-commits@lists.gentoo.org \
--cc=gentoo-dev@lists.gentoo.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox