解决relocation truncated to fit: R_PPC_ADDR24 的问题

在尝试构建BootApp时遇到R_PPC_ADDR24重定位截断错误,修改BSP包makefile中RAM_HIGH_ADRS为0x08000000后,编译时出现问题。错误源于excConnectALib.o中的数据段重定位超出了24位有效地址限制。解决方案可能涉及检查汇编源码并调整地址,或者查阅相关资源如OpenBIOS邮件列表中的讨论。

 

将BSP包makefile中的RAM_HIGH_ADRS 修改为 0x08000000

 

编译时会报以下错误:

intALib.o(.text+0x1fc): relocation truncated to fit: R_PPC_ADDR24 noActionIntEnt

详细问题表述见http://www.vxworksos.info/ae-problem-building-a-bootapp-with-ram_high_adrs-higher-than-0x03f00000

 

问题描述:

I’m trying to build a bootApp in Tornado AE of a custom BSP (A
modified version of ads860 BSP).  My board needs to have ROM_BASE_ADRS
= 0×00000000 and LOCAL_MEM_LOCAL_ADRS = 0×50000000.  I set
RAM_HIGH_ADRS = 0×50300000, RAM_LOW_ADRS = 0×50010000, ROM_TEXT_ADRS =
0×00000100 and ROM_SIZE = 0×00280000 in both 00bsp.cdf and makefile.
When I try to build the bootApp, I always received the following
error:

