summaryrefslogtreecommitdiff
path: root/core/src
diff options
context:
space:
mode:
authorruki <[email protected]>2025-12-11 23:45:05 +0800
committerruki <[email protected]>2025-12-12 09:00:44 +0800
commit2a9ce5f90745e62641ba8c313ff0fa856eaea1f8 (patch)
tree687d309176f268904c17abc7b5dfdeb150a353d9 /core/src
parent65b4b2932a7c2fd6dab3fe60597055d1440bddc5 (diff)
readsyms from ar lib
Diffstat (limited to 'core/src')
-rw-r--r--core/src/xmake/binutils/ar/readsyms.c21
-rw-r--r--core/src/xmake/binutils/macho/readsyms.c2
-rw-r--r--core/src/xmake/binutils/readsyms.c2
3 files changed, 18 insertions, 7 deletions
diff --git a/core/src/xmake/binutils/ar/readsyms.c b/core/src/xmake/binutils/ar/readsyms.c
index 5bb5731c6..c68826c97 100644
--- a/core/src/xmake/binutils/ar/readsyms.c
+++ b/core/src/xmake/binutils/ar/readsyms.c
@@ -19,6 +19,9 @@
*
*/
+#define TB_TRACE_MODULE_NAME "readsyms_ar"
+#define TB_TRACE_MODULE_DEBUG (1)
+
/* //////////////////////////////////////////////////////////////////////////////////////
* includes
*/
@@ -199,12 +202,17 @@ tb_bool_t xm_binutils_ar_read_symbols(tb_stream_ref_t istream, tb_hize_t base_of
tb_bool_t skip = tb_false;
if (!xm_binutils_ar_get_member_name(istream, &header, member_name, sizeof(member_name), &name_len, &name_bytes_read)) {
skip = tb_true;
- } else if (xm_binutils_ar_is_symbol_table(member_name)) {
- // skip symbol tables
- skip = tb_true;
- } else if (!xm_binutils_ar_is_object_file(member_name)) {
- // only extract object files
- skip = tb_true;
+ } else {
+ tb_trace_d("member: %s, size: %lld", member_name, member_size);
+ if (xm_binutils_ar_is_symbol_table(member_name)) {
+ // skip symbol tables
+ skip = tb_true;
+ tb_trace_d("skipping symbol table");
+ } else if (!xm_binutils_ar_is_object_file(member_name)) {
+ // only extract object files
+ skip = tb_true;
+ tb_trace_d("skipping non-object file");
+ }
}
if (skip) {
@@ -223,6 +231,7 @@ tb_bool_t xm_binutils_ar_read_symbols(tb_stream_ref_t istream, tb_hize_t base_of
// detect format
tb_int_t format = xm_binutils_detect_format(istream);
+ tb_trace_d("format: %d", format);
if (format != XM_BINUTILS_FORMAT_UNKNOWN && format != XM_BINUTILS_FORMAT_AR) {
// create entry table
lua_newtable(lua);
diff --git a/core/src/xmake/binutils/macho/readsyms.c b/core/src/xmake/binutils/macho/readsyms.c
index 4c3fbafa6..2d4889c58 100644
--- a/core/src/xmake/binutils/macho/readsyms.c
+++ b/core/src/xmake/binutils/macho/readsyms.c
@@ -319,7 +319,7 @@ tb_bool_t xm_binutils_macho_read_symbols(tb_stream_ref_t istream, tb_hize_t base
// read and check magic
tb_uint8_t magic_bytes[4];
- if (!xm_binutils_read_magic(istream, magic_bytes, 4)) {
+ if (!tb_stream_bread(istream, magic_bytes, 4)) {
return tb_false;
}
diff --git a/core/src/xmake/binutils/readsyms.c b/core/src/xmake/binutils/readsyms.c
index 5a1b40d3c..3bc7d3bb5 100644
--- a/core/src/xmake/binutils/readsyms.c
+++ b/core/src/xmake/binutils/readsyms.c
@@ -80,6 +80,8 @@ tb_int_t xm_binutils_readsyms(lua_State *lua) {
lua_pushfstring(lua, "readsyms: cannot detect file format");
break;
}
+
+ // printf("readsyms: detected format %d\n", format);
// create result list
lua_newtable(lua);