Crosscompiling glibc for the Note 2, native GNU tools on the phone, runnig problem?

白い熊

Senior Member
Aug 29, 2011
713
267
93
相撲道
I've followed the steps from http://forum.xda-developers.com/showthread.php?t=1299962 basically, and crosscompiled glibc and some basic GNU tools, to run natively on the Note 2.

Now, I'm running into some problems, which I need help with from crosscompiling gurus...

Basically, what I did:

- Setup crosstool-ng on the PC.
- Downloaded the Note 2 source from Samsung.
- Got include/drm/exynos_drm.h elsewhere on the web, as it was bombing without it, and for some reason, it's not in Samsung sources.
- Built a crosscompiling toolchain. I set:
target architecture - arm
endianness - little
fpu - neon
instruction set mode - arm
eabi - enabled
vendor string - exynos
alias - arm-linux
os - linux
c library - glibc
threading - nptl
- With it, built glibc for the Note, built no prob. Built also GNU tar to start experimenting.

Now, I transfered glibc and the tar dirs to the Note.

As the author says at http://forum.xda-developers.com/showthread.php?t=1299962:
What I've found so far, the cross compiled executable (like simple Hello world), when dynamically linked, gives "no such file or directory" error when tried to be run at the device (WTF, right :) ). However, when when I do run it with the cross-compiled ld-linux.so (the linker of C library) it runs perfectly...

EUREKA! Found the solution! It's as simple as symbolically linking the library folder of your GlibC as /lib to root file system. You can edit ramdisk accordingly to do this process automatically.
Anyhow for me now, when I try to run the tar executable, I get:
Code:
No such file or directory
This even with the glibc lib dir symlinked to /lib, and/or setting LD_LIBRARY_PATH to the glibc lib dir.

file tar gives me:
ELF 32-bit LSB executable, ARM, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 3.0.31, stripped
so all's looking right.

Why can't I get it to run?
 

白い熊

Senior Member
Aug 29, 2011
713
267
93
相撲道
This is proving to be a somewhat great course on crosscompiling for me.

So, messing with it, and making advances - was able to get the compiled executables to run after bindmounting arm-exynos-linux-gnueabi/sysroot/lib dir, which was built by the toolchain to the phone's /lib directory.

Now getting mixed errors and failures caused by ld etc when running GNU tools built against androids libc, so need to mess with terminal on the phone to get just the glibc to loaded on running, but it's progressing...

It seems I'll be able to do this.
 
  • Like
Reactions: Nazar78 and nyarnon

nyarnon

Senior Member
Apr 29, 2007
324
66
0
Looking forward to that. Highly interested in php lighttpd mc busybox dropbear that kinda ****.

--
Sent from my N7100 with Perseus 25.4 Omega 5.0 and some stuff of Raubkatze
 

白い熊

Senior Member
Aug 29, 2011
713
267
93
相撲道
I'm almost there, I just need to crosscompile gcc and then I can build the necessary GNU tools natively.

I'm just figuring out how to crosscompile gcc, as it depends on mpc, gmp, and mpfr, and having no experience with crosstompiling I'm figuring out how to compile depends and link against them, whether they should be native or crosscompiled...

But I should be able to figure it out soon, very close now towards full working GNU tools on the Note 2.
 

白い熊

Senior Member
Aug 29, 2011
713
267
93
相撲道
OK, need help, have asked for it at http://stackoverflow.com/questions/...with-crosstool-ng-have-toolchain-which-archit also.

If anyone could assist, here goes:

I've built the crosscompiling toolchain with crosstools-ng.

I've cross compiled glibc, fine.

Have built a couple native arm (arm-exynos-linux-gnueabi) utils, like tar etc. and confirmed they work on the Android phone, when symlinking the built x-tools sysroot's lib directory to /lib on the android machine.

Now I need to build the native gcc, so I can develop on the machine. I'm having some philosophical problems with crosscompiling, as I'm relatively inexperienced in it.

I'd therefore like to ask how to proceed in steps exactly, as I've already spent two days with a trial-by-error approach, and so far no luck.

So: gcc depends on mpc, which depends on mpfr, which depends on gmp.

So, how do I proceed?

Which architecture deps do I build, with which host target and build options?

make a tools dir and build these deps there, so as not to mess with the functioning toolchain?
gmp (no host, build, target?)
mpfr (same?)

mpc (same?)

then gcc, how? --host=arm-exynos-linux-gnueabi --build=i686-build_pc-linux-gnu --target=arm-exynos-linux-gnueabi ?

Is this right, or am I messing up in some of the above steps?

Incidentally, I've followed this guide http://forum.xda-developers.com/showthread.php?t=1299962 to build the crosstool-ng toolchain, and it recommends compiling the native apps just with --host=arm...

I've been doing that, and they do work on the Android system, though it doesn't seem right to me, shouldn't it be --target=arm...?
 

白い熊

Senior Member
Aug 29, 2011
713
267
93
相撲道
I've proceeded further, have built glibc 2.14 for the N7100, works, compiled gcc and some utils. The problem for now is that there is a bug in glibc 2.14 making statically compiled binaries fail on dynamic calls to libraries... It should be fixed in glibc 2.16...

So am experimenting now, trying to figure out how to add the latest glibc version support to crosstool-ng... If anyone knows, chime in.
 
Our Apps
Get our official app!
The best way to access XDA on your phone
Nav Gestures
Add swipe gestures to any Android
One Handed Mode
Eases uses one hand with your phone