Created
October 4, 2013 07:38
-
-
Save sanxiyn/6822312 to your computer and use it in GitHub Desktop.
Weak symbol
This file contains hidden or 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
#!/bin/sh | |
gcc -shared -fPIC sub.c -o libhost.so | |
gcc main.c -L. -lhost -o host | |
LD_LIBRARY_PATH=. ./host |
This file contains hidden or 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
int x = 1; | |
void f(void); | |
int main(void) { | |
f(); | |
return 0; | |
} |
This file contains hidden or 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
#include <stdio.h> | |
extern int x __attribute__((weak)); | |
void f(void) { | |
printf("x = %d\n", x); | |
} |
This file contains hidden or 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
#!/bin/sh | |
arm-linux-androideabi-gcc -shared -fPIC sub.c -o libtarget.so | |
arm-linux-androideabi-gcc main.c -L. -ltarget -o target | |
adb shell rm -r /data/tmp | |
adb shell mkdir /data/tmp | |
adb push libtarget.so /data/tmp | |
adb push target /data/tmp | |
adb shell '(cd /data/tmp; LD_LIBRARY_PATH=. ./target)' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment