File indexing completed on 2024-04-28 05:40:56
0001 /* 0002 Copyright (C) 2015 Volker Krause <vkrause@kde.org> 0003 0004 This program is free software; you can redistribute it and/or modify it 0005 under the terms of the GNU Library General Public License as published by 0006 the Free Software Foundation; either version 2 of the License, or (at your 0007 option) any later version. 0008 0009 This program is distributed in the hope that it will be useful, but WITHOUT 0010 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 0011 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public 0012 License for more details. 0013 0014 You should have received a copy of the GNU General Public License 0015 along with this program. If not, see <https://www.gnu.org/licenses/>. 0016 */ 0017 0018 #include <config-elf-dissector-version.h> 0019 0020 #include <elf/elffileset.h> 0021 #include <checks/deadcodefinder.h> 0022 0023 #include <QCoreApplication> 0024 #include <QCommandLineParser> 0025 0026 int main(int argc, char** argv) 0027 { 0028 QCoreApplication::setApplicationName(QStringLiteral("ELF Dead Code Finder")); 0029 QCoreApplication::setOrganizationName(QStringLiteral("KDE")); 0030 QCoreApplication::setOrganizationDomain(QStringLiteral("kde.org")); 0031 QCoreApplication::setApplicationVersion(QStringLiteral(ELF_DISSECTOR_VERSION_STRING)); 0032 0033 QCoreApplication app(argc, argv); 0034 0035 QCommandLineParser parser; 0036 parser.addHelpOption(); 0037 parser.addVersionOption(); 0038 QCommandLineOption excludePrefixOpt(QStringLiteral("exclude-prefix"), QStringLiteral("Exclude ELF files in this prefix."), QStringLiteral("exclude")); 0039 parser.addOption(excludePrefixOpt); 0040 parser.addPositionalArgument(QStringLiteral("elf"), QStringLiteral("ELF objects to analyze"), QStringLiteral("<elf>")); 0041 parser.process(app); 0042 0043 ElfFileSet set; 0044 foreach (const auto &fileName, parser.positionalArguments()) { 0045 set.addFile(fileName); 0046 } 0047 0048 DeadCodeFinder finder; 0049 if (parser.isSet(excludePrefixOpt)) 0050 finder.setExcludePrefixes(parser.values(excludePrefixOpt)); 0051 0052 finder.findUnusedSymbols(&set); 0053 finder.dumpResults(); 0054 0055 return 0; 0056 }