Skip to content

Commit

Permalink
Seems like I got FBI to compile too, going to reachout to Zhenghao ab…
Browse files Browse the repository at this point in the history
…out finalizing the Docker Image creation and testing lava
  • Loading branch information
AndrewQuijano committed Jul 9, 2024
1 parent 4861eae commit e455d80
Show file tree
Hide file tree
Showing 6 changed files with 70 additions and 71 deletions.
79 changes: 31 additions & 48 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,62 +1,45 @@
FROM ubuntu:20.04 as builder
ARG BASE_IMAGE="ubuntu:20.04"

### BASE IMAGE
FROM $BASE_IMAGE as base
ARG BASE_IMAGE

ENV DEBIAN_FRONTEND=noninteractive
ENV LLVM_DIR=/usr/lib/llvm-11

# Copy dependencies lists into container. We copy them all and then do a mv because
# we need to transform base_image into a windows compatible filename which we can't
# do in a COPY command.
COPY ./dependencies/* /tmp
RUN mv /tmp/$(echo "$BASE_IMAGE" | sed 's/:/_/g')_build.txt /tmp/build_dep.txt && \
mv /tmp/$(echo "$BASE_IMAGE" | sed 's/:/_/g')_base.txt /tmp/base_dep.txt

RUN apt-get update && apt-get install -qq -y \
bc \
build-essential \
clang-tools-11 \
cmake \
git \
inotify-tools \
jq \
libclang-11-dev \
libfdt-dev \
libjsoncpp-dev \
libjsoncpp1 \
libpq-dev \
llvm-11-dev \
postgresql \
python3-psycopg2 \
python3-sqlalchemy \
socat \
wget
# Base image just needs runtime dependencies
RUN [ -e /tmp/base_dep.txt ] && \
apt-get -qq update && \
apt-get -qq install -y --no-install-recommends curl $(cat /tmp/base_dep.txt | grep -o '^[^#]*') && \
apt-get clean

# Step 1: Install panda debian package, you need a version that has Dwarf2 Plugin
# Finally: Install panda debian package, you need a version that has the Dwarf2 Plugin
RUN wget https://github.com/panda-re/panda/releases/download/v1.8.23/pandare_20.04.deb
RUN command apt install -qq -y ./pandare_20.04.deb
RUN pip install pandare

# Libodb
RUN cd /tmp && \
wget http://codesynthesis.com/download/odb/2.4/odb_2.4.0-1_amd64.deb && \
wget http://codesynthesis.com/download/odb/2.4/libodb-2.4.0.tar.gz && \
wget http://codesynthesis.com/download/odb/2.4/libodb-pgsql-2.4.0.tar.gz && \
dpkg -i odb_2.4.0-1_amd64.deb && \
tar xf libodb-pgsql-2.4.0.tar.gz && \
tar xf libodb-2.4.0.tar.gz && \
cd /tmp/libodb-2.4.0 && \
CXXFLAGS='-D_GLIBCXX_USE_CXX11_ABI=0' ./configure --enable-shared && \
make -j $(nproc) && \
make install && \
cd /tmp/libodb-pgsql-2.4.0 && \
CXXFLAGS='-D_GLIBCXX_USE_CXX11_ABI=0' ./configure --enable-shared && \
make -j $(nproc) && \
make install
# TODO in main container
#RUN echo "/usr/local/lib" > /etc/ld.so.conf.d/usr-local-lib.conf
#RUN ldconfig
### BUILD IMAGE - STAGE 2
FROM base AS builder
ARG BASE_IMAGE

# Build btrace
COPY tools/btrace /tools/btrace
RUN cd /tools/btrace && \
bash compile.sh
RUN [ -e /tmp/build_dep.txt ] && \
apt-get -qq update && \
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends $(cat /tmp/build_dep.txt | grep -o '^[^#]*') && \
apt-get clean

# Build lavaTool. Depends on headers in lavaODB and tools/lavaDB
#COPY tools/lavaODB/ tools/lavaDB/ tools/lavaTool/ /tools/
COPY tools/ /tools
#### Develop setup: panda built + pypanda installed (in develop mode) - Stage 3
FROM builder as developer

COPY ./tools/ /tools
COPY setup_container.py /
ENV LLVM_DIR=/usr/lib/llvm-11

RUN python3 setup_container.py

# RUN cd /tools && \
Expand Down
1 change: 1 addition & 0 deletions dependencies/ubuntu_20.04_base.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# lava dependencies, needed to run LAVA
24 changes: 24 additions & 0 deletions dependencies/ubuntu_20.04_build.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# lava dependencies, to compile LAVA

# Based on original setup.py after panda is installed step
# https://installati.one/install-odb-ubuntu-20-04/?expand_article=1
odb

# https://installati.one/install-libodbc2-ubuntu-22-04/?expand_article=1
libodbc2

# https://installati.one/install-libodb-pgsql-2.4-ubuntu-20-04/
libodb-pgsql-dev

# Brendan noticed these libraries were needed to compile FBI
libodb-pgsql-2.4


# https://pypi.org/project/pyzmq/
libzmq3-dev

# libc6 needed for compiling btrace?

# libjsoncpp needed for fbi json parsing?

# I may need g++-10?
14 changes: 2 additions & 12 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ progress "Updates complete"
# Dependencies are for a major version, but the filenames include minor versions
# So take our major version, find the first match in dependencies directory and run with it.
# This will give us "./panda/dependencies/ubuntu:20.04" where ubuntu:20.04_build.txt or 20.04_base.txt exists
version=$(lsb_release -r| awk '{print $2}' | awk -F'.' '{print $1}')
version=$(lsb_release -r | awk '{print $2}' | awk -F'.' '{print $1}')
# shellcheck disable=SC2086
dep_base=$(find ./dependencies/ubuntu_${version}.* -print -quit | sed -e "s/_build\.txt\|_base\.txt//")

Expand All @@ -56,16 +56,6 @@ $SUDO pip3 install --upgrade pip
$SUDO pip3 install -r docker/requirements.txt
progress "Installed Python requirements"

# Everything here is everything in setup_container.py
rm -rf tools/build
mkdir -p tools/build
mkdir -p tools/install
cmake -Btools/build -Htools -DCMAKE_INSTALL_PREFIX=tools/install

# Compile lavaTool
make --no-print-directory -j4 install -Ctools/build/lavaTool

# Compile FBI
make --no-print-directory -j4 -C fbi install -Ctools/build
$SUDO python3 setup_container.py

progress "Installed LAVA"
21 changes: 11 additions & 10 deletions tools/fbi/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,12 @@ project (FBI LANGUAGES CXX)
add_executable(fbi find_bug_inj.cpp)
set_property(TARGET fbi PROPERTY CXX_STANDARD 17)

target_compile_options(fbi PRIVATE -D_GLIBCXX_USE_CXX11_ABI=0)
if (${DEBUG})
target_compile_options(fbi PRIVATE -fno-omit-frame-pointer -g -O0)
else()
target_compile_options(fbi PRIVATE -flto -O3)
set_target_properties(fbi PROPERTIES LINK_FLAGS "-flto -fuse-ld=gold")
endif()
#if (${DEBUG})
# target_compile_options(fbi PRIVATE -fno-omit-frame-pointer -g -O0)
#else()
# target_compile_options(fbi PRIVATE -flto -O3)
# set_target_properties(fbi PROPERTIES LINK_FLAGS "-flto -fuse-ld=gold")
#endif()

target_include_directories(fbi BEFORE
PUBLIC
Expand All @@ -21,7 +20,9 @@ target_include_directories(fbi BEFORE
${CMAKE_CURRENT_SOURCE_DIR}/../../include
/usr/lib/odb/x86_64-linux-gnu/include
/usr/local/include
)
/usr/include/jsoncpp
)

add_dependencies(fbi lava-odb_x64)
set_target_properties(fbi PROPERTIES LINK_FLAGS "-L/usr/local/lib")
target_link_libraries(fbi
Expand All @@ -31,10 +32,10 @@ target_link_libraries(fbi
z
odb
odb-pgsql
jsoncpp
pq
protobuf
jsoncpp
)

install (TARGETS fbi
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
Expand Down
2 changes: 1 addition & 1 deletion tools/fbi/src/find_bug_inj.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ extern "C" {
#include <unistd.h>
}

#include <jsoncpp/json/json.h>
#include <json/json.h>

#include <iostream>
#include <fstream>
Expand Down

0 comments on commit e455d80

Please sign in to comment.