Recovery Linker Issues

153 views
Skip to first unread message

Rudolf

unread,
Dec 25, 2011, 7:17:39 AM12/25/11
to android-platform
Hello.

I am porting a custom recovery tool (ClockworkMod) to my device
(Huawei U8800). My phone needs an executable rmt_storage, which is
needed to process modem data. Now, that rmt_storage needs additional
libraries, such as libc, libcutils, liblog and etc. What is the most
proper way of copying the linker and those libs (they're all shared)?
By default, CWM has all static executables, so the linker is not added
into the build.
I took my rmt_storage from a working build, from the system/bin.

Here's what the "file" command says:
rmt_storage: ELF 32-bit LSB executable, ARM, version 1 (SYSV),
dynamically linked (uses shared libs), stripped

I've been struggling with this for 2 weeks now, couldn't get it to
work.

Rudolf.

Hemanth(ヘマント)

unread,
Dec 25, 2011, 11:50:43 PM12/25/11
to android-platform
How about the flag:
LOCAL_FORCE_STATIC_EXECUTABLE ?

Something along the lines of
http://code.google.com/p/flashrec/source/browse/trunk/android-root/Android.mk?r=32

Rudolf

unread,
Dec 26, 2011, 3:35:52 AM12/26/11
to android-platform
I think that would work if I would have the source for the executable,
but I don't have it. I tried to add linker by copying, but it did not
have any effect. That's why I am asking what is the proper way of
adding it.

On Dec 26, 6:50 am, Hemanth(ヘマント) <hemanth....@gmail.com> wrote:
> How about the flag:
> LOCAL_FORCE_STATIC_EXECUTABLE ?
>
> Something along the lines ofhttp://code.google.com/p/flashrec/source/browse/trunk/android-root/An...

Hemanth(ヘマント)

unread,
Dec 27, 2011, 1:10:19 AM12/27/11
to android-platform
Hi,
Looks like someone else is working on something similar.Please take a
look at.https://github.com/Victor-android/android_device_huawei_u8800/
tree/gingerbread/recovery/rmt_storagenote that a different init.rc
files is used (recovery.rc) which uses rmt_storage from /sbin

Rudolf

unread,
Dec 27, 2011, 3:31:22 AM12/27/11
to android-...@googlegroups.com
Yes, I already know that. But the problem is, it is for the older 2.2 version of my phone, which has old bootloader, amss and such.
And when I did copy that, it always closed with some error, I believe it simply doesn't work.

One guy added the linker and libraries, but I haven't got in contact with him.

Rudolf

unread,
Dec 27, 2011, 4:25:44 AM12/27/11
to android-platform
Forgot to add, my repository is available here if you'd like to take a
look: https://github.com/Blefish/android_device_huawei_u8800

Rudolf

unread,
Dec 29, 2011, 5:47:51 AM12/29/11
to android-...@googlegroups.com
Ok, I got it fixed propably, can't test right now.

First thing is to build linker. Then copy the linker to /sbin or wherever you want it. Linker search for libraries in /system/lib and /vendor/lib, so I copied my libs to /vendor/lib. 
Then, rmt_storage searches for linker in /system/bin, so hex edited it to match /sbin and added NULLs to make it same size.

I think moderator can close this now.

Santiago Villafuerte

unread,
Aug 10, 2016, 10:46:42 AM8/10/16
to android-platform, rtamm...@gmail.com
Hi guys

I was also struggling to run dynamically linked binaries in the recovery context. The following command was also returning the dynamic linker location to /system/bin/linker

readelf -d --program-headers myandroidbinary

And I did not want to hex edit the binary to change it. Instead, I placed the linker in /sbin/linker and then in the init.recovery.rc script I added:

on init
    ...
    # Path for shared libraries in the recovery context
    export LD_LIBRARY_PATH /sbin/lib

    # Add a symlink to the Android dynamic linker as some binaries call it from /system/bin
    symlink /sbin/linker /system/bin/linker

Make sure to create the /system/bin path in the Makefile so that the symbolic link that init creates can live in there.

And regarding the SO libraries, I copied them to /sbin/lib and then added some make commands to the /build/core/Makefile so that they were copied into the recovery image.

By doing this you can have logcat and any other dynamically linked binaries running in the recovery context.

Thanks Rudolf.
Reply all
Reply to author
Forward
0 new messages