Android: 3G/1G and 2G/2G kernels problem

在进行MOD Android ROM的时候有可能遇到的问题是:BT的厂家自带的kernel是带着CONFIG_VMSPLIT_2G=y编译的,这个时候如果Android上层按照3G的偏移来做prelink的话就会出问题,解决方法如下:


 1, add the prelink-linux-arm-2G.map to build/core/ and change its name to prelink-arm-2G.map if you have it; or just edit every libs' address in the old prelink-linux-arm.map, eg:

        old:          libdl.so                0xAFF00000 # [<64K]

        new:        libdl.so                0x6FF00000 # [<64K]

每个库的prelink地址都要减去1G


2, in bionic/linker/ - edit the Android.mk:

ifneq ($(TARGET_USES_2G_VM_SPLIT),true)
# This is aligned to 4K page boundary so that both GNU ld and gold work.  Gold
# actually produces a correct binary with starting address 0xB0000100 but the
# extra objcopy step to rename symbols causes the resulting binary to be misaligned
# and unloadable.  Increasing the alignment adds an extra 3840 bytes in padding
# but switching to gold saves about 1M of space.
LINKER_TEXT_BASE := 0xB0001000
else
LINKER_TEXT_BASE := 0x70001000
LOCAL_CFLAGS += -DVM_SPLIT_2G
endif
改写LINKER_TEXT_BASE并且定义宏VM_SPLIT_2G来改变相关代码的行为。


3, in bionic/linker/ - edit linker.h

#ifdef ARCH_SH
#define LIBBASE 0x60000000
#define LIBLAST 0x70000000
#define LIBINC  0x00100000
#elif defined(VM_SPLIT_2G)
#define LIBBASE 0x40000000
#define LIBLAST 0x50000000
#define LIBINC  0x00100000
#else
#define LIBBASE 0x80000000
#define LIBLAST 0x90000000
#define LIBINC  0x00100000
#endif

根据Android.mk中是2G还是3G来选择LIBBASE和LIBLAST


4, in build/tools/apriori - edit Android.mk, add:

ifeq ($(TARGET_USES_2G_VM_SPLIT),true)
LOCAL_CFLAGS += -DVM_SPLIT_2G
endif
 -edit prelinkmap.c, add:

#ifdef VM_SPLIT_2G
#define PRELINK_MAX 0x8FFFFFFF
#define PRELINK_MIN 0x50000000
#else
#define PRELINK_MIN 0x90000000
#define PRELINK_MAX 0xBFFFFFFF
#endif

5, in device/xxx/yyy/ or vendor/xxx/yyy/ - edit BoardConfig[_Common].mk, 打开使这一切生效的开关:

TARGET_USES_2G_VM_SPLIT := true

然后就可以把厂家的kernel带上一起编译了。















你可能感兴趣的:(android,BT,alignment,linker)