1 |
vapier 09/12/01 06:03:43 |
2 |
|
3 |
Modified: paxelf.c |
4 |
Log: |
5 |
cleanup the eabi checks |
6 |
|
7 |
Revision Changes Path |
8 |
1.66 pax-utils/paxelf.c |
9 |
|
10 |
file : http://sources.gentoo.org/viewcvs.py/gentoo-projects/pax-utils/paxelf.c?rev=1.66&view=markup |
11 |
plain: http://sources.gentoo.org/viewcvs.py/gentoo-projects/pax-utils/paxelf.c?rev=1.66&content-type=text/plain |
12 |
diff : http://sources.gentoo.org/viewcvs.py/gentoo-projects/pax-utils/paxelf.c?r1=1.65&r2=1.66 |
13 |
|
14 |
Index: paxelf.c |
15 |
=================================================================== |
16 |
RCS file: /var/cvsroot/gentoo-projects/pax-utils/paxelf.c,v |
17 |
retrieving revision 1.65 |
18 |
retrieving revision 1.66 |
19 |
diff -u -r1.65 -r1.66 |
20 |
--- paxelf.c 1 Dec 2009 05:52:55 -0000 1.65 |
21 |
+++ paxelf.c 1 Dec 2009 06:03:43 -0000 1.66 |
22 |
@@ -1,7 +1,7 @@ |
23 |
/* |
24 |
* Copyright 2003-2007 Gentoo Foundation |
25 |
* Distributed under the terms of the GNU General Public License v2 |
26 |
- * $Header: /var/cvsroot/gentoo-projects/pax-utils/paxelf.c,v 1.65 2009/12/01 05:52:55 vapier Exp $ |
27 |
+ * $Header: /var/cvsroot/gentoo-projects/pax-utils/paxelf.c,v 1.66 2009/12/01 06:03:43 vapier Exp $ |
28 |
* |
29 |
* Copyright 2005-2007 Ned Ludd - <solar@g.o> |
30 |
* Copyright 2005-2007 Mike Frysinger - <vapier@g.o> |
31 |
@@ -108,44 +108,42 @@ |
32 |
|
33 |
const char *get_endian(elfobj *elf) |
34 |
{ |
35 |
- if (elf->data[EI_DATA] == ELFDATA2LSB) |
36 |
- return (char *) "LE"; |
37 |
- if (elf->data[EI_DATA] == ELFDATA2MSB) |
38 |
- return (char *) "BE"; |
39 |
- return (char *) "??"; |
40 |
+ switch (elf->data[EI_DATA]) { |
41 |
+ case ELFDATA2LSB: return "LE"; |
42 |
+ case ELFDATA2MSB: return "BE"; |
43 |
+ default: return "??"; |
44 |
+ } |
45 |
} |
46 |
|
47 |
-static int arm_eabi_poker(elfobj *elf); |
48 |
static int arm_eabi_poker(elfobj *elf) |
49 |
{ |
50 |
- unsigned int eflags = 0; |
51 |
- static char eabi[26]; |
52 |
+ unsigned int emachine, eflags; |
53 |
|
54 |
if (ELFOSABI_NONE != elf->data[EI_OSABI]) |
55 |
return -1; |
56 |
|
57 |
- memset(eabi, 0, sizeof(eabi)); |
58 |
- |
59 |
if (elf->elf_class == ELFCLASS32) { |
60 |
- if ((int)EGET(EHDR32(elf->ehdr)->e_machine) != EM_ARM) |
61 |
- return -1; |
62 |
- eflags = EF_ARM_EABI_VERSION(EGET(EHDR32(elf->ehdr)->e_flags)); |
63 |
+ emachine = EHDR32(elf->ehdr)->e_machine; |
64 |
+ eflags = EHDR32(elf->ehdr)->e_flags; |
65 |
} else { |
66 |
- if ((int)EGET(EHDR64(elf->ehdr)->e_machine) != EM_ARM) |
67 |
- return -1; |
68 |
- eflags = EF_ARM_EABI_VERSION(EGET(EHDR64(elf->ehdr)->e_flags)); |
69 |
+ emachine = EHDR64(elf->ehdr)->e_machine; |
70 |
+ eflags = EHDR64(elf->ehdr)->e_flags; |
71 |
} |
72 |
- return (eflags >> 24); |
73 |
+ |
74 |
+ if (EGET(emachine) == EM_ARM) |
75 |
+ return EF_ARM_EABI_VERSION(EGET(eflags)) >> 24; |
76 |
+ else |
77 |
+ return -1; |
78 |
} |
79 |
|
80 |
const char *get_elf_eabi(elfobj *elf) |
81 |
{ |
82 |
static char buf[26]; |
83 |
int eabi = arm_eabi_poker(elf); |
84 |
- memset(buf, 0, sizeof(buf)); |
85 |
- if (eabi >= 0) { |
86 |
- sprintf(buf, "%d", eabi); |
87 |
- } |
88 |
+ if (eabi >= 0) |
89 |
+ snprintf(buf, sizeof(buf), "%i", eabi); |
90 |
+ else |
91 |
+ strcpy(buf, "?"); |
92 |
return buf; |
93 |
} |
94 |
|
95 |
@@ -155,7 +153,7 @@ |
96 |
if (str) |
97 |
if (strlen(str) > 9) |
98 |
return str + 9; |
99 |
- return (char *) ""; |
100 |
+ return ""; |
101 |
} |
102 |
|
103 |
void print_etypes(FILE *stream) |