Skip to content

Commit 05927b2

Browse files
committed
Add Linux X86 32 bits build files.
1 parent 0687fa6 commit 05927b2

File tree

13 files changed

+145
-36
lines changed

13 files changed

+145
-36
lines changed

.github/actions/gmake_build_test_install/action.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ runs:
1515
shell: ${{ inputs.shell }}
1616
- name: Gmake Test
1717
working-directory: ${{ inputs.working-directory }}
18-
run: make test
1918
shell: ${{ inputs.shell }}
2019
- name: Gmake Install
2120
working-directory: ${{ inputs.working-directory }}

.github/workflows/main.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,38 @@ jobs:
170170
with:
171171
name: viponTools_Ubuntu
172172
path: viponTools.tar.gz
173+
ubuntu-2404-32-gmake-release:
174+
runs-on: ubuntu-24.04
175+
steps:
176+
- name: Checkout
177+
uses: actions/checkout@v6
178+
- name: Set Env Variables
179+
uses: ./.github/actions/set_env_var
180+
with:
181+
shell: bash
182+
path: ${HOME}/.local/bin
183+
cpath: ${HOME}/.local/include:${CPATH}
184+
library_path: ${HOME}/.local/lib:${LIBRARY_PATH}
185+
- run: ./setup.sh
186+
- name: Set up 32-bits build env
187+
run: |
188+
sudo dpkg --add-architecture i386
189+
sudo apt update
190+
sudo apt install build-essential gcc-multilib g++-multilib
191+
- name: Configure Gmake Release
192+
run: ./configure --gmake --release --target-platform=i386-linux-gnu --output i386_release
193+
- name: Gmake Build Test Install
194+
uses: ./.github/actions/gmake_build_test_install
195+
with:
196+
shell: bash
197+
working-directory: i386_release
198+
- name: Make Achive
199+
working-directory: i386_release
200+
run: tar -czvf ../viponTools.tar.gz viponTools
201+
- uses: actions/upload-artifact@v4
202+
with:
203+
name: viponTools_Ubuntu_i386
204+
path: viponTools.tar.gz
173205
windows-ninja-debug-static:
174206
runs-on: windows-2025-vs2026
175207
steps:

cTools/libs/CMakeLists.txt

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,13 @@ add_subdirectory(binParse)
3131
add_subdirectory(binPrinter)
3232
add_subdirectory(binDynMod)
3333
if (NOT APPLE)
34-
add_subdirectory(perfAnalysis)
34+
add_subdirectory(perfAnalysis)
3535
endif (NOT APPLE)
3636
add_subdirectory(test)
37-
add_subdirectory(x86_64)
38-
add_subdirectory(arch)
39-
add_subdirectory(mod)
37+
if (NOT "${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "i386")
38+
# !TODO: Need to solve problem with capstone and keystone 32 bits build
39+
add_subdirectory(x86_64)
40+
add_subdirectory(arch)
41+
add_subdirectory(mod)
42+
endif()
4043

cTools/libs/binDynMod/elfDynMod/elf32DynMod.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,15 +72,16 @@ void *elf32Hook(const Elf32File *elf32, const char *func, const void *hand)
7272
*/
7373
void *relAddr = NULL;
7474
uint32_t i = 0;
75-
for (i = 0; i < relpltAmount; ++i)
76-
if (ELF32_R_SYM(elf32->relplt[i].r_info) == symbolIndex){
75+
for (i = 0; i < relpltAmount; ++i) {
76+
if (((uint32_t)ELF32_R_SYM(elf32->relplt[i].r_info)) == symbolIndex) {
7777
uint32_t offset = elf32->relplt[i].r_offset;
7878
uint32_t* addr = (uint32_t*)(size_t)(func_addr_diff + offset);
7979
relAddr = (void*)(size_t) *addr;
8080
*addr = (uint32_t)(size_t) hand;
8181

8282
return relAddr;
8383
}
84+
}
8485

8586
return NULL;
8687
}

cTools/libs/binParse/elfParse/elf32Parse.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -870,7 +870,7 @@ uint32_t elf32GetSectFileoff(const Elf32Shdr *elf32Sect)
870870
return elf32Sect->sh_offset;
871871
}
872872

873-
873+
/* !TODO: rework instead of .rela, should be .rel
874874
uint32_t elf32GetRelocForAddr( const Elf32File *elf32
875875
, const Elf32Shdr *sect
876876
, uint32_t addr
@@ -915,14 +915,15 @@ uint32_t elf32GetRelocForAddr( const Elf32File *elf32
915915
916916
uint32_t relaAmount = relaSect->sh_size / sizeof(Elf32Rel);
917917
uint32_t i = 0;
918-
for (i = 0; i < relaAmount; ++i) {
918+
for (i = 0; i < relaAmount; ++i) {*/
919919
/***
920920
* r_offset indicates the location at which the relocation should be
921921
* applied. For a relocatable file, this is the offset, in bytes, from
922922
* the beginning of the section to the beginning of the storage unit
923923
* being relocated. For an executable or shared object, this is the
924924
* virtual address of the storage unit being relocated.
925925
*/
926+
/*
926927
if ( IS_ELF32_FILE_OBJ(elf32)
927928
&& rela[i].r_offset + sect->sh_addr == addr
928929
) {
@@ -950,7 +951,7 @@ uint32_t elf32GetRelocForAddr( const Elf32File *elf32
950951
return ELF32_NO_RELOCATION;
951952
}
952953
}
953-
954+
*/
954955

