arm-linux程序的链接地址和原先地址

arm-linux程序的链接地址和原先地址,第1张

连腊雀接器脚本xxx.lds文件中指定的地址,就是链接地址,程序运行时必须位于它的链接地址处,汇编文件中的各个标号或者c文件中的各个函数名轮搜早(函数的入口地址)对应的链接地址就是由链接脚本中的起始链接地址和各个目标文件(.s或.c文件编译但还为链接的文件)的排放顺序有关。这些链接地址可以通过查看可执行文件的反汇编文件即xxx.dis文件来获得.

如果你不使用全局变量或者静态变量,访问这些变量时要使用到链接地址,重定位完成之前不能使用这些类型的变量,adr、b和bl指令都是属于相对跳转指令,即在当前pc值的基础上加减一个偏移值,跳转去执行。如果只使用adr、b或者bl指令,并且不访问全局变量或者静态变量,这类代码被称为“位置无关码”,即代码的存储位置可以不在其链接地址处。如果当使用全局跳转指令ldr时就只能使用链接地址了,如ldr pc,_reset。程序运行时,pc指针的内容是不区分原本地址(存储地址)或链接地址的,只要是”位置无关码“,存储地址可以与链接地址不同,不是位置无关码就要使用到链接地址,即存储地址与链接地址必须相同。即使用之前必须完成代码的重定位。漏唤

ps:望采纳!

你好:

ARM是32位的处理器,地址范围是0-4G,都是默认从0x0开始启动。具体存储介质映射的地址范围每个芯片ARM生肢圆袭产商不尽相同。比如ARM7 ARM9 地址的映射是没有做严格的规定的,这个由芯片生产商自己定,但是可以通过查看各个芯片对应的数据腔宏手册能够看到内存映射图(memory map)。对于cortex M ARM有做了比较详细的内存映射规定,比如前256M(0x00000000-0x1fffffff)空间用来映射Flash(很多芯片生产商不会映射这么大的Flash,只会映射一部分,比如1024K,64K等等),接下来的256M(0x20000000-0x3fffffff)用历兄来映射SRAM,再接下来的256M是外设寄存器,在接下来的1G是片外RAM....(具体可以看《cortex M3的权威指南》)。

1. 内核启动地址

ZTEXTADDR

解压代码运行的开始地址。没有轮渗物理地址和虚拟地址之分,因腊枝脊为此时MMU处于关闭状态。这个地址不一定时RAM的地址,可以是支持读写寻址的flash等存搭指储中介。

Start address of decompressor. here's no point in talking about virtual or physical addresses here, since the MMU will be off at the time when you call the decompressor code. You normally call the kernel at this address to start it booting. This doesn't have to be located in RAM, it can be in flash or other read-only or read-write addressable medium.

在arch/arm/boot/compressed/Makefile中说的很明确

#

# We now have a PIC decompressor implementation. Decompressors running

# from RAM should not define ZTEXTADDR. Decompressors running directly

# from ROM or Flash must define ZTEXTADDR (preferably via the config)

# FIXME: Previous assignment to ztextaddr-y is lost here. See SHARK

ifeq ($(CONFIG_ZBOOT_ROM),y)

ZTEXTADDR := $(CONFIG_ZBOOT_ROM_TEXT)

ZBSSADDR:= $(CONFIG_ZBOOT_ROM_BSS)

else

ZTEXTADDR := 0

ZBSSADDR:= ALIGN(8)

endif

ZRELADDR

内核启动在RAM中的地址。压缩的内核映像被解压到这个地址,然后执行。

This is the address where the decompressed kernel will be written, and eventually executed. The following constraint must be valid:

__virt_to_phys(TEXTADDR) == ZRELADDR

The initial part of the kernel is carefully coded to be position independent.

一般定义在项目目录下,比如:

arch/arm/mach-at91/Makefile.boot: zreladdr-y += 0x70008000

arch/arm/mach-at91/Makefile.boot: zreladdr-y += 0x20008000

arch/arm/mach-cns3xxx/Makefile.boot: zreladdr-y += 0x00008000

arch/arm/mach-davinci/Makefile.boot: zreladdr-y += 0xc0008000

arch/arm/mach-davinci/Makefile.boot: zreladdr-y += 0x80008000

arch/arm/mach-dove/Makefile.boot: zreladdr-y += 0x00008000

arch/arm/mach-ebsa110/Makefile.boot: zreladdr-y += 0x00008000

arch/arm/mach-exynos/Makefile.boot: zreladdr-y += 0x40008000

arch/arm/mach-footbridge/Makefile.boot: zreladdr-y += 0x00008000

arch/arm/mach-gemini/Makefile.boot: zreladdr-y += 0x00008000

arch/arm/mach-gemini/Makefile.boot: zreladdr-y += 0x10008000

arch/arm/mach-integrator/Makefile.boot: zreladdr-y += 0x00008000

arch/arm/mach-iop13xx/Makefile.boot: zreladdr-y += 0x00008000

在arch/arm/boot/Makefile中被赋值:

ZRELADDR := $(zreladdr-y)

PARAMS_PHYS := $(params_phys-y)

INITRD_PHYS := $(initrd_phys-y)

... ...

ifneq ($(LOADADDR),)

UIMAGE_LOADADDR=$(LOADADDR)

else

ifeq ($(CONFIG_ZBOOT_ROM),y)

UIMAGE_LOADADDR=$(CONFIG_ZBOOT_ROM_TEXT)


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/yw/12308927.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-24
下一篇 2023-05-24

发表评论

登录后才能评论

评论列表(0条)

保存