I'm trying to build a stand alone Android kernel and i want to write loadable kernel module, but when i build my module.c file, i have this error
error: smd_private.h: No such file or directory
search at google told me that i should change <smd_private.h> into "smd_private.h" .but the error still exist!!
Can you help me?
Check to make sure smd_private.h is in the same directory as my module.c
Here is info from https://gcc.gnu.org/onlinedocs/cpp/Include-Syntax.html#Include-Syntax
2.1 Include Syntax
Both user and system header files are included using the preprocessing
directive ‘#include’. It has two variants:
#include <file>
This variant is used for system header files. It searches for a file
named file in a standard list of system directories. You can prepend
directories to this list with the -I option (see Invocation).
#include "file"
This variant is used for header files of your own program. It searches
for a file named file first in the directory containing the current
file, then in the quote directories and then the same directories used
for <file>. You can prepend directories to the list of quote directories
with the -iquote option.
The argument of ‘#include’, whether delimited with quote marks or angle
brackets, behaves like a string constant in that comments are not
recognized, and macro names are not expanded. Thus, #include <x/*y>
specifies inclusion of a system header file named x/*y.
However, if backslashes occur within file, they are considered ordinary
text characters, not escape characters. None of the character escape
sequences appropriate to string constants in C are processed.
Thus, #include "x\n\\y" specifies a filename containing three
backslashes. (Some systems interpret ‘\’ as a pathname separator.
All of these also interpret ‘/’ the same way. It is most portable to
use only ‘/’.)
It is an error if there is anything (other than comments) on the line
after the file name.
Related
I'm trying to build libavformat with this MAKEFILE. Although the makefile includes avio.o file in its build instruction but it doesn't add any symbol for the functions that are declared on the header file url.h. Source folder which includes the avio.c, avio.h and url.h files can be found HERE.
The nm command for avio.o returns
nm: avio.o: File format not recognized
file command on avio.o shows the following output
avio.o: LLVM IR bitcode
I have checked the nm command on the generated libavformat.so and did not find any symbols for the functions declared on the url.h file
I have been stuck on this for two days. Could not figure out how to solve this problem!
Calling the ff_check_interrupt method and results in
undefined reference to 'ff_check_interrupt'
Configurations and flags.
FFmpeg Configuration File: Config.h
FFmpeg Root MakeFile: Root MakeFile
CC, CXX, CFLAGS, LDFLAGS: FLAGS
First off, a function declared by url.h should be defined in url.c, not in avio.c.
Second the only use of the ff_check_interrupt in avoi.c is within a static inline function, so indeed the toolchain is likely optimizing this symbol away.
I think what's occurring for you is that the toolchain making the decision that this is only used in this compilation unit.
Moving the definition of ff_check_interrupt to 'url.c' should resolve the issue. This is a library though, so out of your control.
However, this doesn't answer why thousands of users on Github have this same library in their code. I'd suggest comparing your Makefile against those (e.g. first search return is this one.
I have the .aab that I'm planning to upload on play store for publish, and before publishing I'm trying a decompile to see which data may be exposed to user in a reverse engineering process.
In .aab_FILES/base/ I see the assets.pb and resources.pb protobuffs - can these files be open some in some way? Cause for the moment I haven't found any method to reveal their content.
I am actually looking to see where are values/strings.xml packed - cause they are missing from .aab_FILES/base/res/ location and I wanna make sure my maps API key (which resides in strings.xml) won't be exposed to users.
The resources.pb is a serialization of the strings data, so they can't be directly extracted to xml.
There are 2 ways to go around this:
Convert from aab to apk
Use bundletool to convert the aab to a universal apk and read the xmls from there:
java -jar bundletool-all-1.8.0.jar build-apks --mode=universal --bundle=~/test.aab --output=~/universal.apks
The universal.apks file can now be unzipped. It contains a universal.apk file, which the resources can be taken from like any apk. The easiest way to get readable xml files from the apk is by using apktool:
apktool d ~/unzipped_universal_apks/universal.apk -o ~/unzipped_universal
The folder ~/unzipped_universal now contains the decoded universal.apk and the xml resources should be decoded and readable inside it.
Read the protobuf values directly from the protobuf file
In order to read a protobuf file, you need its scheme (or proto file).
The proto files for an aab are in the aapt2 repository:
Resources.proto which depends on Configuration.proto.
These files can be compiled to workable code in a number of programming languages. I'll show it using python as described here.
First though, the Resources.proto should be modified to import Configuration.proto from the same folder location instead of the original (unless you create the whole necessary folder structure).
So, change:
import "frameworks/base/tools/aapt2/Configuration.proto";
To:
import "Configuration.proto";
Now, in the terminal, run:
protoc --python_out=~/proto_output Configuration.proto Resources.proto
Inside ~/proto_output there will now be 2 files: Configuration_pb2.py Resources_pb2.py.
These files contain the python code to access the protobuf structure for the resources.pb file, as well as the protobuf encoded AndroidManifest.xml.
In order to read the protobuf file run:
from google.protobuf.json_format import MessageToDict
from Resources_pb2 import ResourceTable
res_obj = ResourceTable()
res_pb_file_path = '~/unzipped_app_bundle/base/resources.pb'
with open(res_pb_file_path, 'rb') as f:
content = f.read()
res_obj.ParseFromString(content)
# converting the protobuf object to a nice dictionary representation
res_dict = MessageToDict(res_obj)
Try this given de-compile jar BundleDecompiler
de-compile option:
java -jar BundleDecompiler.jar decompile --in=input_app.aab --out=output_dir
How are the names that appear for a symbol generated in a shared library file? For example, when using elfread -Ws to read the symbols in the libutils.so file (android system utils library), I get several symbol names of the format:
_ZN7android10VectorImpl14insertVectorAtERKS0_j
etc. How do you decipher this symbol name?
That appears to be a mangled name, e.g., for C++, and you can make better sense of those using the -C option of nm:
-C
--demangle[=style]
Decode (demangle) low-level symbol names into user-level names. Besides removing any initial underscore prepended by the system, this makes C++ function names readable. Different compilers have different mangling styles. The optional demangling style argument can be used to choose an appropriate demangling style for your compiler. See c++filt, for more information on demangling.
When using nm on shared libraries, this option shows their symbols:
-D
--dynamic
Display the dynamic symbols rather than the normal symbols. This is only meaningful for dynamic objects, such as certain types of shared libraries.
I am a newbie to Android makefiles. While reading this file I see a "-include" statement.
What does this actually mean to the build system?
The include simply means that another makefile should be included. The - means that if the file to include doesn't exist it will simply be ignored:
We can also put a minus sign - in front of include (with no space in-between) to ignore filenames that do not exist. For example:
-include makefile1 makefile2 makefile3
If makefile2 does not exist, then make will skip it, and no error will occur. In general, inserting a minus sign in front of any command tells make to ignore errors that might occur during the execution of that command.
(source)
I notice this question:
Two header with same name in include path
But the problem I encounter is the include path is system include path.
Suppose two headers: dir1/header.h dir2/header.h, they are located in system include path, and dir1 is searched firstly, but the one I really want is dir2/header.h. What could I do in this case?
It's in the Android NDK environment.
Suppose the two system include paths are:
dir1:$(NDK_ROOT)\sources\cxx-stl\gabi++\include
dir2:$(NDK_ROOT)\toolchains\arm-linux-androideabi-4.6\prebuilt\windows-x86_64\lib\gcc\arm-linux-androideabi\4.6\include
Now I want the header in dir2. But the Android compiler will search the header in dir1 firstly. If I used the -I option, How can I change the dir2 path into a platform-independent path (e.g. windows-x86_64 may be linux-x86)?
You must use #include "dir2/header.h" in your source file, then on the compile line you list the parent directory with -I; so for example if the fully-qualified pathname of the second header was /usr/local/include/dir2/header.h you would add -I/usr/local/include to your compile line.
ETA
Nate that in makefiles you should always use forward slashes, not backslashes.
Also, the compiler always searches the directories you provide on the command line with -I, in the order you specify them, before it searches any of the standard locations. So I don't really understand the problem. If the default location is the one you don't want anyway, then just add a -I flag pointing to the other one and it'll be used instead.
I encountered the same problem. There are two header files 'cuda.h', one in the system path '/usr/local/cuda/include/cuda.h', anoter one is specified with '-I' in Makefile, i.e. -I
${PWD}/dependency/libtorch/include/torch/csrc/api/include/torch/cuda.h.
I want to include the first one, but the second one was referred. Then I tried to replace '#include <cuda.h>' with '#include "../../../local/cuda/include/cuda.h"'. It works.
Hope this could help you.