2013-08-09 10:31:14 +00:00
|
|
|
//===- llvm-readobj.cpp - Dump contents of an Object File -----------------===//
|
2012-03-01 01:36:50 +00:00
|
|
|
//
|
2019-01-19 08:50:56 +00:00
|
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
2012-03-01 01:36:50 +00:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
2013-02-05 20:27:22 +00:00
|
|
|
// This is a tool similar to readelf, except it works on multiple object file
|
|
|
|
// formats. The main purpose of this tool is to provide detailed output suitable
|
|
|
|
// for FileCheck.
|
2012-03-02 23:43:51 +00:00
|
|
|
//
|
2013-02-05 20:27:22 +00:00
|
|
|
// Flags should be similar to readelf where supported, but the output format
|
|
|
|
// does not need to be identical. The point is to not make users learn yet
|
|
|
|
// another set of flags.
|
2012-03-02 23:43:51 +00:00
|
|
|
//
|
2013-02-05 20:27:22 +00:00
|
|
|
// Output should be specialized for each format where appropriate.
|
2012-03-02 23:43:51 +00:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
2012-03-01 01:36:50 +00:00
|
|
|
|
2013-02-20 02:37:12 +00:00
|
|
|
#include "llvm-readobj.h"
|
2013-04-03 18:31:38 +00:00
|
|
|
#include "Error.h"
|
|
|
|
#include "ObjDumper.h"
|
2017-09-20 18:33:35 +00:00
|
|
|
#include "WindowsResourceDumper.h"
|
2019-02-07 15:24:18 +00:00
|
|
|
#include "llvm/DebugInfo/CodeView/GlobalTypeTableBuilder.h"
|
2017-11-30 18:39:50 +00:00
|
|
|
#include "llvm/DebugInfo/CodeView/MergingTypeTableBuilder.h"
|
2013-04-03 18:31:38 +00:00
|
|
|
#include "llvm/Object/Archive.h"
|
2015-08-28 07:40:30 +00:00
|
|
|
#include "llvm/Object/COFFImportFile.h"
|
2015-03-24 20:26:55 +00:00
|
|
|
#include "llvm/Object/MachOUniversal.h"
|
2012-12-04 10:44:52 +00:00
|
|
|
#include "llvm/Object/ObjectFile.h"
|
2017-09-20 18:33:35 +00:00
|
|
|
#include "llvm/Object/WindowsResource.h"
|
2013-04-03 18:31:38 +00:00
|
|
|
#include "llvm/Support/Casting.h"
|
2012-03-01 01:36:50 +00:00
|
|
|
#include "llvm/Support/CommandLine.h"
|
2013-04-03 18:31:38 +00:00
|
|
|
#include "llvm/Support/DataTypes.h"
|
2012-03-01 01:36:50 +00:00
|
|
|
#include "llvm/Support/Debug.h"
|
2013-04-03 18:31:38 +00:00
|
|
|
#include "llvm/Support/FileSystem.h"
|
2018-01-10 00:14:19 +00:00
|
|
|
#include "llvm/Support/FormatVariadic.h"
|
2018-04-13 18:26:06 +00:00
|
|
|
#include "llvm/Support/InitLLVM.h"
|
2017-07-19 02:09:37 +00:00
|
|
|
#include "llvm/Support/Path.h"
|
2016-05-03 00:28:04 +00:00
|
|
|
#include "llvm/Support/ScopedPrinter.h"
|
2013-04-03 18:31:38 +00:00
|
|
|
#include "llvm/Support/TargetRegistry.h"
|
2019-04-15 11:17:48 +00:00
|
|
|
#include "llvm/Support/WithColor.h"
|
2013-04-03 18:31:38 +00:00
|
|
|
|
2012-03-01 01:36:50 +00:00
|
|
|
using namespace llvm;
|
|
|
|
using namespace llvm::object;
|
|
|
|
|
2013-04-03 18:31:38 +00:00
|
|
|
namespace opts {
|
|
|
|
cl::list<std::string> InputFilenames(cl::Positional,
|
|
|
|
cl::desc("<input object files>"),
|
|
|
|
cl::ZeroOrMore);
|
|
|
|
|
2019-05-01 05:27:20 +00:00
|
|
|
// --all, -a
|
[llvm-readelf] Make llvm-readelf more compatible with GNU readelf.
Summary:
This change adds a bunch of options that GNU readelf supports. There is one breaking change when invoked as `llvm-readobj`, and three breaking changes when invoked as `llvm-readelf`:
- Add --all (implies --file-header, --program-headers, etc.)
- [Breaking] -a is --all instead of --arm-attributes
- Add --file-header as an alias for --file-headers
- Replace --sections with --sections-headers, keeping --sections as an alias for it
- Add --relocs as an alias for --relocations
- Add --dynamic as an alias for --dynamic-table
- Add --segments as an alias for --program-headers
- Add --section-groups as an alias for --elf-section-groups
- Add --dyn-syms as an alias for --dyn-symbols
- Add --syms as an alias for --symbols
- Add --histogram as an alias for --elf-hash-histogram
- [Breaking] When invoked as `llvm-readelf`, -s is --symbols instead of --sections
- [Breaking] When invoked as `llvm-readelf`, -t is no longer an alias for --symbols
Reviewers: MaskRay, phosek, mcgrathr, jhenderson
Reviewed By: MaskRay, jhenderson
Subscribers: sbc100, aheejin, edd, jhenderson, silvas, echristo, compnerd, kristina, javed.absar, kristof.beyls, llvm-commits, Bigcheese
Differential Revision: https://reviews.llvm.org/D54124
llvm-svn: 346685
2018-11-12 18:02:38 +00:00
|
|
|
cl::opt<bool>
|
|
|
|
All("all",
|
|
|
|
cl::desc("Equivalent to setting: --file-headers, --program-headers, "
|
|
|
|
"--section-headers, --symbols, --relocations, "
|
|
|
|
"--dynamic-table, --notes, --version-info, --unwind, "
|
|
|
|
"--section-groups and --elf-hash-histogram."));
|
|
|
|
cl::alias AllShort("a", cl::desc("Alias for --all"), cl::aliasopt(All));
|
|
|
|
|
2019-11-25 16:04:58 +03:00
|
|
|
// --dependent-libraries
|
|
|
|
cl::opt<bool>
|
|
|
|
DependentLibraries("dependent-libraries",
|
|
|
|
cl::desc("Display the dependent libraries section"));
|
|
|
|
|
2020-08-12 15:49:37 +03:00
|
|
|
// --headers, -e
|
2018-12-11 16:15:03 +00:00
|
|
|
cl::opt<bool>
|
|
|
|
Headers("headers",
|
|
|
|
cl::desc("Equivalent to setting: --file-headers, --program-headers, "
|
|
|
|
"--section-headers"));
|
|
|
|
cl::alias HeadersShort("e", cl::desc("Alias for --headers"),
|
|
|
|
cl::aliasopt(Headers));
|
|
|
|
|
2019-05-01 05:27:20 +00:00
|
|
|
// --wide, -W
|
[llvm-readelf] Make llvm-readelf more compatible with GNU readelf.
Summary:
This change adds a bunch of options that GNU readelf supports. There is one breaking change when invoked as `llvm-readobj`, and three breaking changes when invoked as `llvm-readelf`:
- Add --all (implies --file-header, --program-headers, etc.)
- [Breaking] -a is --all instead of --arm-attributes
- Add --file-header as an alias for --file-headers
- Replace --sections with --sections-headers, keeping --sections as an alias for it
- Add --relocs as an alias for --relocations
- Add --dynamic as an alias for --dynamic-table
- Add --segments as an alias for --program-headers
- Add --section-groups as an alias for --elf-section-groups
- Add --dyn-syms as an alias for --dyn-symbols
- Add --syms as an alias for --symbols
- Add --histogram as an alias for --elf-hash-histogram
- [Breaking] When invoked as `llvm-readelf`, -s is --symbols instead of --sections
- [Breaking] When invoked as `llvm-readelf`, -t is no longer an alias for --symbols
Reviewers: MaskRay, phosek, mcgrathr, jhenderson
Reviewed By: MaskRay, jhenderson
Subscribers: sbc100, aheejin, edd, jhenderson, silvas, echristo, compnerd, kristina, javed.absar, kristof.beyls, llvm-commits, Bigcheese
Differential Revision: https://reviews.llvm.org/D54124
llvm-svn: 346685
2018-11-12 18:02:38 +00:00
|
|
|
cl::opt<bool>
|
|
|
|
WideOutput("wide", cl::desc("Ignored for compatibility with GNU readelf"),
|
|
|
|
cl::Hidden);
|
2017-07-18 23:58:15 +00:00
|
|
|
cl::alias WideOutputShort("W",
|
|
|
|
cl::desc("Alias for --wide"),
|
|
|
|
cl::aliasopt(WideOutput));
|
|
|
|
|
2019-05-01 05:27:20 +00:00
|
|
|
// --file-headers, --file-header, -h
|
2013-04-03 18:31:38 +00:00
|
|
|
cl::opt<bool> FileHeaders("file-headers",
|
|
|
|
cl::desc("Display file headers "));
|
[llvm-readelf] Make llvm-readelf more compatible with GNU readelf.
Summary:
This change adds a bunch of options that GNU readelf supports. There is one breaking change when invoked as `llvm-readobj`, and three breaking changes when invoked as `llvm-readelf`:
- Add --all (implies --file-header, --program-headers, etc.)
- [Breaking] -a is --all instead of --arm-attributes
- Add --file-header as an alias for --file-headers
- Replace --sections with --sections-headers, keeping --sections as an alias for it
- Add --relocs as an alias for --relocations
- Add --dynamic as an alias for --dynamic-table
- Add --segments as an alias for --program-headers
- Add --section-groups as an alias for --elf-section-groups
- Add --dyn-syms as an alias for --dyn-symbols
- Add --syms as an alias for --symbols
- Add --histogram as an alias for --elf-hash-histogram
- [Breaking] When invoked as `llvm-readelf`, -s is --symbols instead of --sections
- [Breaking] When invoked as `llvm-readelf`, -t is no longer an alias for --symbols
Reviewers: MaskRay, phosek, mcgrathr, jhenderson
Reviewed By: MaskRay, jhenderson
Subscribers: sbc100, aheejin, edd, jhenderson, silvas, echristo, compnerd, kristina, javed.absar, kristof.beyls, llvm-commits, Bigcheese
Differential Revision: https://reviews.llvm.org/D54124
llvm-svn: 346685
2018-11-12 18:02:38 +00:00
|
|
|
cl::alias FileHeadersShort("h", cl::desc("Alias for --file-headers"),
|
|
|
|
cl::aliasopt(FileHeaders), cl::NotHidden);
|
|
|
|
cl::alias FileHeadersSingular("file-header",
|
|
|
|
cl::desc("Alias for --file-headers"),
|
|
|
|
cl::aliasopt(FileHeaders));
|
|
|
|
|
2019-05-01 05:27:20 +00:00
|
|
|
// --section-headers, --sections, -S
|
[llvm-readelf] Make llvm-readelf more compatible with GNU readelf.
Summary:
This change adds a bunch of options that GNU readelf supports. There is one breaking change when invoked as `llvm-readobj`, and three breaking changes when invoked as `llvm-readelf`:
- Add --all (implies --file-header, --program-headers, etc.)
- [Breaking] -a is --all instead of --arm-attributes
- Add --file-header as an alias for --file-headers
- Replace --sections with --sections-headers, keeping --sections as an alias for it
- Add --relocs as an alias for --relocations
- Add --dynamic as an alias for --dynamic-table
- Add --segments as an alias for --program-headers
- Add --section-groups as an alias for --elf-section-groups
- Add --dyn-syms as an alias for --dyn-symbols
- Add --syms as an alias for --symbols
- Add --histogram as an alias for --elf-hash-histogram
- [Breaking] When invoked as `llvm-readelf`, -s is --symbols instead of --sections
- [Breaking] When invoked as `llvm-readelf`, -t is no longer an alias for --symbols
Reviewers: MaskRay, phosek, mcgrathr, jhenderson
Reviewed By: MaskRay, jhenderson
Subscribers: sbc100, aheejin, edd, jhenderson, silvas, echristo, compnerd, kristina, javed.absar, kristof.beyls, llvm-commits, Bigcheese
Differential Revision: https://reviews.llvm.org/D54124
llvm-svn: 346685
2018-11-12 18:02:38 +00:00
|
|
|
// Also -s in llvm-readobj mode.
|
|
|
|
cl::opt<bool> SectionHeaders("section-headers",
|
|
|
|
cl::desc("Display all section headers."));
|
|
|
|
cl::alias SectionsShortUpper("S", cl::desc("Alias for --section-headers"),
|
|
|
|
cl::aliasopt(SectionHeaders), cl::NotHidden);
|
|
|
|
cl::alias SectionHeadersAlias("sections",
|
|
|
|
cl::desc("Alias for --section-headers"),
|
|
|
|
cl::aliasopt(SectionHeaders), cl::NotHidden);
|
2013-04-03 18:31:38 +00:00
|
|
|
|
2019-05-01 05:27:20 +00:00
|
|
|
// --section-relocations
|
|
|
|
// Also --sr in llvm-readobj mode.
|
2013-04-03 18:31:38 +00:00
|
|
|
cl::opt<bool> SectionRelocations("section-relocations",
|
|
|
|
cl::desc("Display relocations for each section shown."));
|
|
|
|
|
2019-05-01 05:27:20 +00:00
|
|
|
// --section-symbols
|
|
|
|
// Also --st in llvm-readobj mode.
|
2013-04-03 18:31:38 +00:00
|
|
|
cl::opt<bool> SectionSymbols("section-symbols",
|
|
|
|
cl::desc("Display symbols for each section shown."));
|
|
|
|
|
2019-05-01 05:27:20 +00:00
|
|
|
// --section-data
|
|
|
|
// Also --sd in llvm-readobj mode.
|
2013-04-03 18:31:38 +00:00
|
|
|
cl::opt<bool> SectionData("section-data",
|
|
|
|
cl::desc("Display section data for each section shown."));
|
|
|
|
|
2019-05-01 05:27:20 +00:00
|
|
|
// --section-mapping
|
[llvm-readobj] Add a flag to dump just the section-to-segment mapping.
Summary:
The following patch introduces a new function `printSectionMapping` which is responsible for dumping just the section-to-segment mapping.
This patch also introduces a n option `-section-mapping` that outputs that mapping without the program headers.
Previously, this functionality was controlled by `printProgramHeaders`, and the output from `-program-headers` has not been changed. I am happy to change the option name, I copied the name that was displayed when outputting the mapping table.
Reviewers: khemant, jhenderson, grimar, rupprecht
Reviewed By: jhenderson, grimar, rupprecht
Subscribers: rupprecht, jhenderson, llvm-commits
Differential Revision: https://reviews.llvm.org/D57365
llvm-svn: 352896
2019-02-01 18:51:10 +00:00
|
|
|
cl::opt<cl::boolOrDefault>
|
|
|
|
SectionMapping("section-mapping",
|
|
|
|
cl::desc("Display the section to segment mapping."));
|
|
|
|
|
2019-05-01 05:27:20 +00:00
|
|
|
// --relocations, --relocs, -r
|
2013-04-03 18:31:38 +00:00
|
|
|
cl::opt<bool> Relocations("relocations",
|
|
|
|
cl::desc("Display the relocation entries in the file"));
|
[llvm-readelf] Make llvm-readelf more compatible with GNU readelf.
Summary:
This change adds a bunch of options that GNU readelf supports. There is one breaking change when invoked as `llvm-readobj`, and three breaking changes when invoked as `llvm-readelf`:
- Add --all (implies --file-header, --program-headers, etc.)
- [Breaking] -a is --all instead of --arm-attributes
- Add --file-header as an alias for --file-headers
- Replace --sections with --sections-headers, keeping --sections as an alias for it
- Add --relocs as an alias for --relocations
- Add --dynamic as an alias for --dynamic-table
- Add --segments as an alias for --program-headers
- Add --section-groups as an alias for --elf-section-groups
- Add --dyn-syms as an alias for --dyn-symbols
- Add --syms as an alias for --symbols
- Add --histogram as an alias for --elf-hash-histogram
- [Breaking] When invoked as `llvm-readelf`, -s is --symbols instead of --sections
- [Breaking] When invoked as `llvm-readelf`, -t is no longer an alias for --symbols
Reviewers: MaskRay, phosek, mcgrathr, jhenderson
Reviewed By: MaskRay, jhenderson
Subscribers: sbc100, aheejin, edd, jhenderson, silvas, echristo, compnerd, kristina, javed.absar, kristof.beyls, llvm-commits, Bigcheese
Differential Revision: https://reviews.llvm.org/D54124
llvm-svn: 346685
2018-11-12 18:02:38 +00:00
|
|
|
cl::alias RelocationsShort("r", cl::desc("Alias for --relocations"),
|
|
|
|
cl::aliasopt(Relocations), cl::NotHidden);
|
|
|
|
cl::alias RelocationsGNU("relocs", cl::desc("Alias for --relocations"),
|
|
|
|
cl::aliasopt(Relocations));
|
2013-04-03 18:31:38 +00:00
|
|
|
|
2019-05-01 05:27:20 +00:00
|
|
|
// --notes, -n
|
2016-08-30 18:52:02 +00:00
|
|
|
cl::opt<bool> Notes("notes", cl::desc("Display the ELF notes in the file"));
|
|
|
|
cl::alias NotesShort("n", cl::desc("Alias for --notes"), cl::aliasopt(Notes));
|
|
|
|
|
2019-05-01 05:27:20 +00:00
|
|
|
// --dyn-relocations
|
2015-06-25 21:47:32 +00:00
|
|
|
cl::opt<bool> DynRelocs("dyn-relocations",
|
|
|
|
cl::desc("Display the dynamic relocation entries in the file"));
|
|
|
|
|
2019-05-01 05:27:20 +00:00
|
|
|
// --symbols
|
[llvm-readelf] Make llvm-readelf more compatible with GNU readelf.
Summary:
This change adds a bunch of options that GNU readelf supports. There is one breaking change when invoked as `llvm-readobj`, and three breaking changes when invoked as `llvm-readelf`:
- Add --all (implies --file-header, --program-headers, etc.)
- [Breaking] -a is --all instead of --arm-attributes
- Add --file-header as an alias for --file-headers
- Replace --sections with --sections-headers, keeping --sections as an alias for it
- Add --relocs as an alias for --relocations
- Add --dynamic as an alias for --dynamic-table
- Add --segments as an alias for --program-headers
- Add --section-groups as an alias for --elf-section-groups
- Add --dyn-syms as an alias for --dyn-symbols
- Add --syms as an alias for --symbols
- Add --histogram as an alias for --elf-hash-histogram
- [Breaking] When invoked as `llvm-readelf`, -s is --symbols instead of --sections
- [Breaking] When invoked as `llvm-readelf`, -t is no longer an alias for --symbols
Reviewers: MaskRay, phosek, mcgrathr, jhenderson
Reviewed By: MaskRay, jhenderson
Subscribers: sbc100, aheejin, edd, jhenderson, silvas, echristo, compnerd, kristina, javed.absar, kristof.beyls, llvm-commits, Bigcheese
Differential Revision: https://reviews.llvm.org/D54124
llvm-svn: 346685
2018-11-12 18:02:38 +00:00
|
|
|
// Also -s in llvm-readelf mode, or -t in llvm-readobj mode.
|
2019-01-23 16:15:39 +00:00
|
|
|
cl::opt<bool>
|
|
|
|
Symbols("symbols",
|
|
|
|
cl::desc("Display the symbol table. Also display the dynamic "
|
|
|
|
"symbol table when using GNU output style for ELF"));
|
[llvm-readelf] Make llvm-readelf more compatible with GNU readelf.
Summary:
This change adds a bunch of options that GNU readelf supports. There is one breaking change when invoked as `llvm-readobj`, and three breaking changes when invoked as `llvm-readelf`:
- Add --all (implies --file-header, --program-headers, etc.)
- [Breaking] -a is --all instead of --arm-attributes
- Add --file-header as an alias for --file-headers
- Replace --sections with --sections-headers, keeping --sections as an alias for it
- Add --relocs as an alias for --relocations
- Add --dynamic as an alias for --dynamic-table
- Add --segments as an alias for --program-headers
- Add --section-groups as an alias for --elf-section-groups
- Add --dyn-syms as an alias for --dyn-symbols
- Add --syms as an alias for --symbols
- Add --histogram as an alias for --elf-hash-histogram
- [Breaking] When invoked as `llvm-readelf`, -s is --symbols instead of --sections
- [Breaking] When invoked as `llvm-readelf`, -t is no longer an alias for --symbols
Reviewers: MaskRay, phosek, mcgrathr, jhenderson
Reviewed By: MaskRay, jhenderson
Subscribers: sbc100, aheejin, edd, jhenderson, silvas, echristo, compnerd, kristina, javed.absar, kristof.beyls, llvm-commits, Bigcheese
Differential Revision: https://reviews.llvm.org/D54124
llvm-svn: 346685
2018-11-12 18:02:38 +00:00
|
|
|
cl::alias SymbolsGNU("syms", cl::desc("Alias for --symbols"),
|
|
|
|
cl::aliasopt(Symbols));
|
2013-04-03 18:31:38 +00:00
|
|
|
|
2019-05-01 05:27:20 +00:00
|
|
|
// --dyn-symbols, --dyn-syms
|
|
|
|
// Also --dt in llvm-readobj mode.
|
2013-04-03 18:31:38 +00:00
|
|
|
cl::opt<bool> DynamicSymbols("dyn-symbols",
|
|
|
|
cl::desc("Display the dynamic symbol table"));
|
[llvm-readelf] Make llvm-readelf more compatible with GNU readelf.
Summary:
This change adds a bunch of options that GNU readelf supports. There is one breaking change when invoked as `llvm-readobj`, and three breaking changes when invoked as `llvm-readelf`:
- Add --all (implies --file-header, --program-headers, etc.)
- [Breaking] -a is --all instead of --arm-attributes
- Add --file-header as an alias for --file-headers
- Replace --sections with --sections-headers, keeping --sections as an alias for it
- Add --relocs as an alias for --relocations
- Add --dynamic as an alias for --dynamic-table
- Add --segments as an alias for --program-headers
- Add --section-groups as an alias for --elf-section-groups
- Add --dyn-syms as an alias for --dyn-symbols
- Add --syms as an alias for --symbols
- Add --histogram as an alias for --elf-hash-histogram
- [Breaking] When invoked as `llvm-readelf`, -s is --symbols instead of --sections
- [Breaking] When invoked as `llvm-readelf`, -t is no longer an alias for --symbols
Reviewers: MaskRay, phosek, mcgrathr, jhenderson
Reviewed By: MaskRay, jhenderson
Subscribers: sbc100, aheejin, edd, jhenderson, silvas, echristo, compnerd, kristina, javed.absar, kristof.beyls, llvm-commits, Bigcheese
Differential Revision: https://reviews.llvm.org/D54124
llvm-svn: 346685
2018-11-12 18:02:38 +00:00
|
|
|
cl::alias DynSymsGNU("dyn-syms", cl::desc("Alias for --dyn-symbols"),
|
|
|
|
cl::aliasopt(DynamicSymbols));
|
2013-04-03 18:31:38 +00:00
|
|
|
|
2019-05-01 05:27:20 +00:00
|
|
|
// --hash-symbols
|
[llvm-readelf]Revert --dyn-symbols behaviour to make it GNU compatible, and add new --hash-symbols switch for old behaviour
In r287786, the behaviour of --dyn-symbols in llvm-readelf (but not
llvm-readobj) was changed to print the dynamic symbols as derived from
the hash table, rather than to print the dynamic symbol table contents
directly. The original change was initially submitted without review,
and some comments were made on the commit mailing list implying that the
new behavious is GNU compatible. I argue that it is not:
1) It does not include a null symbol.
2) It prints the symbols based on an order derived from the hash
table.
3) It prints an extra column indicating which bucket it came from.
This could break parsers that expect a fixed number of columns,
with the first column being the symbol index.
4) If the input happens to have both .hash and .gnu.hash section, it
prints interpretations of them both, resulting in most symbols
being printed twice.
5) There is no way of just printing the raw dynamic symbol table,
because --symbols also prints the static symbol table.
This patch reverts the --dyn-symbols behaviour back to its old behaviour
of just printing the contents of the dynamic symbol table, similar to
what is printed by --symbols. As the hashed interpretation is still
desirable to validate the hash table, it puts it under a new switch
"--hash-symbols". This is a no-op on all output forms except for GNU
output style for ELF. If there is no hash table, it does nothing,
unlike the previous behaviour which printed the raw dynamic symbol
table, since the raw dynsym is available under --dyn-symbols.
The yaml input for the test is based on that in
test/tools/llvm-readobj/demangle.test, but stripped down to the bare
minimum to provide a valid dynamic symbol.
Note: some LLD tests needed updating. I will commit a separate patch for
those.
Reviewed by: grimar, rupprecht
Differential Revision: https://reviews.llvm.org/D56910
llvm-svn: 351789
2019-01-22 09:35:35 +00:00
|
|
|
cl::opt<bool> HashSymbols(
|
|
|
|
"hash-symbols",
|
|
|
|
cl::desc("Display the dynamic symbols derived from the hash section"));
|
|
|
|
|
2019-05-01 05:27:20 +00:00
|
|
|
// --unwind, -u
|
2013-04-03 18:31:38 +00:00
|
|
|
cl::opt<bool> UnwindInfo("unwind",
|
|
|
|
cl::desc("Display unwind information"));
|
|
|
|
cl::alias UnwindInfoShort("u",
|
|
|
|
cl::desc("Alias for --unwind"),
|
|
|
|
cl::aliasopt(UnwindInfo));
|
|
|
|
|
2019-05-01 05:27:20 +00:00
|
|
|
// --dynamic-table, --dynamic, -d
|
2013-04-03 18:31:38 +00:00
|
|
|
cl::opt<bool> DynamicTable("dynamic-table",
|
|
|
|
cl::desc("Display the ELF .dynamic section table"));
|
2016-07-20 01:16:28 +00:00
|
|
|
cl::alias DynamicTableShort("d", cl::desc("Alias for --dynamic-table"),
|
[llvm-readelf] Make llvm-readelf more compatible with GNU readelf.
Summary:
This change adds a bunch of options that GNU readelf supports. There is one breaking change when invoked as `llvm-readobj`, and three breaking changes when invoked as `llvm-readelf`:
- Add --all (implies --file-header, --program-headers, etc.)
- [Breaking] -a is --all instead of --arm-attributes
- Add --file-header as an alias for --file-headers
- Replace --sections with --sections-headers, keeping --sections as an alias for it
- Add --relocs as an alias for --relocations
- Add --dynamic as an alias for --dynamic-table
- Add --segments as an alias for --program-headers
- Add --section-groups as an alias for --elf-section-groups
- Add --dyn-syms as an alias for --dyn-symbols
- Add --syms as an alias for --symbols
- Add --histogram as an alias for --elf-hash-histogram
- [Breaking] When invoked as `llvm-readelf`, -s is --symbols instead of --sections
- [Breaking] When invoked as `llvm-readelf`, -t is no longer an alias for --symbols
Reviewers: MaskRay, phosek, mcgrathr, jhenderson
Reviewed By: MaskRay, jhenderson
Subscribers: sbc100, aheejin, edd, jhenderson, silvas, echristo, compnerd, kristina, javed.absar, kristof.beyls, llvm-commits, Bigcheese
Differential Revision: https://reviews.llvm.org/D54124
llvm-svn: 346685
2018-11-12 18:02:38 +00:00
|
|
|
cl::aliasopt(DynamicTable), cl::NotHidden);
|
|
|
|
cl::alias DynamicTableAlias("dynamic", cl::desc("Alias for --dynamic-table"),
|
2016-07-20 01:16:28 +00:00
|
|
|
cl::aliasopt(DynamicTable));
|
2013-04-03 18:31:38 +00:00
|
|
|
|
2019-05-01 05:27:20 +00:00
|
|
|
// --needed-libs
|
2013-04-03 18:31:38 +00:00
|
|
|
cl::opt<bool> NeededLibraries("needed-libs",
|
|
|
|
cl::desc("Display the needed libraries"));
|
2013-04-12 04:01:52 +00:00
|
|
|
|
2019-05-01 05:27:20 +00:00
|
|
|
// --program-headers, --segments, -l
|
2013-04-12 04:07:39 +00:00
|
|
|
cl::opt<bool> ProgramHeaders("program-headers",
|
|
|
|
cl::desc("Display ELF program headers"));
|
2016-07-20 01:16:28 +00:00
|
|
|
cl::alias ProgramHeadersShort("l", cl::desc("Alias for --program-headers"),
|
[llvm-readelf] Make llvm-readelf more compatible with GNU readelf.
Summary:
This change adds a bunch of options that GNU readelf supports. There is one breaking change when invoked as `llvm-readobj`, and three breaking changes when invoked as `llvm-readelf`:
- Add --all (implies --file-header, --program-headers, etc.)
- [Breaking] -a is --all instead of --arm-attributes
- Add --file-header as an alias for --file-headers
- Replace --sections with --sections-headers, keeping --sections as an alias for it
- Add --relocs as an alias for --relocations
- Add --dynamic as an alias for --dynamic-table
- Add --segments as an alias for --program-headers
- Add --section-groups as an alias for --elf-section-groups
- Add --dyn-syms as an alias for --dyn-symbols
- Add --syms as an alias for --symbols
- Add --histogram as an alias for --elf-hash-histogram
- [Breaking] When invoked as `llvm-readelf`, -s is --symbols instead of --sections
- [Breaking] When invoked as `llvm-readelf`, -t is no longer an alias for --symbols
Reviewers: MaskRay, phosek, mcgrathr, jhenderson
Reviewed By: MaskRay, jhenderson
Subscribers: sbc100, aheejin, edd, jhenderson, silvas, echristo, compnerd, kristina, javed.absar, kristof.beyls, llvm-commits, Bigcheese
Differential Revision: https://reviews.llvm.org/D54124
llvm-svn: 346685
2018-11-12 18:02:38 +00:00
|
|
|
cl::aliasopt(ProgramHeaders), cl::NotHidden);
|
|
|
|
cl::alias SegmentsAlias("segments", cl::desc("Alias for --program-headers"),
|
|
|
|
cl::aliasopt(ProgramHeaders));
|
2013-04-12 04:07:39 +00:00
|
|
|
|
2019-05-01 05:27:20 +00:00
|
|
|
// --string-dump, -p
|
2020-07-25 12:24:37 -07:00
|
|
|
cl::list<std::string> StringDump(
|
|
|
|
"string-dump", cl::value_desc("number|name"),
|
|
|
|
cl::desc("Display the specified section(s) as a list of strings"),
|
|
|
|
cl::ZeroOrMore);
|
2018-06-15 14:15:02 +00:00
|
|
|
cl::alias StringDumpShort("p", cl::desc("Alias for --string-dump"),
|
2019-03-29 16:43:13 +00:00
|
|
|
cl::aliasopt(StringDump), cl::Prefix);
|
2018-06-15 14:15:02 +00:00
|
|
|
|
2019-05-01 05:27:20 +00:00
|
|
|
// --hex-dump, -x
|
2020-07-25 12:24:37 -07:00
|
|
|
cl::list<std::string>
|
|
|
|
HexDump("hex-dump", cl::value_desc("number|name"),
|
|
|
|
cl::desc("Display the specified section(s) as hexadecimal bytes"),
|
|
|
|
cl::ZeroOrMore);
|
2018-07-11 10:00:29 +00:00
|
|
|
cl::alias HexDumpShort("x", cl::desc("Alias for --hex-dump"),
|
2019-03-29 16:43:13 +00:00
|
|
|
cl::aliasopt(HexDump), cl::Prefix);
|
2018-07-11 10:00:29 +00:00
|
|
|
|
2019-05-01 05:27:20 +00:00
|
|
|
// --demangle, -C
|
2019-01-17 15:34:12 +00:00
|
|
|
cl::opt<bool> Demangle("demangle",
|
|
|
|
cl::desc("Demangle symbol names in output"));
|
|
|
|
cl::alias DemangleShort("C", cl::desc("Alias for --demangle"),
|
|
|
|
cl::aliasopt(Demangle), cl::NotHidden);
|
|
|
|
|
2019-05-01 05:27:20 +00:00
|
|
|
// --hash-table
|
2015-07-09 22:32:24 +00:00
|
|
|
cl::opt<bool> HashTable("hash-table",
|
|
|
|
cl::desc("Display ELF hash table"));
|
|
|
|
|
2019-05-01 05:27:20 +00:00
|
|
|
// --gnu-hash-table
|
2015-10-14 12:11:50 +00:00
|
|
|
cl::opt<bool> GnuHashTable("gnu-hash-table",
|
|
|
|
cl::desc("Display ELF .gnu.hash section"));
|
|
|
|
|
2019-05-01 05:27:20 +00:00
|
|
|
// --expand-relocs
|
2013-04-12 04:01:52 +00:00
|
|
|
cl::opt<bool> ExpandRelocs("expand-relocs",
|
|
|
|
cl::desc("Expand each shown relocation to multiple lines"));
|
2013-12-19 11:37:14 +00:00
|
|
|
|
2019-05-01 05:27:20 +00:00
|
|
|
// --raw-relr
|
2018-06-28 21:07:34 +00:00
|
|
|
cl::opt<bool> RawRelr("raw-relr",
|
|
|
|
cl::desc("Do not decode relocations in SHT_RELR section, display raw contents"));
|
|
|
|
|
2019-05-01 05:27:20 +00:00
|
|
|
// --codeview
|
2015-02-18 19:32:05 +00:00
|
|
|
cl::opt<bool> CodeView("codeview",
|
|
|
|
cl::desc("Display CodeView debug information"));
|
|
|
|
|
2019-05-01 05:27:20 +00:00
|
|
|
// --codeview-merged-types
|
2016-05-14 00:02:53 +00:00
|
|
|
cl::opt<bool>
|
|
|
|
CodeViewMergedTypes("codeview-merged-types",
|
|
|
|
cl::desc("Display the merged CodeView type stream"));
|
|
|
|
|
2019-05-01 05:27:20 +00:00
|
|
|
// --codeview-ghash
|
2019-02-07 15:24:18 +00:00
|
|
|
cl::opt<bool> CodeViewEnableGHash(
|
|
|
|
"codeview-ghash",
|
|
|
|
cl::desc(
|
|
|
|
"Enable global hashing for CodeView type stream de-duplication"));
|
|
|
|
|
2019-05-01 05:27:20 +00:00
|
|
|
// --codeview-subsection-bytes
|
2015-02-18 19:32:05 +00:00
|
|
|
cl::opt<bool> CodeViewSubsectionBytes(
|
|
|
|
"codeview-subsection-bytes",
|
|
|
|
cl::desc("Dump raw contents of codeview debug sections and records"));
|
2014-01-30 04:46:33 +00:00
|
|
|
|
2019-09-27 20:38:18 +00:00
|
|
|
// --arch-specific
|
|
|
|
cl::opt<bool> ArchSpecificInfo("arch-specific",
|
|
|
|
cl::desc("Displays architecture-specific information, if there is any."));
|
|
|
|
cl::alias ArchSpecifcInfoShort("A", cl::desc("Alias for --arch-specific"),
|
|
|
|
cl::aliasopt(ArchSpecificInfo), cl::NotHidden);
|
2014-06-18 08:47:09 +00:00
|
|
|
|
2019-05-01 05:27:20 +00:00
|
|
|
// --coff-imports
|
2014-10-02 17:02:18 +00:00
|
|
|
cl::opt<bool>
|
|
|
|
COFFImports("coff-imports", cl::desc("Display the PE/COFF import table"));
|
2014-10-07 19:37:52 +00:00
|
|
|
|
2019-05-01 05:27:20 +00:00
|
|
|
// --coff-exports
|
2015-01-03 21:35:09 +00:00
|
|
|
cl::opt<bool>
|
|
|
|
COFFExports("coff-exports", cl::desc("Display the PE/COFF export table"));
|
|
|
|
|
2019-05-01 05:27:20 +00:00
|
|
|
// --coff-directives
|
2014-10-07 19:37:52 +00:00
|
|
|
cl::opt<bool>
|
|
|
|
COFFDirectives("coff-directives",
|
2014-11-19 00:18:07 +00:00
|
|
|
cl::desc("Display the PE/COFF .drectve section"));
|
|
|
|
|
2019-05-01 05:27:20 +00:00
|
|
|
// --coff-basereloc
|
2014-11-19 00:18:07 +00:00
|
|
|
cl::opt<bool>
|
|
|
|
COFFBaseRelocs("coff-basereloc",
|
|
|
|
cl::desc("Display the PE/COFF .reloc section"));
|
2015-06-26 23:56:53 +00:00
|
|
|
|
2019-05-01 05:27:20 +00:00
|
|
|
// --coff-debug-directory
|
2016-06-02 17:10:43 +00:00
|
|
|
cl::opt<bool>
|
|
|
|
COFFDebugDirectory("coff-debug-directory",
|
|
|
|
cl::desc("Display the PE/COFF debug directory"));
|
|
|
|
|
2019-05-01 05:27:20 +00:00
|
|
|
// --coff-resources
|
2017-04-27 19:38:38 +00:00
|
|
|
cl::opt<bool> COFFResources("coff-resources",
|
|
|
|
cl::desc("Display the PE/COFF .rsrc section"));
|
|
|
|
|
2019-05-01 05:27:20 +00:00
|
|
|
// --coff-load-config
|
2017-06-22 01:10:29 +00:00
|
|
|
cl::opt<bool>
|
|
|
|
COFFLoadConfig("coff-load-config",
|
|
|
|
cl::desc("Display the PE/COFF load config"));
|
|
|
|
|
2019-05-01 05:27:20 +00:00
|
|
|
// --elf-linker-options
|
2018-01-30 16:29:29 +00:00
|
|
|
cl::opt<bool>
|
|
|
|
ELFLinkerOptions("elf-linker-options",
|
|
|
|
cl::desc("Display the ELF .linker-options section"));
|
|
|
|
|
2019-05-01 05:27:20 +00:00
|
|
|
// --macho-data-in-code
|
2015-08-21 20:28:30 +00:00
|
|
|
cl::opt<bool>
|
|
|
|
MachODataInCode("macho-data-in-code",
|
|
|
|
cl::desc("Display MachO Data in Code command"));
|
|
|
|
|
2019-05-01 05:27:20 +00:00
|
|
|
// --macho-indirect-symbols
|
2015-09-03 18:10:28 +00:00
|
|
|
cl::opt<bool>
|
|
|
|
MachOIndirectSymbols("macho-indirect-symbols",
|
|
|
|
cl::desc("Display MachO indirect symbols"));
|
|
|
|
|
2019-05-01 05:27:20 +00:00
|
|
|
// --macho-linker-options
|
2015-09-09 00:21:18 +00:00
|
|
|
cl::opt<bool>
|
|
|
|
MachOLinkerOptions("macho-linker-options",
|
|
|
|
cl::desc("Display MachO linker options"));
|
|
|
|
|
2019-05-01 05:27:20 +00:00
|
|
|
// --macho-segment
|
2015-09-02 16:24:24 +00:00
|
|
|
cl::opt<bool>
|
|
|
|
MachOSegment("macho-segment",
|
|
|
|
cl::desc("Display MachO Segment command"));
|
|
|
|
|
2019-05-01 05:27:20 +00:00
|
|
|
// --macho-version-min
|
2015-08-27 15:11:32 +00:00
|
|
|
cl::opt<bool>
|
|
|
|
MachOVersionMin("macho-version-min",
|
|
|
|
cl::desc("Display MachO version min command"));
|
2015-08-31 19:32:31 +00:00
|
|
|
|
2019-05-01 05:27:20 +00:00
|
|
|
// --macho-dysymtab
|
2015-08-31 19:32:31 +00:00
|
|
|
cl::opt<bool>
|
|
|
|
MachODysymtab("macho-dysymtab",
|
|
|
|
cl::desc("Display MachO Dysymtab command"));
|
|
|
|
|
2019-05-01 05:27:20 +00:00
|
|
|
// --stackmap
|
2015-06-26 23:56:53 +00:00
|
|
|
cl::opt<bool>
|
|
|
|
PrintStackMap("stackmap",
|
|
|
|
cl::desc("Display contents of stackmap section"));
|
|
|
|
|
2019-08-05 22:47:07 +00:00
|
|
|
// --stack-sizes
|
|
|
|
cl::opt<bool>
|
|
|
|
PrintStackSizes("stack-sizes",
|
|
|
|
cl::desc("Display contents of all stack sizes sections"));
|
|
|
|
|
2019-05-01 05:27:20 +00:00
|
|
|
// --version-info, -V
|
2015-10-16 23:19:01 +00:00
|
|
|
cl::opt<bool>
|
|
|
|
VersionInfo("version-info",
|
|
|
|
cl::desc("Display ELF version sections (if present)"));
|
|
|
|
cl::alias VersionInfoShort("V", cl::desc("Alias for -version-info"),
|
|
|
|
cl::aliasopt(VersionInfo));
|
2016-01-26 19:46:39 +00:00
|
|
|
|
2019-05-01 05:27:20 +00:00
|
|
|
// --elf-section-groups, --section-groups, -g
|
2016-01-26 19:46:39 +00:00
|
|
|
cl::opt<bool> SectionGroups("elf-section-groups",
|
|
|
|
cl::desc("Display ELF section group contents"));
|
[llvm-readelf] Make llvm-readelf more compatible with GNU readelf.
Summary:
This change adds a bunch of options that GNU readelf supports. There is one breaking change when invoked as `llvm-readobj`, and three breaking changes when invoked as `llvm-readelf`:
- Add --all (implies --file-header, --program-headers, etc.)
- [Breaking] -a is --all instead of --arm-attributes
- Add --file-header as an alias for --file-headers
- Replace --sections with --sections-headers, keeping --sections as an alias for it
- Add --relocs as an alias for --relocations
- Add --dynamic as an alias for --dynamic-table
- Add --segments as an alias for --program-headers
- Add --section-groups as an alias for --elf-section-groups
- Add --dyn-syms as an alias for --dyn-symbols
- Add --syms as an alias for --symbols
- Add --histogram as an alias for --elf-hash-histogram
- [Breaking] When invoked as `llvm-readelf`, -s is --symbols instead of --sections
- [Breaking] When invoked as `llvm-readelf`, -t is no longer an alias for --symbols
Reviewers: MaskRay, phosek, mcgrathr, jhenderson
Reviewed By: MaskRay, jhenderson
Subscribers: sbc100, aheejin, edd, jhenderson, silvas, echristo, compnerd, kristina, javed.absar, kristof.beyls, llvm-commits, Bigcheese
Differential Revision: https://reviews.llvm.org/D54124
llvm-svn: 346685
2018-11-12 18:02:38 +00:00
|
|
|
cl::alias SectionGroupsAlias("section-groups",
|
|
|
|
cl::desc("Alias for -elf-sections-groups"),
|
|
|
|
cl::aliasopt(SectionGroups));
|
2016-01-26 19:46:39 +00:00
|
|
|
cl::alias SectionGroupsShort("g", cl::desc("Alias for -elf-sections-groups"),
|
|
|
|
cl::aliasopt(SectionGroups));
|
[llvm-readelf] Make llvm-readelf more compatible with GNU readelf.
Summary:
This change adds a bunch of options that GNU readelf supports. There is one breaking change when invoked as `llvm-readobj`, and three breaking changes when invoked as `llvm-readelf`:
- Add --all (implies --file-header, --program-headers, etc.)
- [Breaking] -a is --all instead of --arm-attributes
- Add --file-header as an alias for --file-headers
- Replace --sections with --sections-headers, keeping --sections as an alias for it
- Add --relocs as an alias for --relocations
- Add --dynamic as an alias for --dynamic-table
- Add --segments as an alias for --program-headers
- Add --section-groups as an alias for --elf-section-groups
- Add --dyn-syms as an alias for --dyn-symbols
- Add --syms as an alias for --symbols
- Add --histogram as an alias for --elf-hash-histogram
- [Breaking] When invoked as `llvm-readelf`, -s is --symbols instead of --sections
- [Breaking] When invoked as `llvm-readelf`, -t is no longer an alias for --symbols
Reviewers: MaskRay, phosek, mcgrathr, jhenderson
Reviewed By: MaskRay, jhenderson
Subscribers: sbc100, aheejin, edd, jhenderson, silvas, echristo, compnerd, kristina, javed.absar, kristof.beyls, llvm-commits, Bigcheese
Differential Revision: https://reviews.llvm.org/D54124
llvm-svn: 346685
2018-11-12 18:02:38 +00:00
|
|
|
|
2019-05-01 05:27:20 +00:00
|
|
|
// --elf-hash-histogram, --histogram, -I
|
2016-04-11 17:15:30 +00:00
|
|
|
cl::opt<bool> HashHistogram(
|
|
|
|
"elf-hash-histogram",
|
|
|
|
cl::desc("Display bucket list histogram for hash sections"));
|
|
|
|
cl::alias HashHistogramShort("I", cl::desc("Alias for -elf-hash-histogram"),
|
|
|
|
cl::aliasopt(HashHistogram));
|
[llvm-readelf] Make llvm-readelf more compatible with GNU readelf.
Summary:
This change adds a bunch of options that GNU readelf supports. There is one breaking change when invoked as `llvm-readobj`, and three breaking changes when invoked as `llvm-readelf`:
- Add --all (implies --file-header, --program-headers, etc.)
- [Breaking] -a is --all instead of --arm-attributes
- Add --file-header as an alias for --file-headers
- Replace --sections with --sections-headers, keeping --sections as an alias for it
- Add --relocs as an alias for --relocations
- Add --dynamic as an alias for --dynamic-table
- Add --segments as an alias for --program-headers
- Add --section-groups as an alias for --elf-section-groups
- Add --dyn-syms as an alias for --dyn-symbols
- Add --syms as an alias for --symbols
- Add --histogram as an alias for --elf-hash-histogram
- [Breaking] When invoked as `llvm-readelf`, -s is --symbols instead of --sections
- [Breaking] When invoked as `llvm-readelf`, -t is no longer an alias for --symbols
Reviewers: MaskRay, phosek, mcgrathr, jhenderson
Reviewed By: MaskRay, jhenderson
Subscribers: sbc100, aheejin, edd, jhenderson, silvas, echristo, compnerd, kristina, javed.absar, kristof.beyls, llvm-commits, Bigcheese
Differential Revision: https://reviews.llvm.org/D54124
llvm-svn: 346685
2018-11-12 18:02:38 +00:00
|
|
|
cl::alias HistogramAlias("histogram",
|
|
|
|
cl::desc("Alias for --elf-hash-histogram"),
|
|
|
|
cl::aliasopt(HashHistogram));
|
2016-01-26 19:46:39 +00:00
|
|
|
|
2020-06-15 10:21:47 -07:00
|
|
|
// --cg-profile
|
|
|
|
cl::opt<bool> CGProfile("cg-profile",
|
|
|
|
cl::desc("Display callgraph profile section"));
|
|
|
|
cl::alias ELFCGProfile("elf-cg-profile", cl::desc("Alias for --cg-profile"),
|
|
|
|
cl::aliasopt(CGProfile));
|
[MC] Add assembler support for .cg_profile.
Object FIle Representation
At codegen time this is emitted into the ELF file a pair of symbol indices and a weight. In assembly it looks like:
.cg_profile a, b, 32
.cg_profile freq, a, 11
.cg_profile freq, b, 20
When writing an ELF file these are put into a SHT_LLVM_CALL_GRAPH_PROFILE (0x6fff4c02) section as (uint32_t, uint32_t, uint64_t) tuples as (from symbol index, to symbol index, weight).
Differential Revision: https://reviews.llvm.org/D44965
llvm-svn: 333823
2018-06-02 16:33:01 +00:00
|
|
|
|
[llvm-readelf] Make llvm-readelf more compatible with GNU readelf.
Summary:
This change adds a bunch of options that GNU readelf supports. There is one breaking change when invoked as `llvm-readobj`, and three breaking changes when invoked as `llvm-readelf`:
- Add --all (implies --file-header, --program-headers, etc.)
- [Breaking] -a is --all instead of --arm-attributes
- Add --file-header as an alias for --file-headers
- Replace --sections with --sections-headers, keeping --sections as an alias for it
- Add --relocs as an alias for --relocations
- Add --dynamic as an alias for --dynamic-table
- Add --segments as an alias for --program-headers
- Add --section-groups as an alias for --elf-section-groups
- Add --dyn-syms as an alias for --dyn-symbols
- Add --syms as an alias for --symbols
- Add --histogram as an alias for --elf-hash-histogram
- [Breaking] When invoked as `llvm-readelf`, -s is --symbols instead of --sections
- [Breaking] When invoked as `llvm-readelf`, -t is no longer an alias for --symbols
Reviewers: MaskRay, phosek, mcgrathr, jhenderson
Reviewed By: MaskRay, jhenderson
Subscribers: sbc100, aheejin, edd, jhenderson, silvas, echristo, compnerd, kristina, javed.absar, kristof.beyls, llvm-commits, Bigcheese
Differential Revision: https://reviews.llvm.org/D54124
llvm-svn: 346685
2018-11-12 18:02:38 +00:00
|
|
|
// -addrsig
|
2018-08-22 23:58:16 +00:00
|
|
|
cl::opt<bool> Addrsig("addrsig",
|
2018-07-17 22:17:18 +00:00
|
|
|
cl::desc("Display address-significance table"));
|
|
|
|
|
[llvm-readelf] Make llvm-readelf more compatible with GNU readelf.
Summary:
This change adds a bunch of options that GNU readelf supports. There is one breaking change when invoked as `llvm-readobj`, and three breaking changes when invoked as `llvm-readelf`:
- Add --all (implies --file-header, --program-headers, etc.)
- [Breaking] -a is --all instead of --arm-attributes
- Add --file-header as an alias for --file-headers
- Replace --sections with --sections-headers, keeping --sections as an alias for it
- Add --relocs as an alias for --relocations
- Add --dynamic as an alias for --dynamic-table
- Add --segments as an alias for --program-headers
- Add --section-groups as an alias for --elf-section-groups
- Add --dyn-syms as an alias for --dyn-symbols
- Add --syms as an alias for --symbols
- Add --histogram as an alias for --elf-hash-histogram
- [Breaking] When invoked as `llvm-readelf`, -s is --symbols instead of --sections
- [Breaking] When invoked as `llvm-readelf`, -t is no longer an alias for --symbols
Reviewers: MaskRay, phosek, mcgrathr, jhenderson
Reviewed By: MaskRay, jhenderson
Subscribers: sbc100, aheejin, edd, jhenderson, silvas, echristo, compnerd, kristina, javed.absar, kristof.beyls, llvm-commits, Bigcheese
Differential Revision: https://reviews.llvm.org/D54124
llvm-svn: 346685
2018-11-12 18:02:38 +00:00
|
|
|
// -elf-output-style
|
2016-03-01 21:45:22 +00:00
|
|
|
cl::opt<OutputStyleTy>
|
2016-02-10 20:40:55 +00:00
|
|
|
Output("elf-output-style", cl::desc("Specify ELF dump style"),
|
|
|
|
cl::values(clEnumVal(LLVM, "LLVM default style"),
|
2016-10-08 19:41:06 +00:00
|
|
|
clEnumVal(GNU, "GNU readelf style")),
|
2016-02-10 20:40:55 +00:00
|
|
|
cl::init(LLVM));
|
2019-06-21 11:49:20 +00:00
|
|
|
|
|
|
|
cl::extrahelp
|
|
|
|
HelpResponse("\nPass @FILE as argument to read options from FILE.\n");
|
2013-04-03 18:31:38 +00:00
|
|
|
} // namespace opts
|
|
|
|
|
2019-08-20 12:49:15 +00:00
|
|
|
static StringRef ToolName;
|
|
|
|
|
2015-07-20 03:38:17 +00:00
|
|
|
namespace llvm {
|
|
|
|
|
Recommit r369190 "[llvm-readobj/llvm-readelf] - Improve/cleanup the error reporting API."
Fix: Add a `consumeError` call removed by mistake to 'printStackSize',
this should fix the "Expected<T> must be checked before access or destruction." reported by following bot:
http://lab.llvm.org:8011/builders/clang-x64-windows-msvc/builds/9743/steps/stage%201%20check/logs/stdio
Original commit message:
Currently we have the following functions for error reporting:
LLVM_ATTRIBUTE_NORETURN void reportError(Twine Msg);
void reportError(Error Err, StringRef Input);
void reportWarning(Twine Msg);
void reportWarning(StringRef Input, Error Err);
void warn(llvm::Error Err);
void error(std::error_code EC);
Problems are: naming is inconsistent, arguments order is inconsistent,
some of the functions looks excessive.
After applying this patch we have:
void reportError(Error Err, StringRef Input);
void reportError(std::error_code EC, StringRef Input);
void reportWarning(Error Err, StringRef Input);
I'd be happy to remove reportError(std::error_code EC, StringRef Input) too, but it
is used by COFF heavily.
Test cases were updated, they show an improvement introduced.
Differential revision: https://reviews.llvm.org/D66286
llvm-svn: 369194
2019-08-17 16:07:18 +00:00
|
|
|
LLVM_ATTRIBUTE_NORETURN static void error(Twine Msg) {
|
|
|
|
// Flush the standard output to print the error at a
|
|
|
|
// proper place.
|
2019-07-16 11:07:30 +00:00
|
|
|
fouts().flush();
|
2019-08-20 12:49:15 +00:00
|
|
|
WithColor::error(errs(), ToolName) << Msg << "\n";
|
2015-07-20 03:23:55 +00:00
|
|
|
exit(1);
|
2015-07-20 03:01:49 +00:00
|
|
|
}
|
|
|
|
|
Recommit r369190 "[llvm-readobj/llvm-readelf] - Improve/cleanup the error reporting API."
Fix: Add a `consumeError` call removed by mistake to 'printStackSize',
this should fix the "Expected<T> must be checked before access or destruction." reported by following bot:
http://lab.llvm.org:8011/builders/clang-x64-windows-msvc/builds/9743/steps/stage%201%20check/logs/stdio
Original commit message:
Currently we have the following functions for error reporting:
LLVM_ATTRIBUTE_NORETURN void reportError(Twine Msg);
void reportError(Error Err, StringRef Input);
void reportWarning(Twine Msg);
void reportWarning(StringRef Input, Error Err);
void warn(llvm::Error Err);
void error(std::error_code EC);
Problems are: naming is inconsistent, arguments order is inconsistent,
some of the functions looks excessive.
After applying this patch we have:
void reportError(Error Err, StringRef Input);
void reportError(std::error_code EC, StringRef Input);
void reportWarning(Error Err, StringRef Input);
I'd be happy to remove reportError(std::error_code EC, StringRef Input) too, but it
is used by COFF heavily.
Test cases were updated, they show an improvement introduced.
Differential revision: https://reviews.llvm.org/D66286
llvm-svn: 369194
2019-08-17 16:07:18 +00:00
|
|
|
LLVM_ATTRIBUTE_NORETURN void reportError(Error Err, StringRef Input) {
|
2019-08-13 12:07:41 +00:00
|
|
|
assert(Err);
|
2019-07-16 11:07:30 +00:00
|
|
|
if (Input == "-")
|
|
|
|
Input = "<stdin>";
|
2019-08-13 12:07:41 +00:00
|
|
|
handleAllErrors(createFileError(Input, std::move(Err)),
|
Recommit r369190 "[llvm-readobj/llvm-readelf] - Improve/cleanup the error reporting API."
Fix: Add a `consumeError` call removed by mistake to 'printStackSize',
this should fix the "Expected<T> must be checked before access or destruction." reported by following bot:
http://lab.llvm.org:8011/builders/clang-x64-windows-msvc/builds/9743/steps/stage%201%20check/logs/stdio
Original commit message:
Currently we have the following functions for error reporting:
LLVM_ATTRIBUTE_NORETURN void reportError(Twine Msg);
void reportError(Error Err, StringRef Input);
void reportWarning(Twine Msg);
void reportWarning(StringRef Input, Error Err);
void warn(llvm::Error Err);
void error(std::error_code EC);
Problems are: naming is inconsistent, arguments order is inconsistent,
some of the functions looks excessive.
After applying this patch we have:
void reportError(Error Err, StringRef Input);
void reportError(std::error_code EC, StringRef Input);
void reportWarning(Error Err, StringRef Input);
I'd be happy to remove reportError(std::error_code EC, StringRef Input) too, but it
is used by COFF heavily.
Test cases were updated, they show an improvement introduced.
Differential revision: https://reviews.llvm.org/D66286
llvm-svn: 369194
2019-08-17 16:07:18 +00:00
|
|
|
[&](const ErrorInfoBase &EI) { error(EI.message()); });
|
|
|
|
llvm_unreachable("error() call should never return");
|
2019-07-16 11:07:30 +00:00
|
|
|
}
|
|
|
|
|
Recommit r369190 "[llvm-readobj/llvm-readelf] - Improve/cleanup the error reporting API."
Fix: Add a `consumeError` call removed by mistake to 'printStackSize',
this should fix the "Expected<T> must be checked before access or destruction." reported by following bot:
http://lab.llvm.org:8011/builders/clang-x64-windows-msvc/builds/9743/steps/stage%201%20check/logs/stdio
Original commit message:
Currently we have the following functions for error reporting:
LLVM_ATTRIBUTE_NORETURN void reportError(Twine Msg);
void reportError(Error Err, StringRef Input);
void reportWarning(Twine Msg);
void reportWarning(StringRef Input, Error Err);
void warn(llvm::Error Err);
void error(std::error_code EC);
Problems are: naming is inconsistent, arguments order is inconsistent,
some of the functions looks excessive.
After applying this patch we have:
void reportError(Error Err, StringRef Input);
void reportError(std::error_code EC, StringRef Input);
void reportWarning(Error Err, StringRef Input);
I'd be happy to remove reportError(std::error_code EC, StringRef Input) too, but it
is used by COFF heavily.
Test cases were updated, they show an improvement introduced.
Differential revision: https://reviews.llvm.org/D66286
llvm-svn: 369194
2019-08-17 16:07:18 +00:00
|
|
|
void reportWarning(Error Err, StringRef Input) {
|
|
|
|
assert(Err);
|
2019-08-08 07:17:35 +00:00
|
|
|
if (Input == "-")
|
|
|
|
Input = "<stdin>";
|
2012-12-31 16:05:21 +00:00
|
|
|
|
Recommit r369190 "[llvm-readobj/llvm-readelf] - Improve/cleanup the error reporting API."
Fix: Add a `consumeError` call removed by mistake to 'printStackSize',
this should fix the "Expected<T> must be checked before access or destruction." reported by following bot:
http://lab.llvm.org:8011/builders/clang-x64-windows-msvc/builds/9743/steps/stage%201%20check/logs/stdio
Original commit message:
Currently we have the following functions for error reporting:
LLVM_ATTRIBUTE_NORETURN void reportError(Twine Msg);
void reportError(Error Err, StringRef Input);
void reportWarning(Twine Msg);
void reportWarning(StringRef Input, Error Err);
void warn(llvm::Error Err);
void error(std::error_code EC);
Problems are: naming is inconsistent, arguments order is inconsistent,
some of the functions looks excessive.
After applying this patch we have:
void reportError(Error Err, StringRef Input);
void reportError(std::error_code EC, StringRef Input);
void reportWarning(Error Err, StringRef Input);
I'd be happy to remove reportError(std::error_code EC, StringRef Input) too, but it
is used by COFF heavily.
Test cases were updated, they show an improvement introduced.
Differential revision: https://reviews.llvm.org/D66286
llvm-svn: 369194
2019-08-17 16:07:18 +00:00
|
|
|
// Flush the standard output to print the warning at a
|
|
|
|
// proper place.
|
|
|
|
fouts().flush();
|
2019-08-20 12:49:15 +00:00
|
|
|
handleAllErrors(
|
|
|
|
createFileError(Input, std::move(Err)), [&](const ErrorInfoBase &EI) {
|
|
|
|
WithColor::warning(errs(), ToolName) << EI.message() << "\n";
|
|
|
|
});
|
2016-07-14 02:24:01 +00:00
|
|
|
}
|
|
|
|
|
Recommit r369190 "[llvm-readobj/llvm-readelf] - Improve/cleanup the error reporting API."
Fix: Add a `consumeError` call removed by mistake to 'printStackSize',
this should fix the "Expected<T> must be checked before access or destruction." reported by following bot:
http://lab.llvm.org:8011/builders/clang-x64-windows-msvc/builds/9743/steps/stage%201%20check/logs/stdio
Original commit message:
Currently we have the following functions for error reporting:
LLVM_ATTRIBUTE_NORETURN void reportError(Twine Msg);
void reportError(Error Err, StringRef Input);
void reportWarning(Twine Msg);
void reportWarning(StringRef Input, Error Err);
void warn(llvm::Error Err);
void error(std::error_code EC);
Problems are: naming is inconsistent, arguments order is inconsistent,
some of the functions looks excessive.
After applying this patch we have:
void reportError(Error Err, StringRef Input);
void reportError(std::error_code EC, StringRef Input);
void reportWarning(Error Err, StringRef Input);
I'd be happy to remove reportError(std::error_code EC, StringRef Input) too, but it
is used by COFF heavily.
Test cases were updated, they show an improvement introduced.
Differential revision: https://reviews.llvm.org/D66286
llvm-svn: 369194
2019-08-17 16:07:18 +00:00
|
|
|
} // namespace llvm
|
|
|
|
|
2016-09-09 17:46:17 +00:00
|
|
|
namespace {
|
2016-11-08 22:24:53 +00:00
|
|
|
struct ReadObjTypeTableBuilder {
|
2017-03-24 17:26:38 +00:00
|
|
|
ReadObjTypeTableBuilder()
|
2019-02-07 15:24:18 +00:00
|
|
|
: Allocator(), IDTable(Allocator), TypeTable(Allocator),
|
|
|
|
GlobalIDTable(Allocator), GlobalTypeTable(Allocator) {}
|
2014-06-18 08:47:09 +00:00
|
|
|
|
2016-09-09 17:46:17 +00:00
|
|
|
llvm::BumpPtrAllocator Allocator;
|
2017-11-30 18:39:50 +00:00
|
|
|
llvm::codeview::MergingTypeTableBuilder IDTable;
|
|
|
|
llvm::codeview::MergingTypeTableBuilder TypeTable;
|
2019-02-07 15:24:18 +00:00
|
|
|
llvm::codeview::GlobalTypeTableBuilder GlobalIDTable;
|
|
|
|
llvm::codeview::GlobalTypeTableBuilder GlobalTypeTable;
|
|
|
|
std::vector<OwningBinary<Binary>> Binaries;
|
2016-09-09 17:46:17 +00:00
|
|
|
};
|
2019-02-07 15:24:18 +00:00
|
|
|
} // namespace
|
2016-11-08 22:24:53 +00:00
|
|
|
static ReadObjTypeTableBuilder CVTypes;
|
2016-05-14 00:02:53 +00:00
|
|
|
|
2018-05-01 16:10:38 +00:00
|
|
|
/// Creates an format-specific object file dumper.
|
2016-05-03 00:28:04 +00:00
|
|
|
static std::error_code createDumper(const ObjectFile *Obj,
|
|
|
|
ScopedPrinter &Writer,
|
2014-06-13 03:07:50 +00:00
|
|
|
std::unique_ptr<ObjDumper> &Result) {
|
2013-04-03 18:31:38 +00:00
|
|
|
if (!Obj)
|
|
|
|
return readobj_error::unsupported_file_format;
|
|
|
|
|
|
|
|
if (Obj->isCOFF())
|
|
|
|
return createCOFFDumper(Obj, Writer, Result);
|
|
|
|
if (Obj->isELF())
|
|
|
|
return createELFDumper(Obj, Writer, Result);
|
|
|
|
if (Obj->isMachO())
|
|
|
|
return createMachODumper(Obj, Writer, Result);
|
2017-01-30 23:30:52 +00:00
|
|
|
if (Obj->isWasm())
|
|
|
|
return createWasmDumper(Obj, Writer, Result);
|
2019-05-03 12:57:07 +00:00
|
|
|
if (Obj->isXCOFF())
|
|
|
|
return createXCOFFDumper(Obj, Writer, Result);
|
2013-04-03 18:31:38 +00:00
|
|
|
|
|
|
|
return readobj_error::unsupported_obj_file_format;
|
2012-03-01 01:36:50 +00:00
|
|
|
}
|
|
|
|
|
2018-05-01 16:10:38 +00:00
|
|
|
/// Dumps the specified object file.
|
2019-07-15 22:52:01 +00:00
|
|
|
static void dumpObject(const ObjectFile *Obj, ScopedPrinter &Writer,
|
|
|
|
const Archive *A = nullptr) {
|
|
|
|
std::string FileStr =
|
|
|
|
A ? Twine(A->getFileName() + "(" + Obj->getFileName() + ")").str()
|
|
|
|
: Obj->getFileName().str();
|
|
|
|
|
2014-03-06 05:51:42 +00:00
|
|
|
std::unique_ptr<ObjDumper> Dumper;
|
2015-12-05 23:36:52 +00:00
|
|
|
if (std::error_code EC = createDumper(Obj, Writer, Dumper))
|
2019-08-22 08:56:24 +00:00
|
|
|
reportError(errorCodeToError(EC), FileStr);
|
2012-12-31 16:29:44 +00:00
|
|
|
|
2019-08-09 12:30:08 +00:00
|
|
|
if (opts::Output == opts::LLVM || opts::InputFilenames.size() > 1 || A) {
|
|
|
|
Writer.startLine() << "\n";
|
2019-07-15 22:52:01 +00:00
|
|
|
Writer.printString("File", FileStr);
|
2019-08-09 12:30:08 +00:00
|
|
|
}
|
|
|
|
if (opts::Output == opts::LLVM) {
|
2018-01-10 00:14:19 +00:00
|
|
|
Writer.printString("Format", Obj->getFileFormatName());
|
|
|
|
Writer.printString("Arch", Triple::getArchTypeName(
|
|
|
|
(llvm::Triple::ArchType)Obj->getArch()));
|
2020-01-28 20:23:46 +01:00
|
|
|
Writer.printString(
|
|
|
|
"AddressSize",
|
|
|
|
std::string(formatv("{0}bit", 8 * Obj->getBytesInAddress())));
|
2016-02-10 20:40:55 +00:00
|
|
|
Dumper->printLoadName();
|
|
|
|
}
|
2013-04-03 18:31:38 +00:00
|
|
|
|
|
|
|
if (opts::FileHeaders)
|
|
|
|
Dumper->printFileHeaders();
|
[llvm-readelf] Make llvm-readelf more compatible with GNU readelf.
Summary:
This change adds a bunch of options that GNU readelf supports. There is one breaking change when invoked as `llvm-readobj`, and three breaking changes when invoked as `llvm-readelf`:
- Add --all (implies --file-header, --program-headers, etc.)
- [Breaking] -a is --all instead of --arm-attributes
- Add --file-header as an alias for --file-headers
- Replace --sections with --sections-headers, keeping --sections as an alias for it
- Add --relocs as an alias for --relocations
- Add --dynamic as an alias for --dynamic-table
- Add --segments as an alias for --program-headers
- Add --section-groups as an alias for --elf-section-groups
- Add --dyn-syms as an alias for --dyn-symbols
- Add --syms as an alias for --symbols
- Add --histogram as an alias for --elf-hash-histogram
- [Breaking] When invoked as `llvm-readelf`, -s is --symbols instead of --sections
- [Breaking] When invoked as `llvm-readelf`, -t is no longer an alias for --symbols
Reviewers: MaskRay, phosek, mcgrathr, jhenderson
Reviewed By: MaskRay, jhenderson
Subscribers: sbc100, aheejin, edd, jhenderson, silvas, echristo, compnerd, kristina, javed.absar, kristof.beyls, llvm-commits, Bigcheese
Differential Revision: https://reviews.llvm.org/D54124
llvm-svn: 346685
2018-11-12 18:02:38 +00:00
|
|
|
if (opts::SectionHeaders)
|
|
|
|
Dumper->printSectionHeaders();
|
[llvm-readelf]Revert --dyn-symbols behaviour to make it GNU compatible, and add new --hash-symbols switch for old behaviour
In r287786, the behaviour of --dyn-symbols in llvm-readelf (but not
llvm-readobj) was changed to print the dynamic symbols as derived from
the hash table, rather than to print the dynamic symbol table contents
directly. The original change was initially submitted without review,
and some comments were made on the commit mailing list implying that the
new behavious is GNU compatible. I argue that it is not:
1) It does not include a null symbol.
2) It prints the symbols based on an order derived from the hash
table.
3) It prints an extra column indicating which bucket it came from.
This could break parsers that expect a fixed number of columns,
with the first column being the symbol index.
4) If the input happens to have both .hash and .gnu.hash section, it
prints interpretations of them both, resulting in most symbols
being printed twice.
5) There is no way of just printing the raw dynamic symbol table,
because --symbols also prints the static symbol table.
This patch reverts the --dyn-symbols behaviour back to its old behaviour
of just printing the contents of the dynamic symbol table, similar to
what is printed by --symbols. As the hashed interpretation is still
desirable to validate the hash table, it puts it under a new switch
"--hash-symbols". This is a no-op on all output forms except for GNU
output style for ELF. If there is no hash table, it does nothing,
unlike the previous behaviour which printed the raw dynamic symbol
table, since the raw dynsym is available under --dyn-symbols.
The yaml input for the test is based on that in
test/tools/llvm-readobj/demangle.test, but stripped down to the bare
minimum to provide a valid dynamic symbol.
Note: some LLD tests needed updating. I will commit a separate patch for
those.
Reviewed by: grimar, rupprecht
Differential Revision: https://reviews.llvm.org/D56910
llvm-svn: 351789
2019-01-22 09:35:35 +00:00
|
|
|
if (opts::HashSymbols)
|
|
|
|
Dumper->printHashSymbols();
|
2020-03-03 19:49:14 -08:00
|
|
|
if (opts::ProgramHeaders || opts::SectionMapping == cl::BOU_TRUE)
|
|
|
|
Dumper->printProgramHeaders(opts::ProgramHeaders, opts::SectionMapping);
|
2013-04-03 18:31:38 +00:00
|
|
|
if (opts::DynamicTable)
|
|
|
|
Dumper->printDynamicTable();
|
|
|
|
if (opts::NeededLibraries)
|
|
|
|
Dumper->printNeededLibraries();
|
2020-03-03 19:49:14 -08:00
|
|
|
if (opts::Relocations)
|
|
|
|
Dumper->printRelocations();
|
|
|
|
if (opts::DynRelocs)
|
|
|
|
Dumper->printDynamicRelocations();
|
|
|
|
if (opts::UnwindInfo)
|
|
|
|
Dumper->printUnwindInfo();
|
|
|
|
if (opts::Symbols || opts::DynamicSymbols)
|
|
|
|
Dumper->printSymbols(opts::Symbols, opts::DynamicSymbols);
|
2018-06-15 14:15:02 +00:00
|
|
|
if (!opts::StringDump.empty())
|
2019-06-18 14:01:03 +00:00
|
|
|
Dumper->printSectionsAsString(Obj, opts::StringDump);
|
2018-07-11 10:00:29 +00:00
|
|
|
if (!opts::HexDump.empty())
|
2019-06-18 14:01:03 +00:00
|
|
|
Dumper->printSectionsAsHex(Obj, opts::HexDump);
|
2015-07-09 22:32:24 +00:00
|
|
|
if (opts::HashTable)
|
|
|
|
Dumper->printHashTable();
|
2015-10-14 12:11:50 +00:00
|
|
|
if (opts::GnuHashTable)
|
2020-05-13 15:06:01 +03:00
|
|
|
Dumper->printGnuHashTable(Obj);
|
2015-10-16 23:19:01 +00:00
|
|
|
if (opts::VersionInfo)
|
|
|
|
Dumper->printVersionInfo();
|
2016-01-26 19:46:39 +00:00
|
|
|
if (Obj->isELF()) {
|
2019-11-25 16:04:58 +03:00
|
|
|
if (opts::DependentLibraries)
|
|
|
|
Dumper->printDependentLibs();
|
2018-01-30 16:29:29 +00:00
|
|
|
if (opts::ELFLinkerOptions)
|
|
|
|
Dumper->printELFLinkerOptions();
|
2019-10-04 11:59:06 +00:00
|
|
|
if (opts::ArchSpecificInfo)
|
|
|
|
Dumper->printArchSpecificInfo();
|
2016-01-26 19:46:39 +00:00
|
|
|
if (opts::SectionGroups)
|
|
|
|
Dumper->printGroupSections();
|
2016-04-11 17:15:30 +00:00
|
|
|
if (opts::HashHistogram)
|
2020-05-26 13:58:20 +03:00
|
|
|
Dumper->printHashHistograms();
|
[MC] Add assembler support for .cg_profile.
Object FIle Representation
At codegen time this is emitted into the ELF file a pair of symbol indices and a weight. In assembly it looks like:
.cg_profile a, b, 32
.cg_profile freq, a, 11
.cg_profile freq, b, 20
When writing an ELF file these are put into a SHT_LLVM_CALL_GRAPH_PROFILE (0x6fff4c02) section as (uint32_t, uint32_t, uint64_t) tuples as (from symbol index, to symbol index, weight).
Differential Revision: https://reviews.llvm.org/D44965
llvm-svn: 333823
2018-06-02 16:33:01 +00:00
|
|
|
if (opts::CGProfile)
|
|
|
|
Dumper->printCGProfile();
|
2018-07-17 22:17:18 +00:00
|
|
|
if (opts::Addrsig)
|
|
|
|
Dumper->printAddrsig();
|
2016-08-30 18:52:02 +00:00
|
|
|
if (opts::Notes)
|
|
|
|
Dumper->printNotes();
|
2015-05-07 15:40:35 +00:00
|
|
|
}
|
2015-07-24 02:14:20 +00:00
|
|
|
if (Obj->isCOFF()) {
|
|
|
|
if (opts::COFFImports)
|
|
|
|
Dumper->printCOFFImports();
|
|
|
|
if (opts::COFFExports)
|
|
|
|
Dumper->printCOFFExports();
|
|
|
|
if (opts::COFFDirectives)
|
|
|
|
Dumper->printCOFFDirectives();
|
|
|
|
if (opts::COFFBaseRelocs)
|
|
|
|
Dumper->printCOFFBaseReloc();
|
2016-06-02 17:10:43 +00:00
|
|
|
if (opts::COFFDebugDirectory)
|
|
|
|
Dumper->printCOFFDebugDirectory();
|
2017-04-27 19:38:38 +00:00
|
|
|
if (opts::COFFResources)
|
|
|
|
Dumper->printCOFFResources();
|
2017-06-22 01:10:29 +00:00
|
|
|
if (opts::COFFLoadConfig)
|
|
|
|
Dumper->printCOFFLoadConfig();
|
2020-06-15 16:29:36 -07:00
|
|
|
if (opts::CGProfile)
|
|
|
|
Dumper->printCGProfile();
|
2018-08-22 23:58:16 +00:00
|
|
|
if (opts::Addrsig)
|
|
|
|
Dumper->printAddrsig();
|
2015-12-16 18:28:12 +00:00
|
|
|
if (opts::CodeView)
|
|
|
|
Dumper->printCodeViewDebugInfo();
|
2016-05-14 00:02:53 +00:00
|
|
|
if (opts::CodeViewMergedTypes)
|
2019-02-07 15:24:18 +00:00
|
|
|
Dumper->mergeCodeViewTypes(CVTypes.IDTable, CVTypes.TypeTable,
|
|
|
|
CVTypes.GlobalIDTable, CVTypes.GlobalTypeTable,
|
|
|
|
opts::CodeViewEnableGHash);
|
2015-07-24 02:14:20 +00:00
|
|
|
}
|
2015-08-31 17:12:23 +00:00
|
|
|
if (Obj->isMachO()) {
|
2015-08-21 20:28:30 +00:00
|
|
|
if (opts::MachODataInCode)
|
|
|
|
Dumper->printMachODataInCode();
|
2015-09-03 18:10:28 +00:00
|
|
|
if (opts::MachOIndirectSymbols)
|
|
|
|
Dumper->printMachOIndirectSymbols();
|
2015-09-09 00:21:18 +00:00
|
|
|
if (opts::MachOLinkerOptions)
|
|
|
|
Dumper->printMachOLinkerOptions();
|
2015-09-02 16:24:24 +00:00
|
|
|
if (opts::MachOSegment)
|
|
|
|
Dumper->printMachOSegment();
|
2015-08-27 15:11:32 +00:00
|
|
|
if (opts::MachOVersionMin)
|
|
|
|
Dumper->printMachOVersionMin();
|
2015-08-31 19:32:31 +00:00
|
|
|
if (opts::MachODysymtab)
|
|
|
|
Dumper->printMachODysymtab();
|
2015-08-31 17:12:23 +00:00
|
|
|
}
|
2015-06-26 23:56:53 +00:00
|
|
|
if (opts::PrintStackMap)
|
|
|
|
Dumper->printStackMap();
|
2019-08-05 22:47:07 +00:00
|
|
|
if (opts::PrintStackSizes)
|
|
|
|
Dumper->printStackSizes();
|
2012-03-01 22:19:54 +00:00
|
|
|
}
|
|
|
|
|
2018-05-01 16:10:38 +00:00
|
|
|
/// Dumps each object file in \a Arc;
|
2018-01-10 00:14:19 +00:00
|
|
|
static void dumpArchive(const Archive *Arc, ScopedPrinter &Writer) {
|
2016-11-11 04:28:40 +00:00
|
|
|
Error Err = Error::success();
|
2016-07-14 02:24:01 +00:00
|
|
|
for (auto &Child : Arc->children(Err)) {
|
2016-05-17 17:10:12 +00:00
|
|
|
Expected<std::unique_ptr<Binary>> ChildOrErr = Child.getAsBinary();
|
|
|
|
if (!ChildOrErr) {
|
2019-08-13 12:07:41 +00:00
|
|
|
if (auto E = isNotObjectErrorInvalidFileType(ChildOrErr.takeError()))
|
|
|
|
reportError(std::move(E), Arc->getFileName());
|
2013-04-03 18:31:38 +00:00
|
|
|
continue;
|
|
|
|
}
|
2014-06-16 16:08:36 +00:00
|
|
|
if (ObjectFile *Obj = dyn_cast<ObjectFile>(&*ChildOrErr.get()))
|
2019-07-15 22:52:01 +00:00
|
|
|
dumpObject(Obj, Writer, Arc);
|
2016-08-18 14:32:11 +00:00
|
|
|
else if (COFFImportFile *Imp = dyn_cast<COFFImportFile>(&*ChildOrErr.get()))
|
2018-01-10 00:14:19 +00:00
|
|
|
dumpCOFFImportFile(Imp, Writer);
|
2013-04-03 18:31:38 +00:00
|
|
|
else
|
2019-08-22 08:56:24 +00:00
|
|
|
reportError(errorCodeToError(readobj_error::unrecognized_file_format),
|
|
|
|
Arc->getFileName());
|
2012-03-01 01:36:50 +00:00
|
|
|
}
|
2016-07-14 02:24:01 +00:00
|
|
|
if (Err)
|
2019-08-13 12:07:41 +00:00
|
|
|
reportError(std::move(Err), Arc->getFileName());
|
2013-04-03 18:31:38 +00:00
|
|
|
}
|
|
|
|
|
2018-05-01 16:10:38 +00:00
|
|
|
/// Dumps each object file in \a MachO Universal Binary;
|
2018-01-10 00:14:19 +00:00
|
|
|
static void dumpMachOUniversalBinary(const MachOUniversalBinary *UBinary,
|
|
|
|
ScopedPrinter &Writer) {
|
2015-03-24 20:26:55 +00:00
|
|
|
for (const MachOUniversalBinary::ObjectForArch &Obj : UBinary->objects()) {
|
2016-05-31 20:35:34 +00:00
|
|
|
Expected<std::unique_ptr<MachOObjectFile>> ObjOrErr = Obj.getAsObjectFile();
|
2015-04-13 16:05:49 +00:00
|
|
|
if (ObjOrErr)
|
2018-01-10 00:14:19 +00:00
|
|
|
dumpObject(&*ObjOrErr.get(), Writer);
|
2019-08-13 12:07:41 +00:00
|
|
|
else if (auto E = isNotObjectErrorInvalidFileType(ObjOrErr.takeError()))
|
|
|
|
reportError(ObjOrErr.takeError(), UBinary->getFileName());
|
2016-06-28 23:16:13 +00:00
|
|
|
else if (Expected<std::unique_ptr<Archive>> AOrErr = Obj.getAsArchive())
|
2018-01-10 00:14:19 +00:00
|
|
|
dumpArchive(&*AOrErr.get(), Writer);
|
2015-03-24 20:26:55 +00:00
|
|
|
}
|
|
|
|
}
|
2012-03-01 01:36:50 +00:00
|
|
|
|
2018-05-01 16:10:38 +00:00
|
|
|
/// Dumps \a WinRes, Windows Resource (.res) file;
|
2019-06-12 20:16:22 +00:00
|
|
|
static void dumpWindowsResourceFile(WindowsResource *WinRes,
|
|
|
|
ScopedPrinter &Printer) {
|
2017-09-20 18:33:35 +00:00
|
|
|
WindowsRes::Dumper Dumper(WinRes, Printer);
|
|
|
|
if (auto Err = Dumper.printData())
|
2019-08-13 12:07:41 +00:00
|
|
|
reportError(std::move(Err), WinRes->getFileName());
|
2017-09-20 18:33:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-05-01 16:10:38 +00:00
|
|
|
/// Opens \a File and dumps it.
|
2019-06-12 20:16:22 +00:00
|
|
|
static void dumpInput(StringRef File, ScopedPrinter &Writer) {
|
2013-04-03 18:31:38 +00:00
|
|
|
// Attempt to open the binary.
|
2016-04-06 22:14:09 +00:00
|
|
|
Expected<OwningBinary<Binary>> BinaryOrErr = createBinary(File);
|
|
|
|
if (!BinaryOrErr)
|
2019-08-13 12:07:41 +00:00
|
|
|
reportError(BinaryOrErr.takeError(), File);
|
2014-08-19 18:44:46 +00:00
|
|
|
Binary &Binary = *BinaryOrErr.get().getBinary();
|
2012-03-01 01:36:50 +00:00
|
|
|
|
2014-08-01 14:31:55 +00:00
|
|
|
if (Archive *Arc = dyn_cast<Archive>(&Binary))
|
2018-01-10 00:14:19 +00:00
|
|
|
dumpArchive(Arc, Writer);
|
2015-03-24 20:26:55 +00:00
|
|
|
else if (MachOUniversalBinary *UBinary =
|
|
|
|
dyn_cast<MachOUniversalBinary>(&Binary))
|
2018-01-10 00:14:19 +00:00
|
|
|
dumpMachOUniversalBinary(UBinary, Writer);
|
2014-08-01 14:31:55 +00:00
|
|
|
else if (ObjectFile *Obj = dyn_cast<ObjectFile>(&Binary))
|
2018-01-10 00:14:19 +00:00
|
|
|
dumpObject(Obj, Writer);
|
2015-08-28 07:40:30 +00:00
|
|
|
else if (COFFImportFile *Import = dyn_cast<COFFImportFile>(&Binary))
|
2018-01-10 00:14:19 +00:00
|
|
|
dumpCOFFImportFile(Import, Writer);
|
2017-09-20 18:33:35 +00:00
|
|
|
else if (WindowsResource *WinRes = dyn_cast<WindowsResource>(&Binary))
|
2019-06-12 20:16:22 +00:00
|
|
|
dumpWindowsResourceFile(WinRes, Writer);
|
2013-04-03 18:31:38 +00:00
|
|
|
else
|
2019-08-22 08:56:24 +00:00
|
|
|
reportError(errorCodeToError(readobj_error::unrecognized_file_format),
|
|
|
|
File);
|
2019-02-07 15:24:18 +00:00
|
|
|
|
|
|
|
CVTypes.Binaries.push_back(std::move(*BinaryOrErr));
|
2013-04-03 18:31:38 +00:00
|
|
|
}
|
2012-12-31 16:53:01 +00:00
|
|
|
|
[llvm-readelf] Make llvm-readelf more compatible with GNU readelf.
Summary:
This change adds a bunch of options that GNU readelf supports. There is one breaking change when invoked as `llvm-readobj`, and three breaking changes when invoked as `llvm-readelf`:
- Add --all (implies --file-header, --program-headers, etc.)
- [Breaking] -a is --all instead of --arm-attributes
- Add --file-header as an alias for --file-headers
- Replace --sections with --sections-headers, keeping --sections as an alias for it
- Add --relocs as an alias for --relocations
- Add --dynamic as an alias for --dynamic-table
- Add --segments as an alias for --program-headers
- Add --section-groups as an alias for --elf-section-groups
- Add --dyn-syms as an alias for --dyn-symbols
- Add --syms as an alias for --symbols
- Add --histogram as an alias for --elf-hash-histogram
- [Breaking] When invoked as `llvm-readelf`, -s is --symbols instead of --sections
- [Breaking] When invoked as `llvm-readelf`, -t is no longer an alias for --symbols
Reviewers: MaskRay, phosek, mcgrathr, jhenderson
Reviewed By: MaskRay, jhenderson
Subscribers: sbc100, aheejin, edd, jhenderson, silvas, echristo, compnerd, kristina, javed.absar, kristof.beyls, llvm-commits, Bigcheese
Differential Revision: https://reviews.llvm.org/D54124
llvm-svn: 346685
2018-11-12 18:02:38 +00:00
|
|
|
/// Registers aliases that should only be allowed by readobj.
|
|
|
|
static void registerReadobjAliases() {
|
|
|
|
// -s has meant --sections for a very long time in llvm-readobj despite
|
|
|
|
// meaning --symbols in readelf.
|
|
|
|
static cl::alias SectionsShort("s", cl::desc("Alias for --section-headers"),
|
|
|
|
cl::aliasopt(opts::SectionHeaders),
|
|
|
|
cl::NotHidden);
|
|
|
|
|
|
|
|
// Only register -t in llvm-readobj, as readelf reserves it for
|
|
|
|
// --section-details (not implemented yet).
|
|
|
|
static cl::alias SymbolsShort("t", cl::desc("Alias for --symbols"),
|
|
|
|
cl::aliasopt(opts::Symbols), cl::NotHidden);
|
[llvm-readelf] Allow single-letter flags to be merged.
Summary:
This patch adds support for merged arguments (e.g. -SW == -S -W) for llvm-readelf.
No changes are intended for llvm-readobj. There are a few short flags (-sd, -sr, -st, -dt) that would conflict with grouped single letter flags, and having only some grouped flags might be confusing. So, allow merged flags for readelf compatibility, but force separate args for llvm-readobj. From what I can tell, these two-letter flags are only used with llvm-readobj, not llvm-readelf.
This fixes PR40064.
Reviewers: jhenderson, kristina, echristo, phosek
Reviewed By: jhenderson
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D56629
llvm-svn: 351205
2019-01-15 17:04:40 +00:00
|
|
|
|
|
|
|
// The following two-letter aliases are only provided for readobj, as readelf
|
|
|
|
// allows single-letter args to be grouped together.
|
|
|
|
static cl::alias SectionRelocationsShort(
|
|
|
|
"sr", cl::desc("Alias for --section-relocations"),
|
|
|
|
cl::aliasopt(opts::SectionRelocations));
|
|
|
|
static cl::alias SectionDataShort("sd", cl::desc("Alias for --section-data"),
|
|
|
|
cl::aliasopt(opts::SectionData));
|
|
|
|
static cl::alias SectionSymbolsShort("st",
|
|
|
|
cl::desc("Alias for --section-symbols"),
|
|
|
|
cl::aliasopt(opts::SectionSymbols));
|
|
|
|
static cl::alias DynamicSymbolsShort("dt",
|
|
|
|
cl::desc("Alias for --dyn-symbols"),
|
|
|
|
cl::aliasopt(opts::DynamicSymbols));
|
[llvm-readelf] Make llvm-readelf more compatible with GNU readelf.
Summary:
This change adds a bunch of options that GNU readelf supports. There is one breaking change when invoked as `llvm-readobj`, and three breaking changes when invoked as `llvm-readelf`:
- Add --all (implies --file-header, --program-headers, etc.)
- [Breaking] -a is --all instead of --arm-attributes
- Add --file-header as an alias for --file-headers
- Replace --sections with --sections-headers, keeping --sections as an alias for it
- Add --relocs as an alias for --relocations
- Add --dynamic as an alias for --dynamic-table
- Add --segments as an alias for --program-headers
- Add --section-groups as an alias for --elf-section-groups
- Add --dyn-syms as an alias for --dyn-symbols
- Add --syms as an alias for --symbols
- Add --histogram as an alias for --elf-hash-histogram
- [Breaking] When invoked as `llvm-readelf`, -s is --symbols instead of --sections
- [Breaking] When invoked as `llvm-readelf`, -t is no longer an alias for --symbols
Reviewers: MaskRay, phosek, mcgrathr, jhenderson
Reviewed By: MaskRay, jhenderson
Subscribers: sbc100, aheejin, edd, jhenderson, silvas, echristo, compnerd, kristina, javed.absar, kristof.beyls, llvm-commits, Bigcheese
Differential Revision: https://reviews.llvm.org/D54124
llvm-svn: 346685
2018-11-12 18:02:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/// Registers aliases that should only be allowed by readelf.
|
|
|
|
static void registerReadelfAliases() {
|
|
|
|
// -s is here because for readobj it means --sections.
|
|
|
|
static cl::alias SymbolsShort("s", cl::desc("Alias for --symbols"),
|
[llvm-readelf] Allow single-letter flags to be merged.
Summary:
This patch adds support for merged arguments (e.g. -SW == -S -W) for llvm-readelf.
No changes are intended for llvm-readobj. There are a few short flags (-sd, -sr, -st, -dt) that would conflict with grouped single letter flags, and having only some grouped flags might be confusing. So, allow merged flags for readelf compatibility, but force separate args for llvm-readobj. From what I can tell, these two-letter flags are only used with llvm-readobj, not llvm-readelf.
This fixes PR40064.
Reviewers: jhenderson, kristina, echristo, phosek
Reviewed By: jhenderson
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D56629
llvm-svn: 351205
2019-01-15 17:04:40 +00:00
|
|
|
cl::aliasopt(opts::Symbols), cl::NotHidden,
|
|
|
|
cl::Grouping);
|
|
|
|
|
|
|
|
// Allow all single letter flags to be grouped together.
|
|
|
|
for (auto &OptEntry : cl::getRegisteredOptions()) {
|
|
|
|
StringRef ArgName = OptEntry.getKey();
|
|
|
|
cl::Option *Option = OptEntry.getValue();
|
|
|
|
if (ArgName.size() == 1)
|
2019-03-01 09:22:42 +00:00
|
|
|
apply(Option, cl::Grouping);
|
[llvm-readelf] Allow single-letter flags to be merged.
Summary:
This patch adds support for merged arguments (e.g. -SW == -S -W) for llvm-readelf.
No changes are intended for llvm-readobj. There are a few short flags (-sd, -sr, -st, -dt) that would conflict with grouped single letter flags, and having only some grouped flags might be confusing. So, allow merged flags for readelf compatibility, but force separate args for llvm-readobj. From what I can tell, these two-letter flags are only used with llvm-readobj, not llvm-readelf.
This fixes PR40064.
Reviewers: jhenderson, kristina, echristo, phosek
Reviewed By: jhenderson
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D56629
llvm-svn: 351205
2019-01-15 17:04:40 +00:00
|
|
|
}
|
[llvm-readelf] Make llvm-readelf more compatible with GNU readelf.
Summary:
This change adds a bunch of options that GNU readelf supports. There is one breaking change when invoked as `llvm-readobj`, and three breaking changes when invoked as `llvm-readelf`:
- Add --all (implies --file-header, --program-headers, etc.)
- [Breaking] -a is --all instead of --arm-attributes
- Add --file-header as an alias for --file-headers
- Replace --sections with --sections-headers, keeping --sections as an alias for it
- Add --relocs as an alias for --relocations
- Add --dynamic as an alias for --dynamic-table
- Add --segments as an alias for --program-headers
- Add --section-groups as an alias for --elf-section-groups
- Add --dyn-syms as an alias for --dyn-symbols
- Add --syms as an alias for --symbols
- Add --histogram as an alias for --elf-hash-histogram
- [Breaking] When invoked as `llvm-readelf`, -s is --symbols instead of --sections
- [Breaking] When invoked as `llvm-readelf`, -t is no longer an alias for --symbols
Reviewers: MaskRay, phosek, mcgrathr, jhenderson
Reviewed By: MaskRay, jhenderson
Subscribers: sbc100, aheejin, edd, jhenderson, silvas, echristo, compnerd, kristina, javed.absar, kristof.beyls, llvm-commits, Bigcheese
Differential Revision: https://reviews.llvm.org/D54124
llvm-svn: 346685
2018-11-12 18:02:38 +00:00
|
|
|
}
|
|
|
|
|
2013-04-03 18:31:38 +00:00
|
|
|
int main(int argc, const char *argv[]) {
|
2018-04-13 18:26:06 +00:00
|
|
|
InitLLVM X(argc, argv);
|
2019-08-20 12:49:15 +00:00
|
|
|
ToolName = argv[0];
|
2012-12-31 16:29:44 +00:00
|
|
|
|
2013-04-03 18:31:38 +00:00
|
|
|
// Register the target printer for --version.
|
|
|
|
cl::AddExtraVersionPrinter(TargetRegistry::printRegisteredTargetsForVersion);
|
|
|
|
|
[llvm-readelf] Make llvm-readelf more compatible with GNU readelf.
Summary:
This change adds a bunch of options that GNU readelf supports. There is one breaking change when invoked as `llvm-readobj`, and three breaking changes when invoked as `llvm-readelf`:
- Add --all (implies --file-header, --program-headers, etc.)
- [Breaking] -a is --all instead of --arm-attributes
- Add --file-header as an alias for --file-headers
- Replace --sections with --sections-headers, keeping --sections as an alias for it
- Add --relocs as an alias for --relocations
- Add --dynamic as an alias for --dynamic-table
- Add --segments as an alias for --program-headers
- Add --section-groups as an alias for --elf-section-groups
- Add --dyn-syms as an alias for --dyn-symbols
- Add --syms as an alias for --symbols
- Add --histogram as an alias for --elf-hash-histogram
- [Breaking] When invoked as `llvm-readelf`, -s is --symbols instead of --sections
- [Breaking] When invoked as `llvm-readelf`, -t is no longer an alias for --symbols
Reviewers: MaskRay, phosek, mcgrathr, jhenderson
Reviewed By: MaskRay, jhenderson
Subscribers: sbc100, aheejin, edd, jhenderson, silvas, echristo, compnerd, kristina, javed.absar, kristof.beyls, llvm-commits, Bigcheese
Differential Revision: https://reviews.llvm.org/D54124
llvm-svn: 346685
2018-11-12 18:02:38 +00:00
|
|
|
if (sys::path::stem(argv[0]).contains("readelf")) {
|
2017-07-19 02:09:37 +00:00
|
|
|
opts::Output = opts::GNU;
|
[llvm-readelf] Make llvm-readelf more compatible with GNU readelf.
Summary:
This change adds a bunch of options that GNU readelf supports. There is one breaking change when invoked as `llvm-readobj`, and three breaking changes when invoked as `llvm-readelf`:
- Add --all (implies --file-header, --program-headers, etc.)
- [Breaking] -a is --all instead of --arm-attributes
- Add --file-header as an alias for --file-headers
- Replace --sections with --sections-headers, keeping --sections as an alias for it
- Add --relocs as an alias for --relocations
- Add --dynamic as an alias for --dynamic-table
- Add --segments as an alias for --program-headers
- Add --section-groups as an alias for --elf-section-groups
- Add --dyn-syms as an alias for --dyn-symbols
- Add --syms as an alias for --symbols
- Add --histogram as an alias for --elf-hash-histogram
- [Breaking] When invoked as `llvm-readelf`, -s is --symbols instead of --sections
- [Breaking] When invoked as `llvm-readelf`, -t is no longer an alias for --symbols
Reviewers: MaskRay, phosek, mcgrathr, jhenderson
Reviewed By: MaskRay, jhenderson
Subscribers: sbc100, aheejin, edd, jhenderson, silvas, echristo, compnerd, kristina, javed.absar, kristof.beyls, llvm-commits, Bigcheese
Differential Revision: https://reviews.llvm.org/D54124
llvm-svn: 346685
2018-11-12 18:02:38 +00:00
|
|
|
registerReadelfAliases();
|
|
|
|
} else {
|
|
|
|
registerReadobjAliases();
|
|
|
|
}
|
2017-07-19 02:09:37 +00:00
|
|
|
|
2013-04-03 18:31:38 +00:00
|
|
|
cl::ParseCommandLineOptions(argc, argv, "LLVM Object Reader\n");
|
2013-02-20 02:37:12 +00:00
|
|
|
|
2020-07-20 08:47:11 +01:00
|
|
|
// Default to print error if no filename is specified.
|
|
|
|
if (opts::InputFilenames.empty()) {
|
|
|
|
error("no input files specified");
|
|
|
|
}
|
|
|
|
|
[llvm-readelf] Make llvm-readelf more compatible with GNU readelf.
Summary:
This change adds a bunch of options that GNU readelf supports. There is one breaking change when invoked as `llvm-readobj`, and three breaking changes when invoked as `llvm-readelf`:
- Add --all (implies --file-header, --program-headers, etc.)
- [Breaking] -a is --all instead of --arm-attributes
- Add --file-header as an alias for --file-headers
- Replace --sections with --sections-headers, keeping --sections as an alias for it
- Add --relocs as an alias for --relocations
- Add --dynamic as an alias for --dynamic-table
- Add --segments as an alias for --program-headers
- Add --section-groups as an alias for --elf-section-groups
- Add --dyn-syms as an alias for --dyn-symbols
- Add --syms as an alias for --symbols
- Add --histogram as an alias for --elf-hash-histogram
- [Breaking] When invoked as `llvm-readelf`, -s is --symbols instead of --sections
- [Breaking] When invoked as `llvm-readelf`, -t is no longer an alias for --symbols
Reviewers: MaskRay, phosek, mcgrathr, jhenderson
Reviewed By: MaskRay, jhenderson
Subscribers: sbc100, aheejin, edd, jhenderson, silvas, echristo, compnerd, kristina, javed.absar, kristof.beyls, llvm-commits, Bigcheese
Differential Revision: https://reviews.llvm.org/D54124
llvm-svn: 346685
2018-11-12 18:02:38 +00:00
|
|
|
if (opts::All) {
|
|
|
|
opts::FileHeaders = true;
|
|
|
|
opts::ProgramHeaders = true;
|
|
|
|
opts::SectionHeaders = true;
|
|
|
|
opts::Symbols = true;
|
|
|
|
opts::Relocations = true;
|
|
|
|
opts::DynamicTable = true;
|
|
|
|
opts::Notes = true;
|
|
|
|
opts::VersionInfo = true;
|
|
|
|
opts::UnwindInfo = true;
|
|
|
|
opts::SectionGroups = true;
|
|
|
|
opts::HashHistogram = true;
|
2019-10-07 10:29:38 +00:00
|
|
|
if (opts::Output == opts::LLVM) {
|
|
|
|
opts::Addrsig = true;
|
2019-09-23 10:33:19 +00:00
|
|
|
opts::PrintStackSizes = true;
|
2019-10-07 10:29:38 +00:00
|
|
|
}
|
[llvm-readelf] Make llvm-readelf more compatible with GNU readelf.
Summary:
This change adds a bunch of options that GNU readelf supports. There is one breaking change when invoked as `llvm-readobj`, and three breaking changes when invoked as `llvm-readelf`:
- Add --all (implies --file-header, --program-headers, etc.)
- [Breaking] -a is --all instead of --arm-attributes
- Add --file-header as an alias for --file-headers
- Replace --sections with --sections-headers, keeping --sections as an alias for it
- Add --relocs as an alias for --relocations
- Add --dynamic as an alias for --dynamic-table
- Add --segments as an alias for --program-headers
- Add --section-groups as an alias for --elf-section-groups
- Add --dyn-syms as an alias for --dyn-symbols
- Add --syms as an alias for --symbols
- Add --histogram as an alias for --elf-hash-histogram
- [Breaking] When invoked as `llvm-readelf`, -s is --symbols instead of --sections
- [Breaking] When invoked as `llvm-readelf`, -t is no longer an alias for --symbols
Reviewers: MaskRay, phosek, mcgrathr, jhenderson
Reviewed By: MaskRay, jhenderson
Subscribers: sbc100, aheejin, edd, jhenderson, silvas, echristo, compnerd, kristina, javed.absar, kristof.beyls, llvm-commits, Bigcheese
Differential Revision: https://reviews.llvm.org/D54124
llvm-svn: 346685
2018-11-12 18:02:38 +00:00
|
|
|
}
|
|
|
|
|
2018-12-11 16:15:03 +00:00
|
|
|
if (opts::Headers) {
|
|
|
|
opts::FileHeaders = true;
|
|
|
|
opts::ProgramHeaders = true;
|
|
|
|
opts::SectionHeaders = true;
|
|
|
|
}
|
|
|
|
|
2019-06-12 20:16:22 +00:00
|
|
|
ScopedPrinter Writer(fouts());
|
|
|
|
for (const std::string &I : opts::InputFilenames)
|
|
|
|
dumpInput(I, Writer);
|
2017-11-30 18:33:34 +00:00
|
|
|
|
|
|
|
if (opts::CodeViewMergedTypes) {
|
2019-02-07 15:24:18 +00:00
|
|
|
if (opts::CodeViewEnableGHash)
|
2019-06-12 20:16:22 +00:00
|
|
|
dumpCodeViewMergedTypes(Writer, CVTypes.GlobalIDTable.records(),
|
2019-02-07 15:24:18 +00:00
|
|
|
CVTypes.GlobalTypeTable.records());
|
|
|
|
else
|
2019-06-12 20:16:22 +00:00
|
|
|
dumpCodeViewMergedTypes(Writer, CVTypes.IDTable.records(),
|
2019-02-07 15:24:18 +00:00
|
|
|
CVTypes.TypeTable.records());
|
2016-05-14 00:02:53 +00:00
|
|
|
}
|
|
|
|
|
2015-07-20 03:23:55 +00:00
|
|
|
return 0;
|
2012-03-01 01:36:50 +00:00
|
|
|
}
|