Skip to content

Commit

Permalink
Compile some heap test binaries with zig cc
Browse files Browse the repository at this point in the history
  • Loading branch information
disconnect3d committed Aug 23, 2022
1 parent 0589efb commit 738b5fd
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 20 deletions.
2 changes: 2 additions & 0 deletions setup-test-tools.sh
Expand Up @@ -25,6 +25,8 @@ install_apt() {
gcc \
libc6-dev
test -f /usr/bin/go || sudo apt-get install -y golang
# We use zig to compile some test binaries as it is much easier than with gcc
sudo snap install zig --classic --edge
}

if linux; then
Expand Down
46 changes: 26 additions & 20 deletions tests/binaries/makefile
@@ -1,3 +1,5 @@
ZIGCC = zig cc

CC = gcc
DEBUG = 1
CFLAGS += -Wall
Expand Down Expand Up @@ -29,7 +31,8 @@ CFLAGS += -O1
endif

PWD=$(shell pwd)
GLIBC=/glibc_versions/2.29/tcache_x64
# Apparently we don't have this version? :(
#GLIBC=/glibc_versions/2.29/tcache_x64
GLIBC_2_33=$(PWD)/glibcs/2.33

.PHONY : all clean
Expand Down Expand Up @@ -61,27 +64,30 @@ all: $(LINKED) $(LINKED_ASM) $(COMPILED_GO)

heap_bugs.out: heap_bugs.c
@echo "[+] Building heap_bugs.out"
${CC} \
-Wl,-rpath=${GLIBC}:\
${GLIBC}/math:\
${GLIBC}/elf:\
${GLIBC}/dlfcn:\
${GLIBC}/nss:\
${GLIBC}/nis:\
${GLIBC}/rt:\
${GLIBC}/resolv:\
${GLIBC}/crypt:\
${GLIBC}/nptl_db:\
${GLIBC}/nptl:\
-Wl,--dynamic-linker=${GLIBC}/elf/ld.so \
${ZIGCC} \
-target native-native-gnu.2.33 \
-Wl,-rpath=${GLIBC_2_33}:\
${GLIBC_2_33}/math:\
${GLIBC_2_33}/elf:\
${GLIBC_2_33}/dlfcn:\
${GLIBC_2_33}/nss:\
${GLIBC_2_33}/nis:\
${GLIBC_2_33}/rt:\
${GLIBC_2_33}/resolv:\
${GLIBC_2_33}/crypt:\
${GLIBC_2_33}/nptl_db:\
${GLIBC_2_33}/nptl:\
-Wl,--dynamic-linker=${GLIBC_2_33}/ld-linux-x86-64.so.2 \
-g -o heap_bugs.out heap_bugs.c

heap_bins.out: heap_bins.c
@echo "[+] Building heap_bins.out"
${CC} \
-Wl,-rpath=${GLIBC_2_33} \
-Wl,--dynamic-linker=${GLIBC_2_33}/ld-linux-x86-64.so.2 \
-g -O0 -o heap_bins.out heap_bins.c
# TODO/FIXME: We should probably force this to 2.29? a version with tcache?
#heap_bins.out: heap_bins.c
# @echo "[+] Building heap_bins.out"
# ${ZIGCC} \
# -target native-native-gnu.2.33 \
# -Wl,-rpath=${GLIBC_2_33} \
# -Wl,--dynamic-linker=${GLIBC_2_33}/ld-linux-x86-64.so.2 \
# -g -O0 -o heap_bins.out heap_bins.c

# Note: we use -pthread -lpthread because we hit this bug on CI builds:
# https://sourceware.org/bugzilla/show_bug.cgi?id=24548
Expand Down

0 comments on commit 738b5fd

Please sign in to comment.