linker.h 886 B

123456789101112131415161718192021222324252627282930313233343536
  1. // Copyright 2018 yuzu emulator team
  2. // Licensed under GPLv2 or any later version
  3. // Refer to the license.txt file included.
  4. #pragma once
  5. #include <map>
  6. #include <string>
  7. #include "common/common_types.h"
  8. namespace Loader {
  9. class Linker {
  10. protected:
  11. struct Symbol {
  12. Symbol(std::string&& name, u64 value) : name(std::move(name)), value(value) {}
  13. std::string name;
  14. u64 value;
  15. };
  16. struct Import {
  17. VAddr ea;
  18. s64 addend;
  19. };
  20. void WriteRelocations(std::vector<u8>& program_image, const std::vector<Symbol>& symbols,
  21. u64 relocation_offset, u64 size, VAddr load_base);
  22. void Relocate(std::vector<u8>& program_image, u32 dynamic_section_offset, VAddr load_base);
  23. void ResolveImports();
  24. std::map<std::string, Import> imports;
  25. std::map<std::string, VAddr> exports;
  26. };
  27. } // namespace Loader