[Toybox] toys/android/log.c with android NDK?
Rob Landley
rob at landley.net
Fri Mar 16 15:15:48 PDT 2018
On 03/16/2018 01:34 PM, enh wrote:
>> Ah, here's the problem:
>>
>> $ /opt/android/x86-64/bin/llvm-cc -llog hello.c
>> $ ./a.out
>> bash: ./a.out: No such file or directory
>> $ /opt/android/x86-64/bin/llvm-cc -llog hello.c --static
>> /opt/android/x86-64/bin/../lib/gcc/aarch64-linux-android/4.9.x/../../../../aarch64-linux-android/bin/ld:
>> cannot find -llog
>> clang60: error: linker command failed with exit code 1 (use -v to see invocation)
>>
>> The library only exists for dynamic, not static. And I can't run a dynamic
>> bionic binary on an ubuntu host.
>
> not _strictly_ true: you can install /system/bin/linker64 and all the
> libraries you need in /system/lib64.
Hmmm... Different search path, avoids collision with the host libraries. Feasible.
>> Of course...
>>
>> $ /opt/android/x86-64/bin/llvm-cc --static hello.c
>> $ ./a.out
>> Illegal instruction (core dumped)
>>
>> Still an issue with api 28.
>
> works for me.
>
> are you running on hardware so old that it doesn't meet the minimum
> ABI requirements for Android x86-64? from
> https://developer.android.com/ndk/guides/abis.html that's MMX, SSE2,
> SSE3, and SSSE3, SSE4.1, SSE4.2, and POPCNT.
$ grep 'model name' /proc/cpuinfo
model name : AMD C-60 APU with Radeon(tm) HD Graphics
model name : AMD C-60 APU with Radeon(tm) HD Graphics
So yes, probably. (My netbook is the programming equivalent of a ratty old
t-shirt. More than one co-worker has threatened to ritually burn it.)
I'll see if I can throw qemu at the problem.
> if you're seeing SIGILL on an instruction not covered by those, that
> would be a bug. but Android never shipped on CPUs lower than the above
> bar.
Mostly it ships on arm anyway. :)
AOSP and the ADK use a qemu fork and I test with vanilla qemu, but many moons
ago (2010?) I did a contract porting the android base OS layers to the TI netra
for a videoconferencing thing, which meant I built an android kernel from source
and got it to boot to a shell prompt. What I'm trying to do at the moment is
figure out how to shoehorn the android kernel source tree into
https://github.com/landley/mkroot with a config for qemu and use the NDK
toolchain as the compiler, and get it to boot to a shell prompt.
(I have aarch64, armv7l, x86-64, and several others doing that with
musl-cross-make and the vanilla kernel already.)
Would have been nice if it worked on the host, but at least now I know why it
doesn't...
>>>> $ CROSS_COMPILE=... make
>>>> more warnings, more warnings...
>>>> scripts/make.sh: line 28: /opt/android/x86-64/bin/llvm-strip: No such file or
>>>> directory
>>>> strip failed, using unstripped
>>
>> You know that one's trivial enough I might just add a "strip" to toybox. (It's
>> basically objcopy with some excludes.)
>>
>> (The hiccup is that the japanese developers implementing the sh4 toolchain had a
>> translated copy of the ELF spec and the codepage switch turned "_" into "." so
>> they dutifully used . as the symbol prefix, and if you use the wrong strip there
>> it mangles your executables. So one strip working on all targets requires
>> checking to see what if any prefix is currently in use, and that's why I use the
>> prefixed strip.)
And nm doesn't look too hard either. This is a rathole I probably shouldn't go
down _right_ now. Lemme close a few more tabs first...
Rob
More information about the Toybox
mailing list