带有\n的printf被优化成puts

带有\n的printf被优化成puts

test.c

1
2
3
4
5
6
7
8
9
10
11
#include <stdio.h>

int func(int a)
{
return 0;
}
int main()
{
printf("Hello world\n");
return 0;
}

编译成可重定位文件.o gcc -c test.c

  1. 查看elf section table readelf -S test.o

    在这里插入图1片描述

  1. 找到.strtab序号,查看字符串表

  2. 查看.strtab内容readelf -p 11 test.o

    在这里插入图片描述


去掉\n

在这里插入图片描述