Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Static-pie for Psql #79

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions postgresql/Readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Postgres
geitner-max marked this conversation as resolved.
Show resolved Hide resolved
## Psql
geitner-max marked this conversation as resolved.
Show resolved Hide resolved

Use the `build.sh` script to download and build `psql`.
The resulting `psql` binary is a static PIE executable loadable using the Unikraft ELF Loader.
Launching psql with run_elf_loader, it is required to launch with the `-U <username>` parameter, because Unikraft does not provide a default user to `psql`.

# TODO
MTJH1404 marked this conversation as resolved.
Show resolved Hide resolved


- initdb
- scripts
- pgbench
- pg_dump
- pg_test_timing
- pg_checksums
- pgevent
- pg_upgrade
- pg_amcheck
- pg_config
- pg_resetwal
- pg_verifybackup
- pg_archivecleanup
- pg_controldata
- pg_rewind
- pg_waldump
- pg_basebackup
- pg_ctl
- pg_test_fsync

27 changes: 27 additions & 0 deletions postgresql/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Cleanup directory
geitner-max marked this conversation as resolved.
Show resolved Hide resolved
rm -fr postgresql-*

# Download Postgres
wget https://ftp.postgresql.org/pub/source/v15.0/postgresql-15.0.tar.gz
echo ""
echo -n "Unpacking postgreSQL"
tar -xf postgresql-15.0.tar.gz

echo ""
echo $(pwd)
pushd postgresql-15.0 > /dev/null 2>&1
echo "Entering folder and configuring postgreSQL"
patch src/bin/psql/Makefile < ../makefile.patch
mkdir build
./configure --prefix=$(pwd)/build --without-readline --without-zlib CFLAGS='-fPIC' LDFLAGS_EX='-static-pie'
#
echo "CFLAGS: $CLAGS"
echo "LDFLAGS: $LDFLAGS"
echo "Building PostgreSQL"

make
popd > /dev/null 2>&1

ln -fn $(pwd)/postgresql-15.0/src/bin/psql/psql


MTJH1404 marked this conversation as resolved.
Show resolved Hide resolved
10 changes: 10 additions & 0 deletions postgresql/makefile.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
--- ../MakefilePSqlOriginal 2022-10-10 22:57:37.000000000 +0200
+++ src/bin/psql/Makefile 2022-10-23 16:15:38.758539645 +0200
@@ -47,7 +47,7 @@
all: psql

psql: $(OBJS) | submake-libpq submake-libpgport submake-libpgfeutils
- $(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
+ $(CC) $(CFLAGS) $(OBJS) -L../../../src/port -L../../../src/common -L../../../src/fe_utils -lpgfeutils -L../../../src/common -lpgcommon -L../../../src/port -lpgport -L../../../src/interfaces/libpq -lpq $(LDFLAGS_EX) $(LIBS) -o $@$(X)

help.o: sql_help.h
Binary file added postgresql/psql
Binary file not shown.
Empty file.