diff options
| author | ruki <[email protected]> | 2025-12-09 00:33:18 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2025-12-09 00:33:18 +0800 |
| commit | 333af0b66dfe73fabb2c900bce00ba2d50bfe622 (patch) | |
| tree | b8e348021f5a4fff963d8d5de320e109339102ae | |
| parent | acd4bfbcf3b73349f6b56197f3c0f27f204cc135 (diff) | |
fix readsyms for macho
| -rw-r--r-- | core/src/xmake/binutils/macho/prefix.h | 6 | ||||
| -rw-r--r-- | xmake/modules/utils/binary/readsyms.lua | 6 |
2 files changed, 5 insertions, 7 deletions
diff --git a/core/src/xmake/binutils/macho/prefix.h b/core/src/xmake/binutils/macho/prefix.h index c11fbebb6..39ac857f1 100644 --- a/core/src/xmake/binutils/macho/prefix.h +++ b/core/src/xmake/binutils/macho/prefix.h @@ -326,7 +326,7 @@ static __tb_inline__ tb_uint32_t xm_binutils_macho_parse_version(tb_char_t const * * @param istream the input stream * @param strtab_offset the string table offset - * @param offset the string offset (relative to string table content, after size field) + * @param offset the string offset (nlist.strx, relative to string table start, including 4-byte size field) * @param name the buffer to store the string * @param name_size the size of the buffer * @return tb_true on success, tb_false on failure @@ -335,8 +335,8 @@ static __tb_inline__ tb_bool_t xm_binutils_macho_read_string(tb_stream_ref_t ist tb_assert_and_check_return_val(istream && name && name_size > 0, tb_false); tb_hize_t saved_pos = tb_stream_offset(istream); - // string table starts with 4-byte size field, so offset is from after that - if (!tb_stream_seek(istream, strtab_offset + 4 + offset)) { + // nlist.strx is offset from string table start (including 4-byte size field) + if (!tb_stream_seek(istream, strtab_offset + offset)) { return tb_false; } diff --git a/xmake/modules/utils/binary/readsyms.lua b/xmake/modules/utils/binary/readsyms.lua index 899b43f71..103b13891 100644 --- a/xmake/modules/utils/binary/readsyms.lua +++ b/xmake/modules/utils/binary/readsyms.lua @@ -82,14 +82,12 @@ function dump(binaryfile) -- print header print("") print("Symbols:") - local header_format = string.format(" %%-%ds %%-%ds %%-%ds %%-%ds %%-%ds %%s", - value_width, type_width, bind_width, section_width, size_width) + local header_format = " %-" .. value_width .. "s %-" .. type_width .. "s %-" .. bind_width .. "s %-" .. section_width .. "s %-" .. size_width .. "s %s" print(string.format(header_format, "VALUE", "TYPE", "BIND", "SECTION", "SIZE", "NAME")) print(string.rep("-", 80)) -- print symbols - local format_str = string.format(" %%-%ds %%-%ds %%-%ds %%-%ds %%-%ds %%s", - value_width, type_width, bind_width, section_width, size_width) + local format_str = " %-" .. value_width .. "s %-" .. type_width .. "s %-" .. bind_width .. "s %-" .. section_width .. "s %-" .. size_width .. "s %s" for i, sym in ipairs(symbols) do local value_str = sym.value and string.format("0x%x", sym.value) or "" |