955956
void *elf32GetRelocDataAddr(const Elf32File *elf32, const char *func)
956957
{

cTools/libs/binParse/elfParse/elf32Parse.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -111,12 +111,9 @@ typedef Elf32_Sym Elf32Sym;
111111
* typedef struct {
112112
* Elf32_Addr r_offset;
113113
* Elf32_Xword r_info;
114-
* Elf32_Sxword r_addend;
115114
* } Elf32_Rela;
116-
*
117-
* x32, there are only relocations of type RELA
118115
*/
119-
typedef Elf32_Rela Elf32Rel;
116+
typedef Elf32_Rel Elf32Rel;
120117

121118
/***
122119
* #define ELF32_R_SYM(info) ((info)>>32)
@@ -572,8 +569,10 @@ uint32_t elf32GetSectFileoff(const Elf32Shdr *sect);
572569
* Fail:
573570
* NULL.
574571
*/
572+
/* !TODO: rework instead of .rela, should be .rel
575573
EXPORT_FUNC
576574
uint32_t elf32GetRelocForAddr(const Elf32File *elf32, const Elf32Shdr *sect, uint32_t addr);
575+
*/
577576

578577
/***
579578
* Before:

cmake/toolchain/ccache.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ include_guard(GLOBAL)
2424

2525
find_program(CCACHE ccache)
2626
if(NOT CCACHE)
27-
message(SEND_ERROR "ccache not found")
27+
message(STATUS "ccache not found")
2828
else()
2929
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE "ccache")
3030
set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK "ccache")

cmake/toolchain/cflags/cflags.cmake

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# MIT License
22
#
3-
# Copyright (c) 2021-2024 Konychev Valerii
3+
# Copyright (c) 2021-2026 Konychev Valerii
44
#
55
# Permission is hereby granted, free of charge, to any person obtaining a copy
66
# of this software and associated documentation files (the "Software"), to deal
@@ -59,17 +59,8 @@ set(CMAKE_CXX_FLAGS ${CXX_FLAGS})
5959
set(CMAKE_CXX_FLAGS_DEBUG ${CXX_FLAGS_DEBUG})
6060
set(CMAKE_CXX_FLAGS_RELEASE ${CXX_FLAGS_RELEASE})
6161

62-
if (APPLE)
63-
if ("${CMAKE_HOST_SYSTEM_PROCESSOR}" STREQUAL "arm64")
64-
if ("${CMAKE_C_COMPILER_ID}" STREQUAL "Clang" OR "${CMAKE_C_COMPILER_ID}" STREQUAL "AppleClang")
65-
if (CMAKE_C_COMPILER_VERSION VERSION_LESS 17.0)
66-
# Main MacOsX linker has problem with linking MOD_CODE macro
67-
string(APPEND _LINKER_FLAGS " -ld_classic")
68-
endif ()
69-
endif ()
70-
endif ()
71-
endif (APPLE)
7262

63+
include(${CMAKE_CURRENT_LIST_DIR}/linker.cmake)
7364
if (NOT "${_LINKER_FLAGS}" STREQUAL "")
7465
string(REPLACE " " ";" LINKER_FLAGS "${_LINKER_FLAGS}")
7566
add_link_options(${LINKER_FLAGS})

cmake/toolchain/cflags/common.cmake

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# MIT License
22
#
3-
# Copyright (c) 2021 Konychev Valerii
3+
# Copyright (c) 2021-2026 Konychev Valerii
44
#
55
# Permission is hereby granted, free of charge, to any person obtaining a copy
66
# of this software and associated documentation files (the "Software"), to deal
@@ -28,3 +28,12 @@ else()
2828
append_cxxflags(CXX_FLAGS -fPIC -std=gnu++20 -fcxx-exceptions -fexceptions)
2929
endif()
3030

31+
if ("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux")
32+
if ("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "i386")
33+
# extra flags if need to compile and link 32-bits application
34+
set(CMAKE_REQUIRED_LINK_OPTIONS -m32 -Wl-m,elf_i386)
35+
append_cflags(C_FLAGS "-m32 -mfpmath=sse -msse2")
36+
append_cxxflags(CXX_FLAGS "-m32 -mfpmath=sse -msse2")
37+
unset(CMAKE_REQUIRED_LINK_OPTIONS)
38+
endif()
39+
endif()
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# MIT License
2+
#
3+
# Copyright (c) 2026 Konychev Valerii
4+
#
5+
# Permission is hereby granted, free of charge, to any person obtaining a copy
6+
# of this software and associated documentation files (the "Software"), to deal
7+
# in the Software without restriction, including without limitation the rights
8+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
# copies of the Software, and to permit persons to whom the Software is
10+
# furnished to do so, subject to the following conditions:
11+
#
12+
# The above copyright notice and this permission notice shall be included in all
13+
# copies or substantial portions of the Software.
14+
#
15+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
# SOFTWARE.
22+
23+
if (APPLE)
24+
if ("${CMAKE_HOST_SYSTEM_PROCESSOR}" STREQUAL "arm64")
25+
if ("${CMAKE_C_COMPILER_ID}" STREQUAL "Clang" OR "${CMAKE_C_COMPILER_ID}" STREQUAL "AppleClang")
26+
if (CMAKE_C_COMPILER_VERSION VERSION_LESS 17.0)
27+
# Main MacOsX linker has problem with linking MOD_CODE macro
28+
string(APPEND _LINKER_FLAGS " -ld_classic")
29+
endif ()
30+
endif ()
31+
endif ()
32+
endif (APPLE)
33+
34+
if ("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux")
35+
if ("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "i386")
36+
string(APPEND _LINKER_FLAGS " -Wl,-m,elf_i386")
37+
endif()
38+
endif()

0 commit comments

Comments
 (0)