[TOOL] aosp_buildcheck v0.1 (Jan 09, 2013) - Android Software/Hacking General [Developers Only]

I've found building AOSP and its various offshoots (AOKP, Cyanogenmod, Evervolv, ParanoidAndroid) sometimes a bit frustrating to figure out. Although the source code and tutorials are usually around, I've still had a lot of problem getting code to compile. I put together a little python script to help diagnose particular issues like missing libraries, header files, etc and dump that into readable JSON output. It's still very much a work in progress (WIP), but I figure it may help some people out.
What I plan on adding is comparison of the versions of local binaries with the latest versions, and complaining when things are out of date or just not working.
You can access the code here: https://github.com/shurane/aosp_buildcheck
Or if you trust me, you can run the code directly using this line:
Code:
wget -O - raw.github.com/shurane/aosp_buildcheck/master/aosp_buildcheck | python
This is the output you get, including errors:
Code:
errors:
Command '['/bin/bash', '-c', 'adb version 2>/dev/null']' returned non-zero exit status 127
Command '['/bin/bash', '-c', 'which fastboot']' returned non-zero exit status 1
Command '['/bin/bash', '-c', 'find ${PATH//:/ } -maxdepth 1 -name adb -print -quit 2>/dev/null']' returned non-zero exit status 1
Command '['/bin/bash', '-c', 'find ${PATH//:/ } -maxdepth 1 -name fastboot -print -quit 2>/dev/null']' returned non-zero exit status 1
Command '['/bin/bash', '-c', 'which pngout']' returned non-zero exit status 1
{
"aosp_dir": {
"devices": [
"mini_armv7a_neon-userdebug",
"mini_armv7a-userdebug",
"full_maguro-userdebug",
"cm_quincyatt-eng",
"full_vibrantmtd-eng",
"full_panda-userdebug",
"aokp_maguro-userdebug",
"aokp_toro-userdebug",
"aokp_toroplus-userdebug",
"aokp_crespo-userdebug",
"aokp_crespo4g-userdebug",
"aokp_grouper-userdebug",
"aokp_captivatemtd-userdebug",
"aokp_d2att-userdebug",
"aokp_d2tmo-userdebug",
"aokp_d2usc-userdebug",
"aokp_d2vzw-userdebug",
"aokp_evita-userdebug",
"aokp_fascinatemtd-userdebug",
"aokp_galaxysmtd-userdebug",
"aokp_hercules-userdebug",
"aokp_i9100-userdebug",
"aokp_i9100g-userdebug",
"aokp_i9300-userdebug",
"aokp_n7000-userdebug",
"aokp_p3100-userdebug",
"aokp_p3110-userdebug",
"aokp_p3113-userdebug",
"aokp_p5100-userdebug",
"aokp_p5110-userdebug",
"aokp_p5113-userdebug",
"aokp_quincyatt-userdebug",
"aokp_tf101-userdebug",
"aokp_vibrantmtd-userdebug"
],
"projects": {
"aokp": 89,
"aosp": 230,
"cm": 26
},
"projects_total": 345,
"remotes": [
"<remote fetch=\"https://android.googlesource.com/\" name=\"aosp\"/>",
"<remote fetch=\"https://github.com/\" name=\"aokp\" review=\"gerrit.sudoservers.com\"/>",
"<remote fetch=\"https://github.com/CyanogenMod/\" name=\"cm\" review=\"review.cyanogenmod.com\"/>"
]
},
"libGL.so": "/usr/lib/i386-linux-gnu/libGL.so: symbolic link to `/usr/lib/i386-linux-gnu/mesa/libGL.so.1'",
"linux": {
"lsb_release": "Distributor ID:\tUbuntu\nDescription:\tUbuntu 12.04.1 LTS\nRelease:\t12.04\nCodename:\tprecise"
},
"optional": {
"ionice": "ionice from util-linux 2.20.1",
"schedtool": "get/set scheduling policies - v1.3.0, GPL'd, NO WARRANTY"
},
"os": "Linux",
"pngtools": {
"optipng": "OptiPNG 0.6.4: Advanced PNG optimizer.\nUsing libpng version 1.2.46 and zlib version 1.2.3.4",
"pngcrush": "pngcrush 1.7.9, uses libpng 1.2.42 and zlib 1.2.3.3",
"pngout": ""
},
"repo": "repo version v1.12.0\n (from https://gerrit.googlesource.com/git-repo)\nrepo launcher version 1.19\n (from /home/kikin/bin/repo)\ngit version 1.7.9.5\nPython 2.7.3 (default, Aug 1 2012, 05:14:39) \n[GCC 4.6.3]",
"tools": {
"adb": "",
"fastboot": "",
"g++": "g++ (Ubuntu/Linaro 4.6.3-1ubuntu5) 4.6.3",
"gcc": "gcc (Ubuntu/Linaro 4.6.3-1ubuntu5) 4.6.3",
"java": "java version \"1.6.0_38\"\nJava(TM) SE Runtime Environment (build 1.6.0_38-b05)\nJava HotSpot(TM) 64-Bit Server VM (build 20.13-b02, mixed mode)"
},
"uname": "Linux un 3.2.0-29-generic #46-Ubuntu SMP Fri Jul 27 17:03:23 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux"
}
Feel free to complain about any outstanding problems with the script and stuff. I would much rather prefer pull requests over github if you guys have the knowhow to implement features.

Related

ncurses/htop cross compile

I'm not sure if this is the right forum but I figured I'd ask. I'm trying to get an ARM compiled version of htop working for my dream (more as a small test than anything) and I can't seem to get the ncurses libs and headers recognized for compiling htop.
I did get ncurses compiled using:
Code:
CC=/root/mydroid/arm-2009q1/bin/arm-none-linux-gnueabi-gcc CXX=/root/mydroid/arm-2009q1/bin/arm-none-linux-gnueabi-g++ \./configure arm-linux --host=arm-none-linux-gnueabi --with-shared --prefix=/root/mydroid/arm-2009q1 --disable-big-core --enable-termcap --disable-GPM--without-ada
the build seemed to go fine after the compile and the binaries are in fact reporting to be the correct arch:
Code:
# file lib/libncurses.so.5.7
lib/libncurses.so.5.7: ELF 32-bit LSB shared object, ARM, version 1 (SYSV), dynamically linked, not stripped
Then on to the configure of htop:
Code:
CPPFLAGS=-I/root/mydroid/arm-2009q1/include LDFLAGS=-I/root/mydroid/arm-2009q1/lib \./configure CC=/root/mydroid/arm-2009q1/bin/arm-none-linux-gnueabi-gcc CXX=/root/mydroid/arm-2009q1/bin/arm-none-linux-gnueabi-g++ --host=arm --build=arm-linux
I ran into a couple path issues with includes from curses.h but I was able to get past this using full path.
The build however fails misserably unable to find -lcurses
Code:
configure:21591: checking for refresh in -lncurses
configure:21626: /root/mydroid/arm-2009q1/bin/arm-none-linux-gnueabi-gcc -o conftest -g -O2 -I/root/mydroid/arm-2009q1/include -I/root/mydroid/arm-2009q1/libconftest.c -lncurses -lm >&5
/root/mydroid/arm-2009q1/bin/../lib/gcc/arm-none-linux-gnueabi/4.3.3/../../../../arm-none-linux-gnueabi/bin/ld: cannot find -lncurses
collect2: ld returned 1 exit status
That's all the drivel ... I was wondering if someone could kick me in the right direction for how to tell the cross compiler linker where the curses libraries are? I know on the base system I can use ldconfig etc but the ldconfig in the toolchain (all of them) appear to be an ARM binary
Code:
# find . -name ldconfig -exec file {} \;
./arm-none-linux-gnueabi/libc/usr/lib/bin/ldconfig: ELF 32-bit LSB executable, ARM, version 1 (SYSV), statically linked, for GNU/Linux 2.6.14, not stripped
./arm-none-linux-gnueabi/libc/armv4t/usr/lib/bin/ldconfig: ELF 32-bit LSB executable, ARM, version 1 (SYSV), statically linked, for GNU/Linux 2.6.14, not stripped
./arm-none-linux-gnueabi/libc/armv4t/sbin/ldconfig: ELF 32-bit LSB executable, ARM, version 1 (SYSV), statically linked, for GNU/Linux 2.6.14, not stripped
./arm-none-linux-gnueabi/libc/thumb2/usr/lib/bin/ldconfig: ELF 32-bit LSB executable, ARM, version 1 (SYSV), statically linked, for GNU/Linux 2.6.14, not stripped
./arm-none-linux-gnueabi/libc/thumb2/sbin/ldconfig: ELF 32-bit LSB executable, ARM, version 1 (SYSV), statically linked, for GNU/Linux 2.6.14, not stripped
./arm-none-linux-gnueabi/libc/sbin/ldconfig: ELF 32-bit LSB executable, ARM, version 1 (SYSV), statically linked, for GNU/Linux 2.6.14, not stripped
Anyone have any pointers or better ways to set up dev environments for cross-compiling? Or any ideas what I'm doing wrong? So far anything I've come up with is a cludge and not the right way of doing it I'm sure
I'm not sure about the right way to do this, but the path can be specified with -L, pretty much like the include path is specified with -I.
Cross-compiling packages isn't an easy task, as a lot of them depend on broken tools like libtool..
Zappletoo said:
I'm not sure about the right way to do this, but the path can be specified with -L, pretty much like the include path is specified with -I.
Cross-compiling packages isn't an easy task, as a lot of them depend on broken tools like libtool..
Click to expand...
Click to collapse
lmao ... one of my friends was a developer for libtool (Gord Matzigkeit) ... I think even he thought it needed to evolve .... I'll try more options tomorrow and see if I can pop in the -L option, might just have to get creative
Thanks!
I just built htop static vs uclibc for my latest build. I got tired of trying to make ncurses and bionic play nice together.
Try CFLAGS instead of CPPFLAGS, and use -L under LDFLAGS for the library include path instead of -I
cyanogen said:
I just built htop static vs uclibc for my latest build. I got tired of trying to make ncurses and bionic play nice together.
Click to expand...
Click to collapse
lol ... well there goes that one I was building this to use on your rom to hopefully help troubleshoot (not that there aren't enough tools already included, and not that there are a lot of issues ). Meh ... still a good learning experience for if i ever get any other ideas on trying to help/contribute/give feed back
I'll still see if I can get anything successfully built without having to mangle patches to get the compiles to play nice. Either way my assumption is even if I do get something built, yours will be a tighter binary.
Thanks again everyone, I'll post any progress if I get anywhere for posterity.
pokey9000 said:
Try CFLAGS instead of CPPFLAGS, and use -L under LDFLAGS for the library include path instead of -I
Click to expand...
Click to collapse
Well for what it's worth I did get it built with the help of this post and some more mangling.
Actual configure string:
Code:
htop-0.8.3# ac_cv_func_malloc_0_nonnull=yes ac_cv_func_realloc_0_nonnull=yes CFLAGS=-I/root/mydroid/arm-2009q1/include LDFLAGS=-L/root/mydroid/arm-2009q1/lib \./configure CC=/root/mydroid/arm-2009q1/bin/arm-none-linux-gnueabi-gcc CXX=/root/mydroid/arm-2009q1/bin/arm-none-linux-gnueabi-g++ --host=arm --build=arm-linux --with-shared --disable-big-core --enable-termcap --disable-GPM --without-ada
After this the make ran with 0 issues ... after pushing the file to the phone however I still can't execute it. Luckily strace existed, sadly it's great for one offs but not great for real debugging .. what I get from the trace is:
Code:
# pwd && busybox ls -lh htop && strace /system/htop
/system
-rwxrwxrwx 1 0 0 164.3K Aug 13 13:04 htop
execve("/system/htop", ["/system/htop"], [/* 11 vars */]) = -1 ENOENT (No such file or directory)
write(2, "strace: exec", 12strace: exec) = 12
write(2, ": ", 2: ) = 2
write(2, "No such file or directory", 25No such file or directory) = 25
write(2, "\n", 1
) = 1
io_submit(1, -1344067161, {...} <unfinished ... exit status 1>
It would seem I have a lot more to learn than what I thought lol
SpEnTBoY said:
Well for what it's worth I did get it built with the help of this post and some more mangling.
Actual configure string:
Code:
htop-0.8.3# ac_cv_func_malloc_0_nonnull=yes ac_cv_func_realloc_0_nonnull=yes CFLAGS=-I/root/mydroid/arm-2009q1/include LDFLAGS=-L/root/mydroid/arm-2009q1/lib \./configure CC=/root/mydroid/arm-2009q1/bin/arm-none-linux-gnueabi-gcc CXX=/root/mydroid/arm-2009q1/bin/arm-none-linux-gnueabi-g++ --host=arm --build=arm-linux --with-shared --disable-big-core --enable-termcap --disable-GPM --without-ada
After this the make ran with 0 issues ... after pushing the file to the phone however I still can't execute it. Luckily strace existed, sadly it's great for one offs but not great for real debugging .. what I get from the trace is:
Code:
# pwd && busybox ls -lh htop && strace /system/htop
/system
-rwxrwxrwx 1 0 0 164.3K Aug 13 13:04 htop
execve("/system/htop", ["/system/htop"], [/* 11 vars */]) = -1 ENOENT (No such file or directory)
write(2, "strace: exec", 12strace: exec) = 12
write(2, ": ", 2: ) = 2
write(2, "No such file or directory", 25No such file or directory) = 25
write(2, "\n", 1
) = 1
io_submit(1, -1344067161, {...} <unfinished ... exit status 1>
It would seem I have a lot more to learn than what I thought lol
Click to expand...
Click to collapse
Did you solved your "-1 ENOENT (No such file or directory)write(2, "strace: exec", 12strace: exec)" error ?
I have the same problem cross compiling zsh :/
EDIT : solved by static linking
drakaz said:
Did you solved your "-1 ENOENT (No such file or directory)write(2, "strace: exec", 12strace: exec)" error ?
I have the same problem cross compiling zsh :/
Click to expand...
Click to collapse
Don't try to compile static binaries linked with glibc as this will not work
and is not supposed to work, because gnu libc links in other dynamic libraries
(libnss* and others) so what you obtain is not a really static library that fails
because it is looking for other dynamic libraries (ENOENT). Use uClibc for static builds.
can you please upload the compiled htop file? i cant compile myself.

[Q] executing self-compiled c/c++ code in connectbot: Syntax error: word unexpected

Hi all,
(see at the end for setup and device info)
(remove spaces in URLs since I am not allowed to post real URLs yet)
I am trying to compile my own c/c++ code and run it on my android phone.
I got the android toolchain and the program (hello world, "test" binary) compiles:
./agcc -c -o test hello.cpp
file test
test: ELF 32-bit LSB relocatable, ARM, version 1 (SYSV), not stripped
The program executable is "test". I copy it to my android to /data (since other folders apparently do not have execution permission yielding the "permission denied" error when trying to execute) and do "chmod a+x test"
When I start connectbot on my phone, navigate to /data and do "./test" then I get the error: Syntax error: word unexpected (expecting ")")
As if connectbot would try to execute this binary as a shell script.
In principle, a step-by-step manual how to compile and run c/c++ code on android would be here:
"http: //www . hytherion.com/beattidp/comput/android/linux-on-android.html"
But I get this strange error mentioned above.
any ideas?
setup:
=====
Phone: Samsung Galaxy S2
Android: 2.3.4
Kernel: GINGERBREAD.XWKI4 (rooted, works all fine)
Crosscompile Toolchain: from: ./repo init -u https: // android.googlesource.com/platform/manifest
Using acc script from "http: // plausible.org/andy/agcc"
Exporting: export PATH=[PathToToolchain]/prebuilt/linux-x86/toolchain/arm-eabi-4.4.3/bin:$PATH
Hello World example:
// hello.cpp
#include <stdio.h>
int main()
{
int a=1;
printf("hello %d",a);
return 0;
}
compiling with: ./agcc -c -o test hello.cpp
bump bump?

[Q] Android emulator (div by zero)

I got intresting situation with following code:
Code:
static void DivideByZero() {
// volatile to prevent compiler optimizations.
volatile float zero = 0.0f;
volatile float result __attribute__((unused)) = 123.0f / zero;
}
DivideByZero();
int raised = fetestexcept(FE_DIVBYZERO | FE_OVERFLOW);
ASSERT_TRUE((raised & FE_DIVBYZERO) != 0);
When I run my qemu device witout KVM support I got following results:
command line:android -avd x86 -qemu
Code:
FE_DIVBYZERO !=0; //and it's ok
But when I run same source without KVM support:
command line:android -avd x86 -qemu -disable-kvm
Code:
FE_DIVBYZERO ==0; //and it's not ok
As I understand this situation, it's happens because in mxcsr register bit (div by zero) is not setted, by why this bit is not setted i don't understand. Any ideas?
System: Linux

Why can't I compile the msm android kernel?

I've been stuck at this for more than a week, so I'd appreciate any help.
What am I trying to do? (you can skip this part if you want)
I'm trying to do android kernel exploitation. That's not my current problem though. To learn kernel exploitation, I need to be able to get a version of android that is vulnerable to a certain vulnerability. So here's what I'm doing:
1. Going here to select a CVE that I want to learn how to exploit
2. After selecting a CVE, I need to select a build that is vulnerable to that CVE from here
3. Now that I have chosen a build (QQ3A.200805.001 in my case), I note its branch name (android-10.0.0_r41 in my case)
4. Now I need to be able to run this build in the android emulator (qemu) once as a production build, and once with KASAN+KCOV+debugging symbols for gdb
Before I begin, I'm following these guides:
1. https://source.android.com/devices/tech/debug/kasan-kcov
2. https://source.android.com/setup/build/building-kernels-deprecated
3. Google
My Setup:
I did this to download everything I need:
Bash:
git clone https://android.googlesource.com/kernel/msm
cd msm
git fetch --all --tags --prune
git checkout remotes/origin/android-msm-coral-4.14-android10
cd ..
mkdir AOSP
cd AOSP
repo init -u https://android.googlesource.com/platform/manifest
repo sync -j`nproc`
repo init -b android-10.0.0_r41
repo sync -j`nproc`
cd ..
When I went to the AOSP directory and tried compiling with:
Bash:
source ./build/envsetup.sh
lunch aosp_flame-userdebug # For the Pixel 4
m
It compiled in 4 hours, but it worked.
My First Issue:
I then created this bash script in the main folder to try to compile the msm kernel normally (without KASAN/KCOV):
Bash:
###########
# Params: #
###########
ARCH=arm64
CONFIG=cuttlefish_defconfig
###########
# Script: #
###########
read -p "Compile with clang instead of gcc? [y/N] " USE_CLANG
if [ $USE_CLANG == y ] || [ $USE_CLANG == Y ]; then
COMPILER=clang
CC_PATH=$(pwd)/AOSP/prebuilts/clang/host/linux-x86/clang-r346389c/bin/
else
COMPILER=gcc
CC_PATH=$(pwd)/AOSP/prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-4.9/bin/
export CROSS_COMPILE=aarch64-linux-android-
fi
export ARCH=$ARCH
export PATH=$PATH:$CC_PATH
cd msm
make clean
make distclean
make $CONFIG
make CC=$COMPILER
When I run it with GCC, I get bombarded with depreciation warnings and I get an error:
Code:
Android GCC has been deprecated in favor of Clang, and will be removed from
Android in 2020-01 as per the deprecation plan in:
https://android.googlesource.com/platform/prebuilts/clang/host/linux-x86/+/master/GCC_4_9_DEPRECATION.md
...
Cannot use CONFIG_CC_STACKPROTECTOR_STRONG: -fstack-protector-strong not supported by compiler
When I run it with clang, I also get a ton of warnings and this error:
Code:
./arch/arm64/include/asm/stack_pointer.h:8:51: error: register 'sp' unsuitable for global register variables on this target
register unsigned long current_stack_pointer asm ("sp");
...
In file included from ./include/linux/kvm_host.h:14:
./include/linux/signal.h:81:11: warning: array index 3 is past the end of the array (which contains 1 element) [-Warray-bounds]
return (set->sig[3] | set->sig[2] |
Full outputs for the script can be found here (for gcc) and here (for clang). Basically my first issue is that I don't know why I'm getting these compilation errors. So any suggestions would be greatly appreciated.
My Second Issue:
Now, I am checking out the remotes/origin/android-msm-coral-4.14-android10 branch in the msm repo, but I think this isn't the way to go because I need the kernel version that corresponds to a certain build/branch (QQ3A.200805.001 or android-10.0.0_r41 in my case). I think I need to build the exact version that is precompiled in the AOSP repository.
For example, if I go to the AOSP/device/google/coral directory, and run git log, I get something like this:
Code:
commit 62d311ad7cfc3e76a5278634427596462069b44d (HEAD, tag: android-10.0.0_r41, tag: m/android-10.0.0_r41, aosp/android10-qpr3-release)
Merge: 7b91fff 0657c80
Author: android-build-team Robot <[email protected]>
Date: Wed Jun 10 23:45:11 2020 +0000
Merge cherrypicks of [11827366, 11829660, 11829049, 11829662, 11829647, 11829300, 11826697, 11829719, 11829051, 11829663, 11829664, 11829838, 11829052, 11829472, 11829586] into qt-qpr3-release
Change-Id: Ic126de75c24133f8d43df7c9d8f09059a9ca8089
commit 0657c80f016720f70ed6f9618f928a30e71f2b79
Author: wenchangliu <[email protected]>
Date: Tue Mar 24 18:11:18 2020 +0800
coral: Add seccomp policy for Codec2 process
Add seccomp policy for Codec2 process.
Bug: 149511958
Test: adb shell killall media.hwcodec
Change-Id: Iab64bd42ead0c5a27769a757007282c2dddf911d
(cherry picked from commit 3628a510a808a52c4ebf69958a8343928e5df3f2)
(cherry picked from commit 45a6093f3d085ca2a531c2607bd12dbc1eff6bf9)
commit 7b91fffc14afb41cf14772566272c72b37c36785
Merge: 2e7f1a3 e8c9484
Author: android-build-team Robot <[email protected]>
Date: Wed Jun 10 00:37:23 2020 +0000
...
Link for this exact commit/tag can be found here. However, there is no android-10.0.0_r41 tag in the msm source repo, so I don't know which version of the msm repo corresponds to the prebuilt one in the AOSP directory. And.. I don't know where to start looking tbh.
Any help is greatly appreciated.

ELF Problems

Perhaps it's the time of year for elves, but this one is giving me fits. Building Evolution X and can't get past this issue during the build process. ANyone seen this one before or know what I'm doing wrong??
/home/erik/snow/out/target/product/pdx203/system/system_ext/bin/dpmd: error: found ELF prebuilt in PRODUCT_COPY_FILES, us
e cc_prebuilt_binary / cc_prebuilt_library_shared instead.
/home/erik/snow/out/target/product/pdx203/system/system_ext/bin/dpmd: error: found ELF file: vendor/sony/pdx203/proprieta
ry/system_ext/bin/dpmd
19:19:54 ninja failed with: exit status 1
#### failed to build some targets (03:43 (mm:ss)) ####
To answer my own question since there's literally zero info on this out on the internet, here's the fix.
Open your device's boardconfig.mk file and paste in the following text:
BUILD_BROKEN_ELF_PREBUILT_PRODUCT_COPY_FILES := true
Re-run make, and you're all set to start working on the next error.
hi!
I got the same error.
yes, we can add this flag to BoardConfig.mk, but it is not a clean solution since Google encourages the use of Android.bp files instead of Makefiles. Thant's what the soong suggested the use of these modules (cc_prebuilt_binary / cc_prebuilt_library_shared). in my case, solved this problem by creating Android.bp file in the repo where I put my prebuilt libraries, then I added them as product packages in the product mk file. this is an example :
Android.bp :
cc_prebuilt_library {
name: "product_package_name_in_MK_file",
relative_install_path: "sub_lib/sub_sub_lib",
stem: "output_file_name", // .so will be added automatically to out file name.
compile_multilib: "both",
multilib: {
lib32: {
srcs: ["path for src 32bit lib"],
},
lib64: {
srcs: ["path for src 64bit lib"],
},
},
strip: {
none:true,
},
allow_undefined_symbols: true,
check_elf_files: false,
vendor: true,
enabled: true,
}
product_mk file :
...
PRODUCT_PACKAGES += product_package_name_in_MK_file
...

Categories

Resources