diff options
author | Logan Chien <loganchien@google.com> | 2018-10-25 18:47:55 -0700 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2018-10-25 18:47:55 -0700 |
commit | b8b4986f8d7c4691f99a8efe7fa1f625e9dd91eb (patch) | |
tree | 08afc2097c20cfe956ccb87f71b54cc3b2519e3b /tools/versioner/src/SymbolDatabase.cpp | |
parent | 81d55a93b5fa0cfdb9304e7d9490e3e5a46dad90 (diff) | |
parent | 43d8fa3ca0f2314e6e715a25fa1aea51f5835511 (diff) |
Merge changes I70ea4b23,Iedcfe36b,I3f21fc71,Ie99c0eef am: 90856af78b
am: 43d8fa3ca0
Change-Id: Iaececa679a02c5815a73f4cc8ba9e35aacd81c53
Diffstat (limited to 'tools/versioner/src/SymbolDatabase.cpp')
-rw-r--r-- | tools/versioner/src/SymbolDatabase.cpp | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/tools/versioner/src/SymbolDatabase.cpp b/tools/versioner/src/SymbolDatabase.cpp index 5b8ed5ab4..c483c0fc4 100644 --- a/tools/versioner/src/SymbolDatabase.cpp +++ b/tools/versioner/src/SymbolDatabase.cpp @@ -16,6 +16,8 @@ #include "SymbolDatabase.h" +#include "SymbolFileParser.h" + #include <err.h> #include <stdio.h> #include <stdlib.h> @@ -61,3 +63,53 @@ std::unordered_set<std::string> getSymbols(const std::string& filename) { return result; } + +static std::map<std::string, NdkSymbolType> parsePlatform(const CompilationType& type, + const std::string& platform_dir) { + static const std::pair<const char*, bool> wanted_files[] = { + {"crtbegin.map.txt", false}, + {"libc.map.txt", true}, + }; + + std::map<std::string, NdkSymbolType> result; + + for (auto&& [filename, required] : wanted_files) { + std::string path = platform_dir + "/" + filename; + + std::optional<SymbolMap> symbols = parseSymbolFile(path, type); + if (!symbols) { + if (required) { + errx(1, "error: failed to load: %s", path.c_str()); + } + continue; + } + + for (auto&& [symbol_name, symbol_type] : *symbols) { + if (symbol_name.empty()) { + continue; + } + + if (result.count(symbol_name) != 0) { + if (strict) { + printf("duplicated symbol '%s' in '%s'\n", symbol_name.c_str(), path.c_str()); + } + } + + result[symbol_name] = symbol_type; + } + } + + return result; +} + +std::optional<NdkSymbolDatabase> parsePlatforms(const std::set<CompilationType>& types, + const std::string& platform_dir) { + NdkSymbolDatabase result; + for (const CompilationType& type : types) { + std::map<std::string, NdkSymbolType> symbols = parsePlatform(type, platform_dir); + for (const auto& it : symbols) { + result[it.first][type] = it.second; + } + } + return std::make_optional(std::move(result)); +} |