Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
adam.huang
Sunxi Tools
Commits
d62de0d4
Commit
d62de0d4
authored
May 03, 2012
by
Alejandro Mery
Browse files
bin2fex: list section entries
parent
01f3cb19
Changes
1
Hide whitespace changes
Inline
Side-by-side
bin2fex.c
View file @
d62de0d4
...
@@ -27,11 +27,26 @@
...
@@ -27,11 +27,26 @@
#include <fcntl.h>
#include <fcntl.h>
#define errf(...) fprintf(stderr, __VA_ARGS__)
#define errf(...) fprintf(stderr, __VA_ARGS__)
#define pr_info(F, ...) fprintf(stderr, "bin2fex: " F, __VA_ARGS__)
static
int
decompile
(
void
*
bin
,
size_t
bin_size
,
int
out
,
const
char
*
out_name
);
#define PTR(B, OFF) (void*)((char*)(B)+(OFF))
/**
*/
static
int
decompile_section
(
void
*
bin
,
size_t
bin_size
,
static
int
decompile_section
(
void
*
bin
,
size_t
bin_size
,
struct
script_section
*
section
,
struct
script_section
*
section
,
int
out
,
const
char
*
out_named
);
int
out
,
const
char
*
out_named
)
{
int
i
;
struct
script_section_entry
*
entries
=
PTR
(
bin
,
section
->
offset
<<
2
);
for
(
i
=
0
;
i
<
section
->
length
;
i
++
)
{
pr_info
(
"%s.%s
\t
(entry:%d, offset:%d, pattern:0x%05x)
\n
"
,
section
->
name
,
entries
[
i
].
name
,
i
,
entries
[
i
].
offset
,
entries
[
i
].
pattern
);
}
return
1
;
/* success */
}
/**
/**
*/
*/
static
int
decompile
(
void
*
bin
,
size_t
bin_size
,
int
out
,
const
char
*
out_name
)
static
int
decompile
(
void
*
bin
,
size_t
bin_size
,
int
out
,
const
char
*
out_name
)
...
@@ -42,17 +57,17 @@ static int decompile(void *bin, size_t bin_size, int out, const char *out_name)
...
@@ -42,17 +57,17 @@ static int decompile(void *bin, size_t bin_size, int out, const char *out_name)
struct
script_section
sections
[];
struct
script_section
sections
[];
}
*
script
=
bin
;
}
*
script
=
bin
;
errf
(
"b
in
fo
rmat
: %d.%d.%d
\n
"
,
script
->
head
.
version
[
0
],
pr_
info
(
"version
: %d.%d.%d
\n
"
,
script
->
head
.
version
[
0
],
script
->
head
.
version
[
1
],
script
->
head
.
version
[
2
]);
script
->
head
.
version
[
1
],
script
->
head
.
version
[
2
]);
errf
(
"bin
size: %zu (%d sections)
\n
"
,
bin_size
,
pr_info
(
"
size: %zu (%d sections)
\n
"
,
bin_size
,
script
->
head
.
sections
);
script
->
head
.
sections
);
/* TODO: SANITY: compare head.sections with bin_size */
/* TODO: SANITY: compare head.sections with bin_size */
for
(
i
=
0
;
i
<
script
->
head
.
sections
;
i
++
)
{
for
(
i
=
0
;
i
<
script
->
head
.
sections
;
i
++
)
{
struct
script_section
*
section
=
&
script
->
sections
[
i
];
struct
script_section
*
section
=
&
script
->
sections
[
i
];
errf
(
"%s:
(section:%d, length:%d, offset:%d)
\n
"
,
pr_info
(
"%s:
\t
(section:%d, length:%d, offset:%d)
\n
"
,
section
->
name
,
i
+
1
,
section
->
length
,
section
->
offset
);
section
->
name
,
i
+
1
,
section
->
length
,
section
->
offset
);
if
(
!
decompile_section
(
bin
,
bin_size
,
section
,
out
,
out_name
))
if
(
!
decompile_section
(
bin
,
bin_size
,
section
,
out
,
out_name
))
return
1
;
/* failure */
return
1
;
/* failure */
...
@@ -60,15 +75,6 @@ static int decompile(void *bin, size_t bin_size, int out, const char *out_name)
...
@@ -60,15 +75,6 @@ static int decompile(void *bin, size_t bin_size, int out, const char *out_name)
return
0
;
/* success */
return
0
;
/* success */
}
}
/**
*/
static
int
decompile_section
(
void
*
bin
,
size_t
bin_size
,
struct
script_section
*
section
,
int
out
,
const
char
*
out_named
)
{
return
1
;
/* success */
}
/**
/**
*/
*/
int
main
(
int
argc
,
char
*
argv
[])
int
main
(
int
argc
,
char
*
argv
[])
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment