#include <AsmMacroIoLibV8.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 regardless of whether or not we are executing from\r
- // the same offset we were linked at. This is only possible if we are\r
- // running from RAM.\r
- //\r
- adr x8, __reloc_base\r
- adr x9, __reloc_start\r
- adr x10, __reloc_end\r
-\r
-.Lreloc_loop:\r
- cmp x9, x10\r
- bhs .Lreloc_done\r
-\r
- //\r
- // AArch64 uses the ELF64 RELA format, which means each entry in the\r
- // relocation table consists of\r
- //\r
- // UINT64 offset : the relative offset of the value that needs to\r
- // be relocated\r
- // UINT64 info : relocation type and symbol index (the latter is\r
- // not used for R_AARCH64_RELATIVE relocations)\r
- // UINT64 addend : value to be added to the value being relocated\r
- //\r
- ldp x11, x12, [x9], #24 // read offset into x11 and info into x12\r
- cmp x12, #0x403 // check info == R_AARCH64_RELATIVE?\r
- bne .Lreloc_loop // not a relative relocation? then skip\r
-\r
- ldr x12, [x9, #-8] // read addend into x12\r
- add x12, x12, x8 // add reloc base to addend to get relocated value\r
- str x12, [x11, x8] // write relocated value at offset\r
- b .Lreloc_loop\r
-.Lreloc_done:\r
-\r
bl ASM_PFX(DiscoverDramFromDt)\r
\r
// Get ID of this CPU in Multicore system\r
str x1, [x8]\r
str x7, [x9]\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 x0, x7\r
+ adr x1, PeCoffLoaderImageReadFromMemory\r
+ mov sp, x7\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 x0, x28\r
adr x1, PcdGet64 (PcdSystemMemoryBase)\r
adr x2, PcdGet64 (PcdSystemMemorySize)\r
- mov sp, x7\r
bl FindMemnode\r
cbz x0, .Lout\r
\r