链接器生成的 .text 中内容的格式是什么?
What is the format of the content in the .text generated by the linker?
在编译过程中,链接器将我们的代码文本内容映射到代码内存段的.text中。我想知道文本内容是什么意思,是指文本中的实际代码还是汇编中的实际代码?
非常感谢!
does it mean the actual code in text or in assembly?
两者都不是:它是机器指令中的实际代码。
例如:
$ cat > t.c
int foo() { return 42; }
$ gcc -c t.c
$ objdump -d t.o
t.o: file format elf64-x86-64
Disassembly of section .text:
0000000000000000 <foo>:
0: 55 push %rbp
1: 48 89 e5 mov %rsp,%rbp
4: b8 2a 00 00 00 mov [=10=]x2a,%eax
9: 5d pop %rbp
a: c3 retq
.text
段的内容为以下11个字节:
554889e5b82a0000005dc3
更新:
is it correct to say that it contains the assembly code which converted into machine readable binary format?
可以这么说,但不是很清楚
可能“包含机器可读的二进制指令,通过编译和汇编程序源并应用重定位生成”。 (最后一部分是链接器所做的,上面的示例中没有演示。)
在编译过程中,链接器将我们的代码文本内容映射到代码内存段的.text中。我想知道文本内容是什么意思,是指文本中的实际代码还是汇编中的实际代码?
非常感谢!
does it mean the actual code in text or in assembly?
两者都不是:它是机器指令中的实际代码。
例如:
$ cat > t.c
int foo() { return 42; }
$ gcc -c t.c
$ objdump -d t.o
t.o: file format elf64-x86-64
Disassembly of section .text:
0000000000000000 <foo>:
0: 55 push %rbp
1: 48 89 e5 mov %rsp,%rbp
4: b8 2a 00 00 00 mov [=10=]x2a,%eax
9: 5d pop %rbp
a: c3 retq
.text
段的内容为以下11个字节:
554889e5b82a0000005dc3
更新:
is it correct to say that it contains the assembly code which converted into machine readable binary format?
可以这么说,但不是很清楚
可能“包含机器可读的二进制指令,通过编译和汇编程序源并应用重定位生成”。 (最后一部分是链接器所做的,上面的示例中没有演示。)