# Enable PIE manually. Will get reset on $(CLEAR_VARS). This
# is what enabling PIE translates to behind the scenes.
LOCAL_CFLAGS += -fPIE
LOCAL_LDFLAGS += -fPIE -pie
Tag Archives: NDK
lookup name from IP , pretty useless for LAN, since not NBT query. just keep for record that do not spent more time
char* name = argv[1];
sa.sin_family = AF_INET;
sa.sin_addr.s_addr=inet_addr(name);
len = sizeof (struct sockaddr_in);
char hbuf[NI_MAXHOST];
if (int r=getnameinfo((sockaddr *)&sa, len, hbuf, sizeof(hbuf),NULL, 0, NI_NAMEREQD|NI_DGRAM)!=0)
printf("could not resolve hostname %d %s",r,gai_strerror(r));
else
printf("host=%s\n", hbuf);
//EAI_AGAIN
struct hostent *hp;
long addr;
addr = inet_addr(name);
if (hp = gethostbyaddr((char *) &addr, sizeof(addr), AF_INET)) {
printf("Hostname:\t%s\n", hp->h_name);
printf("Aliases:\t");
while (hp->h_aliases[0])
printf("%s ", *hp->h_aliases++);
printf("\n");
printf("Addresses:\t");
while (hp->h_addr_list[0])
printf("%s ", inet_ntoa(*(struct in_addr *) * hp->h_addr_list++));
printf("\n");
exit(0);
}
NDK Android platform compatibility
Native Code CPU Architecture Used Compatible Android Platform(s)
x86 Android 2.3 (API Level 9) and higher
MIPS Android 2.3 (API Level 9) and higher
Enable NDK debug on Eclipse , Ubuntu
Summary
push gdb server to phone
on phone: run gdb server with given TCP port
on unbuntu: set TCP port forwarding
on eclipse: set debug configuration to use TCP connection.
Details:
push gdb server to phone
adb shell push $ANDROID_NDK_ROOT/prebuilt/android-arm/gdbserver/gdbserver /data
Push compiled binary to phone via adb push
adb push /home/victor/workspace/xxx/obj/local/armeabi/testPcap /data/app
on phone: run gdb server with given TCP port
adb shell
On phone: /data/gdbserver :5039 /data/app/testPcap
on unbuntu: set TCP port forwarding 在本地把本地TCP端口forward到设备的TCP端口
adb forward tcp:5039 tcp:5039
on eclipse: set debug configuration to use TCP connection.
Eclipse 设置调试
程序为 /home/victor/workspace/xxx/obj/local/armeabi/testPcap
DEBUGER: gdbserver
gdb debuger: /home/victor/dev/android-ndk-r9d/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gdb
gdb commandline: /home/victor/workspace/xxxx/libs/armeabi/droidsheep
Connection localhost 5039