Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
15 changes: 15 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
**
!plthook_elf.c
!plthook_osx.c
!plthook_win32.c
!plthook.h
!test
test/*.obj
test/libtest.dll
test/libtest.exp
test/libtest.lib
test/libtest.so
test/testprog
test/testprog.exe
test/dummy.c
test/dummy.o
35 changes: 35 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Dockerfile for QEMU testing
# docker build -t metacall/plthook .
FROM ubuntu:latest

RUN apt update \
&& apt install -y \
make \
qemu-user \
gcc-arm-linux-gnueabi \
gcc-arm-linux-gnueabihf \
gcc-aarch64-linux-gnu \
gcc-powerpc-linux-gnu \
gcc-powerpc64le-linux-gnu \
gcc-riscv64-linux-gnu \
libc6-dev-armhf-cross \
libc6-dev-ppc64el-cross \
libc6-dev-powerpc-cross \
libc6-dev-armel-cross \
libc6-dev-arm64-cross

WORKDIR /plthook

COPY . .

WORKDIR /plthook/test

ENV OPT_CFLAGS="-O3"

RUN echo "Running tests" \
&& make relro_pie_tests TARGET_PLATFORM=aarch64-linux-gnu \
&& make relro_pie_tests TARGET_PLATFORM=arm-linux-gnueabi \
&& make relro_pie_tests TARGET_PLATFORM=arm-linux-gnueabihf \
&& make relro_pie_tests TARGET_PLATFORM=powerpc-linux-gnu QEMU_ARCH=ppc \
&& make relro_pie_tests TARGET_PLATFORM=powerpc64le-linux-gnu QEMU_ARCH=ppc64le \
&& make relro_pie_tests TARGET_PLATFORM=riscv64-linux-gnu QEMU_ARCH=riscv64
4 changes: 2 additions & 2 deletions plthook_elf.c
Original file line number Diff line number Diff line change
Expand Up @@ -683,14 +683,14 @@ static int plthook_open_real(plthook_t **plthook_out, struct link_map *lmap)
set_errmsg("failed to find PLT_DT_RELSZ");
return PLTHOOK_INTERNAL_ERROR;
}
total_size = dyn->d_un.d_ptr;
total_size = dyn->d_un.d_val;

dyn = find_dyn_by_tag(lmap->l_ld, PLT_DT_RELENT);
if (dyn == NULL) {
set_errmsg("failed to find PLT_DT_RELENT");
return PLTHOOK_INTERNAL_ERROR;
}
elem_size = dyn->d_un.d_ptr;
elem_size = dyn->d_un.d_val;
plthook.rela_dyn_cnt = total_size / elem_size;
}
#endif
Expand Down
2 changes: 1 addition & 1 deletion test/testprog.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ static void reset_result(void)

static void set_result(hooked_val_t *hv, const char *str, double result)
{
strncpy(hv->str, str, sizeof(hv->str));
strncpy(hv->str, str, sizeof(hv->str) - 1);
hv->result = result;
}

Expand Down