如何写这个剧本的LD? [英] How to write this ld script ?

查看:188
本文介绍了如何写这个剧本的LD?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我想所有的链接.o文件除了z.o。所有的.o(无z.o)在0xC0000000的搬迁而z.o是0xFFFF0000地址,但z.o位于文件偏移量为0x8000。

If I want to link all .o files except z.o .All .o (no z.o) is relocated at 0xC0000000 while z.o is at 0xFFFF0000 but z.o is located at file offset 0x8000.

So.how写这个剧本的LD?

So.how to write this ld script ?

下面是我的loader.lds

Here is my loader.lds

SECTIONS { 
    loader      0x00000000 : { start.o loader.o }
    kloader     0x30100000 : AT(4096) { loaderk.o ../lib/klib.a }
    vect        0xFFFF0000 : AT(0x4000) { high_vect.o }
} 

这是正确的????

Is this right ????

推荐答案

如果您使用的输入节的。只是使用的文件名是不是这样做的正常方式。问题是,在一些点源模块会间的行为,你将有 code 和/或数据来自同一个模块中使用多个位置即可。因此,使部分装载机 kloader 的和的 VECT 的,并使用 GCC 属性编译指示的放置$ C $℃的章节/数据。

It is much easier if you use input sections. Just using filename is not the normal way to do this. The issue is that at some point the source modules will inter-act and you will have code and/or data from multiple location used in the same module. So, make sections loader, kloader and vect and use gcc attributes or pragmas to place code/data in sections.

您的问题是在的牛羚LD的回答输入部分例子的。输出部分名单并不一定要在存储器的顺序。放置的通配符 {*的.o(*的.text)} 的不匹配将被放置在本节最后和输入对象。

Your question is answered in Gnu ld's Input section example. The output section list does not have to be in memory order. Place the wildcard { *.o(.text*) } last and input objects that aren't matched will be placed in this section.

一个例子注释功能可能看起来像,

An example annotated function might look like,

 void data_abort(unsigned int fsr, void* fault) __attribute__ ((section ("vector)))

通常功能/在不同部分的数据必须合作,所以能够给他们的同一个源文件中混合使用,编译器可以在静态项目进行优化,并保持功能相似的项组合在一起,即使它们可能驻留在不同的部分

Often functions/data in different sections must co-operate, so being able to mix them in the same source file allows the compiler to perform optimizations on static items and keeps functionally similar items grouped together, even though they might reside in different sections.

我觉得这可能普遍跟随你要求什么。

I think this might generally follow what you requested.

 SECTIONS { 
     loader      0x00000000 : { start.o loader.o }
     kloader     0x30100000 : AT(4096) { loaderk.o ../lib/klib.a }
     vect        0xFFFF0000 : AT(0x4000) { high_vect.o }
     vect2       0xFFFF0000 : AT(0x8000) { z.o } /* overlay? */
     text        0xC0000000 : { *.o }
 } 

我不知道,如果你打算过度打好载体与否。您可以覆盖的init code一些数据表。通常你想在最低分离的.text 。数据的.bss

I am not sure if you intend to over-lay the vectors or not. You can overlay init code with some data tables. Usually you want to separate at a minimum .text, .data and .bss.

始终生成的映射文件并仔细检查地址在那里。这比装载和插装code来确定的东西已经被放置在错误的地址快得多。

Always generate a map file and double check the addresses there. This is much quicker than loading and instrumenting the code to determine that something has been placed at the wrong address.

请参阅:<一href=\"http://stackoverflow.com/questions/15137214/how-to-run-$c$c-from-ram-on-arm-architecture\">Running从RAM ,<一个code href=\"http://stackoverflow.com/questions/14453996/gnu-linker-map-file-giving-unexpected-load-addresses\">Gnu链接器提供意想不到的地址,而相关的链接了这个问题。

See: Running code from RAM, Gnu Linker giving unexpected address, and the related links to this question.

这篇关于如何写这个剧本的LD?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