简体   繁体   English

GAS @和.type有什么作用?

[英]GAS what does @ and .type do?

I was reading the following code online. 我正在在线阅读以下代码。 I am wondering what the @ symbol next to the function call means. 我想知道函数调用旁边的@符号是什么意思。 I am also wondering what the .type does exactly. 我也想知道.type到底能做什么。 Can someone point me to a URL which explains the different .types? 有人可以指出指向不同类型的URL吗?

.section .rodata
Lhello:
        .asciz "Hello!"

.section .text
        .globl someRelocations
        .type someRelocations, STT_FUNC
someRelocations:
        leaq Lhello(%rip), %rdi
        call puts@PLT
        ret

The ".type" keyword will place some information into the object file generated saying that "someRelocations" is of the type STT_FUNC (which means: it is a function). 关键字“ .type”会将一些信息放入生成的目标文件中,说明“ someRelocations”的类型为STT_FUNC(这意味着:它是一个函数)。

The linker and/or debuggers may use this information. 链接器和/或调试器可以使用此信息。 On some CPUs (such as ARM variants tht support both Thumb and ARM modes) the linker must know if "someRelocations" is a function or a variable because linking is done a bit differently for functions and variables in this case. 在某些CPU(例如同时支持Thumb和ARM模式的ARM变体)上,链接器必须知道“ someRelocations”是函数还是变量,因为在这种情况下,对函数和变量的链接有所不同。

For the assembler the "@" is just a regular character at this point. 对于汇编程序,“ @”此时只是一个常规字符。 "puts@PLT" is processed by the assembler the same way "putsXPLT" would be processed. 汇编程序处理“ puts @ PLT”的方式与处理“ putsXPLT”的方式相同。

To be very unprecise: When a position-independent file is being generated the linker requires "@PLT" to be added to all function names. 非常不精确:生成与位置无关的文件时,链接器要求将“ @PLT”添加到所有函数名称中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM