From b1347c6e6a8ce4002b8b92805d357b2afae1f8fd Mon Sep 17 00:00:00 2001 From: Rui Ueyama Date: Tue, 4 Mar 2014 03:08:45 +0000 Subject: [PATCH] llvm-objdump: Split printRuntimeFunction to two small functions. No functionality change. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@202781 91177308-0d34-0410-b5e6-96231b3b80d8 --- tools/llvm-objdump/COFFDump.cpp | 90 +++++++++++++++++---------------- 1 file changed, 46 insertions(+), 44 deletions(-) diff --git a/tools/llvm-objdump/COFFDump.cpp b/tools/llvm-objdump/COFFDump.cpp index 74d4e369597..ba5de46b9f6 100644 --- a/tools/llvm-objdump/COFFDump.cpp +++ b/tools/llvm-objdump/COFFDump.cpp @@ -413,50 +413,7 @@ static bool getPDataSection(const COFFObjectFile *Obj, return false; } -static void printRuntimeFunction(const COFFObjectFile *Obj, - const RuntimeFunction &RF, - uint64_t SectionOffset, - const std::vector &Rels) { - outs() << "Function Table:\n"; - - outs() << " Start Address: "; - printCOFFSymbolAddress(outs(), Rels, - SectionOffset + - /*offsetof(RuntimeFunction, StartAddress)*/ 0, - RF.StartAddress); - outs() << "\n"; - - outs() << " End Address: "; - printCOFFSymbolAddress(outs(), Rels, - SectionOffset + - /*offsetof(RuntimeFunction, EndAddress)*/ 4, - RF.EndAddress); - outs() << "\n"; - - outs() << " Unwind Info Address: "; - printCOFFSymbolAddress(outs(), Rels, - SectionOffset + - /*offsetof(RuntimeFunction, UnwindInfoOffset)*/ 8, - RF.UnwindInfoOffset); - outs() << "\n"; - - ArrayRef XContents; - uint64_t UnwindInfoOffset = 0; - if (error(getSectionContents( - Obj, Rels, SectionOffset + - /*offsetof(RuntimeFunction, UnwindInfoOffset)*/ 8, - XContents, UnwindInfoOffset))) - return; - if (XContents.empty()) - return; - - UnwindInfoOffset += RF.UnwindInfoOffset; - if (UnwindInfoOffset > XContents.size()) - return; - - const Win64EH::UnwindInfo *UI = reinterpret_cast( - XContents.data() + UnwindInfoOffset); - +static void printWin64EHUnwindInfo(const Win64EH::UnwindInfo *UI) { // The casts to int are required in order to output the value as number. // Without the casts the value would be interpreted as char data (which // results in garbage output). @@ -496,6 +453,51 @@ static void printRuntimeFunction(const COFFObjectFile *Obj, outs().flush(); } +static void printRuntimeFunction(const COFFObjectFile *Obj, + const RuntimeFunction &RF, + uint64_t SectionOffset, + const std::vector &Rels) { + outs() << "Function Table:\n"; + outs() << " Start Address: "; + printCOFFSymbolAddress(outs(), Rels, + SectionOffset + + /*offsetof(RuntimeFunction, StartAddress)*/ 0, + RF.StartAddress); + outs() << "\n"; + + outs() << " End Address: "; + printCOFFSymbolAddress(outs(), Rels, + SectionOffset + + /*offsetof(RuntimeFunction, EndAddress)*/ 4, + RF.EndAddress); + outs() << "\n"; + + outs() << " Unwind Info Address: "; + printCOFFSymbolAddress(outs(), Rels, + SectionOffset + + /*offsetof(RuntimeFunction, UnwindInfoOffset)*/ 8, + RF.UnwindInfoOffset); + outs() << "\n"; + + ArrayRef XContents; + uint64_t UnwindInfoOffset = 0; + if (error(getSectionContents( + Obj, Rels, SectionOffset + + /*offsetof(RuntimeFunction, UnwindInfoOffset)*/ 8, + XContents, UnwindInfoOffset))) + return; + if (XContents.empty()) + return; + + UnwindInfoOffset += RF.UnwindInfoOffset; + if (UnwindInfoOffset > XContents.size()) + return; + + const Win64EH::UnwindInfo *UI = reinterpret_cast( + XContents.data() + UnwindInfoOffset); + printWin64EHUnwindInfo(UI); +} + void llvm::printCOFFUnwindInfo(const COFFObjectFile *Obj) { const coff_file_header *Header; if (error(Obj->getCOFFHeader(Header)))