From 6577bbc3c5c47d8e3868f1205284337c6c672744 Mon Sep 17 00:00:00 2001
From: Yuri Kunde Schlesner <yuriks@yuriks.net>
Date: Sun, 7 May 2017 14:56:23 -0700
Subject: [PATCH] Remove ability to load symbol maps

This was now mostly unused except by thread creation, which used a
symbol of the entrypoint, if available, to name the thread.
---
 src/citra_qt/main.cpp   | 13 -------------
 src/citra_qt/main.h     |  1 -
 src/citra_qt/main.ui    |  1 -
 src/core/hle/svc.cpp    | 10 ++--------
 src/core/loader/elf.cpp | 32 --------------------------------
 5 files changed, 2 insertions(+), 55 deletions(-)

diff --git a/src/citra_qt/main.cpp b/src/citra_qt/main.cpp
index 9beec69bc..d7fad555f 100644
--- a/src/citra_qt/main.cpp
+++ b/src/citra_qt/main.cpp
@@ -38,7 +38,6 @@
 #include "common/scm_rev.h"
 #include "common/scope_exit.h"
 #include "common/string_util.h"
-#include "core/arm/disassembler/load_symbol_map.h"
 #include "core/core.h"
 #include "core/file_sys/archive_source_sd_savedata.h"
 #include "core/gdbstub/gdbstub.h"
