├── LICENSE ├── README.md ├── armeb ├── gdb │ ├── README.md │ ├── gdb │ └── gdbserver ├── lua │ ├── README.md │ └── lua-5.3.0-armeb.tar.xz ├── puma5_toolchain │ ├── README.md │ ├── armeb-linux.tar.xz │ └── puma5_toolchain-2010.02.24.tgz ├── screen │ ├── README.md │ └── screen ├── strace │ ├── README.md │ └── strace └── tcpdump │ ├── README.md │ ├── libpcap.so.1.7.4 │ └── tcpdump └── mips ├── gdb ├── README.md └── gdb ├── mips_toolchain └── README.md ├── strace └── strace └── tcpdump └── tcpdump /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Bernardo Rodrigues 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 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # cross-utils 2 | Cross compiling Utils (ARMEB, ARMEL, MIPS, MIPSEL) 3 | -------------------------------------------------------------------------------- /armeb/gdb/README.md: -------------------------------------------------------------------------------- 1 | gdb and gdbserver (ARMEB) 2 | ========================= 3 | 4 | * Download and extract the latest GDB (v7.11.1 on 07/23/2016): 5 | 6 | ``` 7 | wget https://ftp.gnu.org/gnu/gdb/gdb-7.11.1.tar.xz 8 | tar xf gdb-7.11.1.tar.xz 9 | ``` 10 | 11 | * Comment lines 125 and 126 from /gdb-7.9.1/gdb/gnulib/import/mbrtowc.c (you can also set # define MB_CUR_MAX 1): 12 | 13 | ```c 14 | // if (m >= 4 || m >= MB_CUR_MAX) 15 | // goto invalid; 16 | ``` 17 | 18 | * Setup the build environment variables: 19 | 20 | ```bash 21 | export PATH=${PATH}:/opt/armeb-linux/ti-puma5/usr/bin 22 | export TARGETMACH=armeb-linux 23 | export BUILDMACH=i686-pc-linux-gnu 24 | export CROSS=armeb-linux 25 | export CC=${CROSS}-gcc 26 | export LD=${CROSS}-ld 27 | export AS=${CROSS}-as 28 | export AR=${CROSS}-ar 29 | export LDFLAGS="-static" 30 | ``` 31 | 32 | * Download and install termcap (dependency): 33 | 34 | ``` 35 | wget https://ftp.gnu.org/gnu/termcap/termcap-1.3.1.tar.gz 36 | tar xvzf termcap-1.3.1.tar.gz 37 | cd termcap-1.3.1/ 38 | ./configure --host=$TARGETMACH --prefix='/opt/armeb-linux/ti-puma5/usr' 39 | make install 40 | mv termcap.o /opt/armeb-linux/ti-puma5/lib/ 41 | ``` 42 | 43 | * Configure and cross compile gdb and gdbserver: 44 | 45 | ``` 46 | cd ../gdb-7.11.1/ 47 | ./configure --host=$TARGETMACH --target=$TARGETMACH 48 | make 49 | ``` 50 | 51 | ``` 52 | cd gdb 53 | ./configure --host=$TARGETMACH --target=$TARGETMACH 54 | make 55 | ``` 56 | 57 | * Strip the binaries: 58 | 59 | ``` 60 | armeb-linux-strip gdb 61 | armeb-linux-strip gdbserver/gdbserver 62 | ``` 63 | -------------------------------------------------------------------------------- /armeb/gdb/gdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmaia/cross-utils/7d802919867a171f4b121139d4017d10a410a2f8/armeb/gdb/gdb -------------------------------------------------------------------------------- /armeb/gdb/gdbserver: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmaia/cross-utils/7d802919867a171f4b121139d4017d10a410a2f8/armeb/gdb/gdbserver -------------------------------------------------------------------------------- /armeb/lua/README.md: -------------------------------------------------------------------------------- 1 | lua 5.3.0 (ARMEB) 2 | ================= 3 | 4 | * Download and extract lua 5.3.0: 5 | 6 | ``` 7 | wget https://www.lua.org/ftp/lua-5.3.0.tar.gz 8 | tar xvzf lua-5.3.0.tar.gz 9 | cd lua-5.3.0/ 10 | ``` 11 | 12 | * Edit src/Makefile and change line 98 from CC="gcc -std=c89" to CC="armeb-linux-gcc -std=c89". 13 | 14 | * Cross compile lua: 15 | 16 | ``` 17 | export PATH=${PATH}:/opt/armeb-linux/ti-puma5/usr/bin 18 | make CC=armeb-linux-gcc c89 19 | ``` -------------------------------------------------------------------------------- /armeb/lua/lua-5.3.0-armeb.tar.xz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmaia/cross-utils/7d802919867a171f4b121139d4017d10a410a2f8/armeb/lua/lua-5.3.0-armeb.tar.xz -------------------------------------------------------------------------------- /armeb/puma5_toolchain/README.md: -------------------------------------------------------------------------------- 1 | Description 2 | =========== 3 | 4 | Quick guide to create a working buildroot to cross compile binaries and firmwares from puma5 cable modems, including Motorola SB6120/6121/6141 and Arris TG862 families. 5 | 6 | [puma5_toolchain-2010.02.24.tgz](https://github.com/bmaia/cross-utils/blob/master/armeb/puma5_toolchain/puma5_toolchain-2010.02.24.tgz?raw=true) - ARMEB toolchain (puma5) and installation script and patches. 7 | 8 | Installation 9 | ============ 10 | 11 | The procedure was tested on a Kali Linux 1.1.0a 64 bit Image with GCC 4.7.2. 12 | 13 | * Download and extract the puma5 toolchain: 14 | 15 | ``` 16 | wget https://github.com/bmaia/cross-utils/raw/master/armeb/puma5_toolchain/puma5_toolchain-2010.02.24.tgz 17 | tar xjf puma5_toolchain-2010.02.24.tgz 18 | ``` 19 | 20 | * Install dependencies: 21 | 22 | ``` 23 | sudo apt-get install kernel-package libncurses5-dev fakeroot wget bzip2 build-essential bison flex unifdef build-essential texinfo libc6-dev-i386 quilt g++-multilib 24 | ``` 25 | 26 | * Make sure you're using make 3.8.1: 27 | 28 | ``` 29 | make -version 30 | GNU Make 3.81 31 | ``` 32 | 33 | * Install the puma5 toolchain on the /opt/armeb-linux folder: 34 | 35 | ``` 36 | cd puma5_toolchain/src/ 37 | mkdir /opt/armeb-linux 38 | export TI_PUMA5_TOOLCHAIN_INSTALL_DIR=/opt/armeb-linux 39 | ./build-toolchain.sh 40 | ``` 41 | 42 | * Cross compile a Hello World in C: 43 | 44 | ```c 45 | #include 46 | 47 | main(){ 48 | printf("Hello World\n"); 49 | } 50 | 51 | ``` 52 | 53 | ``` 54 | /opt/armeb-linux/ti-puma5/usr/bin/armeb-linux-cc hello.c -o hello -static 55 | ``` 56 | 57 | * Check the ELF binary 58 | 59 | ``` 60 | file hello 61 | ``` 62 | ``` 63 | hello: ELF 32-bit MSB executable, ARM, version 1 (SYSV), dynamically linked (uses shared libs), not stripped 64 | ``` 65 | 66 | Installation (prebuilt toolchain) 67 | ================================= 68 | 69 | If you don't want to compile everything and you trust the Internet, download the prebuilt puma5 toolchain for Linux 64bits (tested on Kali 1.1.0a): 70 | 71 | ``` 72 | cd /opt/ 73 | wget https://github.com/bmaia/cross-utils/raw/master/armeb/puma5_toolchain/armeb-linux.tar.xz 74 | tar xf armeb-linux.tar.xz 75 | ``` 76 | 77 | References 78 | ========== 79 | 80 | [1] http://www.grandrapidsdevs.com/creating-a-working-buildroot-for-sb6120-6141-komodo.html 81 | 82 | [2] http://sourceforge.net/projects/sb6120.arris/files/SB6120%20SB6121%20SB6141%201.0.6.3-SCM03 83 | 84 | [3] http://sourceforge.net/projects/sb6x2x.arris/files/SBV6x2x_1_0_2_0_SCM01/1.0.2.0SCM01 85 | 86 | [4] http://sourceforge.net/projects/sb6141.arris/files/SB6141_1_0_6_1_SCM00 87 | -------------------------------------------------------------------------------- /armeb/puma5_toolchain/armeb-linux.tar.xz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmaia/cross-utils/7d802919867a171f4b121139d4017d10a410a2f8/armeb/puma5_toolchain/armeb-linux.tar.xz -------------------------------------------------------------------------------- /armeb/puma5_toolchain/puma5_toolchain-2010.02.24.tgz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmaia/cross-utils/7d802919867a171f4b121139d4017d10a410a2f8/armeb/puma5_toolchain/puma5_toolchain-2010.02.24.tgz -------------------------------------------------------------------------------- /armeb/screen/README.md: -------------------------------------------------------------------------------- 1 | screen (ARMEB) 2 | ============== 3 | 4 | * Build Instructions: https://how-to-build-for-arm.wikispaces.com/screen 5 | 6 | * Additional Patch: https://168281.bugs.gentoo.org/attachment.cgi?id=178365 7 | -------------------------------------------------------------------------------- /armeb/screen/screen: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmaia/cross-utils/7d802919867a171f4b121139d4017d10a410a2f8/armeb/screen/screen -------------------------------------------------------------------------------- /armeb/strace/README.md: -------------------------------------------------------------------------------- 1 | strace (ARMEB) 2 | ============== 3 | 4 | * Download and extract the latest strace (v4.12 on 07/23/2016): 5 | 6 | ``` 7 | wget http://downloads.sourceforge.net/project/strace/strace/4.12/strace-4.12.tar.xz 8 | tar xf strace-4.12.tar.xz 9 | cd strace-4.12/ 10 | ``` 11 | 12 | * Edit v4l2.c to include an htole32() replacement before line 70 (print_pixelformat): 13 | 14 | ```c 15 | uint32_t htole32(uint32_t i) 16 | { 17 | uint32_t result; 18 | result = (i & 0x000000ff) << 24 19 | | (i & 0x0000ff00) << 8 20 | | (i & 0x00ff0000) >> 8 21 | | (i & 0xff000000) >> 24; 22 | return result; 23 | } 24 | ``` 25 | 26 | * Edit /opt/armeb-linux/ti-puma5/usr/include/linux/audit.h and define _uu32 before line 265 (struct audit_status) 27 | 28 | ``` 29 | typedef unsigned int __u32; 30 | ``` 31 | 32 | * Setup the build environment variables: 33 | 34 | ```bash 35 | export PATH=${PATH}:/opt/armeb-linux/ti-puma5/usr/bin 36 | export TARGETMACH=armeb-linux 37 | export BUILDMACH=i686-pc-linux-gnu 38 | export CROSS=armeb-linux 39 | export CC=${CROSS}-gcc 40 | export LD=${CROSS}-ld 41 | export AS=${CROSS}-as 42 | export AR=${CROSS}-ar 43 | export CXX=${CROSS}-g++ 44 | export LDFLAGS="-static" 45 | ``` 46 | 47 | * Configure and cross compile strace 48 | 49 | ``` 50 | ./configure --host=$TARGETMACH 51 | make 52 | ``` 53 | 54 | * Strip the binary: 55 | 56 | ``` 57 | armeb-linux-strip strace 58 | ``` 59 | -------------------------------------------------------------------------------- /armeb/strace/strace: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmaia/cross-utils/7d802919867a171f4b121139d4017d10a410a2f8/armeb/strace/strace -------------------------------------------------------------------------------- /armeb/tcpdump/README.md: -------------------------------------------------------------------------------- 1 | tcpdump (ARMEB) 2 | ========================= 3 | 4 | * Download and extract the latest libpcap and tcpdump (v1.7.4 and v4.7.4 on 09/13/2015): 5 | 6 | ``` 7 | wget http://www.tcpdump.org/release/libpcap-1.7.4.tar.gz 8 | wget http://www.tcpdump.org/release/tcpdump-4.7.4.tar.gz 9 | tar xvzf libpcap-1.7.4.tar.gz 10 | tar xvzf tcpdump-4.7.4.tar.gz 11 | ``` 12 | 13 | * Setup the build environment variables: 14 | 15 | ```bash 16 | export PATH=${PATH}:/opt/armeb-linux/ti-puma5/usr/bin 17 | export TARGETMACH=armeb-linux 18 | export BUILDMACH=i686-pc-linux-gnu 19 | export CROSS=armeb-linux 20 | export CC=${CROSS}-gcc 21 | export LD=${CROSS}-ld 22 | export AS=${CROSS}-as 23 | export AR=${CROSS}-ar 24 | export LDFLAGS="-static" 25 | ``` 26 | 27 | * Configure and cross compile libpcap: 28 | 29 | ``` 30 | cd ./libpcap-1.7.4/ 31 | ./configure --host=$TARGETMACH --with-pcap=linux ac_cv_linux_vers=2 32 | make 33 | mv libpcap.so.1.7.4 /opt/armeb-linux/ti-puma5/lib/ 34 | ``` 35 | 36 | * Configure and cross compile tcpdump: 37 | 38 | ``` 39 | cd ../tcpdump-4.7.4/ 40 | ./configure --build=$BUILDMACH --host=$TARGETMACH ac_cv_linux_vers=2 41 | ``` 42 | 43 | * Strip the binaries: 44 | 45 | ``` 46 | armeb-linux-strip tcpdump 47 | ``` 48 | -------------------------------------------------------------------------------- /armeb/tcpdump/libpcap.so.1.7.4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmaia/cross-utils/7d802919867a171f4b121139d4017d10a410a2f8/armeb/tcpdump/libpcap.so.1.7.4 -------------------------------------------------------------------------------- /armeb/tcpdump/tcpdump: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmaia/cross-utils/7d802919867a171f4b121139d4017d10a410a2f8/armeb/tcpdump/tcpdump -------------------------------------------------------------------------------- /mips/gdb/README.md: -------------------------------------------------------------------------------- 1 | gdb and gdbserver (MIPS) 2 | ========================= 3 | 4 | * On a newer Ubuntu System (16.04+), install the MIPS toolchain: 5 | 6 | ``` 7 | sudo apt update 8 | sudo apt install g++-mips-linux-gnu gcc-mips-linux-gnu 9 | ``` 10 | 11 | * Download and extract the latest GDB (v8.0 on 04/06/2017): 12 | 13 | ``` 14 | wget ftp://ftp.gnu.org/gnu/gdb/gdb-8.0.tar.xz 15 | tar xvf gdb-8.0.tar.xz 16 | ``` 17 | 18 | * Setup the build environment variables: 19 | 20 | ```bash 21 | export TARGETMACH=mips-linux-gnu 22 | export CROSS=mips-linux-gnu 23 | export CC=${CROSS}-gcc 24 | export LD=${CROSS}-ld 25 | export AS=${CROSS}-as 26 | export AR=${CROSS}-ar 27 | export CXX=${CROSS}-g++ 28 | export LDFLAGS="-static" 29 | ``` 30 | 31 | * Configure and cross compile gdb and gdbserver: 32 | 33 | ``` 34 | cd gdb-8.0/ 35 | ./configure --host=$TARGETMACH --target=$TARGETMACH 36 | make 37 | ``` 38 | 39 | * Strip the binaries: 40 | 41 | ``` 42 | mips-linux-gnu-strip gdb 43 | mips-linux-gnu-strip gdbserver/gdbserver 44 | ``` 45 | 46 | -------------------------------------------------------------------------------- /mips/gdb/gdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmaia/cross-utils/7d802919867a171f4b121139d4017d10a410a2f8/mips/gdb/gdb -------------------------------------------------------------------------------- /mips/mips_toolchain/README.md: -------------------------------------------------------------------------------- 1 | Description 2 | =========== 3 | 4 | Download OpenWRT/LEDE SDK for a device that has the same arch/SOC as your target. On our case, let's use **ar71xx**: 5 | 6 | ```bash 7 | wget https://downloads.lede-project.org/releases/17.01.1/targets/ar71xx/generic/lede-sdk-17.01.1-ar71xx-generic_gcc-5.4.0_musl-1.1.16.Linux-x86_64.tar.xz 8 | tar xvf lede-sdk-17.01.1-ar71xx-generic_gcc-5.4.0_musl-1.1.16.Linux-x86_64.tar.xz 9 | cd lede-sdk-17.01.1-ar71xx-generic_gcc-5.4.0_musl-1.1.16.Linux-x86_64/ 10 | ``` 11 | 12 | Follow the instructions from the OpenWRT/LEDE docs to compile packages using the SDK: 13 | 14 | - [https://lede-project.org/docs/guide-developer/compile_packages_for_lede_with_the_sdk](https://lede-project.org/docs/guide-developer/compile_packages_for_lede_with_the_sdk) 15 | 16 | Go to the SDK folder and then open the SDK's menu: 17 | 18 | ```bash 19 | make menuconfig 20 | ``` 21 | 22 | Select Global Build Settings and press enter, in the submenu deselect/exclude the following options: 23 | 24 | ``` 25 | “Select all target specific packages by default” 26 | “Select all kernel module packages by default” 27 | “Select all userspace packages by default” 28 | ``` 29 | 30 | Save the configuration and then update the package lists 31 | 32 | ``` 33 | ./scripts/feeds update -a 34 | ``` 35 | 36 | Select the packages you want to compile: 37 | 38 | ```bash 39 | ./scripts/feeds install 40 | ``` 41 | 42 | Type ```make menuconfig``` again, find the package you want to build and select it using "m", save the config and compile the package using: 43 | 44 | ```bash 45 | make 46 | ``` 47 | 48 | Now go to the **bin/packages/mips_24kc/base/** directory and check the newly created .ipk package. If you want to use the standalone binaries, just extract the ipk using tar: 49 | 50 | ```bash 51 | $ cd bin/packages/mips_24kc/base/ 52 | $ tar xvf strace_4.15-1_mips_24kc.ipk 53 | $ tar xvf data.tar.gz 54 | ./ 55 | ./usr/ 56 | ./usr/bin/ 57 | ./usr/bin/strace 58 | $ file ./usr/bin/strace 59 | ./usr/bin/strace: ELF 32-bit MSB executable, MIPS, MIPS32 rel2 version 1 (SYSV), dynamically linked, interpreter /lib/ld-musl-mips-sf.so.1, corrupted section header size 60 | ``` 61 | 62 | If you want to statically compile the binary, you can change the package Makefile and include **LDFLAGS+="-static"** to the MAKE_FLAGS entry. 63 | 64 | ``` 65 | vim package/feeds/base/strace/Makefile 66 | ``` 67 | 68 | ```bash 69 | MAKE_FLAGS := \ 70 | CCOPT="$(TARGET_CFLAGS)" LDFLAGS+="-static" 71 | ``` 72 | 73 | ```bash 74 | make 75 | ``` 76 | 77 | Extract the .ipk package again and get the statically compiled binary: 78 | 79 | ```bash 80 | $ file bin/packages/mips_24kc/base/usr/bin/strace 81 | bin/packages/mips_24kc/base/usr/bin/strace: ELF 32-bit MSB executable, MIPS, MIPS32 rel2 version 1 (SYSV), statically linked, corrupted section header size 82 | ``` 83 | -------------------------------------------------------------------------------- /mips/strace/strace: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmaia/cross-utils/7d802919867a171f4b121139d4017d10a410a2f8/mips/strace/strace -------------------------------------------------------------------------------- /mips/tcpdump/tcpdump: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmaia/cross-utils/7d802919867a171f4b121139d4017d10a410a2f8/mips/tcpdump/tcpdump --------------------------------------------------------------------------------