“global main” in Assembly

时间秒杀一切 提交于 2019-12-14 00:21:12

问题


I came across this snippet of code:

section .text
    global  main    ;must be declared for linker (gcc)

and then there is a function called main after this line:

main:    ;tell linker entry point

but i don't seem to understand what global main means, and the comment doesn't seem to help much...

i am using this site as a reference to Assembly language programming.

i can analyse that main refers to the function main, but i don't understand the use of the global keyword...

thank you in advance...


回答1:


global main basically means that the symbol should be visible to the linker because other object files will use it. Without it, the symbol main is considered local to the object file it's assembled to, and will not appear after the assembly file is assembled.



来源:https://stackoverflow.com/questions/17882936/global-main-in-assembly

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!