@@ -253,8 +252,6 @@ void GMainWindow::ConnectWidgetEvents() {
 void GMainWindow::ConnectMenuEvents() {
     // File
     connect(ui.action_Load_File, &QAction::triggered, this, &GMainWindow::OnMenuLoadFile);
-    connect(ui.action_Load_Symbol_Map, &QAction::triggered, this,
-            &GMainWindow::OnMenuLoadSymbolMap);
     connect(ui.action_Select_Game_List_Root, &QAction::triggered, this,
             &GMainWindow::OnMenuSelectGameListRoot);
     connect(ui.action_Exit, &QAction::triggered, this, &QMainWindow::close);
@@ -506,16 +503,6 @@ void GMainWindow::OnMenuLoadFile() {
     }
 }
 
-void GMainWindow::OnMenuLoadSymbolMap() {
-    QString filename = QFileDialog::getOpenFileName(
-        this, tr("Load Symbol Map"), UISettings::values.symbols_path, tr("Symbol Map (*.*)"));
-    if (!filename.isEmpty()) {
-        UISettings::values.symbols_path = QFileInfo(filename).path();
-
-        LoadSymbolMap(filename.toStdString());
-    }
-}
-
 void GMainWindow::OnMenuSelectGameListRoot() {
     QString dir_path = QFileDialog::getExistingDirectory(this, tr("Select Directory"));
     if (!dir_path.isEmpty()) {
diff --git a/src/citra_qt/main.h b/src/citra_qt/main.h
index ded089580..cb2e87cbd 100644
--- a/src/citra_qt/main.h
+++ b/src/citra_qt/main.h
@@ -116,7 +116,6 @@ private slots:
     void OnGameListLoadFile(QString game_path);
     void OnGameListOpenSaveFolder(u64 program_id);
     void OnMenuLoadFile();
-    void OnMenuLoadSymbolMap();
     /// Called whenever a user selects the "File->Select Game List Root" menu item
     void OnMenuSelectGameListRoot();
     void OnMenuRecentFile();
diff --git a/src/citra_qt/main.ui b/src/citra_qt/main.ui
index f64b878f0..b13d578f5 100644
--- a/src/citra_qt/main.ui
+++ b/src/citra_qt/main.ui
@@ -58,7 +58,6 @@
      </property>
     </widget>
     <addaction name="action_Load_File"/>
-    <addaction name="action_Load_Symbol_Map"/>
     <addaction name="separator"/>
     <addaction name="action_Select_Game_List_Root"/>
     <addaction name="menu_recent_files"/>
diff --git a/src/core/hle/svc.cpp b/src/core/hle/svc.cpp
index 2db823c61..8538cfc9d 100644
--- a/src/core/hle/svc.cpp
+++ b/src/core/hle/svc.cpp
@@ -2,12 +2,12 @@
 // Licensed under GPLv2 or any later version
 // Refer to the license.txt file included.
 
+#include <cinttypes>
 #include <map>
 #include "common/logging/log.h"
 #include "common/microprofile.h"
 #include "common/scope_exit.h"
 #include "common/string_util.h"
-#include "common/symbols.h"
 #include "core/arm/arm_interface.h"
 #include "core/core_timing.h"
 #include "core/hle/function_wrappers.h"
@@ -524,13 +524,7 @@ static ResultCode CreateThread(Kernel::Handle* out_handle, s32 priority, u32 ent
                                u32 stack_top, s32 processor_id) {
     using Kernel::Thread;
 
-    std::string name;
-    if (Symbols::HasSymbol(entry_point)) {
-        TSymbol symbol = Symbols::GetSymbol(entry_point);
-        name = symbol.name;
-    } else {
-        name = Common::StringFromFormat("unknown-%08x", entry_point);
-    }
+    std::string name = Common::StringFromFormat("unknown-%08" PRIX32, entry_point);
 
     if (priority > THREADPRIO_LOWEST) {
         return ResultCode(ErrorDescription::OutOfRange, ErrorModule::OS,
diff --git a/src/core/loader/elf.cpp b/src/core/loader/elf.cpp
index 8eb5200ab..cfcde9167 100644
--- a/src/core/loader/elf.cpp
+++ b/src/core/loader/elf.cpp
@@ -8,7 +8,6 @@
 #include "common/common_types.h"
 #include "common/file_util.h"
 #include "common/logging/log.h"
-#include "common/symbols.h"
 #include "core/hle/kernel/process.h"
 #include "core/hle/kernel/resource_limit.h"
 #include "core/loader/elf.h"
@@ -210,7 +209,6 @@ public:
         return (u32)(header->e_flags);
     }
     SharedPtr<CodeSet> LoadInto(u32 vaddr);
-    bool LoadSymbols();
 
     int GetNumSegments() const {
         return (int)(header->e_phnum);
@@ -258,8 +256,6 @@ ElfReader::ElfReader(void* ptr) {
     sections = (Elf32_Shdr*)(base + header->e_shoff);
 
     entryPoint = header->e_entry;
-
-    LoadSymbols();
 }
 
 const char* ElfReader::GetSectionName(int section) const {
@@ -362,34 +358,6 @@ SectionID ElfReader::GetSectionByName(const char* name, int firstSection) const
     return -1;
 }
 
-bool ElfReader::LoadSymbols() {
-    bool hasSymbols = false;
-    SectionID sec = GetSectionByName(".symtab");
-    if (sec != -1) {
-        int stringSection = sections[sec].sh_link;
-        const char* stringBase = reinterpret_cast<const char*>(GetSectionDataPtr(stringSection));
-
-        // We have a symbol table!
-        const Elf32_Sym* symtab = reinterpret_cast<const Elf32_Sym*>(GetSectionDataPtr(sec));
-        unsigned int numSymbols = sections[sec].sh_size / sizeof(Elf32_Sym);
-        for (unsigned sym = 0; sym < numSymbols; sym++) {
-            int size = symtab[sym].st_size;
-            if (size == 0)
-                continue;
-
-            int type = symtab[sym].st_info & 0xF;
-
-            const char* name = stringBase + symtab[sym].st_name;
-
-            Symbols::Add(symtab[sym].st_value, name, size, type);
-
-            hasSymbols = true;
-        }
-    }
-
-    return hasSymbols;
-}
-
 ////////////////////////////////////////////////////////////////////////////////////////////////////
 // Loader namespace