From d111c8ddcf4f1fd52b11577e4c01ede6dc15d8b1 Mon Sep 17 00:00:00 2001 From: Disconnect3d Date: Tue, 23 Aug 2022 03:53:51 +0200 Subject: [PATCH] Fix heap test binaries build (#1087) * Fix heap test binaries build * Compile some heap test binaries with zig cc --- setup-test-tools.sh | 2 ++ tests/binaries/makefile | 48 ++++++++++++++++++++++++----------------- 2 files changed, 30 insertions(+), 20 deletions(-) diff --git a/setup-test-tools.sh b/setup-test-tools.sh index 170a33d3a..c02bdb0f4 100755 --- a/setup-test-tools.sh +++ b/setup-test-tools.sh @@ -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 diff --git a/tests/binaries/makefile b/tests/binaries/makefile index 955b797d9..9df0733f3 100644 --- a/tests/binaries/makefile +++ b/tests/binaries/makefile @@ -1,3 +1,5 @@ +ZIGCC = zig cc + CC = gcc DEBUG = 1 CFLAGS += -Wall @@ -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 @@ -59,27 +62,32 @@ all: $(LINKED) $(LINKED_ASM) $(COMPILED_GO) @GOARCH=amd64 $(GO) build $? @# Not stripped on purpose -heap_bugs: heap_bugs.c - ${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 \ +heap_bugs.out: heap_bugs.c + @echo "[+] Building heap_bugs.out" + ${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: heap_bins.c - ${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