Skip to content

Commit

Permalink
Partially work around bug with passing arguments on stack for powerpc…
Browse files Browse the repository at this point in the history
…64-linux-gnu.
  • Loading branch information
yugr committed Mar 27, 2024
1 parent 2cce6ca commit 6167855
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 9 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ where `TARGET` can be any of
* mipsel-linux-gnu
* mips64el-linux-gnuabi64
* e2k-linux-gnu
* powerpc64-linux-gnu, powerpc64le-linux-gnu (preliminary support)
* powerpc64le-linux-gnu
* powerpc64-linux-gnu (limited support)

Script generates two files: `libxyz.so.tramp.S` and `libxyz.so.init.c` which need to be linked to your application (instead of `-lxyz`):

Expand Down
28 changes: 24 additions & 4 deletions arch/powerpc64/trampoline.S.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -37,24 +37,44 @@ $sym:

// TODO:
// We need to somehow get rid of additional stack frame
// because it breaks arguments which are passed on stack
// because it breaks arguments which are passed on stack.
// Currently we work around this by duplicating parameters
// in new stack frame but this supports only 16 parameters
// and is very inefficient.

mflr 0
std 0, 16(1)
stdu 1, -112(1)
.cfi_def_cfa_offset 112
stdu 1, -176(1)
.cfi_def_cfa_offset 176
.cfi_offset lr, 16

std 2, 40(1)

ld 0, 176+112(1)
std 0, 112(1)
ld 0, 176+120(1)
std 0, 120(1)
ld 0, 176+128(1)
std 0, 128(1)
ld 0, 176+136(1)
std 0, 136(1)
ld 0, 176+144(1)
std 0, 144(1)
ld 0, 176+152(1)
std 0, 152(1)
ld 0, 176+160(1)
std 0, 160(1)
ld 0, 176+168(1)
std 0, 168(1)

ld 2, 8(11)
ld 11, 0(11)

mtctr 11
bctrl

ld 2, 40(1)
addi 1, 1, 112
addi 1, 1, 176
.cfi_def_cfa_offset 0
ld 0, 16(1)
mtlr 0
Expand Down
5 changes: 1 addition & 4 deletions scripts/travis.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,4 @@ tests/multiple-dlopens-3/run.sh $ARCH
if ! echo "$ARCH" | grep -q powerpc; then
tests/many-functions/run.sh $ARCH
fi
if ! echo "$ARCH" | grep -q 'powerpc64-'; then
# FIXME: enable for all platforms !
tests/stack-args/run.sh $ARCH
fi
tests/stack-args/run.sh $ARCH

0 comments on commit 6167855

Please sign in to comment.