Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/sh
- cat>test.c<<'C'
- #include <unistd.h>
- #include <stdio.h>
- int add(int x,int y);
- int main(int argc,char** argv) {
- enum { buf_size=4096 }; char buf[buf_size];
- int rd=readlink("/proc/self/exe",buf,buf_size-1); buf[rd]=0;
- printf("readlink=%s\n",buf);
- return add(1,-1);
- }
- C
- cat>add.c<<'C'
- int add(int x,int y) { return x+y; }
- C
- echo '--build x32 executables--'
- gcc -m32 -o libadd.so -shared add.c
- gcc -m32 -o test test.c -L. -ladd -Xlinker '-rpath=$ORIGIN/../libs:$ORIGIN/libs'
- mkdir -p libs
- mv libadd.so libs
- echo '--test localy--'
- ./test && echo success1 || echo fail1
- echo '--prepare archives--'
- mkdir -p bin
- sudo mount -t tmpfs -osize=1M none bin
- cp test bin
- mkdir -p bin/libs
- cp libs/libadd.so bin/libs
- rm -f bin.squashfs
- mksquashfs bin bin.squashfs -comp xz 2>&1 > /dev/null
- sudo umount bin
- echo '--mount fs--'
- sudo mount -t tmpfs -osize=1M none bin
- mkdir bin/app bin/rom bin/diff
- sudo mount -t squashfs -o ro bin.squashfs bin/rom
- sudo mount -t overlayfs -o lowerdir=bin/rom,upperdir=bin/diff none bin/app
- #sudo mount -t aufs -o br=bin/rom:bin/diff none bin/app
- cd bin/app
- ./test && echo success2 || (
- echo fail2
- strace ./test 2>&1 | grep open | head
- )
- echo '--using crutch--'
- LD_LIBRARY_PATH=$PWD/libs ./test && echo success3 || echo fail3
- cd ../..
- cd bin/rom
- ./test && echo success4 || echo fail4
- cd ../..
- sudo umount bin/app
- sudo umount bin/rom
- sudo umount bin
Add Comment
Please, Sign In to add comment