mirror of https://github.com/Nonannet/pelfy.git
Cross compile Docker for test files added
This commit is contained in:
parent
ae0db88b87
commit
f68167c386
|
@ -0,0 +1,47 @@
|
||||||
|
# Start with a base image containing build tools and libraries
|
||||||
|
FROM ubuntu:latest as builder
|
||||||
|
|
||||||
|
# Set the working directory
|
||||||
|
WORKDIR /src
|
||||||
|
|
||||||
|
# Install necessary build tools
|
||||||
|
RUN apt-get update && apt-get install -y \
|
||||||
|
build-essential \
|
||||||
|
gcc \
|
||||||
|
# g++ \
|
||||||
|
# make \
|
||||||
|
# wget \
|
||||||
|
# curl \
|
||||||
|
# git \
|
||||||
|
# ca-certificates \
|
||||||
|
# bison \
|
||||||
|
# flex \
|
||||||
|
# python3 \
|
||||||
|
# texinfo
|
||||||
|
|
||||||
|
# Install cross-compilers for x86, ARM, MIPS, and RISC-V
|
||||||
|
RUN apt-get install -y \
|
||||||
|
gcc-multilib \
|
||||||
|
gcc-arm-linux-gnueabihf \
|
||||||
|
gcc-mips-linux-gnu \
|
||||||
|
gcc-riscv64-linux-gnu \
|
||||||
|
gcc-aarch64-linux-gnu
|
||||||
|
|
||||||
|
# Copy the C file into the container
|
||||||
|
COPY test.c /src/
|
||||||
|
|
||||||
|
# Compile the C file for x86
|
||||||
|
RUN gcc -c -O0 -o obj/test-x86-o0.o test.c \
|
||||||
|
gcc -c -03 -o obj/test-x86-o3.o test.c \
|
||||||
|
# Compile the C file for ARM
|
||||||
|
arm-linux-gnueabihf-gcc -c -O0 -o obj/test-arm-o0.o test.c \
|
||||||
|
arm-linux-gnueabihf-gcc -c -O3 -o obj/test-arm-o3.o test.c \
|
||||||
|
# Compile the C file for MIPS
|
||||||
|
mips-linux-gnu-gcc -c -O0 -o obj/test-mips-o0.o test.c \
|
||||||
|
mips-linux-gnu-gcc -c -O3 -o obj/test-mips-o3.o test.c \
|
||||||
|
# Compile the C file for RISC-V
|
||||||
|
riscv64-linux-gnu-gcc -c -O0 -o obj/test-riscv-o0.o test.c \
|
||||||
|
riscv64-linux-gnu-gcc -c -03 -o obj/test-riscv-o3.o test.c
|
||||||
|
|
||||||
|
# Set the default command (just listing the files as an example)
|
||||||
|
CMD ["ls", "-l"]
|
|
@ -0,0 +1,4 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
docker build -t pelfy-test-cross-compiler .
|
||||||
|
docker run --rm -v $(pwd)/obj:/obj pelfy-test-cross-compiler
|
|
@ -0,0 +1,36 @@
|
||||||
|
|
||||||
|
//Assebly x86-64 gcc 14.1 -O3
|
||||||
|
|
||||||
|
//dummy for heap variables
|
||||||
|
float read_float_ret = 1337;
|
||||||
|
|
||||||
|
//Dummy helper functions
|
||||||
|
int __attribute__ ((noinline)) result_float(float ret1){
|
||||||
|
asm ("");
|
||||||
|
return (int)ret1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int __attribute__ ((noinline)) result_float_float(float ret1, float ret2){
|
||||||
|
asm ("");
|
||||||
|
return (int)ret1 + (int)ret2;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Operations
|
||||||
|
void add_float_float(float arg1, float arg2){
|
||||||
|
result_float(arg1 + arg2);
|
||||||
|
//addss %xmm1, %xmm0
|
||||||
|
//jmp result_float
|
||||||
|
}
|
||||||
|
|
||||||
|
void mul_float_float(float arg1, float arg2){
|
||||||
|
result_float(arg1 * arg2);
|
||||||
|
//mulss %xmm1, %xmm0
|
||||||
|
//jmp result_float
|
||||||
|
}
|
||||||
|
|
||||||
|
//Read global variables from heap
|
||||||
|
void read_float(float arg1){
|
||||||
|
result_float_float(arg1, read_float_ret);
|
||||||
|
//movss read_float_ret(%rip), %xmm1
|
||||||
|
//jmp result_float_float
|
||||||
|
}
|
Loading…
Reference in New Issue