diff options
author | dim <dim@FreeBSD.org> | 2016-12-26 20:36:37 +0000 |
---|---|---|
committer | dim <dim@FreeBSD.org> | 2016-12-26 20:36:37 +0000 |
commit | 06210ae42d418d50d8d9365d5c9419308ae9e7ee (patch) | |
tree | ab60b4cdd6e430dda1f292a46a77ddb744723f31 /contrib/llvm/tools/llvm-readobj/llvm-readobj.cpp | |
parent | 2dd166267f53df1c3748b4325d294b9b839de74b (diff) | |
download | FreeBSD-src-06210ae42d418d50d8d9365d5c9419308ae9e7ee.zip FreeBSD-src-06210ae42d418d50d8d9365d5c9419308ae9e7ee.tar.gz |
MFC r309124:
Upgrade our copies of clang, llvm, lldb, compiler-rt and libc++ to 3.9.0
release, and add lld 3.9.0. Also completely revamp the build system for
clang, llvm, lldb and their related tools.
Please note that from 3.5.0 onwards, clang, llvm and lldb require C++11
support to build; see UPDATING for more information.
Release notes for llvm, clang and lld are available here:
<http://llvm.org/releases/3.9.0/docs/ReleaseNotes.html>
<http://llvm.org/releases/3.9.0/tools/clang/docs/ReleaseNotes.html>
<http://llvm.org/releases/3.9.0/tools/lld/docs/ReleaseNotes.html>
Thanks to Ed Maste, Bryan Drewery, Andrew Turner, Antoine Brodin and Jan
Beich for their help.
Relnotes: yes
MFC r309147:
Pull in r282174 from upstream llvm trunk (by Krzysztof Parzyszek):
[PPC] Set SP after loading data from stack frame, if no red zone is
present
Follow-up to r280705: Make sure that the SP is only restored after
all data is loaded from the stack frame, if there is no red zone.
This completes the fix for
https://llvm.org/bugs/show_bug.cgi?id=26519.
Differential Revision: https://reviews.llvm.org/D24466
Reported by: Mark Millard
PR: 214433
MFC r309149:
Pull in r283060 from upstream llvm trunk (by Hal Finkel):
[PowerPC] Refactor soft-float support, and enable PPC64 soft float
This change enables soft-float for PowerPC64, and also makes
soft-float disable all vector instruction sets for both 32-bit and
64-bit modes. This latter part is necessary because the PPC backend
canonicalizes many Altivec vector types to floating-point types, and
so soft-float breaks scalarization support for many operations. Both
for embedded targets and for operating-system kernels desiring
soft-float support, it seems reasonable that disabling hardware
floating-point also disables vector instructions (embedded targets
without hardware floating point support are unlikely to have Altivec,
etc. and operating system kernels desiring not to use floating-point
registers to lower syscall cost are unlikely to want to use vector
registers either). If someone needs this to work, we'll need to
change the fact that we promote many Altivec operations to act on
v4f32. To make it possible to disable Altivec when soft-float is
enabled, hardware floating-point support needs to be expressed as a
positive feature, like the others, and not a negative feature,
because target features cannot have dependencies on the disabling of
some other feature. So +soft-float has now become -hard-float.
Fixes PR26970.
Pull in r283061 from upstream clang trunk (by Hal Finkel):
[PowerPC] Enable soft-float for PPC64, and +soft-float -> -hard-float
Enable soft-float support on PPC64, as the backend now supports it.
Also, the backend now uses -hard-float instead of +soft-float, so set
the target features accordingly.
Fixes PR26970.
Reported by: Mark Millard
PR: 214433
MFC r309212:
Add a few missed clang 3.9.0 files to OptionalObsoleteFiles.
MFC r309262:
Fix packaging for clang, lldb and lld 3.9.0
During the upgrade of clang/llvm etc to 3.9.0 in r309124, the PACKAGE
directive in the usr.bin/clang/*.mk files got dropped accidentally.
Restore it, with a few minor changes and additions:
* Correct license in clang.ucl to NCSA
* Add PACKAGE=clang for clang and most of the "ll" tools
* Put lldb in its own package
* Put lld in its own package
Reviewed by: gjb, jmallett
Differential Revision: https://reviews.freebsd.org/D8666
MFC r309656:
During the bootstrap phase, when building the minimal llvm library on
PowerPC, add lib/Support/Atomic.cpp. This is needed because upstream
llvm revision r271821 disabled the use of std::call_once, which causes
some fallback functions from Atomic.cpp to be used instead.
Reported by: Mark Millard
PR: 214902
MFC r309835:
Tentatively apply https://reviews.llvm.org/D18730 to work around gcc PR
70528 (bogus error: constructor required before non-static data member).
This should fix buildworld with the external gcc package.
Reported by: https://jenkins.freebsd.org/job/FreeBSD_HEAD_amd64_gcc/
MFC r310194:
Upgrade our copies of clang, llvm, lld, lldb, compiler-rt and libc++ to
3.9.1 release.
Please note that from 3.5.0 onwards, clang, llvm and lldb require C++11
support to build; see UPDATING for more information.
Release notes for llvm, clang and lld will be available here:
<http://releases.llvm.org/3.9.1/docs/ReleaseNotes.html>
<http://releases.llvm.org/3.9.1/tools/clang/docs/ReleaseNotes.html>
<http://releases.llvm.org/3.9.1/tools/lld/docs/ReleaseNotes.html>
Relnotes: yes
Diffstat (limited to 'contrib/llvm/tools/llvm-readobj/llvm-readobj.cpp')
-rw-r--r-- | contrib/llvm/tools/llvm-readobj/llvm-readobj.cpp | 149 |
1 files changed, 110 insertions, 39 deletions
diff --git a/contrib/llvm/tools/llvm-readobj/llvm-readobj.cpp b/contrib/llvm/tools/llvm-readobj/llvm-readobj.cpp index fa8fee2..c293919 100644 --- a/contrib/llvm/tools/llvm-readobj/llvm-readobj.cpp +++ b/contrib/llvm/tools/llvm-readobj/llvm-readobj.cpp @@ -22,7 +22,7 @@ #include "llvm-readobj.h" #include "Error.h" #include "ObjDumper.h" -#include "StreamWriter.h" +#include "llvm/DebugInfo/CodeView/MemoryTypeTableBuilder.h" #include "llvm/Object/Archive.h" #include "llvm/Object/COFFImportFile.h" #include "llvm/Object/ELFObjectFile.h" @@ -35,6 +35,7 @@ #include "llvm/Support/FileSystem.h" #include "llvm/Support/ManagedStatic.h" #include "llvm/Support/PrettyStackTrace.h" +#include "llvm/Support/ScopedPrinter.h" #include "llvm/Support/Signals.h" #include "llvm/Support/TargetRegistry.h" #include "llvm/Support/TargetSelect.h" @@ -144,6 +145,11 @@ namespace opts { cl::opt<bool> CodeView("codeview", cl::desc("Display CodeView debug information")); + // -codeview-merged-types + cl::opt<bool> + CodeViewMergedTypes("codeview-merged-types", + cl::desc("Display the merged CodeView type stream")); + // -codeview-subsection-bytes cl::opt<bool> CodeViewSubsectionBytes( "codeview-subsection-bytes", @@ -168,6 +174,10 @@ namespace opts { cl::opt<bool> MipsReginfo("mips-reginfo", cl::desc("Display the MIPS .reginfo section")); + // -mips-options + cl::opt<bool> MipsOptions("mips-options", + cl::desc("Display the MIPS .MIPS.options section")); + // -coff-imports cl::opt<bool> COFFImports("coff-imports", cl::desc("Display the PE/COFF import table")); @@ -186,6 +196,11 @@ namespace opts { COFFBaseRelocs("coff-basereloc", cl::desc("Display the PE/COFF .reloc section")); + // -coff-debug-directory + cl::opt<bool> + COFFDebugDirectory("coff-debug-directory", + cl::desc("Display the PE/COFF debug directory")); + // -macho-data-in-code cl::opt<bool> MachODataInCode("macho-data-in-code", @@ -227,6 +242,22 @@ namespace opts { cl::desc("Display ELF version sections (if present)")); cl::alias VersionInfoShort("V", cl::desc("Alias for -version-info"), cl::aliasopt(VersionInfo)); + + cl::opt<bool> SectionGroups("elf-section-groups", + cl::desc("Display ELF section group contents")); + cl::alias SectionGroupsShort("g", cl::desc("Alias for -elf-sections-groups"), + cl::aliasopt(SectionGroups)); + 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)); + + cl::opt<OutputStyleTy> + Output("elf-output-style", cl::desc("Specify ELF dump style"), + cl::values(clEnumVal(LLVM, "LLVM default style"), + clEnumVal(GNU, "GNU readelf style"), clEnumValEnd), + cl::init(LLVM)); } // namespace opts namespace llvm { @@ -264,6 +295,17 @@ static void reportError(StringRef Input, StringRef Message) { reportError(Twine(Input) + ": " + Message); } +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); +} + static bool isMipsArch(unsigned Arch) { switch (Arch) { case llvm::Triple::mips: @@ -276,8 +318,11 @@ static bool isMipsArch(unsigned Arch) { } } +static llvm::codeview::MemoryTypeTableBuilder CVTypes; + /// @brief Creates an format-specific object file dumper. -static std::error_code createDumper(const ObjectFile *Obj, StreamWriter &Writer, +static std::error_code createDumper(const ObjectFile *Obj, + ScopedPrinter &Writer, std::unique_ptr<ObjDumper> &Result) { if (!Obj) return readobj_error::unsupported_file_format; @@ -294,19 +339,20 @@ static std::error_code createDumper(const ObjectFile *Obj, StreamWriter &Writer, /// @brief Dumps the specified object file. static void dumpObject(const ObjectFile *Obj) { - StreamWriter Writer(outs()); + ScopedPrinter Writer(outs()); std::unique_ptr<ObjDumper> Dumper; if (std::error_code EC = createDumper(Obj, Writer, Dumper)) reportError(Obj->getFileName(), EC); - outs() << '\n'; - outs() << "File: " << Obj->getFileName() << "\n"; - outs() << "Format: " << Obj->getFileFormatName() << "\n"; - outs() << "Arch: " - << Triple::getArchTypeName((llvm::Triple::ArchType)Obj->getArch()) - << "\n"; - outs() << "AddressSize: " << (8*Obj->getBytesInAddress()) << "bit\n"; - Dumper->printLoadName(); + if (opts::Output == opts::LLVM) { + outs() << '\n'; + outs() << "File: " << Obj->getFileName() << "\n"; + outs() << "Format: " << Obj->getFileFormatName() << "\n"; + outs() << "Arch: " << Triple::getArchTypeName( + (llvm::Triple::ArchType)Obj->getArch()) << "\n"; + outs() << "AddressSize: " << (8 * Obj->getBytesInAddress()) << "bit\n"; + Dumper->printLoadName(); + } if (opts::FileHeaders) Dumper->printFileHeaders(); @@ -334,16 +380,24 @@ static void dumpObject(const ObjectFile *Obj) { Dumper->printGnuHashTable(); if (opts::VersionInfo) Dumper->printVersionInfo(); - if (Obj->getArch() == llvm::Triple::arm && Obj->isELF()) - if (opts::ARMAttributes) - Dumper->printAttributes(); - if (isMipsArch(Obj->getArch()) && Obj->isELF()) { - if (opts::MipsPLTGOT) - Dumper->printMipsPLTGOT(); - if (opts::MipsABIFlags) - Dumper->printMipsABIFlags(); - if (opts::MipsReginfo) - Dumper->printMipsReginfo(); + if (Obj->isELF()) { + 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(); + if (opts::MipsOptions) + Dumper->printMipsOptions(); + } + if (opts::SectionGroups) + Dumper->printGroupSections(); + if (opts::HashHistogram) + Dumper->printHashHistogram(); } if (Obj->isCOFF()) { if (opts::COFFImports) @@ -354,8 +408,12 @@ static void dumpObject(const ObjectFile *Obj) { Dumper->printCOFFDirectives(); if (opts::COFFBaseRelocs) Dumper->printCOFFBaseReloc(); + if (opts::COFFDebugDirectory) + Dumper->printCOFFDebugDirectory(); if (opts::CodeView) Dumper->printCodeViewDebugInfo(); + if (opts::CodeViewMergedTypes) + Dumper->mergeCodeViewTypes(CVTypes); } if (Obj->isMachO()) { if (opts::MachODataInCode) @@ -377,35 +435,43 @@ static void dumpObject(const ObjectFile *Obj) { /// @brief Dumps each object file in \a Arc; static void dumpArchive(const Archive *Arc) { - for (auto &ErrorOrChild : Arc->children()) { - if (std::error_code EC = ErrorOrChild.getError()) - reportError(Arc->getFileName(), EC.message()); - const auto &Child = *ErrorOrChild; - ErrorOr<std::unique_ptr<Binary>> ChildOrErr = Child.getAsBinary(); - if (std::error_code EC = ChildOrErr.getError()) { - // Ignore non-object files. - if (EC != object_error::invalid_file_type) - reportError(Arc->getFileName(), EC.message()); + Error Err; + for (auto &Child : Arc->children(Err)) { + Expected<std::unique_ptr<Binary>> ChildOrErr = Child.getAsBinary(); + if (!ChildOrErr) { + if (auto E = isNotObjectErrorInvalidFileType(ChildOrErr.takeError())) { + std::string Buf; + raw_string_ostream OS(Buf); + logAllUnhandledErrors(ChildOrErr.takeError(), OS, ""); + OS.flush(); + reportError(Arc->getFileName(), Buf); + } continue; } - if (ObjectFile *Obj = dyn_cast<ObjectFile>(&*ChildOrErr.get())) dumpObject(Obj); else reportError(Arc->getFileName(), readobj_error::unrecognized_file_format); } + if (Err) + reportError(Arc->getFileName(), std::move(Err)); } /// @brief Dumps each object file in \a MachO Universal Binary; static void dumpMachOUniversalBinary(const MachOUniversalBinary *UBinary) { for (const MachOUniversalBinary::ObjectForArch &Obj : UBinary->objects()) { - ErrorOr<std::unique_ptr<MachOObjectFile>> ObjOrErr = Obj.getAsObjectFile(); + Expected<std::unique_ptr<MachOObjectFile>> ObjOrErr = Obj.getAsObjectFile(); if (ObjOrErr) dumpObject(&*ObjOrErr.get()); - else if (ErrorOr<std::unique_ptr<Archive>> AOrErr = Obj.getAsArchive()) + else if (auto E = isNotObjectErrorInvalidFileType(ObjOrErr.takeError())) { + std::string Buf; + raw_string_ostream OS(Buf); + logAllUnhandledErrors(ObjOrErr.takeError(), OS, ""); + OS.flush(); + reportError(UBinary->getFileName(), Buf); + } + else if (Expected<std::unique_ptr<Archive>> AOrErr = Obj.getAsArchive()) dumpArchive(&*AOrErr.get()); - else - reportError(UBinary->getFileName(), ObjOrErr.getError().message()); } } @@ -413,9 +479,9 @@ static void dumpMachOUniversalBinary(const MachOUniversalBinary *UBinary) { static void dumpInput(StringRef File) { // Attempt to open the binary. - ErrorOr<OwningBinary<Binary>> BinaryOrErr = createBinary(File); - if (std::error_code EC = BinaryOrErr.getError()) - reportError(File, EC); + Expected<OwningBinary<Binary>> BinaryOrErr = createBinary(File); + if (!BinaryOrErr) + reportError(File, errorToErrorCode(BinaryOrErr.takeError())); Binary &Binary = *BinaryOrErr.get().getBinary(); if (Archive *Arc = dyn_cast<Archive>(&Binary)) @@ -432,7 +498,7 @@ static void dumpInput(StringRef File) { } int main(int argc, const char *argv[]) { - sys::PrintStackTraceOnErrorSignal(); + sys::PrintStackTraceOnErrorSignal(argv[0]); PrettyStackTraceProgram X(argc, argv); llvm_shutdown_obj Y; @@ -448,5 +514,10 @@ int main(int argc, const char *argv[]) { std::for_each(opts::InputFilenames.begin(), opts::InputFilenames.end(), dumpInput); + if (opts::CodeViewMergedTypes) { + ScopedPrinter W(outs()); + dumpCodeViewMergedTypes(W, CVTypes); + } + return 0; } |