#include <AsmMacroIoLib.h>\r
\r
ASM_FUNC(_ModuleEntryPoint)\r
- //\r
- // We are built as a ET_DYN PIE executable, so we need to process all\r
- // relative relocations if we are executing from a different offset than we\r
- // were linked at. This is only possible if we are running from RAM.\r
- //\r
- ADRL (r4, __reloc_base)\r
- ADRL (r5, __reloc_start)\r
- ADRL (r6, __reloc_end)\r
-\r
-.Lreloc_loop:\r
- cmp r5, r6\r
- bhs .Lreloc_done\r
-\r
- //\r
- // AArch32 uses the ELF32 REL format, which means each entry in the\r
- // relocation table consists of\r
- //\r
- // UINT32 offset : the relative offset of the value that needs to\r
- // be relocated\r
- // UINT32 info : relocation type and symbol index (the latter is\r
- // not used for R_ARM_RELATIVE relocations)\r
- //\r
- ldrd r8, r9, [r5], #8 // read offset into r8 and info into r9\r
- cmp r9, #23 // check info == R_ARM_RELATIVE?\r
- bne .Lreloc_loop // not a relative relocation? then skip\r
-\r
- ldr r9, [r8, r4] // read addend into r9\r
- add r9, r9, r1 // add image base to addend to get relocated value\r
- str r9, [r8, r4] // write relocated value at offset\r
- b .Lreloc_loop\r
-.Lreloc_done:\r
-\r
// Do early platform specific actions\r
bl ASM_PFX(ArmPlatformPeiBootAction)\r
\r
str r1, [r8]\r
str r5, [r7]\r
\r
+ //\r
+ // The runtime address may be different from the link time address so fix\r
+ // up the PE/COFF relocations. Since we are calling a C function, use the\r
+ // window at the beginning of the FD image as a temp stack.\r
+ //\r
+ mov r0, r5\r
+ ADRL (r1, PeCoffLoaderImageReadFromMemory)\r
+ mov sp, r5\r
+ bl RelocatePeCoffImage\r
+\r
//\r
// Discover the memory size and offset from the DTB, and record in the\r
// respective PCDs. This will also return false if a corrupt DTB is\r
- // encountered. Since we are calling a C function, use the window at the\r
- // beginning of the FD image as a temp stack.\r
+ // encountered.\r
//\r
+ mov r0, r10\r
ADRL (r1, PcdGet64 (PcdSystemMemoryBase))\r
ADRL (r2, PcdGet64 (PcdSystemMemorySize))\r
- mov sp, r5\r
bl FindMemnode\r
teq r0, #0\r
beq .Lout\r