ldppc -X -e usrInit -Ttext 50300000 $/(PRJ_OBJS/) $/(bootKernel_OBJS/)
-o bootApp_reloc
C:/Tornado_AE/target/lib/objPPC860gnuvx/excConnectALib.o: In function
`excConnectCode’:
C:/Tornado_AE/target/lib/objPPC860gnuvx/excConnectALib.o(.data+0×28):
relocation truncated to fit: R_PPC_ADDR24 excEnt
C:/Tornado_AE/target/lib/objPPC860gnuvx/excConnectALib.o(.data+0×34):
relocation truncated to fit: R_PPC_ADDR24 excExcHandle
C:/Tornado_AE/target/lib/objPPC860gnuvx/excConnectALib.o(.data+0x3c):
relocation truncated to fit: R_PPC_ADDR24 excExit
C:/Tornado_AE/target/lib/objPPC860gnuvx/excConnectALib.o(.data+0×48):
relocation truncated to fit: R_PPC_ADDR24 excEnt
C:/Tornado_AE/target/lib/objPPC860gnuvx/excConnectALib.o(.data+0×54):
relocation truncated to fit: R_PPC_ADDR24 excExcHandle
C:/Tornado_AE/target/lib/objPPC860gnuvx/excConnectALib.o(.data+0x5c):
relocation truncated to fit: R_PPC_ADDR24 excExit
C:/Tornado_AE/target/lib/objPPC860gnuvx/excConnectALib.o(.data+0×68):
relocation truncated to fit: R_PPC_ADDR24 excEnt
C:/Tornado_AE/target/lib/objPPC860gnuvx/excConnectALib.o(.data+0×74):
relocation truncated to fit: R_PPC_ADDR24 excExcHandle
C:/Tornado_AE/target/lib/objPPC860gnuvx/excConnectALib.o(.data+0x7c):
relocation truncated to fit: R_PPC_ADDR24 excExit

make[1]: *** [bootApp_reloc] Error 0×1
make[1]: Leaving directory `R:/bootApp/test_ads/PPC860gnu_romCopy’
make: Leaving directory `R:/bootApp/test_ads’
make: *** [bootApp_romCopy] Error 0×2

It seems that I cannot modified RAM_LOW_ADRS and RAM_HIGH_ADRS to be
higher than 0x03F00000 approximately.

Is their anyone that have an idea about the nature of my problem?

Thanks.

David

 

 

解决办法1:

My hunch is that the assembly language module excConnectALib.s, which sounds
like it provides support for connecting to the exception vectors in low
memory, uses instructions with 24-bit effective address operands. Relocating
the code where you did makes this exceed the 24 bits available to generate
the effective address.

If you have the source code, you should be able to see and possibly correct
the problem; otherwise, you are restricted to addresses below 0x00ffffff.

Out of curiosity, it sounds like the hardware engineer decided to route the
SDRAM chip selects to an extremely high part of the address space. If so,
can this be changed?

 

解决办法2:

http://www.openfirmware.info/pipermail/openbios/2009-April/003667.html

[OpenBIOS] QEMU OpenBIOS booting?

Steven Noonan steven at uplinklabs.net
Mon Apr 20 00:36:14 CEST 2009
On Sun, Apr 19, 2009 at 3:28 PM, Steven Noonan <steven at uplinklabs.net> wrote:
> On Sun, Apr 19, 2009 at 2:32 PM, Steven Noonan <steven at uplinklabs.net> wrote:
>> On Sun, Apr 19, 2009 at 2:02 PM, Steven Noonan <steven at uplinklabs.net> wrote:
>>> On Sun, Apr 19, 2009 at 1:48 PM, Laurent Vivier <Laurent at vivier.eu> wrote:
>>>> Le dimanche 19 avril 2009 à 13:33 -0700, Steven Noonan a écrit :
>>>>> On Sun, Apr 19, 2009 at 1:24 PM, Laurent Vivier <Laurent at vivier.eu> wrote:
>>>>> > Le dimanche 19 avril 2009 à 13:14 -0700, Steven Noonan a écrit :
>>>>> > The problem is in OpenBios: I put some structures in memory without
>>>>> > knowing this... but this is not part of openfirmware specification.
>>>>>
>>>>> Agreed, this seems to be an undocumented Apple-ism. But since OSes
>>>>> other than Mac OS X run on PowerPC macs (i.e. BSD, Linux), I must
>>>>
>>>> AIX is also using OpenFirmware / PPC / CHRP, and I think they don't care
>>>> of Apple-ism.
>>>>
>>>>> assume that they are aware of these quirks and don't hammer those
>>>>> memory locations. Since that's the case, it may be wise to conform to
>>>>> what Apple's Open Firmware does, even if it _is_ undocumented.
>>>>
>>>> 'Yes, we can' (R).
>>>>
>>>>> How easy would it be to get OpenBIOS to load to the position Mac OS X
>>>>> and BootX expect it to be? Based on what the book says, there are 8MB
>>>>> of memory available to the Open Firmware, would that be enough for the
>>>>> OpenBIOS executable image and any allocations it would need to
>>>>> perform?
>>>>>
>>>>> >
>>>>> >> the wrong location. From the book "Mac OS X Internals: A Systems
>>>>> >> Approach":
>>>>> >>
>>>>> >> Table 45. BootX Logical Memory Map
>>>>> >>
>>>>> >> Starting Address   Ending Address    Purpose
>>>>> >> 0x00000000    0x00003FFF    Exception vectors.
>>>>> >> 0x00004000    0x03FFFFFF    Kernel image, boot structures, and drivers.
>>>>> >
>>>>> > I put there some memory allocation information.
>>>>> >
>>>>> >> 0x04000000    0x04FFFFFF    File load area.
>>>>> >> 0x05000000    0x053FFFFF    Simple read-time cache for file system
>>>>> >> metadata. Cache hits are serviced from memory, whereas cache misses
>>>>> >> result in disk access.
>>>>> >> 0x05400000    0x055FFFFF    Malloc zone: a simple memory allocator is
>>>>> >> implemented in BootX's libclite subproject. The starting and ending
>>>>> >> addresses of this range define the block of memory used by the
>>>>> >> allocator.
>>>>> >
>>>>> > BootX should use openBIOS functions to allocate memory (as Yaboot
>>>>> > does...)
>>>>>
>>>>> Apparently BootX is tricky that way. I don't have the BootX source
>>>>> code, so I can't verify the author's statement, but I would guess he
>>>>> knows what he's talking about.
>>>>
>>>> Look here:
>>>>
>>>> http://www.opensource.apple.com/darwinsource/tarballs/apsl/BootX-81.tar.gz
>>>>
>>>> (You need an Apple Developer ID)
>>>>
>>>
>>> Aha. From sl.h:
>>>
>>> /*
>>>
>>> Memory Map:  assumed 96 MB (temporarily bumping to 112 MB for 4359362)
>>>
>>> Physical Address
>>>
>>> Open Firmware Version    3x, 4x, ...
>>> 00000000 - 00003FFF  :   Exception Vectors
>>> 00004000 - 057FFFFF  :   Free Memory
>>> // 05800000 - 05FFFFFF  :   OF Image (top 8 MB reserved) [96 MB map]
>>> 06800000 - 06FFFFFF  :   OF Image (top 8 MB reserved) [112 MB map]
>>>
>>>
>>> Logical Address
>>>
>>> // 96 MB map (currently unused - 4363357 tracks re-adoption)
>>> 00000000 - 00003FFF  : Exception Vectors
>>> 00004000 - 03FFFFFF  : Kernel Image, Boot Struct and Drivers (~64 MB)
>>> 04000000 - 04FFFFFF  : File Load Area (16 MB)   [80 MB]
>>> 05000000 - 053FFFFF  : FS Cache    (4 MB)       [84 MB]
>>> 05400000 - 055FFFFF  : Malloc Zone (2 MB)       [86 MB]
>>> 05600000 - 057FFFFF  : BootX Image (2 MB)       [88 MB]
>>> 05800000 - 05FFFFFF  : Unused/OF   (8 MB)       [96 MB]
>>>
>>> // 112 MB map (per 4359362)
>>> 00000000 - 00003FFF  : Exception Vectors
>>> 00004000 - 03FFFFFF  : Kernel Image, Boot Struct and Drivers (~64 MB)
>>> 04000000 - 05FFFFFF  : File Load Area (32 MB)   [96 MB]
>>> 06000000 - 063FFFFF  : FS Cache    (4 MB)       [100 MB]
>>> 06400000 - 065FFFFF  : Malloc Zone (2 MB)       [102 MB]
>>> 06600000 - 067FFFFF  : BootX Image (2 MB)       [104 MB]
>>> 06800000 - 06FFFFFF  : Unused/OF   (8 MB)       [112 MB]
>>> */
>>>
>>>
>>> The 96MB map looks like what we're trying to conform to. I wonder what
>>> this "4359362" they refer to is? An internal bug number or document
>>> number?
>>>
>>
>> OK, so I guess we should use the 112MB map, since the other one says
>> "currently unused", which reads to me as "deprecated".
>>
>> So I'm looking into changing it to load to the position Apple's Open
>> Firmware would. Do these values seem right to you? (it's intentionally
>> space-smashed to prevent someone applying this to mainline)
>>
>>        diff --git a/arch/ppc/qemu/ldscript b/arch/ppc/qemu/ldscript
>>        index 66fcbcd..8fdf654 100644
>>        --- a/arch/ppc/qemu/ldscript
>>        +++ b/arch/ppc/qemu/ldscript
>>        @@ -3,15 +3,15 @@ OUTPUT_ARCH(powerpc)
>>
>>         /* Initial load address
>>          */
>>        -BASE_ADDR = 0xfff00000;
>>        +BASE_ADDR = 0x06800000;
>>
>>        -/* As NVRAM is at 0xfff04000, the .text needs to be after that
>>        +/* As NVRAM is at 0x06804000, the .text needs to be after that
>>          */
>>        -TEXT_ADDR = 0xfff08000;
>>        +TEXT_ADDR = 0x06808000;
>>
>>         /* Hard reset vector address
>>          */
>>        -HRESET_ADDR = 0xfffffffc;
>>        +HRESET_ADDR = 0x06ffffff;
>>
>>         CSTACK_SIZE = 32768;   /* client stack size */
>
> With the above numbers, I get linker problems:
>
> target/arch/ppc/qemu/start.o: In function `vector__0x300':
> (.text.vectors+0x384): relocation truncated to fit: R_PPC_ADDR24
> against `.text.vectors'+c
> target/arch/ppc/qemu/start.o: In function `vector__0x400':
> (.text.vectors+0x484): relocation truncated to fit: R_PPC_ADDR24
> against `.text.vectors'+c
>
> I don't see why it'd do that.
>


What the hell? Why would this change resolve it?

	diff --git a/arch/ppc/qemu/start.S b/arch/ppc/qemu/start.S
	index 66df9a2..108fd9b 100644
	--- a/arch/ppc/qemu/start.S
	+++ b/arch/ppc/qemu/start.S
	@@ -206,7 +206,7 @@ VECTOR( 0x300, "DSI" ):
	        addi    r3,r3,LO(dsi_exception)
	        mtctr   r3
	        bctrl
	-       ba      exception_return
	+       b       exception_return
	
	 VECTOR( 0x400, "ISI" ):
	        EXCEPTION_PREAMBLE
	@@ -214,7 +214,7 @@ VECTOR( 0x400, "ISI" ):
	        addi    r3,r3,LO(isi_exception)
	        mtctr   r3
	        bctrl
	-       ba      exception_return
	+       b       exception_return
	
	        ILLEGAL_VECTOR( 0x500 )
	        ILLEGAL_VECTOR( 0x600 )


>>
>> The only issue with doing things this way is now to figure out what to
>> change this to:
>>
>> #define FREE_BASE               0x00004000
>>
>> My first thought was to utilize all 8MB of the space that Apple says
>> we can have, and use any space after the OpenBIOS image. My second
>> thought was: how do we know where the OpenBIOS executable image ends?
>>
>> Any ideas?
>>
>
评论 1
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值