kern/ldr: enable the use of relr for relocations
This commit is contained in:
@@ -14,6 +14,7 @@ SECTIONS
|
||||
/* =========== CODE section =========== */
|
||||
PROVIDE(__start__ = 0x0);
|
||||
. = __start__;
|
||||
__bin_start__ = .;
|
||||
__code_start = . ;
|
||||
|
||||
.start :
|
||||
@@ -159,6 +160,7 @@ SECTIONS
|
||||
__bss_start__ = .;
|
||||
|
||||
.rela.dyn : { *(.rela.*) } :data
|
||||
.relr.dyn : { *(.relr.*) } :data
|
||||
|
||||
.bss ADDR(.rela.dyn) (NOLOAD) : {
|
||||
*(.dynbss)
|
||||
@@ -169,6 +171,7 @@ SECTIONS
|
||||
|
||||
__bss_end__ = .;
|
||||
|
||||
__bin_end__ = .;
|
||||
__end__ = ABSOLUTE(.);
|
||||
|
||||
/* ==================
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
%rename link old_link
|
||||
|
||||
*link:
|
||||
%(old_link) -T %:getenv(ATMOSPHERE_TOPDIR /kernel.ld) -pie --gc-sections -z text -z nodynamic-undefined-weak -nostdlib
|
||||
%(old_link) -T %:getenv(ATMOSPHERE_TOPDIR /kernel.ld) -pie --gc-sections -z text -z nodynamic-undefined-weak -z pack-relative-relocs -nostdlib
|
||||
|
||||
*startfile:
|
||||
crti%O%s crtbegin%O%s
|
||||
|
||||
@@ -15,8 +15,8 @@
|
||||
*/
|
||||
#include <mesosphere.hpp>
|
||||
|
||||
extern "C" void _start();
|
||||
extern "C" void __end__();
|
||||
extern "C" void __bin_start__();
|
||||
extern "C" void __bin_end__();
|
||||
|
||||
namespace ams::kern {
|
||||
|
||||
@@ -264,8 +264,8 @@ namespace ams::kern::init {
|
||||
KMemoryLayout::GetPhysicalMemoryRegionTree().InsertDirectly(KernelPhysicalAddressSpaceBase, KernelPhysicalAddressSpaceBase + KernelPhysicalAddressSpaceSize - 1);
|
||||
|
||||
/* Save start and end for ease of use. */
|
||||
const uintptr_t code_start_virt_addr = reinterpret_cast<uintptr_t>(_start);
|
||||
const uintptr_t code_end_virt_addr = reinterpret_cast<uintptr_t>(__end__);
|
||||
const uintptr_t code_start_virt_addr = reinterpret_cast<uintptr_t>(__bin_start__);
|
||||
const uintptr_t code_end_virt_addr = reinterpret_cast<uintptr_t>(__bin_end__);
|
||||
|
||||
/* Setup the containing kernel region. */
|
||||
constexpr size_t KernelRegionSize = 1_GB;
|
||||
|
||||
Reference in New Issue
Block a user