1 /*
2 Copyright (C) 2015 Volker Krause <vkrause@kde.org>
3
4 This program is free software; you can redistribute it and/or modify it
5 under the terms of the GNU Library General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or (at your
7 option) any later version.
8
9 This program is distributed in the hope that it will be useful, but WITHOUT
10 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
12 License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>.
16 */
17
18 #include <config-elf-dissector-version.h>
19
20 #include <checks/dependenciescheck.h>
21
22 #include <elf/elffileset.h>
23
24 #include <QCoreApplication>
25 #include <QCommandLineParser>
26
main(int argc,char ** argv)27 int main(int argc, char** argv)
28 {
29 QCoreApplication::setApplicationName(QStringLiteral("ELF Dissector"));
30 QCoreApplication::setOrganizationName(QStringLiteral("KDE"));
31 QCoreApplication::setOrganizationDomain(QStringLiteral("kde.org"));
32 QCoreApplication::setApplicationVersion(QStringLiteral(ELF_DISSECTOR_VERSION_STRING));
33
34 QCoreApplication app(argc, argv);
35
36 QCommandLineParser parser;
37 parser.addHelpOption();
38 parser.addVersionOption();
39 QCommandLineOption recursiveOption(QStringList() << QStringLiteral("r") << QStringLiteral("recursive"), QStringLiteral("Check all dependencies recursively as well"));
40 parser.addOption(recursiveOption);
41 parser.addPositionalArgument(QStringLiteral("elf"), QStringLiteral("ELF library to open"), QStringLiteral("<elf>"));
42 parser.process(app);
43
44 foreach (const auto &fileName, parser.positionalArguments()) {
45 ElfFileSet set;
46 set.addFile(fileName);
47 if (set.size() == 0)
48 continue;
49 const auto unusedDeps = DependenciesCheck::unusedDependencies(&set, parser.isSet(recursiveOption) ? -1 : 0);
50 DependenciesCheck::printUnusedDependencies(&set, unusedDeps);
51 }
52
53 return 0;
54 }
55