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
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
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"
|
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"
|
|
|
|
|
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);
|
|
|
|
|
[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
|
|
|
// -all, -a
|
|
|
|
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));
|
|
|
|
|
2017-07-18 23:58:15 +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));
|
|
|
|
|
[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
|
|
|
// -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));
|
|
|
|
|
|
|
|
// -section-headers, -sections, -S
|
|
|
|
// 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
|
|
|
|
|
|
|
// -section-relocations, -sr
|
|
|
|
cl::opt<bool> SectionRelocations("section-relocations",
|
|
|
|
cl::desc("Display relocations for each section shown."));
|
|
|
|
cl::alias SectionRelocationsShort("sr",
|
|
|
|
cl::desc("Alias for --section-relocations"),
|
|
|
|
cl::aliasopt(SectionRelocations));
|
|
|
|
|
|
|
|
// -section-symbols, -st
|
|
|
|
cl::opt<bool> SectionSymbols("section-symbols",
|
|
|
|
cl::desc("Display symbols for each section shown."));
|
|
|
|
cl::alias SectionSymbolsShort("st",
|
|
|
|
cl::desc("Alias for --section-symbols"),
|
|
|
|
cl::aliasopt(SectionSymbols));
|
|
|
|
|
|
|
|
// -section-data, -sd
|
|
|
|
cl::opt<bool> SectionData("section-data",
|
|
|
|
cl::desc("Display section data for each section shown."));
|
|
|
|
cl::alias SectionDataShort("sd",
|
|
|
|
cl::desc("Alias for --section-data"),
|
|
|
|
cl::aliasopt(SectionData));
|
|
|
|
|
[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
|
|
|
// -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
|
|
|
|
2016-08-30 18:52:02 +00:00
|
|
|
// -notes, -n
|
|
|
|
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));
|
|
|
|
|
2015-06-25 21:47:32 +00:00
|
|
|
// -dyn-relocations
|
|
|
|
cl::opt<bool> DynRelocs("dyn-relocations",
|
|
|
|
cl::desc("Display the dynamic 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
|
|
|
// -symbols
|
|
|
|
// Also -s in llvm-readelf mode, or -t in llvm-readobj mode.
|
2013-04-03 18:31:38 +00:00
|
|
|
cl::opt<bool> Symbols("symbols",
|
|
|
|
cl::desc("Display the 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 SymbolsGNU("syms", cl::desc("Alias for --symbols"),
|
|
|
|
cl::aliasopt(Symbols));
|
2013-04-03 18:31: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
|
|
|
// -dyn-symbols, -dyn-syms, -dt
|
2013-04-03 18:31:38 +00:00
|
|
|
cl::opt<bool> DynamicSymbols("dyn-symbols",
|
|
|
|
cl::desc("Display the dynamic symbol table"));
|
|
|
|
cl::alias DynamicSymbolsShort("dt",
|
|
|
|
cl::desc("Alias for --dyn-symbols"),
|
|
|
|
cl::aliasopt(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
|
|
|
cl::alias DynSymsGNU("dyn-syms", cl::desc("Alias for --dyn-symbols"),
|
|
|
|
cl::aliasopt(DynamicSymbols));
|
2013-04-03 18:31:38 +00:00
|
|
|
|
|
|
|
// -unwind, -u
|
|
|
|
cl::opt<bool> UnwindInfo("unwind",
|
|
|
|
cl::desc("Display unwind information"));
|
|
|
|
cl::alias UnwindInfoShort("u",
|
|
|
|
cl::desc("Alias for --unwind"),
|
|
|
|
cl::aliasopt(UnwindInfo));
|
|
|
|
|
[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
|
|
|
// -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
|
|
|
|
|
|
|
// -needed-libs
|
|
|
|
cl::opt<bool> NeededLibraries("needed-libs",
|
|
|
|
cl::desc("Display the needed libraries"));
|
2013-04-12 04:01:52 +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
|
|
|
// -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
|
|
|
|
[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
|
|
|
// -string-dump, -p
|
2018-06-15 14:15:02 +00:00
|
|
|
cl::list<std::string> StringDump("string-dump", cl::desc("<number|name>"),
|
|
|
|
cl::ZeroOrMore);
|
|
|
|
cl::alias StringDumpShort("p", cl::desc("Alias for --string-dump"),
|
|
|
|
cl::aliasopt(StringDump));
|
|
|
|
|
[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
|
|
|
// -hex-dump, -x
|
2018-07-11 10:00:29 +00:00
|
|
|
cl::list<std::string> HexDump("hex-dump", cl::desc("<number|name>"),
|
|
|
|
cl::ZeroOrMore);
|
|
|
|
cl::alias HexDumpShort("x", cl::desc("Alias for --hex-dump"),
|
|
|
|
cl::aliasopt(HexDump));
|
|
|
|
|
2015-07-09 22:32:24 +00:00
|
|
|
// -hash-table
|
|
|
|
cl::opt<bool> HashTable("hash-table",
|
|
|
|
cl::desc("Display ELF hash table"));
|
|
|
|
|
2015-10-14 12:11:50 +00:00
|
|
|
// -gnu-hash-table
|
|
|
|
cl::opt<bool> GnuHashTable("gnu-hash-table",
|
|
|
|
cl::desc("Display ELF .gnu.hash section"));
|
|
|
|
|
2013-04-12 04:01:52 +00:00
|
|
|
// -expand-relocs
|
|
|
|
cl::opt<bool> ExpandRelocs("expand-relocs",
|
|
|
|
cl::desc("Expand each shown relocation to multiple lines"));
|
2013-12-19 11:37:14 +00:00
|
|
|
|
2018-06-28 21:07:34 +00:00
|
|
|
// -raw-relr
|
|
|
|
cl::opt<bool> RawRelr("raw-relr",
|
|
|
|
cl::desc("Do not decode relocations in SHT_RELR section, display raw contents"));
|
|
|
|
|
2015-02-18 19:32:05 +00:00
|
|
|
// -codeview
|
|
|
|
cl::opt<bool> CodeView("codeview",
|
|
|
|
cl::desc("Display CodeView debug information"));
|
|
|
|
|
2016-05-14 00:02:53 +00:00
|
|
|
// -codeview-merged-types
|
|
|
|
cl::opt<bool>
|
|
|
|
CodeViewMergedTypes("codeview-merged-types",
|
|
|
|
cl::desc("Display the merged CodeView type stream"));
|
|
|
|
|
2015-02-18 19:32:05 +00:00
|
|
|
// -codeview-subsection-bytes
|
|
|
|
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
|
|
|
|
[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
|
|
|
// -arm-attributes
|
2014-01-30 04:46:33 +00:00
|
|
|
cl::opt<bool> ARMAttributes("arm-attributes",
|
|
|
|
cl::desc("Display the ARM attributes section"));
|
2014-06-18 08:47:09 +00:00
|
|
|
|
|
|
|
// -mips-plt-got
|
|
|
|
cl::opt<bool>
|
|
|
|
MipsPLTGOT("mips-plt-got",
|
|
|
|
cl::desc("Display the MIPS GOT and PLT GOT sections"));
|
2014-10-02 17:02:18 +00:00
|
|
|
|
2015-05-07 15:40:35 +00:00
|
|
|
// -mips-abi-flags
|
|
|
|
cl::opt<bool> MipsABIFlags("mips-abi-flags",
|
|
|
|
cl::desc("Display the MIPS.abiflags section"));
|
|
|
|
|
2015-06-16 21:47:43 +00:00
|
|
|
// -mips-reginfo
|
|
|
|
cl::opt<bool> MipsReginfo("mips-reginfo",
|
|
|
|
cl::desc("Display the MIPS .reginfo section"));
|
|
|
|
|
2016-05-04 05:58:57 +00:00
|
|
|
// -mips-options
|
|
|
|
cl::opt<bool> MipsOptions("mips-options",
|
|
|
|
cl::desc("Display the MIPS .MIPS.options section"));
|
|
|
|
|
2014-10-02 17:02:18 +00:00
|
|
|
// -coff-imports
|
|
|
|
cl::opt<bool>
|
|
|
|
COFFImports("coff-imports", cl::desc("Display the PE/COFF import table"));
|
2014-10-07 19:37:52 +00:00
|
|
|
|
2015-01-03 21:35:09 +00:00
|
|
|
// -coff-exports
|
|
|
|
cl::opt<bool>
|
|
|
|
COFFExports("coff-exports", cl::desc("Display the PE/COFF export table"));
|
|
|
|
|
2014-10-07 19:37:52 +00:00
|
|
|
// -coff-directives
|
|
|
|
cl::opt<bool>
|
|
|
|
COFFDirectives("coff-directives",
|
2014-11-19 00:18:07 +00:00
|
|
|
cl::desc("Display the PE/COFF .drectve section"));
|
|
|
|
|
|
|
|
// -coff-basereloc
|
|
|
|
cl::opt<bool>
|
|
|
|
COFFBaseRelocs("coff-basereloc",
|
|
|
|
cl::desc("Display the PE/COFF .reloc section"));
|
2015-06-26 23:56:53 +00:00
|
|
|
|
2016-06-02 17:10:43 +00:00
|
|
|
// -coff-debug-directory
|
|
|
|
cl::opt<bool>
|
|
|
|
COFFDebugDirectory("coff-debug-directory",
|
|
|
|
cl::desc("Display the PE/COFF debug directory"));
|
|
|
|
|
2017-04-27 19:38:38 +00:00
|
|
|
// -coff-resources
|
|
|
|
cl::opt<bool> COFFResources("coff-resources",
|
|
|
|
cl::desc("Display the PE/COFF .rsrc section"));
|
|
|
|
|
2017-06-22 01:10:29 +00:00
|
|
|
// -coff-load-config
|
|
|
|
cl::opt<bool>
|
|
|
|
COFFLoadConfig("coff-load-config",
|
|
|
|
cl::desc("Display the PE/COFF load config"));
|
|
|
|
|
2018-01-30 16:29:29 +00:00
|
|
|
// -elf-linker-options
|
|
|
|
cl::opt<bool>
|
|
|
|
ELFLinkerOptions("elf-linker-options",
|
|
|
|
cl::desc("Display the ELF .linker-options section"));
|
|
|
|
|
2015-08-21 20:28:30 +00:00
|
|
|
// -macho-data-in-code
|
|
|
|
cl::opt<bool>
|
|
|
|
MachODataInCode("macho-data-in-code",
|
|
|
|
cl::desc("Display MachO Data in Code command"));
|
|
|
|
|
2015-09-03 18:10:28 +00:00
|
|
|
// -macho-indirect-symbols
|
|
|
|
cl::opt<bool>
|
|
|
|
MachOIndirectSymbols("macho-indirect-symbols",
|
|
|
|
cl::desc("Display MachO indirect symbols"));
|
|
|
|
|
2015-09-09 00:21:18 +00:00
|
|
|
// -macho-linker-options
|
|
|
|
cl::opt<bool>
|
|
|
|
MachOLinkerOptions("macho-linker-options",
|
|
|
|
cl::desc("Display MachO linker options"));
|
|
|
|
|
2015-09-02 16:24:24 +00:00
|
|
|
// -macho-segment
|
|
|
|
cl::opt<bool>
|
|
|
|
MachOSegment("macho-segment",
|
|
|
|
cl::desc("Display MachO Segment command"));
|
|
|
|
|
2015-08-27 15:11:32 +00:00
|
|
|
// -macho-version-min
|
|
|
|
cl::opt<bool>
|
|
|
|
MachOVersionMin("macho-version-min",
|
|
|
|
cl::desc("Display MachO version min command"));
|
2015-08-31 19:32:31 +00:00
|
|
|
|
|
|
|
// -macho-dysymtab
|
|
|
|
cl::opt<bool>
|
|
|
|
MachODysymtab("macho-dysymtab",
|
|
|
|
cl::desc("Display MachO Dysymtab command"));
|
|
|
|
|
2015-06-26 23:56:53 +00:00
|
|
|
// -stackmap
|
|
|
|
cl::opt<bool>
|
|
|
|
PrintStackMap("stackmap",
|
|
|
|
cl::desc("Display contents of stackmap section"));
|
|
|
|
|
[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
|
|
|
// -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
|
|
|
|
[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-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
|
|
|
|
|
|
|
// -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
|
|
|
|
[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-cg-profile
|
[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
|
|
|
cl::opt<bool> CGProfile("elf-cg-profile", cl::desc("Display callgraph profile section"));
|
|
|
|
|
[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));
|
2013-04-03 18:31:38 +00:00
|
|
|
} // namespace opts
|
|
|
|
|
2015-07-20 03:38:17 +00:00
|
|
|
namespace llvm {
|
|
|
|
|
2015-12-04 19:29:49 +00:00
|
|
|
LLVM_ATTRIBUTE_NORETURN void reportError(Twine Msg) {
|
2015-12-23 19:29:34 +00:00
|
|
|
errs() << "\nError reading file: " << Msg << ".\n";
|
|
|
|
errs().flush();
|
2015-07-20 03:23:55 +00:00
|
|
|
exit(1);
|
2015-07-20 03:01:49 +00:00
|
|
|
}
|
|
|
|
|
[CodeView] Decouple record deserialization from visitor dispatch.
Until now, our use case for the visitor has been to take a stream of bytes
representing a type stream, deserialize the records in sequence, and do
something with them, where "something" is determined by how the user
implements a particular set of callbacks on an abstract class.
For actually writing PDBs, however, we want to do the reverse. We have
some kind of description of the list of records in their in-memory format,
and we want to process each one. Perhaps by serializing them to a byte
stream, or perhaps by converting them from one description format (Yaml)
to another (in-memory representation).
This was difficult in the current model because deserialization and
invoking the callbacks were tightly coupled.
With this patch we change this so that TypeDeserializer is itself an
implementation of the particular set of callbacks. This decouples
deserialization from the iteration over a list of records and invocation
of the callbacks. TypeDeserializer is initialized with another
implementation of the callback interface, so that upon deserialization it
can pass the deserialized record through to the next set of callbacks. In
a sense this is like an implementation of the Decorator design pattern,
where the Deserializer is a decorator.
This will be useful for writing Pdbs from yaml, where we have a
description of the type records in Yaml format. In this case, the visitor
implementation would have each visitation callback method implemented in
such a way as to extract the proper set of fields from the Yaml, and it
could maintain state that builds up a list of these records. Finally at
the end we can pass this information through to another set of callbacks
which serializes them into a byte stream.
Reviewed By: majnemer, ruiu, rnk
Differential Revision: https://reviews.llvm.org/D23177
llvm-svn: 277871
2016-08-05 21:45:34 +00:00
|
|
|
void error(Error EC) {
|
2016-08-04 19:39:55 +00:00
|
|
|
if (!EC)
|
|
|
|
return;
|
|
|
|
handleAllErrors(std::move(EC),
|
[CodeView] Decouple record deserialization from visitor dispatch.
Until now, our use case for the visitor has been to take a stream of bytes
representing a type stream, deserialize the records in sequence, and do
something with them, where "something" is determined by how the user
implements a particular set of callbacks on an abstract class.
For actually writing PDBs, however, we want to do the reverse. We have
some kind of description of the list of records in their in-memory format,
and we want to process each one. Perhaps by serializing them to a byte
stream, or perhaps by converting them from one description format (Yaml)
to another (in-memory representation).
This was difficult in the current model because deserialization and
invoking the callbacks were tightly coupled.
With this patch we change this so that TypeDeserializer is itself an
implementation of the particular set of callbacks. This decouples
deserialization from the iteration over a list of records and invocation
of the callbacks. TypeDeserializer is initialized with another
implementation of the callback interface, so that upon deserialization it
can pass the deserialized record through to the next set of callbacks. In
a sense this is like an implementation of the Decorator design pattern,
where the Deserializer is a decorator.
This will be useful for writing Pdbs from yaml, where we have a
description of the type records in Yaml format. In this case, the visitor
implementation would have each visitation callback method implemented in
such a way as to extract the proper set of fields from the Yaml, and it
could maintain state that builds up a list of these records. Finally at
the end we can pass this information through to another set of callbacks
which serializes them into a byte stream.
Reviewed By: majnemer, ruiu, rnk
Differential Revision: https://reviews.llvm.org/D23177
llvm-svn: 277871
2016-08-05 21:45:34 +00:00
|
|
|
[&](const ErrorInfoBase &EI) { reportError(EI.message()); });
|
2016-08-04 19:39:55 +00:00
|
|
|
}
|
|
|
|
|
2015-07-20 03:23:55 +00:00
|
|
|
void error(std::error_code EC) {
|
2013-04-03 18:31:38 +00:00
|
|
|
if (!EC)
|
2015-07-20 03:23:55 +00:00
|
|
|
return;
|
2015-08-06 21:54:37 +00:00
|
|
|
reportError(EC.message());
|
2012-12-31 16:05:21 +00:00
|
|
|
}
|
|
|
|
|
2013-04-03 18:31:38 +00:00
|
|
|
bool relocAddressLess(RelocationRef a, RelocationRef b) {
|
2015-07-06 15:53:43 +00:00
|
|
|
return a.getOffset() < b.getOffset();
|
2012-12-31 16:29:44 +00:00
|
|
|
}
|
|
|
|
|
2013-04-03 18:31:38 +00:00
|
|
|
} // namespace llvm
|
2012-03-01 01:36:50 +00:00
|
|
|
|
2014-06-13 03:07:50 +00:00
|
|
|
static void reportError(StringRef Input, std::error_code EC) {
|
2013-04-03 18:31:38 +00:00
|
|
|
if (Input == "-")
|
|
|
|
Input = "<stdin>";
|
2012-12-31 16:29:44 +00:00
|
|
|
|
2015-07-20 03:01:49 +00:00
|
|
|
reportError(Twine(Input) + ": " + EC.message());
|
2012-12-31 16:29:44 +00:00
|
|
|
}
|
|
|
|
|
2016-07-14 02:24:01 +00:00
|
|
|
static void reportError(StringRef Input, Error Err) {
|
|
|
|
if (Input == "-")
|
|
|
|
Input = "<stdin>";
|
|
|
|
std::string ErrMsg;
|
|
|
|
{
|
|
|
|
raw_string_ostream ErrStream(ErrMsg);
|
|
|
|
logAllUnhandledErrors(std::move(Err), ErrStream, Input + ": ");
|
|
|
|
}
|
|
|
|
reportError(ErrMsg);
|
|
|
|
}
|
|
|
|
|
2014-06-18 08:47:09 +00:00
|
|
|
static bool isMipsArch(unsigned Arch) {
|
|
|
|
switch (Arch) {
|
|
|
|
case llvm::Triple::mips:
|
|
|
|
case llvm::Triple::mipsel:
|
|
|
|
case llvm::Triple::mips64:
|
|
|
|
case llvm::Triple::mips64el:
|
|
|
|
return true;
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
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()
|
|
|
|
: Allocator(), IDTable(Allocator), TypeTable(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;
|
2016-09-09 17:46:17 +00:00
|
|
|
};
|
|
|
|
}
|
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);
|
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.
|
2018-01-10 00:14:19 +00:00
|
|
|
static void dumpObject(const ObjectFile *Obj, ScopedPrinter &Writer) {
|
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))
|
2013-04-03 18:31:38 +00:00
|
|
|
reportError(Obj->getFileName(), EC);
|
2012-12-31 16:29:44 +00:00
|
|
|
|
2016-02-10 20:40:55 +00:00
|
|
|
if (opts::Output == opts::LLVM) {
|
2018-01-10 00:14:19 +00:00
|
|
|
Writer.startLine() << "\n";
|
|
|
|
Writer.printString("File", Obj->getFileName());
|
|
|
|
Writer.printString("Format", Obj->getFileFormatName());
|
|
|
|
Writer.printString("Arch", Triple::getArchTypeName(
|
|
|
|
(llvm::Triple::ArchType)Obj->getArch()));
|
|
|
|
Writer.printString("AddressSize",
|
|
|
|
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();
|
2013-04-03 18:31:38 +00:00
|
|
|
if (opts::Relocations)
|
|
|
|
Dumper->printRelocations();
|
2015-06-25 21:47:32 +00:00
|
|
|
if (opts::DynRelocs)
|
|
|
|
Dumper->printDynamicRelocations();
|
2013-04-03 18:31:38 +00:00
|
|
|
if (opts::Symbols)
|
|
|
|
Dumper->printSymbols();
|
|
|
|
if (opts::DynamicSymbols)
|
|
|
|
Dumper->printDynamicSymbols();
|
|
|
|
if (opts::UnwindInfo)
|
|
|
|
Dumper->printUnwindInfo();
|
|
|
|
if (opts::DynamicTable)
|
|
|
|
Dumper->printDynamicTable();
|
|
|
|
if (opts::NeededLibraries)
|
|
|
|
Dumper->printNeededLibraries();
|
2013-04-12 04:07:39 +00:00
|
|
|
if (opts::ProgramHeaders)
|
|
|
|
Dumper->printProgramHeaders();
|
2018-06-15 14:15:02 +00:00
|
|
|
if (!opts::StringDump.empty())
|
2018-07-18 18:00:41 +00:00
|
|
|
llvm::for_each(opts::StringDump, [&Dumper, Obj](StringRef SectionName) {
|
|
|
|
Dumper->printSectionAsString(Obj, SectionName);
|
2018-06-15 14:15:02 +00:00
|
|
|
});
|
2018-07-11 10:00:29 +00:00
|
|
|
if (!opts::HexDump.empty())
|
2018-07-25 10:04:37 +00:00
|
|
|
llvm::for_each(opts::HexDump, [&Dumper, Obj](StringRef SectionName) {
|
|
|
|
Dumper->printSectionAsHex(Obj, SectionName);
|
2018-07-11 10:00:29 +00:00
|
|
|
});
|
2015-07-09 22:32:24 +00:00
|
|
|
if (opts::HashTable)
|
|
|
|
Dumper->printHashTable();
|
2015-10-14 12:11:50 +00:00
|
|
|
if (opts::GnuHashTable)
|
|
|
|
Dumper->printGnuHashTable();
|
2015-10-16 23:19:01 +00:00
|
|
|
if (opts::VersionInfo)
|
|
|
|
Dumper->printVersionInfo();
|
2016-01-26 19:46:39 +00:00
|
|
|
if (Obj->isELF()) {
|
2018-01-30 16:29:29 +00:00
|
|
|
if (opts::ELFLinkerOptions)
|
|
|
|
Dumper->printELFLinkerOptions();
|
2016-01-26 19:46:39 +00:00
|
|
|
if (Obj->getArch() == llvm::Triple::arm)
|
|
|
|
if (opts::ARMAttributes)
|
|
|
|
Dumper->printAttributes();
|
|
|
|
if (isMipsArch(Obj->getArch())) {
|
|
|
|
if (opts::MipsPLTGOT)
|
|
|
|
Dumper->printMipsPLTGOT();
|
|
|
|
if (opts::MipsABIFlags)
|
|
|
|
Dumper->printMipsABIFlags();
|
|
|
|
if (opts::MipsReginfo)
|
|
|
|
Dumper->printMipsReginfo();
|
2016-05-04 05:58:57 +00:00
|
|
|
if (opts::MipsOptions)
|
|
|
|
Dumper->printMipsOptions();
|
2016-01-26 19:46:39 +00:00
|
|
|
}
|
|
|
|
if (opts::SectionGroups)
|
|
|
|
Dumper->printGroupSections();
|
2016-04-11 17:15:30 +00:00
|
|
|
if (opts::HashHistogram)
|
|
|
|
Dumper->printHashHistogram();
|
[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();
|
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)
|
2017-03-24 17:26:38 +00:00
|
|
|
Dumper->mergeCodeViewTypes(CVTypes.IDTable, CVTypes.TypeTable);
|
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();
|
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) {
|
|
|
|
if (auto E = isNotObjectErrorInvalidFileType(ChildOrErr.takeError())) {
|
2017-05-10 14:18:11 +00:00
|
|
|
reportError(Arc->getFileName(), ChildOrErr.takeError());
|
2016-05-17 17:10:12 +00:00
|
|
|
}
|
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()))
|
2018-01-10 00:14:19 +00:00
|
|
|
dumpObject(Obj, Writer);
|
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
|
|
|
|
reportError(Arc->getFileName(), readobj_error::unrecognized_file_format);
|
2012-03-01 01:36:50 +00:00
|
|
|
}
|
2016-07-14 02:24:01 +00:00
|
|
|
if (Err)
|
|
|
|
reportError(Arc->getFileName(), std::move(Err));
|
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);
|
2016-05-31 20:35:34 +00:00
|
|
|
else if (auto E = isNotObjectErrorInvalidFileType(ObjOrErr.takeError())) {
|
2017-05-10 14:18:11 +00:00
|
|
|
reportError(UBinary->getFileName(), ObjOrErr.takeError());
|
2016-05-31 20:35:34 +00:00
|
|
|
}
|
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;
|
2017-09-20 18:33:35 +00:00
|
|
|
static void dumpWindowsResourceFile(WindowsResource *WinRes) {
|
|
|
|
ScopedPrinter Printer{outs()};
|
|
|
|
WindowsRes::Dumper Dumper(WinRes, Printer);
|
|
|
|
if (auto Err = Dumper.printData())
|
|
|
|
reportError(WinRes->getFileName(), std::move(Err));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-05-01 16:10:38 +00:00
|
|
|
/// Opens \a File and dumps it.
|
2013-04-03 18:31:38 +00:00
|
|
|
static void dumpInput(StringRef File) {
|
2018-01-10 00:14:19 +00:00
|
|
|
ScopedPrinter Writer(outs());
|
2012-03-01 01:36:50 +00:00
|
|
|
|
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)
|
2017-05-10 14:18:11 +00:00
|
|
|
reportError(File, BinaryOrErr.takeError());
|
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))
|
|
|
|
dumpWindowsResourceFile(WinRes);
|
2013-04-03 18:31:38 +00:00
|
|
|
else
|
|
|
|
reportError(File, readobj_error::unrecognized_file_format);
|
|
|
|
}
|
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);
|
|
|
|
}
|
|
|
|
|
|
|
|
/// 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"),
|
|
|
|
cl::aliasopt(opts::Symbols), cl::NotHidden);
|
|
|
|
}
|
|
|
|
|
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);
|
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
|
|
|
|
[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;
|
|
|
|
}
|
|
|
|
|
2013-04-03 18:31:38 +00:00
|
|
|
// Default to stdin if no filename is specified.
|
2017-11-30 18:33:34 +00:00
|
|
|
if (opts::InputFilenames.size() == 0)
|
|
|
|
opts::InputFilenames.push_back("-");
|
|
|
|
|
|
|
|
llvm::for_each(opts::InputFilenames, dumpInput);
|
|
|
|
|
|
|
|
if (opts::CodeViewMergedTypes) {
|
|
|
|
ScopedPrinter W(outs());
|
2017-03-24 17:26:38 +00:00
|
|
|
dumpCodeViewMergedTypes(W, CVTypes.IDTable, CVTypes.TypeTable);
|
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
|
|
|
}
|