diff options
| author | ruki <[email protected]> | 2026-01-30 23:03:48 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2026-01-30 23:03:48 +0800 |
| commit | 7fee203a6cabfdc83ee9304ee2b92d8b0202a6c5 (patch) | |
| tree | 6d9f35348a2624d95946252cca551522acbbcca5 /core/src | |
| parent | e836941e029a2999a0d904b77df2196ec8f8eac6 (diff) | |
improve format.c
Diffstat (limited to 'core/src')
| -rw-r--r-- | core/src/xmake/binutils/format.c | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/core/src/xmake/binutils/format.c b/core/src/xmake/binutils/format.c index 1a12d8742..dd7e836f3 100644 --- a/core/src/xmake/binutils/format.c +++ b/core/src/xmake/binutils/format.c @@ -61,10 +61,7 @@ static tb_bool_t xm_binutils_format_is_pe(tb_stream_ref_t istream, tb_byte_t* fi } // e_lfanew points to PE signature offset - tb_uint32_t e_lfanew = (tb_uint32_t)( (tb_uint32_t)p[XM_BINUTILS_PE_DOS_ELFANEW_OFFSET] - | ((tb_uint32_t)p[XM_BINUTILS_PE_DOS_ELFANEW_OFFSET + 1] << 8) - | ((tb_uint32_t)p[XM_BINUTILS_PE_DOS_ELFANEW_OFFSET + 2] << 16) - | ((tb_uint32_t)p[XM_BINUTILS_PE_DOS_ELFANEW_OFFSET + 3] << 24)); + tb_uint32_t e_lfanew = tb_bits_get_u32_le(p + XM_BINUTILS_PE_DOS_ELFANEW_OFFSET); tb_check_break(e_lfanew >= XM_BINUTILS_PE_DOS_STUB_MIN_SIZE); tb_check_break((tb_size_t)e_lfanew + 4 <= max_peek); tb_check_break(size <= 0 || (tb_hize_t)e_lfanew + 4 <= (tb_hize_t)size); @@ -105,9 +102,9 @@ static __tb_inline__ tb_bool_t xm_binutils_format_is_macho(tb_byte_t const* firs } static __tb_inline__ tb_bool_t xm_binutils_format_is_coff(tb_byte_t const* first8) { - tb_uint16_t machine = (tb_uint16_t)((first8[1] << 8) | first8[0]); + tb_uint16_t machine = tb_bits_get_u16_le(first8); if (machine == 0x0000) { - tb_uint16_t machine2 = (tb_uint16_t)((first8[3] << 8) | first8[2]); + tb_uint16_t machine2 = tb_bits_get_u16_le(first8 + 2); if (machine2 == 0xffff) { return tb_true; } |
