完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
嗨,很长一段时间我想了解链接器如何组合两个对象文件。这个句子像解决外部符号冲突和创建可重定位的对象文件等等有点混淆。我试图用GCC编译器理解这个步骤,并为简单的MAI创建了一个目标文件(main .o)。N.C文件。但是当我做NM或ObjDip的时候也一样。我看到大量的内容,不明白。任何人可以解释我的链接器操作一步一步采取2个简单的源文件,以及链接器如何工作这2个对象文件。我也想知道静态和动态链接。我在这里提出这个问题,假设链接器工作的概念与PIC C18控制器相同。
以上来自于百度翻译 以下为原文 Hi , Its been long time i am trying to understand how linker combines two object files .The sentence like resolves external symbol conflicts and create relocatable object file etc are bit confusing. I tried to understand this step using gcc compiler and created an object file(main.o) for a simple main.c file. but when i did nm or objdump for the same. i see lot of content and not understood. can anyone explain me the linker operation step by step by taking 2 simple source files and how linker works on these 2 object files. i would also like to know static and dynamic linking. I am posting this question here assuming that the concept of linker working is same as in PIC c18 controllers also. Regards, Anand |
|
相关推荐
8个回答
|
|
当我们说链接时,有时也涉及“加载”。但是它们是两个不同的过程。有一个很好的指导书“链接器和加载器”,这是作者的网站:HTTPS://www. iECcCOM/Link(一个简单的想法是:假设你有数据(常量、变量)和函数1。首先,您将在它们上创建标签(或标签)。2。然后,使用内存映射的信息来分配资源(用于数据和函数)。这就像求解方程,并找到标签(标签)3的值。然后将其合并到汇编代码中,动态链接通常意味着动态链接和加载。因此,只在加载之前才加载库代码。因此,库代码可以存储在不同的文件中。使用微控制器,特别是PIC18,这可能不是很有用。也许用PIC32,您可以动态地将库代码从外部存储器设备加载到RAM中执行。
以上来自于百度翻译 以下为原文 When we say linking, sometimes it also involves "loading". But they are two different processes. There is a good instruction book "Linkers and Loaders", this is the author's website: https://www.iecc.com/linker/ A simple idea is like: Say you have data(constants, variables) and functions 1. at first, you will create tags(or labels) on them. 2. Then you use the information of the memory map to allocate the resource (for the data and function). It's like solving the equations, and find the values for the tags(labels) 3. Then "merge" it into the assembly code. Dynamic linking usually means dynamic linking and loading. So the library code is loaded only until it's used. So the library code can be stored in a different file. With the microcontroller, especially PIC18, this is probably not very useful. Maybe with PIC32, you can dynamically load the library code from external memory device to RAM for execution. |
|
|
|
h Timijk,感谢链接。基本上,当我们在多个源文件中定义函数并将所有对象文件合并为单个exe/out文件时,链接器就会进入图片。假设如果我们在一个源代码文件中写入所有函数,那么我们根本就不需要链接器,对吗?问候,阿南德
以上来自于百度翻译 以下为原文 H Timijk, Thanks for the link. Basically the linker comes into picture when we have functions defined in multiple source files and combining all object files into single exe/.out file. Suppose if we write all functions in one source code file, then we don't need linker at all, is it right? Regards, Anand |
|
|
|
“所有功能”可能不包括一切。如果我们在C中编写代码,那么就有启动代码和子程序(函数)来清理初始变量(将它们设置为零或一些初始化值)。当然,你可以把它们都包含在一个源文件中。我认为这是一种传统的或标准的代码编译过程。即使使用汇编程序,您也可能希望使用链接器来帮助您分配资源,特别是如果将程序集与其他编程语言混合在一起。另一个问题是,有时不同的PIC可能具有不同的内存组织。然后链接器可以帮助您重新分配资源。如果我们不使用链接器,就好像我们在做链接器的工作,这是我们自己链接的。
以上来自于百度翻译 以下为原文 "all functions" might not include everything. If we write code in C, then there are startup codes and the subroutine(function) to cleanup the initial variables (set them to zero or some initialized values). Of course, you can have all of them included in a single source file. I think it's kind of tradition or standard procedures for code compilation. Even you use assembly, you may also want to use the linker to help you to allocate the resources, especially if you mix assembly with other programming languages. The other thing is, sometimes different PICs may have different memory organizations. Then the linker can help you to reallocate the resources. If we don't use the linker, it's like we are doing the linker's job, which is linking, by ourselves. |
|
|
|
“C18”是PIC18F家庭设备过时的C编译器,它是由XC8取代的。
以上来自于百度翻译 以下为原文 I think you are confused. "C18" is an obsolete C compiler for PIC18F family devices. It was replaced by XC8 years ago. |
|
|
|
嗨,Timijk,你在链接器和加载器上提供的链接,即,HTTPS://www. iECCCON/LIKEL/看起来很旧。我需要一些链接来帮助我尝试与最新的处理器架构并行的链接和加载操作。这将帮助我获得实用的知识。请问候,阿南德。
以上来自于百度翻译 以下为原文 Hi Timijk, The link you provided on linkers and loaders i.e, [url=https://www.iecc.com/linker/]https://www.iecc.com/linker/[/url] looks very old . I need some link which help me to try the linking and loading exercise parallel with latest processor architectures. This will help me to gain practical knowledge. Regards, Anand |
|
|
|
|
|
|
|
|
|
|
|
HI,编译的一般概念:链接和-gt;加载和执行是相当普遍的,所以你也可以读一个较老的文本,直到你理解这些概念。然后在链接过程的实际实现中有变化和例外,所以在一些上下文中,术语:程序构建是比较合适的。为了构建PIC18和PIC16微控制器的程序,XC8是一个以某种非典型的方式执行编译、链接和加载的程序包。在XC8中,代码生成通常被认为是编译器的工作,在连接TH之后执行。详细说明了XC8在MPLAB XC8C编译器用户指南中所使用的构建过程。它与XC8程序、库和文档一起安装。参见类似的内容:C//程序文件(X86)/Microchip /XC8/V1.45/DOCS/…迈西尔
以上来自于百度翻译 以下为原文 Hi, The general concepts of: Compilation -> Linking -> Loading -> Execution are quite general, so you may just as well read an older text until you understand the concepts. Then there are variations and exceptions in actual implementation of the linking process, so in some contexts, the term: program build is more appropriate. For building programs for PIC18 and PIC16 microcontrollers, XC8 is a package that perform both Compilation, Linking and Loading in somewhat atypical ways. In XC8, code generation, which is typically regarded as the work of the compiler, is performed after linking the different functions and libraries together. There is careful explanation of the build process used by XC8 in: MPLAB XC8 C Compiler User's Guide. It is installed in a together with XC8 programs, libraries and documentation. See somewhere like this: C:/Program Files (x86)/Microchip/xc8/v1.45/docs/... Mysil |
|
|
|
只有小组成员才能发言,加入小组>>
5192 浏览 9 评论
2011 浏览 8 评论
1936 浏览 10 评论
请问是否能把一个ADC值转换成两个字节用来设置PWM占空比?
3183 浏览 3 评论
请问电源和晶体值之间有什么关系吗?PIC在正常条件下运行4MHz需要多少电压?
2238 浏览 5 评论
746浏览 1评论
632浏览 1评论
有偿咨询,关于MPLAB X IPE烧录PIC32MX所遇到的问题
517浏览 1评论
PIC Kit3出现目标设备ID(00000000)与预期的设备ID(02c20000)不匹配。是什么原因
644浏览 0评论
544浏览 0评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-1 08:18 , Processed in 1.535554 second(s), Total 94, Slave 77 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号