diff --git a/config/common.mk b/config/common.mk index ecb4fd92..5d6136a1 100644 --- a/config/common.mk +++ b/config/common.mk @@ -52,7 +52,7 @@ ATMOSPHERE_DEFINES += -DATMOSPHERE_GIT_BRANCH=\"$(ATMOSPHERE_GIT_BRANCH)\" -DATM #--------------------------------------------------------------------------------- # Ensure top directory is set. #--------------------------------------------------------------------------------- -export TOPDIR ?= $(CURDIR) +TOPDIR ?= $(CURDIR) #--------------------------------------------------------------------------------- # TARGET is the name of the output @@ -60,13 +60,13 @@ export TOPDIR ?= $(CURDIR) # DATA is a list of directories containing data files # INCLUDES is a list of directories containing header files #--------------------------------------------------------------------------------- -export TARGET ?= $(notdir $(CURDIR)) -export BUILD := build -export DATA := data -export INCLUDES := include -export SOURCES ?= $(shell find source -type d \ - -not \( -path source/arch -prune \) \ - -not \( -path source/board -prune \) \) +TARGET := $(notdir $(CURDIR)) +BUILD := build +DATA := data +INCLUDES := include +SOURCES ?= $(shell find source -type d \ + -not \( -path source/arch -prune \) \ + -not \( -path source/board -prune \) \) ifneq ($(strip $(wildcard source/$(ATMOSPHERE_ARCH_DIR)/.*)),) SOURCES += $(shell find source/$(ATMOSPHERE_ARCH_DIR) -type d) diff --git a/libmesosphere/include/mesosphere/init/kern_init_page_table_select.hpp b/libmesosphere/include/mesosphere/init/kern_init_page_table_select.hpp index e0e6b423..6539bca4 100644 --- a/libmesosphere/include/mesosphere/init/kern_init_page_table_select.hpp +++ b/libmesosphere/include/mesosphere/init/kern_init_page_table_select.hpp @@ -18,5 +18,5 @@ #ifdef ATMOSPHERE_ARCH_ARM64 #include "../arch/arm64/init/kern_k_init_page_table.hpp" #else - #error "Unknown architecutre for KInitialPageTable" + #error "Unknown architecture for KInitialPageTable" #endif diff --git a/libmesosphere/source/arch/arm64/init/kern_init_elf64.cpp b/libmesosphere/source/arch/arm64/init/kern_init_elf64.cpp index 8e60b51e..6f846763 100644 --- a/libmesosphere/source/arch/arm64/init/kern_init_elf64.cpp +++ b/libmesosphere/source/arch/arm64/init/kern_init_elf64.cpp @@ -17,66 +17,68 @@ namespace ams::kern::init::Elf::Elf64 { - /* API to apply relocations or call init array. */ - void ApplyRelocations(uintptr_t base_address, const Dyn *dynamic) { - uintptr_t dyn_rel = 0; - uintptr_t dyn_rela = 0; - uintptr_t rel_count = 0; - uintptr_t rela_count = 0; - uintptr_t rel_ent = 0; - uintptr_t rela_ent = 0; + /* API to apply relocations or call init array. */ + void ApplyRelocations(uintptr_t base_address, const Dyn *dynamic) { + uintptr_t dyn_rel = 0; + uintptr_t dyn_rela = 0; + uintptr_t rel_count = 0; + uintptr_t rela_count = 0; + uintptr_t rel_ent = 0; + uintptr_t rela_ent = 0; - /* Iterate over all tags, identifying important extents. */ - for (const Dyn *cur_entry = dynamic; cur_entry->GetTag() != DT_NULL; cur_entry++) { - switch (cur_entry->GetTag()) { - case DT_REL: - dyn_rel = base_address + cur_entry->GetPtr(); - break; - case DT_RELA: - dyn_rela = base_address + cur_entry->GetPtr(); - break; - case DT_RELENT: - rel_ent = cur_entry->GetValue(); - break; - case DT_RELAENT: - rela_ent = cur_entry->GetValue(); - break; - case DT_RELCOUNT: - rel_count = cur_entry->GetValue(); - break; - case DT_RELACOUNT: - rela_count = cur_entry->GetValue(); - break; - } - } + /* Iterate over all tags, identifying important extents. */ + for (const Dyn *cur_entry = dynamic; cur_entry->GetTag() != DT_NULL; cur_entry++) { + switch (cur_entry->GetTag()) { + case DT_REL: + dyn_rel = base_address + cur_entry->GetPtr(); + break; + case DT_RELA: + dyn_rela = base_address + cur_entry->GetPtr(); + break; + case DT_RELENT: + rel_ent = cur_entry->GetValue(); + break; + case DT_RELAENT: + rela_ent = cur_entry->GetValue(); + break; + case DT_RELCOUNT: + rel_count = cur_entry->GetValue(); + break; + case DT_RELACOUNT: + rela_count = cur_entry->GetValue(); + break; + } + } - /* Apply all Rel relocations */ - for (size_t i = 0; i < rel_count; i++) { - const auto &rel = *reinterpret_cast(dyn_rel + rel_ent * i); + /* Apply all Rel relocations */ + for (size_t i = 0; i < rel_count; i++) { + const auto &rel = *reinterpret_cast(dyn_rel + rel_ent * i); - /* Only allow R_AARCH64_RELATIVE relocations. */ - while (rel.GetType() != R_AARCH64_RELATIVE) { /* ... */ } + /* Only allow R_AARCH64_RELATIVE relocations. */ + while (rel.GetType() != R_AARCH64_RELATIVE) { /* ... */ } - /* Apply the relocation. */ - Elf64::Addr *target_address = reinterpret_cast(base_address + rel.GetOffset()); - *target_address += base_address; - } + /* Apply the relocation. */ + Elf64::Addr *target_address = reinterpret_cast(base_address + rel.GetOffset()); + *target_address += base_address; + } - /* Apply all Rela relocations. */ - for (size_t i = 0; i < rela_count; i++) { - const auto &rela = *reinterpret_cast(dyn_rela + rela_ent * i); + /* Apply all Rela relocations. */ + for (size_t i = 0; i < rela_count; i++) { + const auto &rela = *reinterpret_cast(dyn_rela + rela_ent * i); - /* Only allow R_AARCH64_RELATIVE relocations. */ - while (rela.GetType() != R_AARCH64_RELATIVE) { /* ... */ } + /* Only allow R_AARCH64_RELATIVE relocations. */ + while (rela.GetType() != R_AARCH64_RELATIVE) { /* ... */ } - /* Apply the relocation. */ - Elf64::Addr *target_address = reinterpret_cast(base_address + rela.GetOffset()); - *target_address = base_address + rela.GetAddend(); - } - } + /* Apply the relocation. */ + Elf64::Addr *target_address = reinterpret_cast(base_address + rela.GetOffset()); + *target_address = base_address + rela.GetAddend(); + } + } - void CallInitArrayFuncs(uintptr_t init_array_start, uintptr_t init_array_end) { - - } + void CallInitArrayFuncs(uintptr_t init_array_start, uintptr_t init_array_end) { + for (uintptr_t cur_entry = init_array_start; cur_entry < init_array_end; cur_entry += sizeof(void *)) { + (*(void (**)())(cur_entry))(); + } + } } \ No newline at end of file diff --git a/libmesosphere/source/arch/arm64/kern_init_elf64.cpp b/libmesosphere/source/arch/arm64/kern_init_elf64.cpp deleted file mode 100644 index 6f846763..00000000 --- a/libmesosphere/source/arch/arm64/kern_init_elf64.cpp +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Copyright (c) 2018-2019 Atmosphère-NX - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -#include - -namespace ams::kern::init::Elf::Elf64 { - - /* API to apply relocations or call init array. */ - void ApplyRelocations(uintptr_t base_address, const Dyn *dynamic) { - uintptr_t dyn_rel = 0; - uintptr_t dyn_rela = 0; - uintptr_t rel_count = 0; - uintptr_t rela_count = 0; - uintptr_t rel_ent = 0; - uintptr_t rela_ent = 0; - - /* Iterate over all tags, identifying important extents. */ - for (const Dyn *cur_entry = dynamic; cur_entry->GetTag() != DT_NULL; cur_entry++) { - switch (cur_entry->GetTag()) { - case DT_REL: - dyn_rel = base_address + cur_entry->GetPtr(); - break; - case DT_RELA: - dyn_rela = base_address + cur_entry->GetPtr(); - break; - case DT_RELENT: - rel_ent = cur_entry->GetValue(); - break; - case DT_RELAENT: - rela_ent = cur_entry->GetValue(); - break; - case DT_RELCOUNT: - rel_count = cur_entry->GetValue(); - break; - case DT_RELACOUNT: - rela_count = cur_entry->GetValue(); - break; - } - } - - /* Apply all Rel relocations */ - for (size_t i = 0; i < rel_count; i++) { - const auto &rel = *reinterpret_cast(dyn_rel + rel_ent * i); - - /* Only allow R_AARCH64_RELATIVE relocations. */ - while (rel.GetType() != R_AARCH64_RELATIVE) { /* ... */ } - - /* Apply the relocation. */ - Elf64::Addr *target_address = reinterpret_cast(base_address + rel.GetOffset()); - *target_address += base_address; - } - - /* Apply all Rela relocations. */ - for (size_t i = 0; i < rela_count; i++) { - const auto &rela = *reinterpret_cast(dyn_rela + rela_ent * i); - - /* Only allow R_AARCH64_RELATIVE relocations. */ - while (rela.GetType() != R_AARCH64_RELATIVE) { /* ... */ } - - /* Apply the relocation. */ - Elf64::Addr *target_address = reinterpret_cast(base_address + rela.GetOffset()); - *target_address = base_address + rela.GetAddend(); - } - } - - void CallInitArrayFuncs(uintptr_t init_array_start, uintptr_t init_array_end) { - for (uintptr_t cur_entry = init_array_start; cur_entry < init_array_end; cur_entry += sizeof(void *)) { - (*(void (**)())(cur_entry))(); - } - } - -} \ No newline at end of file