diff --git a/test/Makefile b/test/Makefile index 27075ee..cffcd92 100644 --- a/test/Makefile +++ b/test/Makefile @@ -49,6 +49,12 @@ test_avx: normalize_prefix clean: rm -rf *.o $(TARGET) +lib_test.a: lib_test.cpp + $(CXX) -c $(CFLAGS) lib_test.cpp + ar r lib_test.a lib_test.o + +lib_run: lib_test.a lib_run.cpp + $(CXX) $(CFLAGS) lib_run.cpp lib_test.a -o lib_run make_nm: make_nm.cpp $(XBYAK_INC) diff --git a/test/lib_run.cpp b/test/lib_run.cpp new file mode 100644 index 0000000..d1e1127 --- /dev/null +++ b/test/lib_run.cpp @@ -0,0 +1,9 @@ +#include + +int ret123(); + +int main() +{ + printf("ret=%d\n", ret123()); +} + diff --git a/test/lib_test.cpp b/test/lib_test.cpp new file mode 100644 index 0000000..399d1fa --- /dev/null +++ b/test/lib_test.cpp @@ -0,0 +1,17 @@ +#include + +struct Code : public Xbyak::CodeGenerator { + Code() + { + mov(eax, 5); + ret(); + } +}; + +int ret123() +{ + static Code code; + int (*f)() = (int (*)())code.getCode(); + return f(); +} +