标签:opt macos make elf vmlinux m1 内核 linux homebrew
说明
结合网上一些资源并折腾了一段时间后才成功的。因为完全参考无法正常编译,记录一下供有需要的,希望能对其有所帮助
uboot也可以参考编译通过
macos版本
uname -a
Darwin finnmac-mini.local 21.5.0 Darwin Kernel Version 21.5.0: Tue Apr 26 21:08:29 PDT 2022; root:xnu-8020.121.3~4/RELEASE_ARM64_T8101 arm64
安装环境
brew install make
brew install aarch64-elf-gcc
brew install openssl@1.1
依赖环境
个人在内核源码同级新建include目录,拷贝其中
编译步骤
- 下载内核
linux-5.18.9 - 配置内核
/opt/homebrew/opt/make/libexec/gnubin/make ARCH=arm64 CROSS_COMPILE=aarch64-elf- defconfig
# 去掉CONFIG_KVM选项避免不必要的报错
# [ ] Virtualization ----
/opt/homebrew/opt/make/libexec/gnubin/make ARCH=arm64 CROSS_COMPILE=aarch64-elf- menuconfig
- 修改内核
diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c
index 1c451d5..0d66689 100644
--- a/scripts/mod/file2alias.c
+++ b/scripts/mod/file2alias.c
@@ -43,6 +43,10 @@ typedef struct {
__u8 b[16];
} uuid_le;
+#ifdef __APPLE__
+#define uuid_t compat_uuid_t
+#endif
+
typedef struct {
__u8 b[16];
} uuid_t;
- 编译内核
/opt/homebrew/opt/make/libexec/gnubin/make ARCH=arm64 CROSS_COMPILE=aarch64-elf- HOSTCFLAGS="-I../include -I/opt/homebrew/opt/openssl@1.1/include/" HOSTLDFLAGS="-L/opt/homebrew/opt/openssl@1.1/lib/" -j8
效果展示
(master) ~/WorkSpace/github/linux-5.18.9 ✘ ls
1.txt Kconfig README compile_commands.json init modules-only.symvers samples usr
COPYING LICENSES System.map crypto ipc modules.builtin scripts virt
CREDITS MAINTAINERS arch drivers kernel modules.builtin.modinfo security vmlinux
Documentation Makefile block fs lib modules.order sound vmlinux.o
Kbuild Module.symvers certs include mm net tools vmlinux.symvers
(master) ~/WorkSpace/github/linux-5.18.9 ✘ file vmlinux
vmlinux: ELF 64-bit LSB pie executable, ARM aarch64, version 1 (SYSV), statically linked, BuildID[sha1]=3cfb7eb4d00450fdddde0bf6f1c1dcef63b7ad4a, not stripped
(master) ~/WorkSpace/github/linux-5.18.9 ✘
标签:opt,macos,make,elf,vmlinux,m1,内核,linux,homebrew 来源: https://www.cnblogs.com/rdwr/p/16464620.html
本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享; 2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关; 3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关; 4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除; 5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。