summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2025-12-21 21:57:56 +0800
committerruki <[email protected]>2025-12-21 21:57:56 +0800
commit4a16fe7f90f6d9d5a06e9d34866c075af07d73b5 (patch)
treead74dfbc3348cb21bf1bf684da9e268234dc8d33
parenta836f5742fc9c704c89281ae5f525cdaa4a903de (diff)
remove unused codes
-rw-r--r--core/src/xmake/binutils/macho/bin2macho.c5
-rw-r--r--core/src/xmake/binutils/macho/deplibs.c2
-rw-r--r--core/src/xmake/binutils/macho/prefix.h11
-rw-r--r--core/src/xmake/binutils/macho/readsyms.c3
-rw-r--r--core/src/xmake/binutils/macho/rpath.c6
-rw-r--r--core/src/xmake/binutils/rpath.c2
-rw-r--r--core/src/xmake/engine.c2
-rw-r--r--xmake/core/base/binutils.lua19
-rw-r--r--xmake/core/sandbox/modules/import/core/base/binutils.lua15
-rw-r--r--xmake/modules/utils/binary/rpath.lua9
10 files changed, 12 insertions, 62 deletions
diff --git a/core/src/xmake/binutils/macho/bin2macho.c b/core/src/xmake/binutils/macho/bin2macho.c
index 8abd020e9..0b9dad0c2 100644
--- a/core/src/xmake/binutils/macho/bin2macho.c
+++ b/core/src/xmake/binutils/macho/bin2macho.c
@@ -326,7 +326,7 @@ static tb_bool_t xm_binutils_bin2macho_dump_32(tb_stream_ref_t istream,
tb_snprintf(symbol_end, sizeof(symbol_end), "%s_end", symbol_name);
// calculate offsets
- tb_uint32_t header_size = sizeof(xm_macho_header_t);
+ tb_uint32_t header_size = sizeof(xm_macho_header_32_t);
tb_uint32_t segment_cmd_size = sizeof(xm_macho_segment_command_t);
tb_uint32_t section_size = sizeof(xm_macho_section_t);
tb_uint32_t symtab_cmd_size = sizeof(xm_macho_symtab_command_t);
@@ -347,7 +347,7 @@ static tb_bool_t xm_binutils_bin2macho_dump_32(tb_stream_ref_t istream,
strtab_size = xm_binutils_macho_align(strtab_size, 4);
// write Mach-O header
- xm_macho_header_t header;
+ xm_macho_header_32_t header;
tb_memset(&header, 0, sizeof(header));
header.magic = XM_MACHO_MAGIC_32;
header.cputype = xm_binutils_macho_get_cputype(arch);
@@ -617,4 +617,3 @@ tb_int_t xm_binutils_bin2macho(lua_State *lua) {
return ok ? 1 : 2;
}
-
diff --git a/core/src/xmake/binutils/macho/deplibs.c b/core/src/xmake/binutils/macho/deplibs.c
index f2f3bfbeb..affc96944 100644
--- a/core/src/xmake/binutils/macho/deplibs.c
+++ b/core/src/xmake/binutils/macho/deplibs.c
@@ -47,7 +47,7 @@ tb_bool_t xm_binutils_macho_deplibs(tb_stream_ref_t istream, tb_hize_t base_offs
}
// skip header to reach load commands
- tb_size_t header_size = context.is64 ? sizeof(xm_macho_header_64_t) : sizeof(xm_macho_header_t);
+ tb_size_t header_size = context.is64 ? sizeof(xm_macho_header_64_t) : sizeof(xm_macho_header_32_t);
if (!tb_stream_seek(istream, base_offset + header_size)) {
return tb_false;
}
diff --git a/core/src/xmake/binutils/macho/prefix.h b/core/src/xmake/binutils/macho/prefix.h
index 39e0958e7..18450ca82 100644
--- a/core/src/xmake/binutils/macho/prefix.h
+++ b/core/src/xmake/binutils/macho/prefix.h
@@ -78,7 +78,7 @@
* types
*/
#include "tbox/prefix/packed.h"
-typedef struct __xm_macho_header_t {
+typedef struct __xm_macho_header_32_t {
tb_uint32_t magic;
tb_uint32_t cputype;
tb_uint32_t cpusubtype;
@@ -86,7 +86,7 @@ typedef struct __xm_macho_header_t {
tb_uint32_t ncmds;
tb_uint32_t sizeofcmds;
tb_uint32_t flags;
-} __tb_packed__ xm_macho_header_t;
+} __tb_packed__ xm_macho_header_32_t;
typedef struct __xm_macho_header_64_t {
tb_uint32_t magic;
@@ -216,7 +216,7 @@ typedef struct __xm_macho_dylib_command_t {
typedef struct __xm_macho_context_t {
union {
- xm_macho_header_t header32;
+ xm_macho_header_32_t header32;
xm_macho_header_64_t header64;
} header;
tb_bool_t is64;
@@ -231,7 +231,7 @@ typedef struct __xm_macho_context_t {
*/
// byte-swap Mach-O header fields if needed
-static __tb_inline__ tb_void_t xm_binutils_macho_swap_header_32(xm_macho_header_t *header, tb_bool_t swap) {
+static __tb_inline__ tb_void_t xm_binutils_macho_swap_header_32(xm_macho_header_32_t *header, tb_bool_t swap) {
if (swap) {
header->magic = tb_bits_swap_u32(header->magic);
header->cputype = tb_bits_swap_u32(header->cputype);
@@ -263,7 +263,7 @@ static __tb_inline__ tb_bool_t xm_binutils_macho_context_init(tb_stream_ref_t is
// read Mach-O header
if (!tb_stream_seek(istream, base_offset)) return tb_false;
- if (!tb_stream_bread(istream, (tb_byte_t*)&context->header.header32, sizeof(xm_macho_header_t))) return tb_false;
+ if (!tb_stream_bread(istream, (tb_byte_t*)&context->header.header32, sizeof(xm_macho_header_32_t))) return tb_false;
// check magic
tb_uint32_t magic = context->header.header32.magic;
@@ -579,4 +579,3 @@ static __tb_inline__ tb_char_t const *xm_binutils_macho_get_symbol_bind(tb_uint8
}
#endif
-
diff --git a/core/src/xmake/binutils/macho/readsyms.c b/core/src/xmake/binutils/macho/readsyms.c
index 5a622cb6d..fa94205a2 100644
--- a/core/src/xmake/binutils/macho/readsyms.c
+++ b/core/src/xmake/binutils/macho/readsyms.c
@@ -41,7 +41,7 @@ tb_bool_t xm_binutils_macho_read_symbols_32(tb_stream_ref_t istream, tb_hize_t b
xm_macho_symtab_command_t symtab_cmd;
tb_bool_t found_symtab = tb_false;
- tb_uint32_t offset = sizeof(xm_macho_header_t);
+ tb_uint32_t offset = sizeof(xm_macho_header_32_t);
for (tb_uint32_t i = 0; i < context->ncmds; i++) {
tb_uint32_t cmd;
tb_uint32_t cmdsize;
@@ -254,4 +254,3 @@ tb_bool_t xm_binutils_macho_read_symbols(tb_stream_ref_t istream, tb_hize_t base
}
}
-
diff --git a/core/src/xmake/binutils/macho/rpath.c b/core/src/xmake/binutils/macho/rpath.c
index 473877a45..d9cad4524 100644
--- a/core/src/xmake/binutils/macho/rpath.c
+++ b/core/src/xmake/binutils/macho/rpath.c
@@ -43,7 +43,7 @@ tb_bool_t xm_binutils_macho_rpath_list(tb_stream_ref_t istream, tb_hize_t base_o
if (!xm_binutils_macho_context_init(istream, base_offset, &context)) break;
// skip header to reach load commands
- tb_size_t header_size = context.is64 ? sizeof(xm_macho_header_64_t) : sizeof(xm_macho_header_t);
+ tb_size_t header_size = context.is64 ? sizeof(xm_macho_header_64_t) : sizeof(xm_macho_header_32_t);
if (!tb_stream_seek(istream, base_offset + header_size)) break;
tb_size_t result_count = 0;
@@ -103,7 +103,7 @@ tb_bool_t xm_binutils_macho_rpath_clean(tb_stream_ref_t istream, tb_hize_t base_
xm_macho_context_t context;
if (!xm_binutils_macho_context_init(istream, base_offset, &context)) break;
- tb_size_t header_size = context.is64 ? sizeof(xm_macho_header_64_t) : sizeof(xm_macho_header_t);
+ tb_size_t header_size = context.is64 ? sizeof(xm_macho_header_64_t) : sizeof(xm_macho_header_32_t);
if (!tb_stream_seek(istream, base_offset + header_size)) break;
tb_hize_t read_offset = base_offset + header_size;
@@ -176,7 +176,7 @@ tb_bool_t xm_binutils_macho_rpath_clean(tb_stream_ref_t istream, tb_hize_t base_
context.header.header32.sizeofcmds = new_sizeofcmds;
xm_binutils_macho_swap_header_32(&context.header.header32, context.swap);
if (!tb_stream_seek(istream, base_offset)) break;
- if (!tb_stream_bwrit(istream, (tb_byte_t const*)&context.header.header32, sizeof(xm_macho_header_t))) break;
+ if (!tb_stream_bwrit(istream, (tb_byte_t const*)&context.header.header32, sizeof(xm_macho_header_32_t))) break;
}
}
diff --git a/core/src/xmake/binutils/rpath.c b/core/src/xmake/binutils/rpath.c
index d67b88923..63754c891 100644
--- a/core/src/xmake/binutils/rpath.c
+++ b/core/src/xmake/binutils/rpath.c
@@ -38,8 +38,6 @@
tb_bool_t xm_binutils_elf_rpath_list(tb_stream_ref_t istream, tb_hize_t base_offset, lua_State *lua);
tb_bool_t xm_binutils_macho_rpath_list(tb_stream_ref_t istream, tb_hize_t base_offset, lua_State *lua);
-
-
tb_bool_t xm_binutils_elf_rpath_clean(tb_stream_ref_t istream, tb_hize_t base_offset);
tb_bool_t xm_binutils_macho_rpath_clean(tb_stream_ref_t istream, tb_hize_t base_offset);
diff --git a/core/src/xmake/engine.c b/core/src/xmake/engine.c
index 4bad4d6e8..db8e8b4c1 100644
--- a/core/src/xmake/engine.c
+++ b/core/src/xmake/engine.c
@@ -343,8 +343,6 @@ tb_int_t xm_binutils_bin2elf(lua_State *lua);
tb_int_t xm_binutils_readsyms(lua_State *lua);
tb_int_t xm_binutils_deplibs(lua_State *lua);
tb_int_t xm_binutils_rpath_list(lua_State *lua);
-tb_int_t xm_binutils_rpath_insert(lua_State *lua);
-tb_int_t xm_binutils_rpath_remove(lua_State *lua);
tb_int_t xm_binutils_rpath_clean(lua_State *lua);
tb_int_t xm_binutils_extractlib(lua_State *lua);
diff --git a/xmake/core/base/binutils.lua b/xmake/core/base/binutils.lua
index 9258f99a3..b513be0b1 100644
--- a/xmake/core/base/binutils.lua
+++ b/xmake/core/base/binutils.lua
@@ -32,8 +32,6 @@ binutils._bin2elf = binutils._bin2elf or binutils.bin2elf
binutils._readsyms = binutils._readsyms or binutils.readsyms
binutils._deplibs = binutils._deplibs or binutils.deplibs
binutils._rpath_list = binutils._rpath_list or binutils.rpath_list
-binutils._rpath_insert = binutils._rpath_insert or binutils.rpath_insert
-binutils._rpath_remove = binutils._rpath_remove or binutils.rpath_remove
binutils._rpath_clean = binutils._rpath_clean or binutils.rpath_clean
binutils._extractlib = binutils._extractlib or binutils.extractlib
@@ -125,22 +123,6 @@ function binutils.rpath_list(binaryfile)
end
-- insert rpath to binary file (auto-detect format: ELF or Mach-O)
-function binutils.rpath_insert(binaryfile, rpath)
- if binutils._rpath_insert then
- return binutils._rpath_insert(binaryfile, rpath)
- else
- return false, "binutils: internal rpath_insert not supported!"
- end
-end
-
--- remove rpath from binary file (auto-detect format: ELF or Mach-O)
-function binutils.rpath_remove(binaryfile, rpath)
- if binutils._rpath_remove then
- return binutils._rpath_remove(binaryfile, rpath)
- else
- return false, "binutils: internal rpath_remove not supported!"
- end
-end
-- clean rpaths from binary file (auto-detect format: ELF or Mach-O)
function binutils.rpath_clean(binaryfile)
@@ -173,4 +155,3 @@ end
-- return module
return binutils
-
diff --git a/xmake/core/sandbox/modules/import/core/base/binutils.lua b/xmake/core/sandbox/modules/import/core/base/binutils.lua
index 27e788182..6622836ea 100644
--- a/xmake/core/sandbox/modules/import/core/base/binutils.lua
+++ b/xmake/core/sandbox/modules/import/core/base/binutils.lua
@@ -73,20 +73,6 @@ function sandbox_core_base_binutils.rpath_list(binaryfile)
end
-- insert rpath to binary file (auto-detect format: ELF or Mach-O)
-function sandbox_core_base_binutils.rpath_insert(binaryfile, rpath)
- local ok, errors = binutils.rpath_insert(binaryfile, rpath)
- if not ok then
- raise("rpath_insert: %s", errors or "unknown errors")
- end
-end
-
--- remove rpath from binary file (auto-detect format: ELF or Mach-O)
-function sandbox_core_base_binutils.rpath_remove(binaryfile, rpath)
- local ok, errors = binutils.rpath_remove(binaryfile, rpath)
- if not ok then
- raise("rpath_remove: %s", errors or "unknown errors")
- end
-end
-- clean rpaths from binary file (auto-detect format: ELF or Mach-O)
function sandbox_core_base_binutils.rpath_clean(binaryfile)
@@ -106,4 +92,3 @@ end
-- return module
return sandbox_core_base_binutils
-
diff --git a/xmake/modules/utils/binary/rpath.lua b/xmake/modules/utils/binary/rpath.lua
index fe783751e..33cab5a43 100644
--- a/xmake/modules/utils/binary/rpath.lua
+++ b/xmake/modules/utils/binary/rpath.lua
@@ -295,13 +295,6 @@ function _clean_rpath_by_patchelf(binaryfile, opt)
return ok
end
-function _insert_rpath_by_binutils(binaryfile, rpath, opt)
- return binutils.rpath_insert(binaryfile, rpath)
-end
-
-function _remove_rpath_by_binutils(binaryfile, rpath, opt)
- return binutils.rpath_remove(binaryfile, rpath)
-end
function _clean_rpath_by_binutils(binaryfile, opt)
return binutils.rpath_clean(binaryfile)
@@ -332,7 +325,6 @@ function insert(binaryfile, rpath, opt)
opt = opt or {}
local ops = {
_insert_rpath_by_patchelf,
- _insert_rpath_by_binutils
}
if is_host("macosx") then
table.insert(ops, 1, _insert_rpath_by_install_name_tool)
@@ -355,7 +347,6 @@ function remove(binaryfile, rpath, opt)
opt = opt or {}
local ops = {
_remove_rpath_by_patchelf,
- _remove_rpath_by_binutils
}
if is_host("macosx") then
table.insert(ops, 1, _remove_rpath_by_install_name_tool)