building Linux kernel on Mac OS X

后端 未结 6 1053
执念已碎
执念已碎 2021-01-30 14:29

I am doing a project to modify the Linux kernel. I have a desktop Linux machine and I have no problem building kernel on it.

However, I am going on a trip and I want to

6条回答
  •  攒了一身酷
    2021-01-30 15:17

    Here is an update for Android 6.0 Marshmallow and OSX 10.10 Yosemite. I have done several successful cross builds using this method. The only limitation is that I have only done these with the full AOSP source checked out.

    I used brew's libelf to get a nice package managed elf library. This gets us the elf file we need to include, usr/local/opt/libelf/include/libelf/gelf.h

    brew install libelf
    

    But this will still throw errors on build if you symlink it to usr/local/include as apparently some definitions are missing. So I stole the missing definitions from /arch/arm/include/asm/elf.h and created a shim include file:

    cat <> /usr/local/include/elf.h
    #include "../opt/libelf/include/libelf/gelf.h"
    #define R_386_NONE 0
    #define R_386_32 1
    #define R_386_PC32 2
    #define R_ARM_NONE 0
    #define R_ARM_PC24 1
    #define R_ARM_ABS32 2
    #define R_MIPS_NONE 0
    #define R_MIPS_16 1
    #define R_MIPS_32 2
    #define R_MIPS_REL32 3
    #define R_MIPS_26 4
    #define R_MIPS_HI16 5
    #define R_MIPS_LO16 6
    #define R_IA64_IMM64 0x23 /* symbol + addend, mov imm64 */
    #define R_PPC_ADDR32 1 /* 32bit absolute address */
    #define R_PPC64_ADDR64 38 /* doubleword64 S + A */
    #define R_SH_DIR32 1
    #define R_SPARC_64 32 /* Direct 64 bit */
    #define R_X86_64_64 1 /* Direct 64 bit */
    #define R_390_32 4 /* Direct 32 bit. */
    #define R_390_64 22 /* Direct 64 bit. */
    #define R_MIPS_64 18
    EOT
    

    That should be enough to get the build to complete. If anyone needs further information on this, I have a post that covers a full Android kernel build on OSX.

提交回复
热议问题