i'm new here, i was trying port c++ game server code from windows to android armeabi-v7a but i came across this alert from android ndk, the process should continue to run because it is a server:
C:/Users/Home/Documents/samps/jni/raknet/SingleProducerConsumer.h:138:3: note: when a volatile object spans multiple type-sized locations, the compiler must choose bet
ween using a single mis-aligned access to preserve the volatility, or using multiple aligned accesses to avoid runtime faults; this code may fail at runtime if the har
dware does not allow this access
if (writeAheadPointer->next==readPointer ||
^
and in the android shows segmentation fault:
raksamp on android
Can this be solved? thanks.
Related
I'm porting a C and C++ library that currently works on iOS to be used on an Android application. I'm down to these last 3 linker errors (obfuscated for privacy reasons):
/Users/fer662/projects/xxx/jni/xxx_preprocessing.c:10184: error: undefined reference to 'cexp'
/Users/fer662/projects/xxx/jni/xxx_preprocessing.c:10184: error: undefined reference to 'cpowf'
/Users/fer662/projects/xxx/jni/xxx_preprocessing.c:10285: error: undefined reference to 'cabs'
Now I understand these normally come from linking with libm.so (-lm), but i'm doing that already. If I go and check the offending so with nm:
nm -g /Users/fer662/Library/Android/sdk/ndk-bundle/platforms/android-22/arch-x86/usr/lib/libm.so | grep cpow
Nothing comes back. It DOES hoever, if I use api 28
nm -g /Users/fer662/Library/Android/sdk/ndk-bundle/platforms/android-28/arch-x86/usr/lib/libm.so | grep cpow
00003900 T cpow
00003910 T cpowf
00003920 T cpowl
Also, in the static library it does show, even on api 22:
nm -g /Users/fer662/Library/Android/sdk/ndk-bundle/platforms/android-22/arch-x86/usr/lib/libm.a | grep cpow
s_cpow.o:
00000000 T cpow
s_cpowf.o:
00000000 T cpowf
s_cpowl.o:
00000000 T cpowl
The inconsistency is puzzling. Shouldn't it be missing from the header altogether if not supported? Why does the static lib have it and the dylib not?
Would it make sense to statically link against it? And if so, how would I do it, taking into account the right path for the current api version?
My other option seems to go steal an implementation of libm (say http://openlibm.org/) or just these 3 functions I'm using from it.
tl;dr: yes, static linking libm.a should be fine
Check the libm.map.txt file: https://android.googlesource.com/platform/bionic/+/master/libm/libm.map.txt#289
These functions weren't added to Android until O.
Also, in the static library it does show, even on api 22
The static library isn't an API 22 static library. It's actually a ToT build from AOSP. If you're going to static link something, there's no point in using something old.
The reason it (there's actually only one version of libc.a/libm.a per ABI) is duplicated into each API directory is because build systems made for old NDKs expect it. If you look at the unified toolchain in r19 (toolchains/llvm/prebuilts/$HOST), you'll see that there's only one copy per ABI.
The inconsistency is puzzling. Shouldn't it be missing from the header altogether if not supported? Why does the static lib have it and the dylib not?
The header has an ifdef guard that hides it: https://android.googlesource.com/platform/prebuilts/ndk/+/dev/platform/sysroot/usr/include/complex.h#237
If you had a declaration for these functions and you think you were building for API 22, there's something wrong with your build system.
Would it make sense to statically link against it? And if so, how would I do it, taking into account the right path for the current api version?
In general for these sorts of problems this isn't a good solution since the Zygote has already loaded a libc, and loading another one can lead to all sorts of issues since they can conflict. Additionally, much of libc's networking is actually dispatched to netd, and the protocol between libc and netd has changed in the past (and is unfortunately not a versioned protocol).
Building with libc.a is only viable with standalone executables (think strace and gdbserver) rather than apps, and even then only if you don't need networking.
That said, libm.a is much simpler. The complex interactions that make libc.a unusable for apps don't affect libm. The only time you'll end up actually running code in libm is when the compiler somehow failed to inline the operation. Static linking libm.a into your application should be fine.
The upshot is I want to run code on the Hexagon DSP.
I've tried building Android-MSM for msm8994-eng (for a Nexus 6P) and msm8998-eng (for Intrinsyc APQ8098) but I get build errors with both.
I'm building on Ubuntu 14.04 with openjdk-8.
Not finding a lot of help in either the project or filing tickets for the board so as a last ditch effort thought I'd ask here.
Anyone with experience building Android-MSM for either msm8994 or msm8998?
The specific build error for msm8998-eng (for Intrinsyc APQ8098) is:
In file included from /media/openq835/OpenQ-835_Android-N_v1.0/OpenQ-835-v1.0/Source_Package/APQ8098_LA.UM.5.8.r1-01900-8x98.0_OpenQ835-v1.0/kernel/msm-4.4/include/linux/seqlock.h:35:0,
from /media/openq835/OpenQ-835_Android-N_v1.0/OpenQ-835-v1.0/Source_Package/APQ8098_LA.UM.5.8.r1-01900-8x98.0_OpenQ835-v1.0/kernel/msm-4.4/include/linux/time.h:5,
from /media/openq835/OpenQ-835_Android-N_v1.0/OpenQ-835-v1.0/Source_Package/APQ8098_LA.UM.5.8.r1-01900-8x98.0_OpenQ835-v1.0/kernel/msm-4.4/include/uapi/linux/timex.h:56,
from /media/openq835/OpenQ-835_Android-N_v1.0/OpenQ-835-v1.0/Source_Package/APQ8098_LA.UM.5.8.r1-01900-8x98.0_OpenQ835-v1.0/kernel/msm-4.4/include/linux/timex.h:56,
from /media/openq835/OpenQ-835_Android-N_v1.0/OpenQ-835-v1.0/Source_Package/APQ8098_LA.UM.5.8.r1-01900-8x98.0_OpenQ835-v1.0/kernel/msm-4.4/include/linux/sched.h:19,
from /media/openq835/OpenQ-835_Android-N_v1.0/OpenQ-835-v1.0/Source_Package/APQ8098_LA.UM.5.8.r1-01900-8x98.0_OpenQ835-v1.0/kernel/msm-4.4/arch/arm64/include/asm/compat.h:25,
from /media/openq835/OpenQ-835_Android-N_v1.0/OpenQ-835-v1.0/Source_Package/APQ8098_LA.UM.5.8.r1-01900-8x98.0_OpenQ835-v1.0/kernel/msm-4.4/arch/arm64/include/asm/stat.h:23,
from /media/openq835/OpenQ-835_Android-N_v1.0/OpenQ-835-v1.0/Source_Package/APQ8098_LA.UM.5.8.r1-01900-8x98.0_OpenQ835-v1.0/kernel/msm-4.4/include/linux/stat.h:5,
from /media/openq835/OpenQ-835_Android-N_v1.0/OpenQ-835-v1.0/Source_Package/APQ8098_LA.UM.5.8.r1-01900-8x98.0_OpenQ835-v1.0/kernel/msm-4.4/include/linux/module.h:10,
from /media/openq835/OpenQ-835_Android-N_v1.0/OpenQ-835-v1.0/Source_Package/APQ8098_LA.UM.5.8.r1-01900-8x98.0_OpenQ835-v1.0/kernel/msm-4.4/drivers/soc/qcom/qdsp6v2/apr_tal.c:15:
/media/openq835/OpenQ-835_Android-N_v1.0/OpenQ-835-v1.0/Source_Package/APQ8098_LA.UM.5.8.r1-01900-8x98.0_OpenQ835-v1.0/kernel/msm-4.4/drivers/soc/qcom/qdsp6v2/apr_tal.c:290:40: error: 'struct apr_svc_ch_dev' has no member named 'lock'
spin_lock_init(&apr_svc_ch[i][j][k].lock);
^
/media/openq835/OpenQ-835_Android-N_v1.0/OpenQ-835-v1.0/Source_Package/APQ8098_LA.UM.5.8.r1-01900-8x98.0_OpenQ835-v1.0/kernel/msm-4.4/include/linux/spinlock.h:99:24: note: in definition of macro 'raw_spin_lock_init'
__raw_spin_lock_init((lock), #lock, &__key); \
^
/media/openq835/OpenQ-835_Android-N_v1.0/OpenQ-835-v1.0/Source_Package/APQ8098_LA.UM.5.8.r1-01900-8x98.0_OpenQ835-v1.0/kernel/msm-4.4/drivers/soc/qcom/qdsp6v2/apr_tal.c:290:5: note: in expansion of macro 'spin_lock_init'
spin_lock_init(&apr_svc_ch[i][j][k].lock);
^
You need to backport functions from older kernel or update those drivers.
Cheers
I'm trying to debug JNI code written in C running on Android 5. When one of my functions is called, I want to write a stack trace to the adb log so I can see where the function was called from.
The first resources I found indicated I needed to use libcorkscrew, and included complete examples of how to use the library. Unfortunately it seems libcorkscrew is gone from Android 5, and now libunwind is supposed to be used. For my project, there are several problems:
Instructions for getting libunwind into the project are sparse and/or misleading - some resources say to download the project from github and build it (with directions that do not work), others indicate the library is already part of Android 5.
All of the examples are written in C++, and it seems that libunwind only has C++ bindings for the functions within it. Since my code is C, not C++, and writing to a log function rather than through the C++ stdlib, this isn't usable.
Among others, I looked at these pages:
Native Stack Traces on Android Lollipop with libunwind
There's no "libcorkscrew" in Android 5.0...
Android NDK: getting the backtrace
Is there a way to get a stack trace in C code on Android 5 without crashing the program?
Instructions for getting libunwind into the project are sparse and/or misleading
Compiled libunwind is included into modern Android NDKs, such as NDK r16b, at sources/cxx-stl/llvm-libc++/libs/armeabi-v7a/libunwind.a. You will have to provide this file to the linker. You will also need to download matching headers, namely libunwind.h and __libunwind_config.h. For NDK r16b, these headers can be fetched here: https://android.googlesource.com/platform/external/libunwind_llvm/+/ndk-r16/include/ .
it seems that libunwind only has C++ bindings
No, it's not so. Most of libunwind bindings are C bindings.
Here is a sample Android command-line app in pure C that uses libunwind:
https://github.com/alexeikh/android-ndk-backtrace-test
Can you use backtrace_symbos_fd at Android? If you can, you could use this one:
void *array[100];
size_t size;
size = backtrace (array, 100);
backtrace_symbols_fd (array, size, STDOUT_FILENO);
Ok so first off,
Im brand new to android dev. This is my first attempt at any form of kernel anything. I have a limited knowledge of java and python, but no C.
I have a galaxy tab 4 sm-t330nu running 4.4.2. its running a qualcomm snapdragon 400 msm8226 cpu. im simply trying to do a test build with a vanilla kernel at this point. (also my build environment is the newest kali 1.1 and im loosely following the tutorial at https://github.com/offensive-security/kali-nethunter/wiki/Porting-Nethunter)
so i have all of the required dependencies (i hope), and ive downloaded my source from samsung opensource. unzipped and went through the available defconfigs. after finding "msm8226-sec_milletwifiue_defconfig" i decided it was the most likely candidate for my tablet. (when doing a custom recovery i remember it being "philz touch milletwifiue something)
Ive done my exports (arch= subarch= cross_compile=) and all seems well. When i run a build following exactly as the tutorial says (using the defconfig in their example as a test) i receive an error stating "must define variant_defconfig". So i instead do "make variant_defconfig=msm8974_sec_defconfig" and it builds great.
Now the issue:
When i change "msm8974_sec_defconfig" to my actual msm8226 i receive an error on every build that i cannot seem to workaround. (cut down for size)
CC arch/arm/kernel/armksyms.o
CC arch/arm/kernel/module.o
AS arch/arm/kernel/sleep.o
CC arch/arm/kernel/suspend.o
CC arch/arm/kernel/io.o
arch/arm/kernel/io.c: In function '_memcpy_fromio':
arch/arm/kernel/io.c:14:3: error: implicit declaration of function 'nop' [-Werror=implicit-function-declaration]
cc1: some warnings being treated as errors
make[1]: *** [arch/arm/kernel/io.o] Error 1
make: *** [arch/arm/kernel] Error 2
My exact bash line reads
make VARIANT_DEFCONFIG=msm8226-sec_milletwifiue_defconfig
Any assistance on clearing this up would be great
edit
although im not familiar with c, it seems to me that '_memcpy_fromio' is where the error lies. and my google searches tell me that the error is that a function is used without being declared. however i dont know if memcpy is a function? or is the function within class memcpy (dont know if c has classes just closest equivalent that i know of) how do i debug this code and declare what needs to be declared (more importantly, if this is a stock kernel thats used by thousands of devices, how can it possibly have an undeclared function?
/edit
found the answer! needed
#import linux/modules.h
#import linux/kernel.h
I want to create a Android program in Delphi XE5 to work with XML files. I use TXMLDocument.
I can't compile and run it, though, because Delphi repeatedly adds Xml.Win.msxmldom in the uses section. The following error occurs:
[DCC Fatal Error] Unit1.pas(11): F1026 File not found:
'C:\Users\HamiD\Documents\RAD Studio\Projects\Xml.Win.msxmldom.dcu'
(unit scope "Xml.Win" indicates Win32, Win64 only)
How do I avoid using that unit in my project?
In the TXMLDocument, change the DOM vendor from MSXML to ADOMXML v4, to stop the need to use the MSXML unit.
This is covered in the documentation for TXMLDocument.DOMVendor. Although it mentions specifically Mac, the same applies to other FireMonkey applications on iOS and Android.
Tip: If you are designing a FireMonkey application that is intended to run on Mac OS X, then you should perform the following steps to ensure that the compilation succeeds:
Change DOMVendor from MSXML to ADOM XML v4.
If the Xml.Win.msxmldom unit is in the uses clause then remove it.
Compile your application for Mac OS X.
The documentation was modified in the XE5 version to read instead:
Tip: To use TXMLDocument in Mac OS X or Mobile applications, in the Object Inspector, set the DOMVendor property to ADOM XML v4 right after dropping this component onto the Form Designer. Otherwise, the TXMLDocument component is no longer usable for iOS/Android/OSX applications.