Linker: No Magic Here

Linker: No Magic Here

Walter Bright emphasizes that many programmers view the linking process from source code to a statically linked executable as a magical process. They believe that something magical happens during the linking step, which only wizards and warlocks can understand. However, the reality is that the linking step is straightforward, and the linker program is not magical but pedestrian. It concatenates the code and data sections of the object files, connects the references to symbols with their definitions, pulls unresolved symbols out of the library, and writes out an executable. The tedious aspect of writing a linker is mainly related to decoding and generating the file formats. Therefore, when the linker complains about symbols being defined more than once or being unresolved, it is necessary to check the declarations and definitions of symbols in the code. To determine the size of an executable, programmers can look at the map file that linkers generate. The map file lists all the symbols in the executable, along with their addresses, and shows the modules that were linked in from the library and their sizes. In summary, there is nothing magical about linkers, and understanding the mechanics requires figuring out the details of each case. #UnderstandingLinkers




要查看或添加评论,请登录

Harshit Walia的更多文章

社区洞察

其他会员也浏览了