-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
107 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/* | ||
* Copyright 2024 Yury Gribov | ||
* | ||
* The MIT License (MIT) | ||
* | ||
* Use of this source code is governed by MIT license that can be | ||
* found in the LICENSE.txt file. | ||
*/ | ||
|
||
#include <stdio.h> | ||
#include "interposed.h" | ||
|
||
__attribute__((visibility("default"))) | ||
void foo(int x0, int x1, int x2, int x3, int x4, int x5, int x6, int x7, int x8, int x9, int x10, int x11, int x12, int x13, int x14, int x15) { | ||
printf("%d ", x0); | ||
printf("%d ", x1); | ||
printf("%d ", x2); | ||
printf("%d ", x3); | ||
printf("%d ", x4); | ||
printf("%d ", x5); | ||
printf("%d ", x6); | ||
printf("%d ", x7); | ||
printf("%d ", x8); | ||
printf("%d ", x9); | ||
printf("%d ", x10); | ||
printf("%d ", x11); | ||
printf("%d ", x12); | ||
printf("%d ", x13); | ||
printf("%d ", x14); | ||
printf("%d\n", x15); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
/* | ||
* Copyright 2024 Yury Gribov | ||
* | ||
* The MIT License (MIT) | ||
* | ||
* Use of this source code is governed by MIT license that can be | ||
* found in the LICENSE.txt file. | ||
*/ | ||
|
||
#ifndef INTERPOSED_H | ||
#define INTERPOSED_H | ||
|
||
extern void foo(int x0, int x1, int x2, int x3, int x4, int x5, int x6, int x7, int x8, int x9, int x10, int x11, int x12, int x13, int x14, int x15); | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
/* | ||
* Copyright 2024 Yury Gribov | ||
* | ||
* The MIT License (MIT) | ||
* | ||
* Use of this source code is governed by MIT license that can be | ||
* found in the LICENSE.txt file. | ||
*/ | ||
|
||
#include "interposed.h" | ||
|
||
int main() { | ||
foo(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#!/bin/sh | ||
|
||
# Copyright 2024 Yury Gribov | ||
# | ||
# The MIT License (MIT) | ||
# | ||
# Use of this source code is governed by MIT license that can be | ||
# found in the LICENSE.txt file. | ||
|
||
# This is a simple test for Implib.so functionality. | ||
# Run it like | ||
# ./run.sh ARCH | ||
# where ARCH stands for any supported arch (arm, x86_64, etc., see `implib-gen -h' for full list). | ||
# Note that you may need to install qemu-user for respective platform | ||
# (i386 also needs gcc-multilib). | ||
|
||
set -eu | ||
|
||
cd $(dirname $0) | ||
|
||
if test -n "${1:-}"; then | ||
ARCH="$1" | ||
fi | ||
|
||
. ../common.sh | ||
|
||
CFLAGS="-g -O2 $CFLAGS" | ||
|
||
# Build shlib to test against | ||
$CC $CFLAGS -shared -fPIC interposed.c -o libinterposed.so | ||
|
||
# Prepare implib | ||
${PYTHON:-} ../../implib-gen.py -q --target $TARGET libinterposed.so | ||
|
||
# Build app | ||
$CC $CFLAGS main.c libinterposed.so.tramp.S libinterposed.so.init.c $LIBS | ||
|
||
LD_LIBRARY_PATH=.:${LD_LIBRARY_PATH:-} $INTERP ./a.out > a.out.log | ||
diff test.ref a.out.log | ||
|
||
echo SUCCESS |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |