相关疑难解决方法(0)

对于小程序,链接后的最小可执行文件大小现在比 2 年前大 10 倍?

对于大学课程,我喜欢比较使用 gcc/clang 与汇编编写和编译的功能相似程序的代码大小。在重新评估如何进一步缩小某些可执行文件的大小的过程中,当我 2 年前组装/链接的完全相同的汇编代码在重新构建后现在已经增长了 10 倍以上时,我简直不敢相信自己的眼睛适用于多个程序,不仅是 helloworld):

$ make
as -32 -o helloworld-asm-2020.o helloworld-asm-2020.s
ld -melf_i386 -o helloworld-asm-2020 helloworld-asm-2020.o

$ ls -l
-rwxr-xr-x 1 xxx users  708 Jul 18  2018 helloworld-asm-2018*
-rwxr-xr-x 1 xxx users 8704 Nov 25 15:00 helloworld-asm-2020*
-rwxr-xr-x 1 xxx users 4724 Nov 25 15:00 helloworld-asm-2020-n*
-rwxr-xr-x 1 xxx users 4228 Nov 25 15:00 helloworld-asm-2020-n-sstripped*
-rwxr-xr-x 1 xxx users  604 Nov 25 15:00 helloworld-asm-2020.o*
-rw-r--r-- 1 xxx users  498 Nov 25 14:44 helloworld-asm-2020.s
Run Code Online (Sandbox Code Playgroud)

汇编代码是:

.code32
.section …
Run Code Online (Sandbox Code Playgroud)

linux x86 assembly linker ld

8
推荐指数
1
解决办法
246
查看次数

标签 统计

assembly ×1

ld ×1

linker ×1

linux ×1

x86 ×1