aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--elf.h9
-rw-r--r--man/scanelf.docbook10
-rw-r--r--paxelf.c48
-rw-r--r--paxelf.h4
-rw-r--r--scanelf.c27
5 files changed, 91 insertions, 7 deletions
diff --git a/elf.h b/elf.h
index 3342cac..90d9c92 100644
--- a/elf.h
+++ b/elf.h
@@ -2118,6 +2118,9 @@ typedef Elf32_Addr Elf32_Conflict;
#define EF_ARM_ALIGN8 0x40 /* 8-bit structure alignment is in use */
#define EF_ARM_NEW_ABI 0x80
#define EF_ARM_OLD_ABI 0x100
+#define EF_ARM_SOFT_FLOAT 0x200
+#define EF_ARM_VFP_FLOAT 0x400
+#define EF_ARM_MAVERICK_FLOAT 0x800
/* Other constants defined in the ARM ELF spec. version B-01. */
/* NB. These conflict with values defined above. */
@@ -2130,6 +2133,12 @@ typedef Elf32_Addr Elf32_Conflict;
#define EF_ARM_EABI_UNKNOWN 0x00000000
#define EF_ARM_EABI_VER1 0x01000000
#define EF_ARM_EABI_VER2 0x02000000
+#define EF_ARM_EABI_VER3 0x03000000
+#define EF_ARM_EABI_VER4 0x04000000
+#define EF_ARM_EABI_VER5 0x05000000
+
+/* EI_OSABI values */
+#define ELFOSABI_ARM_AEABI 64 /* Contains symbol versioning. */
/* Additional symbol types for Thumb */
#define STT_ARM_TFUNC 0xd
diff --git a/man/scanelf.docbook b/man/scanelf.docbook
index fa89c31..7f48076 100644
--- a/man/scanelf.docbook
+++ b/man/scanelf.docbook
@@ -104,6 +104,14 @@
<listitem><para>Print Endianness</para></listitem>
</varlistentry>
<varlistentry>
+ <term><option>-I</option>, <option>--osabi</option> </term>
+ <listitem><para>Print OSABI</para></listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><option>-Y</option>, <option>--eabi</option> </term>
+ <listitem><para>Print EABI (EM_ARM Only)</para></listitem>
+ </varlistentry>
+ <varlistentry>
<term><option>-O</option>, <option>--perms</option> <replaceable>PERMS</replaceable></term>
<listitem><para>Print only ELF files with matching specified octal bits (like 755)</para></listitem>
</varlistentry>
@@ -221,6 +229,8 @@
<listitem><para><emphasis remap='B'>b</emphasis> - bind flags</para></listitem>
<listitem><para><emphasis remap='B'>e</emphasis> - program headers</para></listitem>
<listitem><para><emphasis remap='B'>D</emphasis> - endian</para></listitem>
+ <listitem><para><emphasis remap='B'>I</emphasis> - osabi</para></listitem>
+ <listitem><para><emphasis remap='B'>Y</emphasis> - eabi</para></listitem>
<listitem><para><emphasis remap='B'>F</emphasis> - long filename</para></listitem>
<listitem><para><emphasis remap='B'>f</emphasis> - short filename</para></listitem>
<listitem><para><emphasis remap='B'>i</emphasis> - interp</para></listitem>
diff --git a/paxelf.c b/paxelf.c
index cbbf972..bf0b0af 100644
--- a/paxelf.c
+++ b/paxelf.c
@@ -1,7 +1,7 @@
/*
* Copyright 2003-2007 Gentoo Foundation
* Distributed under the terms of the GNU General Public License v2
- * $Header: /var/cvsroot/gentoo-projects/pax-utils/paxelf.c,v 1.58 2008/01/17 04:37:19 solar Exp $
+ * $Header: /var/cvsroot/gentoo-projects/pax-utils/paxelf.c,v 1.59 2008/06/17 17:07:57 solar Exp $
*
* Copyright 2005-2007 Ned Ludd - <solar@gentoo.org>
* Copyright 2005-2007 Mike Frysinger - <vapier@gentoo.org>
@@ -115,6 +115,52 @@ const char *get_endian(elfobj *elf)
return (char *) "??";
}
+
+
+static int arm_eabi_poker(elfobj *elf);
+static int arm_eabi_poker(elfobj *elf)
+{
+ unsigned int eflags = 0;
+ static char eabi[26];
+
+ if (ELFOSABI_NONE != elf->data[EI_OSABI])
+ return -1;
+
+ memset(eabi, 0, sizeof(eabi));
+
+ if (elf->elf_class == ELFCLASS32) {
+ if ((int)EGET(EHDR32(elf->ehdr)->e_machine) != EM_ARM)
+ return -1;
+ eflags = EF_ARM_EABI_VERSION(EGET(EHDR32(elf->ehdr)->e_flags));
+ } else {
+ if ((int)EGET(EHDR64(elf->ehdr)->e_machine) != EM_ARM)
+ return -1;
+ eflags = EF_ARM_EABI_VERSION(EGET(EHDR64(elf->ehdr)->e_flags));
+ }
+ return (eflags >> 24);
+}
+
+
+const char *get_elf_eabi(elfobj *elf)
+{
+ static char buf[26];
+ int eabi = arm_eabi_poker(elf);
+ memset(buf, 0, sizeof(buf));
+ if (eabi >= 0) {
+ sprintf(buf, "%d", eabi);
+ }
+ return buf;
+}
+
+const char *get_elfosabi(elfobj *elf)
+{
+ const char *str = get_elfeitype(EI_OSABI, elf->data[EI_OSABI]);
+ if (str)
+ if (strlen(str) > 9)
+ return str + 9;
+ return (char *) "";
+}
+
void print_etypes(FILE *stream)
{
int i, wrap = 0;
diff --git a/paxelf.h b/paxelf.h
index 4a5e73f..3013ec2 100644
--- a/paxelf.h
+++ b/paxelf.h
@@ -1,7 +1,7 @@
/*
* Copyright 2005-2007 Gentoo Foundation
* Distributed under the terms of the GNU General Public License v2
- * $Header: /var/cvsroot/gentoo-projects/pax-utils/paxelf.h,v 1.49 2007/06/29 17:09:12 solar Exp $
+ * $Header: /var/cvsroot/gentoo-projects/pax-utils/paxelf.h,v 1.50 2008/06/17 17:07:57 solar Exp $
*
* Copyright 2005-2007 Ned Ludd - <solar@gentoo.org>
* Copyright 2005-2007 Mike Frysinger - <vapier@gentoo.org>
@@ -52,6 +52,8 @@ extern void unreadelf(elfobj *elf);
extern const char *get_elfeitype(int ei_type, int type);
extern const char *get_elfetype(elfobj *elf);
extern const char *get_endian(elfobj *elf);
+extern const char *get_elfosabi(elfobj *elf);
+extern const char *get_elf_eabi(elfobj *elf);
extern const char *get_elfemtype(elfobj *elf);
extern const char *get_elfptype(int type);
extern const char *get_elfdtype(int type);
diff --git a/scanelf.c b/scanelf.c
index 1f8f04e..330b2a6 100644
--- a/scanelf.c
+++ b/scanelf.c
@@ -1,13 +1,13 @@
/*
* Copyright 2003-2007 Gentoo Foundation
* Distributed under the terms of the GNU General Public License v2
- * $Header: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v 1.190 2008/04/19 22:31:49 solar Exp $
+ * $Header: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v 1.191 2008/06/17 17:07:57 solar Exp $
*
* Copyright 2003-2007 Ned Ludd - <solar@gentoo.org>
* Copyright 2004-2007 Mike Frysinger - <vapier@gentoo.org>
*/
-static const char *rcsid = "$Id: scanelf.c,v 1.190 2008/04/19 22:31:49 solar Exp $";
+static const char *rcsid = "$Id: scanelf.c,v 1.191 2008/06/17 17:07:57 solar Exp $";
const char * const argv0 = "scanelf";
#include "paxinc.h"
@@ -51,6 +51,8 @@ static char show_soname = 0;
static char show_textrels = 0;
static char show_banner = 1;
static char show_endian = 0;
+static char show_osabi = 0;
+static char show_eabi = 0;
static char be_quiet = 0;
static char be_verbose = 0;
static char be_wewy_wewy_quiet = 0;
@@ -1154,6 +1156,8 @@ static int scanelf_elfobj(elfobj *elf)
case 'T': prints("TEXTRELS "); break;
case 'k': prints("SECTION "); break;
case 'a': prints("ARCH "); break;
+ case 'I': prints("OSABI "); break;
+ case 'Y': prints("EABI "); break;
case 'O': prints("PERM "); break;
case 'D': prints("ENDIAN "); break;
default: warnf("'%c' has no title ?", out_format[i]);
@@ -1226,6 +1230,8 @@ static int scanelf_elfobj(elfobj *elf)
case 's': out = scanelf_file_sym(elf, &found_sym); break;
case 'k': out = scanelf_file_sections(elf, &found_section); break;
case 'a': out = get_elfemtype(elf); break;
+ case 'I': out = get_elfosabi(elf); break;
+ case 'Y': out = get_elf_eabi(elf); break;
case 'Z': snprintf(ubuf, sizeof(ubuf), "%lu", elf->len); out = ubuf; break;;
default: warnf("'%c' has no scan code?", out_format[i]);
}
@@ -1591,8 +1597,8 @@ static void scanelf_envpath(void)
free(path);
}
-/* usage / invocation handling functions */ /* Free Flags: c d j u w C G H I J K P Q U W Y */
-#define PARSE_FLAGS "plRmyAXz:xetrnLibSs:k:gN:TaqvF:f:o:E:M:DO:ZBhV"
+/* usage / invocation handling functions */ /* Free Flags: c d j u w C G H J K P Q U W */
+#define PARSE_FLAGS "plRmyAXz:xetrnLibSs:k:gN:TaqvF:f:o:E:M:DIYO:ZBhV"
#define a_argument required_argument
static struct option const long_opts[] = {
{"path", no_argument, NULL, 'p'},
@@ -1620,6 +1626,8 @@ static struct option const long_opts[] = {
{"etype", a_argument, NULL, 'E'},
{"bits", a_argument, NULL, 'M'},
{"endian", no_argument, NULL, 'D'},
+ {"osabi", no_argument, NULL, 'I'},
+ {"eabi", no_argument, NULL, 'Y'},
{"perms", a_argument, NULL, 'O'},
{"size", no_argument, NULL, 'Z'},
{"all", no_argument, NULL, 'a'},
@@ -1660,6 +1668,8 @@ static const char *opts_help[] = {
"Print only ELF files matching etype ET_DYN,ET_EXEC ...",
"Print only ELF files matching numeric bits",
"Print Endianness",
+ "Print OSABI",
+ "Print EABI (EM_ARM Only)",
"Print only ELF files matching octal permissions",
"Print ELF file size",
"Print all scanned info (-x -e -t -r -b)\n",
@@ -1833,6 +1843,8 @@ static int parseargs(int argc, char *argv[])
case 'v': be_verbose = (be_verbose % 20) + 1; break;
case 'a': show_perms = show_pax = show_phdr = show_textrel = show_rpath = show_bind = show_endian = 1; break;
case 'D': show_endian = 1; break;
+ case 'I': show_osabi = 1; break;
+ case 'Y': show_eabi = 1; break;
case ':':
err("Option '%c' is missing parameter", optopt);
case '?':
@@ -1849,7 +1861,8 @@ static int parseargs(int argc, char *argv[])
if (out_format) {
show_pax = show_phdr = show_textrel = show_rpath = \
show_needed = show_interp = show_bind = show_soname = \
- show_textrels = show_perms = show_endian = show_size = 0;
+ show_textrels = show_perms = show_endian = show_size = \
+ show_osabi = show_eabi = 0;
for (i = 0; out_format[i]; ++i) {
if (!IS_MODIFIER(out_format[i])) continue;
@@ -1868,6 +1881,8 @@ static int parseargs(int argc, char *argv[])
case 'M': break;
case 'Z': show_size = 1; break;
case 'D': show_endian = 1; break;
+ case 'I': show_osabi = 1; break;
+ case 'Y': show_eabi = 1; break;
case 'O': show_perms = 1; break;
case 'x': show_pax = 1; break;
case 'e': show_phdr = 1; break;
@@ -1893,6 +1908,8 @@ static int parseargs(int argc, char *argv[])
if (show_perms) xstrcat(&out_format, "%O ", &fmt_len);
if (show_size) xstrcat(&out_format, "%Z ", &fmt_len);
if (show_endian) xstrcat(&out_format, "%D ", &fmt_len);
+ if (show_osabi) xstrcat(&out_format, "%I ", &fmt_len);
+ if (show_eabi) xstrcat(&out_format, "%Y ", &fmt_len);
if (show_phdr) xstrcat(&out_format, "%e ", &fmt_len);
if (show_textrel) xstrcat(&out_format, "%t ", &fmt_len);
if (show_rpath) xstrcat(&out_format, "%r ", &fmt_len);