<div dir="ltr">Integrating an addition would be better to isolate the patch</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Feb 27, 2019 at 5:06 PM Alexey Lapshin <<a href="mailto:a.v.lapshin@mail.ru">a.v.lapshin@mail.ru</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div><div class="gmail-m_-1667393507495084419js-helper gmail-m_-1667393507495084419js-readmsg-msg">
<div>
<div id="gmail-m_-1667393507495084419style_15512832040000000352_BODY"><div class="gmail-m_-1667393507495084419class_1551285425">
Sure, I will.<br><br>Do you know how it would be better to do ? I mean should I revert and resubmit patch or just integrate an addition ? <br><br>Thank you, Alexey.<br><br><br><blockquote style="border-left:1px solid rgb(8,87,166);margin:10px;padding:0px 0px 0px 10px">
Среда, 27 февраля 2019, 18:05 +03:00 от Kadir Çetinkaya <<a href="mailto:kadircet@google.com" target="_blank">kadircet@google.com</a>>:<br>
<br>
<div id="gmail-m_-1667393507495084419">
<div class="gmail-m_-1667393507495084419js-helper_mailru_css_attribute_postfix gmail-m_-1667393507495084419js-readmsg-msg_mailru_css_attribute_postfix">
<div>
<div id="gmail-m_-1667393507495084419style_15512799550000000650_BODY_mailru_css_attribute_postfix"><div class="gmail-m_-1667393507495084419class_1551314044_mailru_css_attribute_postfix"><div dir="ltr"><div dir="ltr">Hey, this patch is breaking the compiler-rt builds, could you also update the call sites in file: <a href="https://github.com/llvm-project/compiler-rt/blob/master/lib/sanitizer_common/symbolizer/sanitizer_symbolize.cc#L55" rel="noopener noreferrer" target="_blank">https://github.com/llvm-project/compiler-rt/blob/master/lib/sanitizer_common/symbolizer/sanitizer_symbolize.cc#L55</a><br></div></div><br><div class="gmail-m_-1667393507495084419gmail_quote_mailru_css_attribute_postfix_mailru_css_attribute_postfix"><div class="gmail-m_-1667393507495084419gmail_attr_mailru_css_attribute_postfix_mailru_css_attribute_postfix" dir="ltr">On Wed, Feb 27, 2019 at 2:16 PM Alexey Lapshin via llvm-commits <<a href="http://e.mail.ru/compose/?mailto=mailto%3allvm%2dcommits@lists.llvm.org" rel="noopener noreferrer" target="_blank">llvm-commits@lists.llvm.org</a>> wrote:<br></div><blockquote style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex" class="gmail-m_-1667393507495084419gmail_quote_mailru_css_attribute_postfix_mailru_css_attribute_postfix">Author: avl<br>
Date: Wed Feb 27 05:17:36 2019<br>
New Revision: 354972<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=354972&view=rev" rel="noopener noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=354972&view=rev</a><br>
Log:<br>
[DebugInfo] add SectionedAddress to DebugInfo interfaces.<br>
<br>
That patch is the fix for <a href="https://bugs.llvm.org/show_bug.cgi?id=40703" rel="noopener noreferrer" target="_blank">https://bugs.llvm.org/show_bug.cgi?id=40703</a><br>
"wrong line number info for obj file compiled with -ffunction-sections"<br>
bug. The problem happened with only .o files. If object file contains<br>
several .text sections then line number information showed incorrectly.<br>
The reason for this is that DwarfLineTable could not detect section which<br>
corresponds to specified address(because address is the local to the<br>
section). And as the result it could not select proper sequence in the<br>
line table. The fix is to pass SectionIndex with the address. So that it<br>
would be possible to differentiate addresses from various sections. With<br>
this fix llvm-objdump shows correct line numbers for disassembled code.<br>
<br>
Differential review: <a href="https://reviews.llvm.org/D58194" rel="noopener noreferrer" target="_blank">https://reviews.llvm.org/D58194</a><br>
<br>
Added:<br>
llvm/trunk/test/tools/llvm-objdump/X86/function-sections-line-numbers.s<br>
Modified:<br>
llvm/trunk/include/llvm/DebugInfo/DIContext.h<br>
llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFContext.h<br>
llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFDebugLine.h<br>
llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFDebugRangeList.h<br>
llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFDebugRnglists.h<br>
llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFFormValue.h<br>
llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFListTable.h<br>
llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFSection.h<br>
llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFUnit.h<br>
llvm/trunk/include/llvm/DebugInfo/PDB/PDBContext.h<br>
llvm/trunk/include/llvm/DebugInfo/Symbolize/SymbolizableModule.h<br>
llvm/trunk/include/llvm/DebugInfo/Symbolize/Symbolize.h<br>
llvm/trunk/include/llvm/Object/ObjectFile.h<br>
llvm/trunk/lib/DebugInfo/DWARF/DWARFContext.cpp<br>
llvm/trunk/lib/DebugInfo/DWARF/DWARFDataExtractor.cpp<br>
llvm/trunk/lib/DebugInfo/DWARF/DWARFDebugLine.cpp<br>
llvm/trunk/lib/DebugInfo/DWARF/DWARFDebugRangeList.cpp<br>
llvm/trunk/lib/DebugInfo/DWARF/DWARFDebugRnglists.cpp<br>
llvm/trunk/lib/DebugInfo/DWARF/DWARFDie.cpp<br>
llvm/trunk/lib/DebugInfo/DWARF/DWARFFormValue.cpp<br>
llvm/trunk/lib/DebugInfo/DWARF/DWARFUnit.cpp<br>
llvm/trunk/lib/DebugInfo/DWARF/DWARFVerifier.cpp<br>
llvm/trunk/lib/DebugInfo/PDB/PDBContext.cpp<br>
llvm/trunk/lib/DebugInfo/Symbolize/SymbolizableObjectFile.cpp<br>
llvm/trunk/lib/DebugInfo/Symbolize/SymbolizableObjectFile.h<br>
llvm/trunk/lib/DebugInfo/Symbolize/Symbolize.cpp<br>
llvm/trunk/tools/dsymutil/DwarfLinker.cpp<br>
llvm/trunk/tools/dsymutil/DwarfStreamer.cpp<br>
llvm/trunk/tools/llvm-cfi-verify/lib/FileAnalysis.cpp<br>
llvm/trunk/tools/llvm-cfi-verify/lib/FileAnalysis.h<br>
llvm/trunk/tools/llvm-cfi-verify/lib/GraphBuilder.cpp<br>
llvm/trunk/tools/llvm-cfi-verify/lib/GraphBuilder.h<br>
llvm/trunk/tools/llvm-cfi-verify/llvm-cfi-verify.cpp<br>
llvm/trunk/tools/llvm-dwarfdump/llvm-dwarfdump.cpp<br>
llvm/trunk/tools/llvm-objdump/MachODump.cpp<br>
llvm/trunk/tools/llvm-objdump/llvm-objdump.cpp<br>
llvm/trunk/tools/llvm-rtdyld/llvm-rtdyld.cpp<br>
llvm/trunk/tools/llvm-symbolizer/llvm-symbolizer.cpp<br>
llvm/trunk/tools/llvm-xray/func-id-helper.cpp<br>
llvm/trunk/tools/sancov/sancov.cpp<br>
llvm/trunk/tools/sanstats/sanstats.cpp<br>
llvm/trunk/unittests/tools/llvm-cfi-verify/FileAnalysis.cpp<br>
llvm/trunk/unittests/tools/llvm-cfi-verify/GraphBuilder.cpp<br>
<br>
Modified: llvm/trunk/include/llvm/DebugInfo/DIContext.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/DIContext.h?rev=354972&r1=354971&r2=354972&view=diff" rel="noopener noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/DIContext.h?rev=354972&r1=354971&r2=354972&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/include/llvm/DebugInfo/DIContext.h (original)<br>
+++ llvm/trunk/include/llvm/DebugInfo/DIContext.h Wed Feb 27 05:17:36 2019<br>
@@ -203,11 +203,14 @@ public:<br>
return true;<br>
}<br>
<br>
- virtual DILineInfo getLineInfoForAddress(uint64_t Address,<br>
+ virtual DILineInfo getLineInfoForAddress(<br>
+ object::SectionedAddress Address,<br>
DILineInfoSpecifier Specifier = DILineInfoSpecifier()) = 0;<br>
- virtual DILineInfoTable getLineInfoForAddressRange(uint64_t Address,<br>
- uint64_t Size, DILineInfoSpecifier Specifier = DILineInfoSpecifier()) = 0;<br>
- virtual DIInliningInfo getInliningInfoForAddress(uint64_t Address,<br>
+ virtual DILineInfoTable getLineInfoForAddressRange(<br>
+ object::SectionedAddress Address, uint64_t Size,<br>
+ DILineInfoSpecifier Specifier = DILineInfoSpecifier()) = 0;<br>
+ virtual DIInliningInfo getInliningInfoForAddress(<br>
+ object::SectionedAddress Address,<br>
DILineInfoSpecifier Specifier = DILineInfoSpecifier()) = 0;<br>
<br>
private:<br>
<br>
Modified: llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFContext.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFContext.h?rev=354972&r1=354971&r2=354972&view=diff" rel="noopener noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFContext.h?rev=354972&r1=354971&r2=354972&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFContext.h (original)<br>
+++ llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFContext.h Wed Feb 27 05:17:36 2019<br>
@@ -317,13 +317,18 @@ public:<br>
<br>
/// Get the compilation unit, the function DIE and lexical block DIE for the<br>
/// given address where applicable.<br>
+ /// TODO: change input parameter from "uint64_t Address"<br>
+ /// into "SectionedAddress Address"<br>
DIEsForAddress getDIEsForAddress(uint64_t Address);<br>
<br>
- DILineInfo getLineInfoForAddress(uint64_t Address,<br>
+ DILineInfo getLineInfoForAddress(<br>
+ object::SectionedAddress Address,<br>
DILineInfoSpecifier Specifier = DILineInfoSpecifier()) override;<br>
- DILineInfoTable getLineInfoForAddressRange(uint64_t Address, uint64_t Size,<br>
+ DILineInfoTable getLineInfoForAddressRange(<br>
+ object::SectionedAddress Address, uint64_t Size,<br>
DILineInfoSpecifier Specifier = DILineInfoSpecifier()) override;<br>
- DIInliningInfo getInliningInfoForAddress(uint64_t Address,<br>
+ DIInliningInfo getInliningInfoForAddress(<br>
+ object::SectionedAddress Address,<br>
DILineInfoSpecifier Specifier = DILineInfoSpecifier()) override;<br>
<br>
bool isLittleEndian() const { return DObj->isLittleEndian(); }<br>
@@ -366,6 +371,8 @@ public:<br>
private:<br>
/// Return the compile unit which contains instruction with provided<br>
/// address.<br>
+ /// TODO: change input parameter from "uint64_t Address"<br>
+ /// into "SectionedAddress Address"<br>
DWARFCompileUnit *getCompileUnitForAddress(uint64_t Address);<br>
};<br>
<br>
<br>
Modified: llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFDebugLine.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFDebugLine.h?rev=354972&r1=354971&r2=354972&view=diff" rel="noopener noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFDebugLine.h?rev=354972&r1=354971&r2=354972&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFDebugLine.h (original)<br>
+++ llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFDebugLine.h Wed Feb 27 05:17:36 2019<br>
@@ -139,12 +139,16 @@ public:<br>
static void dumpTableHeader(raw_ostream &OS);<br>
<br>
static bool orderByAddress(const Row &LHS, const Row &RHS) {<br>
- return LHS.Address < RHS.Address;<br>
+ return std::tie(LHS.Address.SectionIndex, LHS.Address.Address) <<br>
+ std::tie(RHS.Address.SectionIndex, RHS.Address.Address);<br>
}<br>
<br>
/// The program-counter value corresponding to a machine instruction<br>
- /// generated by the compiler.<br>
- uint64_t Address;<br>
+ /// generated by the compiler and section index pointing to the section<br>
+ /// containg this PC. If relocation information is present then section<br>
+ /// index is the index of the section which contains above address.<br>
+ /// Otherwise this is object::SectionedAddress::Undef value.<br>
+ object::SectionedAddress Address;<br>
/// An unsigned integer indicating a source line number. Lines are numbered<br>
/// beginning at 1. The compiler may emit the value 0 in cases where an<br>
/// instruction cannot be attributed to any source line.<br>
@@ -192,6 +196,10 @@ public:<br>
/// and is described by line table rows [FirstRowIndex, LastRowIndex).<br>
uint64_t LowPC;<br>
uint64_t HighPC;<br>
+ /// If relocation information is present then this is the index of the<br>
+ /// section which contains above addresses. Otherwise this is<br>
+ /// object::SectionedAddress::Undef value.<br>
+ uint64_t SectionIndex;<br>
unsigned FirstRowIndex;<br>
unsigned LastRowIndex;<br>
bool Empty;<br>
@@ -199,14 +207,18 @@ public:<br>
void reset();<br>
<br>
static bool orderByLowPC(const Sequence &LHS, const Sequence &RHS) {<br>
- return LHS.LowPC < RHS.LowPC;<br>
+ return std::tie(LHS.SectionIndex, LHS.LowPC) <<br>
+ std::tie(RHS.SectionIndex, RHS.LowPC);<br>
}<br>
<br>
bool isValid() const {<br>
return !Empty && (LowPC < HighPC) && (FirstRowIndex < LastRowIndex);<br>
}<br>
<br>
- bool containsPC(uint64_t PC) const { return (LowPC <= PC && PC < HighPC); }<br>
+ bool containsPC(object::SectionedAddress PC) const {<br>
+ return SectionIndex == PC.SectionIndex &&<br>
+ (LowPC <= PC.Address && PC.Address < HighPC);<br>
+ }<br>
};<br>
<br>
struct LineTable {<br>
@@ -223,9 +235,9 @@ public:<br>
<br>
/// Returns the index of the row with file/line info for a given address,<br>
/// or UnknownRowIndex if there is no such row.<br>
- uint32_t lookupAddress(uint64_t Address) const;<br>
+ uint32_t lookupAddress(object::SectionedAddress Address) const;<br>
<br>
- bool lookupAddressRange(uint64_t Address, uint64_t Size,<br>
+ bool lookupAddressRange(object::SectionedAddress Address, uint64_t Size,<br>
std::vector<uint32_t> &Result) const;<br>
<br>
bool hasFileAtIndex(uint64_t FileIndex) const;<br>
@@ -238,7 +250,8 @@ public:<br>
<br>
/// Fills the Result argument with the file and line information<br>
/// corresponding to Address. Returns true on success.<br>
- bool getFileLineInfoForAddress(uint64_t Address, const char *CompDir,<br>
+ bool getFileLineInfoForAddress(object::SectionedAddress Address,<br>
+ const char *CompDir,<br>
DILineInfoSpecifier::FileLineInfoKind Kind,<br>
DILineInfo &Result) const;<br>
<br>
@@ -263,10 +276,15 @@ public:<br>
<br>
private:<br>
uint32_t findRowInSeq(const DWARFDebugLine::Sequence &Seq,<br>
- uint64_t Address) const;<br>
+ object::SectionedAddress Address) const;<br>
Optional<StringRef><br>
getSourceByIndex(uint64_t FileIndex,<br>
DILineInfoSpecifier::FileLineInfoKind Kind) const;<br>
+<br>
+ uint32_t lookupAddressImpl(object::SectionedAddress Address) const;<br>
+<br>
+ bool lookupAddressRangeImpl(object::SectionedAddress Address, uint64_t Size,<br>
+ std::vector<uint32_t> &Result) const;<br>
};<br>
<br>
const LineTable *getLineTable(uint32_t Offset) const;<br>
<br>
Modified: llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFDebugRangeList.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFDebugRangeList.h?rev=354972&r1=354971&r2=354972&view=diff" rel="noopener noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFDebugRangeList.h?rev=354972&r1=354971&r2=354972&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFDebugRangeList.h (original)<br>
+++ llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFDebugRangeList.h Wed Feb 27 05:17:36 2019<br>
@@ -76,7 +76,7 @@ public:<br>
/// list. Has to be passed base address of the compile unit referencing this<br>
/// range list.<br>
DWARFAddressRangesVector<br>
- getAbsoluteRanges(llvm::Optional<SectionedAddress> BaseAddr) const;<br>
+ getAbsoluteRanges(llvm::Optional<object::SectionedAddress> BaseAddr) const;<br>
};<br>
<br>
} // end namespace llvm<br>
<br>
Modified: llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFDebugRnglists.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFDebugRnglists.h?rev=354972&r1=354971&r2=354972&view=diff" rel="noopener noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFDebugRnglists.h?rev=354972&r1=354971&r2=354972&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFDebugRnglists.h (original)<br>
+++ llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFDebugRnglists.h Wed Feb 27 05:17:36 2019<br>
@@ -37,7 +37,7 @@ struct RangeListEntry : public DWARFList<br>
Error extract(DWARFDataExtractor Data, uint32_t End, uint32_t *OffsetPtr);<br>
void dump(raw_ostream &OS, uint8_t AddrSize, uint8_t MaxEncodingStringLength,<br>
uint64_t &CurrentBase, DIDumpOptions DumpOpts,<br>
- llvm::function_ref<Optional<SectionedAddress>(uint32_t)><br>
+ llvm::function_ref<Optional<object::SectionedAddress>(uint32_t)><br>
LookupPooledAddress) const;<br>
bool isSentinel() const { return EntryKind == dwarf::DW_RLE_end_of_list; }<br>
};<br>
@@ -47,7 +47,7 @@ class DWARFDebugRnglist : public DWARFLi<br>
public:<br>
/// Build a DWARFAddressRangesVector from a rangelist.<br>
DWARFAddressRangesVector<br>
- getAbsoluteRanges(llvm::Optional<SectionedAddress> BaseAddr,<br>
+ getAbsoluteRanges(llvm::Optional<object::SectionedAddress> BaseAddr,<br>
DWARFUnit &U) const;<br>
};<br>
<br>
<br>
Modified: llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFFormValue.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFFormValue.h?rev=354972&r1=354971&r2=354972&view=diff" rel="noopener noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFFormValue.h?rev=354972&r1=354971&r2=354972&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFFormValue.h (original)<br>
+++ llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFFormValue.h Wed Feb 27 05:17:36 2019<br>
@@ -79,7 +79,7 @@ public:<br>
const DWARFUnit *getUnit() const { return U; }<br>
void dump(raw_ostream &OS, DIDumpOptions DumpOpts = DIDumpOptions()) const;<br>
void dumpSectionedAddress(raw_ostream &OS, DIDumpOptions DumpOpts,<br>
- SectionedAddress SA) const;<br>
+ object::SectionedAddress SA) const;<br>
static void dumpAddressSection(const DWARFObject &Obj, raw_ostream &OS,<br>
DIDumpOptions DumpOpts, uint64_t SectionIndex);<br>
<br>
@@ -108,7 +108,7 @@ public:<br>
Optional<int64_t> getAsSignedConstant() const;<br>
Optional<const char *> getAsCString() const;<br>
Optional<uint64_t> getAsAddress() const;<br>
- Optional<SectionedAddress> getAsSectionedAddress() const;<br>
+ Optional<object::SectionedAddress> getAsSectionedAddress() const;<br>
Optional<uint64_t> getAsSectionOffset() const;<br>
Optional<ArrayRef<uint8_t>> getAsBlock() const;<br>
Optional<uint64_t> getAsCStringOffset() const;<br>
@@ -246,7 +246,7 @@ inline Optional<uint64_t> toAddress(cons<br>
return None;<br>
}<br>
<br>
-inline Optional<SectionedAddress><br>
+inline Optional<object::SectionedAddress><br>
toSectionedAddress(const Optional<DWARFFormValue> &V) {<br>
if (V)<br>
return V->getAsSectionedAddress();<br>
<br>
Modified: llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFListTable.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFListTable.h?rev=354972&r1=354971&r2=354972&view=diff" rel="noopener noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFListTable.h?rev=354972&r1=354971&r2=354972&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFListTable.h (original)<br>
+++ llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFListTable.h Wed Feb 27 05:17:36 2019<br>
@@ -157,7 +157,7 @@ public:<br>
uint8_t getAddrSize() const { return Header.getAddrSize(); }<br>
<br>
void dump(raw_ostream &OS,<br>
- llvm::function_ref<Optional<SectionedAddress>(uint32_t)><br>
+ llvm::function_ref<Optional<object::SectionedAddress>(uint32_t)><br>
LookupPooledAddress,<br>
DIDumpOptions DumpOpts = {}) const;<br>
<br>
@@ -234,7 +234,7 @@ Error DWARFListType<ListEntryType>::extr<br>
template <typename DWARFListType><br>
void DWARFListTableBase<DWARFListType>::dump(<br>
raw_ostream &OS,<br>
- llvm::function_ref<Optional<SectionedAddress>(uint32_t)><br>
+ llvm::function_ref<Optional<object::SectionedAddress>(uint32_t)><br>
LookupPooledAddress,<br>
DIDumpOptions DumpOpts) const {<br>
Header.dump(OS, DumpOpts);<br>
<br>
Modified: llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFSection.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFSection.h?rev=354972&r1=354971&r2=354972&view=diff" rel="noopener noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFSection.h?rev=354972&r1=354971&r2=354972&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFSection.h (original)<br>
+++ llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFSection.h Wed Feb 27 05:17:36 2019<br>
@@ -22,11 +22,6 @@ struct SectionName {<br>
bool IsNameUnique;<br>
};<br>
<br>
-struct SectionedAddress {<br>
- uint64_t Address;<br>
- uint64_t SectionIndex;<br>
-};<br>
-<br>
} // end namespace llvm<br>
<br>
#endif // LLVM_DEBUGINFO_DWARF_DWARFSECTION_H<br>
<br>
Modified: llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFUnit.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFUnit.h?rev=354972&r1=354971&r2=354972&view=diff" rel="noopener noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFUnit.h?rev=354972&r1=354971&r2=354972&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFUnit.h (original)<br>
+++ llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFUnit.h Wed Feb 27 05:17:36 2019<br>
@@ -217,7 +217,7 @@ class DWARFUnit {<br>
Optional<DWARFDebugRnglistTable> RngListTable;<br>
<br>
mutable const DWARFAbbreviationDeclarationSet *Abbrevs;<br>
- llvm::Optional<SectionedAddress> BaseAddr;<br>
+ llvm::Optional<object::SectionedAddress> BaseAddr;<br>
/// The compile unit debug information entry items.<br>
std::vector<DWARFDebugInfoEntry> DieArray;<br>
<br>
@@ -304,7 +304,8 @@ public:<br>
RangeSectionBase = Base;<br>
}<br>
<br>
- Optional<SectionedAddress> getAddrOffsetSectionItem(uint32_t Index) const;<br>
+ Optional<object::SectionedAddress><br>
+ getAddrOffsetSectionItem(uint32_t Index) const;<br>
Optional<uint64_t> getStringOffsetSectionItem(uint32_t Index) const;<br>
<br>
DWARFDataExtractor getDebugInfoExtractor() const;<br>
@@ -375,7 +376,7 @@ public:<br>
llvm_unreachable("Invalid UnitType.");<br>
}<br>
<br>
- llvm::Optional<SectionedAddress> getBaseAddress();<br>
+ llvm::Optional<object::SectionedAddress> getBaseAddress();<br>
<br>
DWARFDie getUnitDIE(bool ExtractUnitDIEOnly = true) {<br>
extractDIEsIfNeeded(ExtractUnitDIEOnly);<br>
<br>
Modified: llvm/trunk/include/llvm/DebugInfo/PDB/PDBContext.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/PDB/PDBContext.h?rev=354972&r1=354971&r2=354972&view=diff" rel="noopener noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/PDB/PDBContext.h?rev=354972&r1=354971&r2=354972&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/include/llvm/DebugInfo/PDB/PDBContext.h (original)<br>
+++ llvm/trunk/include/llvm/DebugInfo/PDB/PDBContext.h Wed Feb 27 05:17:36 2019<br>
@@ -43,13 +43,13 @@ namespace pdb {<br>
void dump(raw_ostream &OS, DIDumpOptions DIDumpOpts) override;<br>
<br>
DILineInfo getLineInfoForAddress(<br>
- uint64_t Address,<br>
+ object::SectionedAddress Address,<br>
DILineInfoSpecifier Specifier = DILineInfoSpecifier()) override;<br>
DILineInfoTable getLineInfoForAddressRange(<br>
- uint64_t Address, uint64_t Size,<br>
+ object::SectionedAddress Address, uint64_t Size,<br>
DILineInfoSpecifier Specifier = DILineInfoSpecifier()) override;<br>
DIInliningInfo getInliningInfoForAddress(<br>
- uint64_t Address,<br>
+ object::SectionedAddress Address,<br>
DILineInfoSpecifier Specifier = DILineInfoSpecifier()) override;<br>
<br>
private:<br>
<br>
Modified: llvm/trunk/include/llvm/DebugInfo/Symbolize/SymbolizableModule.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/Symbolize/SymbolizableModule.h?rev=354972&r1=354971&r2=354972&view=diff" rel="noopener noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/Symbolize/SymbolizableModule.h?rev=354972&r1=354971&r2=354972&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/include/llvm/DebugInfo/Symbolize/SymbolizableModule.h (original)<br>
+++ llvm/trunk/include/llvm/DebugInfo/Symbolize/SymbolizableModule.h Wed Feb 27 05:17:36 2019<br>
@@ -24,13 +24,14 @@ class SymbolizableModule {<br>
public:<br>
virtual ~SymbolizableModule() = default;<br>
<br>
- virtual DILineInfo symbolizeCode(uint64_t ModuleOffset,<br>
+ virtual DILineInfo symbolizeCode(object::SectionedAddress ModuleOffset,<br>
FunctionNameKind FNKind,<br>
bool UseSymbolTable) const = 0;<br>
- virtual DIInliningInfo symbolizeInlinedCode(uint64_t ModuleOffset,<br>
- FunctionNameKind FNKind,<br>
- bool UseSymbolTable) const = 0;<br>
- virtual DIGlobal symbolizeData(uint64_t ModuleOffset) const = 0;<br>
+ virtual DIInliningInfo<br>
+ symbolizeInlinedCode(object::SectionedAddress ModuleOffset,<br>
+ FunctionNameKind FNKind, bool UseSymbolTable) const = 0;<br>
+ virtual DIGlobal<br>
+ symbolizeData(object::SectionedAddress ModuleOffset) const = 0;<br>
<br>
// Return true if this is a 32-bit x86 PE COFF module.<br>
virtual bool isWin32Module() const = 0;<br>
<br>
Modified: llvm/trunk/include/llvm/DebugInfo/Symbolize/Symbolize.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/Symbolize/Symbolize.h?rev=354972&r1=354971&r2=354972&view=diff" rel="noopener noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/Symbolize/Symbolize.h?rev=354972&r1=354971&r2=354972&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/include/llvm/DebugInfo/Symbolize/Symbolize.h (original)<br>
+++ llvm/trunk/include/llvm/DebugInfo/Symbolize/Symbolize.h Wed Feb 27 05:17:36 2019<br>
@@ -60,13 +60,14 @@ public:<br>
}<br>
<br>
Expected<DILineInfo> symbolizeCode(const std::string &ModuleName,<br>
- uint64_t ModuleOffset,<br>
+ object::SectionedAddress ModuleOffset,<br>
StringRef DWPName = "");<br>
- Expected<DIInliningInfo> symbolizeInlinedCode(const std::string &ModuleName,<br>
- uint64_t ModuleOffset,<br>
- StringRef DWPName = "");<br>
+ Expected<DIInliningInfo><br>
+ symbolizeInlinedCode(const std::string &ModuleName,<br>
+ object::SectionedAddress ModuleOffset,<br>
+ StringRef DWPName = "");<br>
Expected<DIGlobal> symbolizeData(const std::string &ModuleName,<br>
- uint64_t ModuleOffset);<br>
+ object::SectionedAddress ModuleOffset);<br>
void flush();<br>
<br>
static std::string<br>
<br>
Modified: llvm/trunk/include/llvm/Object/ObjectFile.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Object/ObjectFile.h?rev=354972&r1=354971&r2=354972&view=diff" rel="noopener noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Object/ObjectFile.h?rev=354972&r1=354971&r2=354972&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/include/llvm/Object/ObjectFile.h (original)<br>
+++ llvm/trunk/include/llvm/Object/ObjectFile.h Wed Feb 27 05:17:36 2019<br>
@@ -135,6 +135,30 @@ public:<br>
const ObjectFile *getObject() const;<br>
};<br>
<br>
+struct SectionedAddress {<br>
+ // TODO: constructors could be removed when C++14 would be adopted.<br>
+ SectionedAddress() {}<br>
+ SectionedAddress(uint64_t Addr, uint64_t SectIdx)<br>
+ : Address(Addr), SectionIndex(SectIdx) {}<br>
+<br>
+ const static uint64_t UndefSection = UINT64_MAX;<br>
+<br>
+ uint64_t Address = 0;<br>
+ uint64_t SectionIndex = UndefSection;<br>
+};<br>
+<br>
+inline bool operator<(const SectionedAddress &LHS,<br>
+ const SectionedAddress &RHS) {<br>
+ return std::tie(LHS.SectionIndex, LHS.Address) <<br>
+ std::tie(RHS.SectionIndex, RHS.Address);<br>
+}<br>
+<br>
+inline bool operator==(const SectionedAddress &LHS,<br>
+ const SectionedAddress &RHS) {<br>
+ return std::tie(LHS.SectionIndex, LHS.Address) ==<br>
+ std::tie(RHS.SectionIndex, RHS.Address);<br>
+}<br>
+<br>
/// This is a value type class that represents a single symbol in the list of<br>
/// symbols in the object file.<br>
class SymbolRef : public BasicSymbolRef {<br>
<br>
Modified: llvm/trunk/lib/DebugInfo/DWARF/DWARFContext.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARF/DWARFContext.cpp?rev=354972&r1=354971&r2=354972&view=diff" rel="noopener noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARF/DWARFContext.cpp?rev=354972&r1=354971&r2=354972&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/DebugInfo/DWARF/DWARFContext.cpp (original)<br>
+++ llvm/trunk/lib/DebugInfo/DWARF/DWARFContext.cpp Wed Feb 27 05:17:36 2019<br>
@@ -268,11 +268,11 @@ static void dumpAddrSection(raw_ostream<br>
}<br>
<br>
// Dump the .debug_rnglists or .debug_rnglists.dwo section (DWARF v5).<br>
-static void<br>
-dumpRnglistsSection(raw_ostream &OS, DWARFDataExtractor &rnglistData,<br>
- llvm::function_ref<Optional<SectionedAddress>(uint32_t)><br>
- LookupPooledAddress,<br>
- DIDumpOptions DumpOpts) {<br>
+static void dumpRnglistsSection(<br>
+ raw_ostream &OS, DWARFDataExtractor &rnglistData,<br>
+ llvm::function_ref<Optional<object::SectionedAddress>(uint32_t)><br>
+ LookupPooledAddress,<br>
+ DIDumpOptions DumpOpts) {<br>
uint32_t Offset = 0;<br>
while (rnglistData.isValidOffset(Offset)) {<br>
llvm::DWARFDebugRnglistTable Rnglists;<br>
@@ -938,6 +938,8 @@ DWARFContext::DIEsForAddress DWARFContex<br>
return Result;<br>
}<br>
<br>
+/// TODO: change input parameter from "uint64_t Address"<br>
+/// into "SectionedAddress Address"<br>
static bool getFunctionNameAndStartLineForAddress(DWARFCompileUnit *CU,<br>
uint64_t Address,<br>
FunctionNameKind Kind,<br>
@@ -966,36 +968,37 @@ static bool getFunctionNameAndStartLineF<br>
return FoundResult;<br>
}<br>
<br>
-DILineInfo DWARFContext::getLineInfoForAddress(uint64_t Address,<br>
+DILineInfo DWARFContext::getLineInfoForAddress(object::SectionedAddress Address,<br>
DILineInfoSpecifier Spec) {<br>
DILineInfo Result;<br>
<br>
- DWARFCompileUnit *CU = getCompileUnitForAddress(Address);<br>
+ DWARFCompileUnit *CU = getCompileUnitForAddress(Address.Address);<br>
if (!CU)<br>
return Result;<br>
- getFunctionNameAndStartLineForAddress(CU, Address, Spec.FNKind,<br>
- Result.FunctionName,<br>
- Result.StartLine);<br>
+<br>
+ getFunctionNameAndStartLineForAddress(CU, Address.Address, Spec.FNKind,<br>
+ Result.FunctionName, Result.StartLine);<br>
if (Spec.FLIKind != FileLineInfoKind::None) {<br>
- if (const DWARFLineTable *LineTable = getLineTableForUnit(CU))<br>
- LineTable->getFileLineInfoForAddress(Address, CU->getCompilationDir(),<br>
- Spec.FLIKind, Result);<br>
+ if (const DWARFLineTable *LineTable = getLineTableForUnit(CU)) {<br>
+ LineTable->getFileLineInfoForAddress(<br>
+ {Address.Address, Address.SectionIndex}, CU->getCompilationDir(),<br>
+ Spec.FLIKind, Result);<br>
+ }<br>
}<br>
return Result;<br>
}<br>
<br>
-DILineInfoTable<br>
-DWARFContext::getLineInfoForAddressRange(uint64_t Address, uint64_t Size,<br>
- DILineInfoSpecifier Spec) {<br>
+DILineInfoTable DWARFContext::getLineInfoForAddressRange(<br>
+ object::SectionedAddress Address, uint64_t Size, DILineInfoSpecifier Spec) {<br>
DILineInfoTable Lines;<br>
- DWARFCompileUnit *CU = getCompileUnitForAddress(Address);<br>
+ DWARFCompileUnit *CU = getCompileUnitForAddress(Address.Address);<br>
if (!CU)<br>
return Lines;<br>
<br>
std::string FunctionName = "<invalid>";<br>
uint32_t StartLine = 0;<br>
- getFunctionNameAndStartLineForAddress(CU, Address, Spec.FNKind, FunctionName,<br>
- StartLine);<br>
+ getFunctionNameAndStartLineForAddress(CU, Address.Address, Spec.FNKind,<br>
+ FunctionName, StartLine);<br>
<br>
// If the Specifier says we don't need FileLineInfo, just<br>
// return the top-most function at the starting address.<br>
@@ -1003,7 +1006,7 @@ DWARFContext::getLineInfoForAddressRange<br>
DILineInfo Result;<br>
Result.FunctionName = FunctionName;<br>
Result.StartLine = StartLine;<br>
- Lines.push_back(std::make_pair(Address, Result));<br>
+ Lines.push_back(std::make_pair(Address.Address, Result));<br>
return Lines;<br>
}<br>
<br>
@@ -1011,8 +1014,10 @@ DWARFContext::getLineInfoForAddressRange<br>
<br>
// Get the index of row we're looking for in the line table.<br>
std::vector<uint32_t> RowVector;<br>
- if (!LineTable->lookupAddressRange(Address, Size, RowVector))<br>
+ if (!LineTable->lookupAddressRange({Address.Address, Address.SectionIndex},<br>
+ Size, RowVector)) {<br>
return Lines;<br>
+ }<br>
<br>
for (uint32_t RowIndex : RowVector) {<br>
// Take file number and line/column from the row.<br>
@@ -1024,33 +1029,33 @@ DWARFContext::getLineInfoForAddressRange<br>
Result.Line = Row.Line;<br>
Result.Column = Row.Column;<br>
Result.StartLine = StartLine;<br>
- Lines.push_back(std::make_pair(Row.Address, Result));<br>
+ Lines.push_back(std::make_pair(Row.Address.Address, Result));<br>
}<br>
<br>
return Lines;<br>
}<br>
<br>
DIInliningInfo<br>
-DWARFContext::getInliningInfoForAddress(uint64_t Address,<br>
+DWARFContext::getInliningInfoForAddress(object::SectionedAddress Address,<br>
DILineInfoSpecifier Spec) {<br>
DIInliningInfo InliningInfo;<br>
<br>
- DWARFCompileUnit *CU = getCompileUnitForAddress(Address);<br>
+ DWARFCompileUnit *CU = getCompileUnitForAddress(Address.Address);<br>
if (!CU)<br>
return InliningInfo;<br>
<br>
const DWARFLineTable *LineTable = nullptr;<br>
SmallVector<DWARFDie, 4> InlinedChain;<br>
- CU->getInlinedChainForAddress(Address, InlinedChain);<br>
+ CU->getInlinedChainForAddress(Address.Address, InlinedChain);<br>
if (InlinedChain.size() == 0) {<br>
// If there is no DIE for address (e.g. it is in unavailable .dwo file),<br>
// try to at least get file/line info from symbol table.<br>
if (Spec.FLIKind != FileLineInfoKind::None) {<br>
DILineInfo Frame;<br>
LineTable = getLineTableForUnit(CU);<br>
- if (LineTable &&<br>
- LineTable->getFileLineInfoForAddress(Address, CU->getCompilationDir(),<br>
- Spec.FLIKind, Frame))<br>
+ if (LineTable && LineTable->getFileLineInfoForAddress(<br>
+ {Address.Address, Address.SectionIndex},<br>
+ CU->getCompilationDir(), Spec.FLIKind, Frame))<br>
InliningInfo.addFrame(Frame);<br>
}<br>
return InliningInfo;<br>
@@ -1072,8 +1077,9 @@ DWARFContext::getInliningInfoForAddress(<br>
LineTable = getLineTableForUnit(CU);<br>
// For the topmost routine, get file/line info from line table.<br>
if (LineTable)<br>
- LineTable->getFileLineInfoForAddress(Address, CU->getCompilationDir(),<br>
- Spec.FLIKind, Frame);<br>
+ LineTable->getFileLineInfoForAddress(<br>
+ {Address.Address, Address.SectionIndex}, CU->getCompilationDir(),<br>
+ Spec.FLIKind, Frame);<br>
} else {<br>
// Otherwise, use call file, call line and call column from<br>
// previous DIE in inlined chain.<br>
<br>
Modified: llvm/trunk/lib/DebugInfo/DWARF/DWARFDataExtractor.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARF/DWARFDataExtractor.cpp?rev=354972&r1=354971&r2=354972&view=diff" rel="noopener noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARF/DWARFDataExtractor.cpp?rev=354972&r1=354971&r2=354972&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/DebugInfo/DWARF/DWARFDataExtractor.cpp (original)<br>
+++ llvm/trunk/lib/DebugInfo/DWARF/DWARFDataExtractor.cpp Wed Feb 27 05:17:36 2019<br>
@@ -15,7 +15,7 @@ using namespace llvm;<br>
uint64_t DWARFDataExtractor::getRelocatedValue(uint32_t Size, uint32_t *Off,<br>
uint64_t *SecNdx) const {<br>
if (SecNdx)<br>
- *SecNdx = -1ULL;<br>
+ *SecNdx = object::SectionedAddress::UndefSection;<br>
if (!Section)<br>
return getUnsigned(Off, Size);<br>
Optional<RelocAddrEntry> Rel = Obj->find(*Section, *Off);<br>
<br>
Modified: llvm/trunk/lib/DebugInfo/DWARF/DWARFDebugLine.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARF/DWARFDebugLine.cpp?rev=354972&r1=354971&r2=354972&view=diff" rel="noopener noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARF/DWARFDebugLine.cpp?rev=354972&r1=354971&r2=354972&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/DebugInfo/DWARF/DWARFDebugLine.cpp (original)<br>
+++ llvm/trunk/lib/DebugInfo/DWARF/DWARFDebugLine.cpp Wed Feb 27 05:17:36 2019<br>
@@ -353,7 +353,8 @@ void DWARFDebugLine::Row::postAppend() {<br>
}<br>
<br>
void DWARFDebugLine::Row::reset(bool DefaultIsStmt) {<br>
- Address = 0;<br>
+ Address.Address = 0;<br>
+ Address.SectionIndex = object::SectionedAddress::UndefSection;<br>
Line = 1;<br>
Column = 0;<br>
File = 1;<br>
@@ -373,7 +374,7 @@ void DWARFDebugLine::Row::dumpTableHeade<br>
}<br>
<br>
void DWARFDebugLine::Row::dump(raw_ostream &OS) const {<br>
- OS << format("0x%16.16" PRIx64 " %6u %6u", Address, Line, Column)<br>
+ OS << format("0x%16.16" PRIx64 " %6u %6u", Address.Address, Line, Column)<br>
<< format(" %6u %3u %13u ", File, Isa, Discriminator)<br>
<< (IsStmt ? " is_stmt" : "") << (BasicBlock ? " basic_block" : "")<br>
<< (PrologueEnd ? " prologue_end" : "")<br>
@@ -386,6 +387,7 @@ DWARFDebugLine::Sequence::Sequence() { r<br>
void DWARFDebugLine::Sequence::reset() {<br>
LowPC = 0;<br>
HighPC = 0;<br>
+ SectionIndex = object::SectionedAddress::UndefSection;<br>
FirstRowIndex = 0;<br>
LastRowIndex = 0;<br>
Empty = true;<br>
@@ -426,15 +428,16 @@ void DWARFDebugLine::ParsingState::appen<br>
if (Sequence.Empty) {<br>
// Record the beginning of instruction sequence.<br>
Sequence.Empty = false;<br>
- Sequence.LowPC = Row.Address;<br>
+ Sequence.LowPC = Row.Address.Address;<br>
Sequence.FirstRowIndex = RowNumber;<br>
}<br>
++RowNumber;<br>
LineTable->appendRow(Row);<br>
if (Row.EndSequence) {<br>
// Record the end of instruction sequence.<br>
- Sequence.HighPC = Row.Address;<br>
+ Sequence.HighPC = Row.Address.Address;<br>
Sequence.LastRowIndex = RowNumber;<br>
+ Sequence.SectionIndex = Row.Address.SectionIndex;<br>
if (Sequence.isValid())<br>
LineTable->appendSequence(Sequence);<br>
Sequence.reset();<br>
@@ -565,9 +568,10 @@ Error DWARFDebugLine::LineTable::parse(<br>
ExtOffset, DebugLineData.getAddressSize(),<br>
Len - 1);<br>
}<br>
- State.Row.Address = DebugLineData.getRelocatedAddress(OffsetPtr);<br>
+ State.Row.Address.Address = DebugLineData.getRelocatedAddress(<br>
+ OffsetPtr, &State.Row.Address.SectionIndex);<br>
if (OS)<br>
- *OS << format(" (0x%16.16" PRIx64 ")", State.Row.Address);<br>
+ *OS << format(" (0x%16.16" PRIx64 ")", State.Row.Address.Address);<br>
break;<br>
<br>
case DW_LNE_define_file:<br>
@@ -654,7 +658,7 @@ Error DWARFDebugLine::LineTable::parse(<br>
{<br>
uint64_t AddrOffset =<br>
DebugLineData.getULEB128(OffsetPtr) * Prologue.MinInstLength;<br>
- State.Row.Address += AddrOffset;<br>
+ State.Row.Address.Address += AddrOffset;<br>
if (OS)<br>
*OS << " (" << AddrOffset << ")";<br>
}<br>
@@ -712,7 +716,7 @@ Error DWARFDebugLine::LineTable::parse(<br>
uint8_t AdjustOpcode = 255 - Prologue.OpcodeBase;<br>
uint64_t AddrOffset =<br>
(AdjustOpcode / Prologue.LineRange) * Prologue.MinInstLength;<br>
- State.Row.Address += AddrOffset;<br>
+ State.Row.Address.Address += AddrOffset;<br>
if (OS)<br>
*OS<br>
<< format(" (0x%16.16" PRIx64 ")", AddrOffset);<br>
@@ -731,7 +735,7 @@ Error DWARFDebugLine::LineTable::parse(<br>
// can use DW_LNS_fixed_advance_pc instead, sacrificing compression.<br>
{<br>
uint16_t PCOffset = DebugLineData.getU16(OffsetPtr);<br>
- State.Row.Address += PCOffset;<br>
+ State.Row.Address.Address += PCOffset;<br>
if (OS)<br>
*OS<br>
<< format(" (0x%16.16" PRIx64 ")", PCOffset);<br>
@@ -814,7 +818,7 @@ Error DWARFDebugLine::LineTable::parse(<br>
int32_t LineOffset =<br>
Prologue.LineBase + (AdjustOpcode % Prologue.LineRange);<br>
State.Row.Line += LineOffset;<br>
- State.Row.Address += AddrOffset;<br>
+ State.Row.Address.Address += AddrOffset;<br>
<br>
if (OS) {<br>
*OS << "address += " << AddrOffset << ", line += " << LineOffset<br>
@@ -850,11 +854,12 @@ Error DWARFDebugLine::LineTable::parse(<br>
return Error::success();<br>
}<br>
<br>
-uint32_t<br>
-DWARFDebugLine::LineTable::findRowInSeq(const DWARFDebugLine::Sequence &Seq,<br>
- uint64_t Address) const {<br>
+uint32_t DWARFDebugLine::LineTable::findRowInSeq(<br>
+ const DWARFDebugLine::Sequence &Seq,<br>
+ object::SectionedAddress Address) const {<br>
if (!Seq.containsPC(Address))<br>
return UnknownRowIndex;<br>
+ assert(Seq.SectionIndex == Address.SectionIndex);<br>
// Search for instruction address in the rows describing the sequence.<br>
// Rows are stored in a vector, so we may use arithmetical operations with<br>
// iterators.<br>
@@ -867,8 +872,9 @@ DWARFDebugLine::LineTable::findRowInSeq(<br>
if (RowPos == LastRow) {<br>
return Seq.LastRowIndex - 1;<br>
}<br>
+ assert(Seq.SectionIndex == RowPos->Address.SectionIndex);<br>
uint32_t Index = Seq.FirstRowIndex + (RowPos - FirstRow);<br>
- if (RowPos->Address > Address) {<br>
+ if (RowPos->Address.Address > Address.Address) {<br>
if (RowPos == FirstRow)<br>
return UnknownRowIndex;<br>
else<br>
@@ -877,42 +883,81 @@ DWARFDebugLine::LineTable::findRowInSeq(<br>
return Index;<br>
}<br>
<br>
-uint32_t DWARFDebugLine::LineTable::lookupAddress(uint64_t Address) const {<br>
+uint32_t DWARFDebugLine::LineTable::lookupAddress(<br>
+ object::SectionedAddress Address) const {<br>
+<br>
+ // Search for relocatable addresses<br>
+ uint32_t Result = lookupAddressImpl(Address);<br>
+<br>
+ if (Result != UnknownRowIndex ||<br>
+ Address.SectionIndex == object::SectionedAddress::UndefSection)<br>
+ return Result;<br>
+<br>
+ // Search for absolute addresses<br>
+ Address.SectionIndex = object::SectionedAddress::UndefSection;<br>
+ return lookupAddressImpl(Address);<br>
+}<br>
+<br>
+uint32_t DWARFDebugLine::LineTable::lookupAddressImpl(<br>
+ object::SectionedAddress Address) const {<br>
if (Sequences.empty())<br>
return UnknownRowIndex;<br>
// First, find an instruction sequence containing the given address.<br>
DWARFDebugLine::Sequence Sequence;<br>
- Sequence.LowPC = Address;<br>
+ Sequence.SectionIndex = Address.SectionIndex;<br>
+ Sequence.LowPC = Address.Address;<br>
SequenceIter FirstSeq = Sequences.begin();<br>
SequenceIter LastSeq = Sequences.end();<br>
SequenceIter SeqPos = std::lower_bound(<br>
FirstSeq, LastSeq, Sequence, DWARFDebugLine::Sequence::orderByLowPC);<br>
DWARFDebugLine::Sequence FoundSeq;<br>
+<br>
if (SeqPos == LastSeq) {<br>
FoundSeq = Sequences.back();<br>
- } else if (SeqPos->LowPC == Address) {<br>
+ } else if (SeqPos->LowPC == Address.Address &&<br>
+ SeqPos->SectionIndex == Address.SectionIndex) {<br>
FoundSeq = *SeqPos;<br>
} else {<br>
if (SeqPos == FirstSeq)<br>
return UnknownRowIndex;<br>
FoundSeq = *(SeqPos - 1);<br>
}<br>
+ if (FoundSeq.SectionIndex != Address.SectionIndex)<br>
+ return UnknownRowIndex;<br>
return findRowInSeq(FoundSeq, Address);<br>
}<br>
<br>
bool DWARFDebugLine::LineTable::lookupAddressRange(<br>
- uint64_t Address, uint64_t Size, std::vector<uint32_t> &Result) const {<br>
+ object::SectionedAddress Address, uint64_t Size,<br>
+ std::vector<uint32_t> &Result) const {<br>
+<br>
+ // Search for relocatable addresses<br>
+ if (lookupAddressRangeImpl(Address, Size, Result))<br>
+ return true;<br>
+<br>
+ if (Address.SectionIndex == object::SectionedAddress::UndefSection)<br>
+ return false;<br>
+<br>
+ // Search for absolute addresses<br>
+ Address.SectionIndex = object::SectionedAddress::UndefSection;<br>
+ return lookupAddressRangeImpl(Address, Size, Result);<br>
+}<br>
+<br>
+bool DWARFDebugLine::LineTable::lookupAddressRangeImpl(<br>
+ object::SectionedAddress Address, uint64_t Size,<br>
+ std::vector<uint32_t> &Result) const {<br>
if (Sequences.empty())<br>
return false;<br>
- uint64_t EndAddr = Address + Size;<br>
+ uint64_t EndAddr = Address.Address + Size;<br>
// First, find an instruction sequence containing the given address.<br>
DWARFDebugLine::Sequence Sequence;<br>
- Sequence.LowPC = Address;<br>
+ Sequence.SectionIndex = Address.SectionIndex;<br>
+ Sequence.LowPC = Address.Address;<br>
SequenceIter FirstSeq = Sequences.begin();<br>
SequenceIter LastSeq = Sequences.end();<br>
SequenceIter SeqPos = std::lower_bound(<br>
FirstSeq, LastSeq, Sequence, DWARFDebugLine::Sequence::orderByLowPC);<br>
- if (SeqPos == LastSeq || SeqPos->LowPC != Address) {<br>
+ if (SeqPos == LastSeq || !SeqPos->containsPC(Address)) {<br>
if (SeqPos == FirstSeq)<br>
return false;<br>
SeqPos--;<br>
@@ -934,7 +979,8 @@ bool DWARFDebugLine::LineTable::lookupAd<br>
FirstRowIndex = findRowInSeq(CurSeq, Address);<br>
<br>
// Figure out the last row in the range.<br>
- uint32_t LastRowIndex = findRowInSeq(CurSeq, EndAddr - 1);<br>
+ uint32_t LastRowIndex =<br>
+ findRowInSeq(CurSeq, {EndAddr - 1, Address.SectionIndex});<br>
if (LastRowIndex == UnknownRowIndex)<br>
LastRowIndex = CurSeq.LastRowIndex - 1;<br>
<br>
@@ -1011,8 +1057,8 @@ bool DWARFDebugLine::LineTable::getFileN<br>
}<br>
<br>
bool DWARFDebugLine::LineTable::getFileLineInfoForAddress(<br>
- uint64_t Address, const char *CompDir, FileLineInfoKind Kind,<br>
- DILineInfo &Result) const {<br>
+ object::SectionedAddress Address, const char *CompDir,<br>
+ FileLineInfoKind Kind, DILineInfo &Result) const {<br>
// Get the index of row we're looking for in the line table.<br>
uint32_t RowIndex = lookupAddress(Address);<br>
if (RowIndex == -1U)<br>
<br>
Modified: llvm/trunk/lib/DebugInfo/DWARF/DWARFDebugRangeList.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARF/DWARFDebugRangeList.cpp?rev=354972&r1=354971&r2=354972&view=diff" rel="noopener noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARF/DWARFDebugRangeList.cpp?rev=354972&r1=354971&r2=354972&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/DebugInfo/DWARF/DWARFDebugRangeList.cpp (original)<br>
+++ llvm/trunk/lib/DebugInfo/DWARF/DWARFDebugRangeList.cpp Wed Feb 27 05:17:36 2019<br>
@@ -68,7 +68,7 @@ void DWARFDebugRangeList::dump(raw_ostre<br>
}<br>
<br>
DWARFAddressRangesVector DWARFDebugRangeList::getAbsoluteRanges(<br>
- llvm::Optional<SectionedAddress> BaseAddr) const {<br>
+ llvm::Optional<object::SectionedAddress> BaseAddr) const {<br>
DWARFAddressRangesVector Res;<br>
for (const RangeListEntry &RLE : Entries) {<br>
if (RLE.isBaseAddressSelectionEntry(AddressSize)) {<br>
<br>
Modified: llvm/trunk/lib/DebugInfo/DWARF/DWARFDebugRnglists.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARF/DWARFDebugRnglists.cpp?rev=354972&r1=354971&r2=354972&view=diff" rel="noopener noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARF/DWARFDebugRnglists.cpp?rev=354972&r1=354971&r2=354972&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/DebugInfo/DWARF/DWARFDebugRnglists.cpp (original)<br>
+++ llvm/trunk/lib/DebugInfo/DWARF/DWARFDebugRnglists.cpp Wed Feb 27 05:17:36 2019<br>
@@ -112,9 +112,8 @@ Error RangeListEntry::extract(DWARFDataE<br>
return Error::success();<br>
}<br>
<br>
-DWARFAddressRangesVector<br>
-DWARFDebugRnglist::getAbsoluteRanges(llvm::Optional<SectionedAddress> BaseAddr,<br>
- DWARFUnit &U) const {<br>
+DWARFAddressRangesVector DWARFDebugRnglist::getAbsoluteRanges(<br>
+ llvm::Optional<object::SectionedAddress> BaseAddr, DWARFUnit &U) const {<br>
DWARFAddressRangesVector Res;<br>
for (const RangeListEntry &RLE : Entries) {<br>
if (RLE.EntryKind == dwarf::DW_RLE_end_of_list)<br>
@@ -174,7 +173,7 @@ DWARFDebugRnglist::getAbsoluteRanges(llv<br>
void RangeListEntry::dump(<br>
raw_ostream &OS, uint8_t AddrSize, uint8_t MaxEncodingStringLength,<br>
uint64_t &CurrentBase, DIDumpOptions DumpOpts,<br>
- llvm::function_ref<Optional<SectionedAddress>(uint32_t)><br>
+ llvm::function_ref<Optional<object::SectionedAddress>(uint32_t)><br>
LookupPooledAddress) const {<br>
auto PrintRawEntry = [](raw_ostream &OS, const RangeListEntry &Entry,<br>
uint8_t AddrSize, DIDumpOptions DumpOpts) {<br>
<br>
Modified: llvm/trunk/lib/DebugInfo/DWARF/DWARFDie.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARF/DWARFDie.cpp?rev=354972&r1=354971&r2=354972&view=diff" rel="noopener noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARF/DWARFDie.cpp?rev=354972&r1=354971&r2=354972&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/DebugInfo/DWARF/DWARFDie.cpp (original)<br>
+++ llvm/trunk/lib/DebugInfo/DWARF/DWARFDie.cpp Wed Feb 27 05:17:36 2019<br>
@@ -100,7 +100,7 @@ static void dumpLocation(raw_ostream &OS<br>
auto LL = DebugLoc.parseOneLocationList(Data, &Offset);<br>
if (LL) {<br>
uint64_t BaseAddr = 0;<br>
- if (Optional<SectionedAddress> BA = U->getBaseAddress())<br>
+ if (Optional<object::SectionedAddress> BA = U->getBaseAddress())<br>
BaseAddr = BA->Address;<br>
LL->dump(OS, Ctx.isLittleEndian(), Obj.getAddressSize(), MRI, U,<br>
BaseAddr, Indent);<br>
@@ -125,7 +125,7 @@ static void dumpLocation(raw_ostream &OS<br>
Data, &Offset, UseLocLists ? U->getVersion() : 4);<br>
<br>
uint64_t BaseAddr = 0;<br>
- if (Optional<SectionedAddress> BA = U->getBaseAddress())<br>
+ if (Optional<object::SectionedAddress> BA = U->getBaseAddress())<br>
BaseAddr = BA->Address;<br>
<br>
if (LL)<br>
<br>
Modified: llvm/trunk/lib/DebugInfo/DWARF/DWARFFormValue.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARF/DWARFFormValue.cpp?rev=354972&r1=354971&r2=354972&view=diff" rel="noopener noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARF/DWARFFormValue.cpp?rev=354972&r1=354971&r2=354972&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/DebugInfo/DWARF/DWARFFormValue.cpp (original)<br>
+++ llvm/trunk/lib/DebugInfo/DWARF/DWARFFormValue.cpp Wed Feb 27 05:17:36 2019<br>
@@ -360,7 +360,7 @@ bool DWARFFormValue::extractValue(const<br>
<br>
void DWARFFormValue::dumpSectionedAddress(raw_ostream &OS,<br>
DIDumpOptions DumpOpts,<br>
- SectionedAddress SA) const {<br>
+ object::SectionedAddress SA) const {<br>
OS << format("0x%016" PRIx64, SA.Address);<br>
dumpAddressSection(U->getContext().getDWARFObj(), OS, DumpOpts,<br>
SA.SectionIndex);<br>
@@ -397,7 +397,7 @@ void DWARFFormValue::dump(raw_ostream &O<br>
case DW_FORM_addrx3:<br>
case DW_FORM_addrx4:<br>
case DW_FORM_GNU_addr_index: {<br>
- Optional<SectionedAddress> A = U->getAddrOffsetSectionItem(UValue);<br>
+ Optional<object::SectionedAddress> A = U->getAddrOffsetSectionItem(UValue);<br>
if (!A || DumpOpts.Verbose)<br>
AddrOS << format("indexed (%8.8x) address = ", (uint32_t)UValue);<br>
if (U == nullptr)<br>
@@ -618,14 +618,15 @@ Optional<uint64_t> DWARFFormValue::getAs<br>
return SA->Address;<br>
return None;<br>
}<br>
-Optional<SectionedAddress> DWARFFormValue::getAsSectionedAddress() const {<br>
+Optional<object::SectionedAddress><br>
+DWARFFormValue::getAsSectionedAddress() const {<br>
if (!isFormClass(FC_Address))<br>
return None;<br>
if (Form == DW_FORM_GNU_addr_index || Form == DW_FORM_addrx) {<br>
uint32_t Index = Value.uval;<br>
if (!U)<br>
return None;<br>
- Optional<SectionedAddress> SA = U->getAddrOffsetSectionItem(Index);<br>
+ Optional<object::SectionedAddress> SA = U->getAddrOffsetSectionItem(Index);<br>
if (!SA)<br>
return None;<br>
return SA;<br>
<br>
Modified: llvm/trunk/lib/DebugInfo/DWARF/DWARFUnit.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARF/DWARFUnit.cpp?rev=354972&r1=354971&r2=354972&view=diff" rel="noopener noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARF/DWARFUnit.cpp?rev=354972&r1=354971&r2=354972&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/DebugInfo/DWARF/DWARFUnit.cpp (original)<br>
+++ llvm/trunk/lib/DebugInfo/DWARF/DWARFUnit.cpp Wed Feb 27 05:17:36 2019<br>
@@ -197,7 +197,7 @@ DWARFDataExtractor DWARFUnit::getDebugIn<br>
getAddressByteSize());<br>
}<br>
<br>
-Optional<SectionedAddress><br>
+Optional<object::SectionedAddress><br>
DWARFUnit::getAddrOffsetSectionItem(uint32_t Index) const {<br>
if (IsDWO) {<br>
auto R = Context.info_section_units();<br>
@@ -744,7 +744,7 @@ const DWARFAbbreviationDeclarationSet *D<br>
return Abbrevs;<br>
}<br>
<br>
-llvm::Optional<SectionedAddress> DWARFUnit::getBaseAddress() {<br>
+llvm::Optional<object::SectionedAddress> DWARFUnit::getBaseAddress() {<br>
if (BaseAddr)<br>
return BaseAddr;<br>
<br>
<br>
Modified: llvm/trunk/lib/DebugInfo/DWARF/DWARFVerifier.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARF/DWARFVerifier.cpp?rev=354972&r1=354971&r2=354972&view=diff" rel="noopener noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARF/DWARFVerifier.cpp?rev=354972&r1=354971&r2=354972&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/DebugInfo/DWARF/DWARFVerifier.cpp (original)<br>
+++ llvm/trunk/lib/DebugInfo/DWARF/DWARFVerifier.cpp Wed Feb 27 05:17:36 2019<br>
@@ -772,7 +772,7 @@ void DWARFVerifier::verifyDebugLineRows(<br>
uint32_t RowIndex = 0;<br>
for (const auto &Row : LineTable->Rows) {<br>
// Verify row address.<br>
- if (Row.Address < PrevAddress) {<br>
+ if (Row.Address.Address < PrevAddress) {<br>
++NumDebugLineErrors;<br>
error() << ".debug_line["<br>
<< format("0x%08" PRIx64,<br>
@@ -802,7 +802,7 @@ void DWARFVerifier::verifyDebugLineRows(<br>
if (Row.EndSequence)<br>
PrevAddress = 0;<br>
else<br>
- PrevAddress = Row.Address;<br>
+ PrevAddress = Row.Address.Address;<br>
++RowIndex;<br>
}<br>
}<br>
<br>
Modified: llvm/trunk/lib/DebugInfo/PDB/PDBContext.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/PDB/PDBContext.cpp?rev=354972&r1=354971&r2=354972&view=diff" rel="noopener noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/PDB/PDBContext.cpp?rev=354972&r1=354971&r2=354972&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/DebugInfo/PDB/PDBContext.cpp (original)<br>
+++ llvm/trunk/lib/DebugInfo/PDB/PDBContext.cpp Wed Feb 27 05:17:36 2019<br>
@@ -30,14 +30,14 @@ PDBContext::PDBContext(const COFFObjectF<br>
<br>
void PDBContext::dump(raw_ostream &OS, DIDumpOptions DumpOpts){}<br>
<br>
-DILineInfo PDBContext::getLineInfoForAddress(uint64_t Address,<br>
+DILineInfo PDBContext::getLineInfoForAddress(object::SectionedAddress Address,<br>
DILineInfoSpecifier Specifier) {<br>
DILineInfo Result;<br>
- Result.FunctionName = getFunctionName(Address, Specifier.FNKind);<br>
+ Result.FunctionName = getFunctionName(Address.Address, Specifier.FNKind);<br>
<br>
uint32_t Length = 1;<br>
std::unique_ptr<PDBSymbol> Symbol =<br>
- Session->findSymbolByAddress(Address, PDB_SymType::None);<br>
+ Session->findSymbolByAddress(Address.Address, PDB_SymType::None);<br>
if (auto Func = dyn_cast_or_null<PDBSymbolFunc>(Symbol.get())) {<br>
Length = Func->getLength();<br>
} else if (auto Data = dyn_cast_or_null<PDBSymbolData>(Symbol.get())) {<br>
@@ -46,7 +46,7 @@ DILineInfo PDBContext::getLineInfoForAdd<br>
<br>
// If we couldn't find a symbol, then just assume 1 byte, so that we get<br>
// only the line number of the first instruction.<br>
- auto LineNumbers = Session->findLineNumbersByAddress(Address, Length);<br>
+ auto LineNumbers = Session->findLineNumbersByAddress(Address.Address, Length);<br>
if (!LineNumbers || LineNumbers->getChildCount() == 0)<br>
return Result;<br>
<br>
@@ -63,26 +63,27 @@ DILineInfo PDBContext::getLineInfoForAdd<br>
}<br>
<br>
DILineInfoTable<br>
-PDBContext::getLineInfoForAddressRange(uint64_t Address, uint64_t Size,<br>
+PDBContext::getLineInfoForAddressRange(object::SectionedAddress Address,<br>
+ uint64_t Size,<br>
DILineInfoSpecifier Specifier) {<br>
if (Size == 0)<br>
return DILineInfoTable();<br>
<br>
DILineInfoTable Table;<br>
- auto LineNumbers = Session->findLineNumbersByAddress(Address, Size);<br>
+ auto LineNumbers = Session->findLineNumbersByAddress(Address.Address, Size);<br>
if (!LineNumbers || LineNumbers->getChildCount() == 0)<br>
return Table;<br>
<br>
while (auto LineInfo = LineNumbers->getNext()) {<br>
- DILineInfo LineEntry =<br>
- getLineInfoForAddress(LineInfo->getVirtualAddress(), Specifier);<br>
+ DILineInfo LineEntry = getLineInfoForAddress(<br>
+ {LineInfo->getVirtualAddress(), Address.SectionIndex}, Specifier);<br>
Table.push_back(std::make_pair(LineInfo->getVirtualAddress(), LineEntry));<br>
}<br>
return Table;<br>
}<br>
<br>
DIInliningInfo<br>
-PDBContext::getInliningInfoForAddress(uint64_t Address,<br>
+PDBContext::getInliningInfoForAddress(object::SectionedAddress Address,<br>
DILineInfoSpecifier Specifier) {<br>
DIInliningInfo InlineInfo;<br>
DILineInfo Frame = getLineInfoForAddress(Address, Specifier);<br>
<br>
Modified: llvm/trunk/lib/DebugInfo/Symbolize/SymbolizableObjectFile.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/Symbolize/SymbolizableObjectFile.cpp?rev=354972&r1=354971&r2=354972&view=diff" rel="noopener noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/Symbolize/SymbolizableObjectFile.cpp?rev=354972&r1=354971&r2=354972&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/DebugInfo/Symbolize/SymbolizableObjectFile.cpp (original)<br>
+++ llvm/trunk/lib/DebugInfo/Symbolize/SymbolizableObjectFile.cpp Wed Feb 27 05:17:36 2019<br>
@@ -222,9 +222,10 @@ bool SymbolizableObjectFile::shouldOverr<br>
isa<DWARFContext>(DebugInfoContext.get());<br>
}<br>
<br>
-DILineInfo SymbolizableObjectFile::symbolizeCode(uint64_t ModuleOffset,<br>
- FunctionNameKind FNKind,<br>
- bool UseSymbolTable) const {<br>
+DILineInfo<br>
+SymbolizableObjectFile::symbolizeCode(object::SectionedAddress ModuleOffset,<br>
+ FunctionNameKind FNKind,<br>
+ bool UseSymbolTable) const {<br>
DILineInfo LineInfo;<br>
if (DebugInfoContext) {<br>
LineInfo = DebugInfoContext->getLineInfoForAddress(<br>
@@ -234,7 +235,7 @@ DILineInfo SymbolizableObjectFile::symbo<br>
if (shouldOverrideWithSymbolTable(FNKind, UseSymbolTable)) {<br>
std::string FunctionName;<br>
uint64_t Start, Size;<br>
- if (getNameFromSymbolTable(SymbolRef::ST_Function, ModuleOffset,<br>
+ if (getNameFromSymbolTable(SymbolRef::ST_Function, ModuleOffset.Address,<br>
FunctionName, Start, Size)) {<br>
LineInfo.FunctionName = FunctionName;<br>
}<br>
@@ -243,7 +244,8 @@ DILineInfo SymbolizableObjectFile::symbo<br>
}<br>
<br>
DIInliningInfo SymbolizableObjectFile::symbolizeInlinedCode(<br>
- uint64_t ModuleOffset, FunctionNameKind FNKind, bool UseSymbolTable) const {<br>
+ object::SectionedAddress ModuleOffset, FunctionNameKind FNKind,<br>
+ bool UseSymbolTable) const {<br>
DIInliningInfo InlinedContext;<br>
<br>
if (DebugInfoContext)<br>
@@ -257,7 +259,7 @@ DIInliningInfo SymbolizableObjectFile::s<br>
if (shouldOverrideWithSymbolTable(FNKind, UseSymbolTable)) {<br>
std::string FunctionName;<br>
uint64_t Start, Size;<br>
- if (getNameFromSymbolTable(SymbolRef::ST_Function, ModuleOffset,<br>
+ if (getNameFromSymbolTable(SymbolRef::ST_Function, ModuleOffset.Address,<br>
FunctionName, Start, Size)) {<br>
InlinedContext.getMutableFrame(InlinedContext.getNumberOfFrames() - 1)<br>
->FunctionName = FunctionName;<br>
@@ -267,9 +269,10 @@ DIInliningInfo SymbolizableObjectFile::s<br>
return InlinedContext;<br>
}<br>
<br>
-DIGlobal SymbolizableObjectFile::symbolizeData(uint64_t ModuleOffset) const {<br>
+DIGlobal SymbolizableObjectFile::symbolizeData(<br>
+ object::SectionedAddress ModuleOffset) const {<br>
DIGlobal Res;<br>
- getNameFromSymbolTable(SymbolRef::ST_Data, ModuleOffset, Res.Name, Res.Start,<br>
- Res.Size);<br>
+ getNameFromSymbolTable(SymbolRef::ST_Data, ModuleOffset.Address, Res.Name,<br>
+ Res.Start, Res.Size);<br>
return Res;<br>
}<br>
<br>
Modified: llvm/trunk/lib/DebugInfo/Symbolize/SymbolizableObjectFile.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/Symbolize/SymbolizableObjectFile.h?rev=354972&r1=354971&r2=354972&view=diff" rel="noopener noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/Symbolize/SymbolizableObjectFile.h?rev=354972&r1=354971&r2=354972&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/DebugInfo/Symbolize/SymbolizableObjectFile.h (original)<br>
+++ llvm/trunk/lib/DebugInfo/Symbolize/SymbolizableObjectFile.h Wed Feb 27 05:17:36 2019<br>
@@ -33,12 +33,13 @@ public:<br>
static ErrorOr<std::unique_ptr<SymbolizableObjectFile>><br>
create(object::ObjectFile *Obj, std::unique_ptr<DIContext> DICtx);<br>
<br>
- DILineInfo symbolizeCode(uint64_t ModuleOffset, FunctionNameKind FNKind,<br>
+ DILineInfo symbolizeCode(object::SectionedAddress ModuleOffset,<br>
+ FunctionNameKind FNKind,<br>
bool UseSymbolTable) const override;<br>
- DIInliningInfo symbolizeInlinedCode(uint64_t ModuleOffset,<br>
+ DIInliningInfo symbolizeInlinedCode(object::SectionedAddress ModuleOffset,<br>
FunctionNameKind FNKind,<br>
bool UseSymbolTable) const override;<br>
- DIGlobal symbolizeData(uint64_t ModuleOffset) const override;<br>
+ DIGlobal symbolizeData(object::SectionedAddress ModuleOffset) const override;<br>
<br>
// Return true if this is a 32-bit x86 PE COFF module.<br>
bool isWin32Module() const override;<br>
<br>
Modified: llvm/trunk/lib/DebugInfo/Symbolize/Symbolize.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/Symbolize/Symbolize.cpp?rev=354972&r1=354971&r2=354972&view=diff" rel="noopener noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/Symbolize/Symbolize.cpp?rev=354972&r1=354971&r2=354972&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/DebugInfo/Symbolize/Symbolize.cpp (original)<br>
+++ llvm/trunk/lib/DebugInfo/Symbolize/Symbolize.cpp Wed Feb 27 05:17:36 2019<br>
@@ -52,7 +52,8 @@ namespace symbolize {<br>
<br>
Expected<DILineInfo><br>
LLVMSymbolizer::symbolizeCode(const std::string &ModuleName,<br>
- uint64_t ModuleOffset, StringRef DWPName) {<br>
+ object::SectionedAddress ModuleOffset,<br>
+ StringRef DWPName) {<br>
SymbolizableModule *Info;<br>
if (auto InfoOrErr = getOrCreateModuleInfo(ModuleName, DWPName))<br>
Info = InfoOrErr.get();<br>
@@ -67,7 +68,7 @@ LLVMSymbolizer::symbolizeCode(const std:<br>
// If the user is giving us relative addresses, add the preferred base of the<br>
// object to the offset before we do the query. It's what DIContext expects.<br>
if (Opts.RelativeAddresses)<br>
- ModuleOffset += Info->getModulePreferredBase();<br>
+ ModuleOffset.Address += Info->getModulePreferredBase();<br>
<br>
DILineInfo LineInfo = Info->symbolizeCode(ModuleOffset, Opts.PrintFunctions,<br>
Opts.UseSymbolTable);<br>
@@ -78,7 +79,8 @@ LLVMSymbolizer::symbolizeCode(const std:<br>
<br>
Expected<DIInliningInfo><br>
LLVMSymbolizer::symbolizeInlinedCode(const std::string &ModuleName,<br>
- uint64_t ModuleOffset, StringRef DWPName) {<br>
+ object::SectionedAddress ModuleOffset,<br>
+ StringRef DWPName) {<br>
SymbolizableModule *Info;<br>
if (auto InfoOrErr = getOrCreateModuleInfo(ModuleName, DWPName))<br>
Info = InfoOrErr.get();<br>
@@ -93,7 +95,7 @@ LLVMSymbolizer::symbolizeInlinedCode(con<br>
// If the user is giving us relative addresses, add the preferred base of the<br>
// object to the offset before we do the query. It's what DIContext expects.<br>
if (Opts.RelativeAddresses)<br>
- ModuleOffset += Info->getModulePreferredBase();<br>
+ ModuleOffset.Address += Info->getModulePreferredBase();<br>
<br>
DIInliningInfo InlinedContext = Info->symbolizeInlinedCode(<br>
ModuleOffset, Opts.PrintFunctions, Opts.UseSymbolTable);<br>
@@ -106,8 +108,9 @@ LLVMSymbolizer::symbolizeInlinedCode(con<br>
return InlinedContext;<br>
}<br>
<br>
-Expected<DIGlobal> LLVMSymbolizer::symbolizeData(const std::string &ModuleName,<br>
- uint64_t ModuleOffset) {<br>
+Expected<DIGlobal><br>
+LLVMSymbolizer::symbolizeData(const std::string &ModuleName,<br>
+ object::SectionedAddress ModuleOffset) {<br>
SymbolizableModule *Info;<br>
if (auto InfoOrErr = getOrCreateModuleInfo(ModuleName))<br>
Info = InfoOrErr.get();<br>
@@ -123,7 +126,7 @@ Expected<DIGlobal> LLVMSymbolizer::symbo<br>
// the object to the offset before we do the query. It's what DIContext<br>
// expects.<br>
if (Opts.RelativeAddresses)<br>
- ModuleOffset += Info->getModulePreferredBase();<br>
+ ModuleOffset.Address += Info->getModulePreferredBase();<br>
<br>
DIGlobal Global = Info->symbolizeData(ModuleOffset);<br>
if (Opts.Demangle)<br>
<br>
Added: llvm/trunk/test/tools/llvm-objdump/X86/function-sections-line-numbers.s<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-objdump/X86/function-sections-line-numbers.s?rev=354972&view=auto" rel="noopener noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-objdump/X86/function-sections-line-numbers.s?rev=354972&view=auto</a><br>
==============================================================================<br>
--- llvm/trunk/test/tools/llvm-objdump/X86/function-sections-line-numbers.s (added)<br>
+++ llvm/trunk/test/tools/llvm-objdump/X86/function-sections-line-numbers.s Wed Feb 27 05:17:36 2019<br>
@@ -0,0 +1,221 @@<br>
+# The code below is the reduced version of the output<br>
+# from the following invocation and source:<br>
+#<br>
+# // test.cpp:<br>
+#void f1() {}<br>
+#void f2() {}<br>
+#<br>
+# clang -gdwarf-5 -ffunction-sections test.cpp -o test.s -S<br>
+<br>
+# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux -dwarf-version=5 %s -o %t.o<br>
+# RUN: llvm-objdump -disassemble -line-numbers -r -s -section-headers -t %t.o | FileCheck %s<br>
+<br>
+<br>
+# CHECK: 0000000000000000 _Z2f1v<br>
+# CHECK-NOT: test.cpp:2<br>
+# CHECK: test.cpp:1<br>
+# CHECK-NOT: test.cpp:2<br>
+# CHECK: 0000000000000000 _Z2f2v<br>
+# CHECK-NOT: test.cpp:1<br>
+# CHECK: test.cpp:2<br>
+# CHECK-NOT: test.cpp:1<br>
+<br>
+<br>
+ .text<br>
+ .file "test.cpp"<br>
+ .section .text._Z2f1v,"ax",@progbits<br>
+ .globl _Z2f1v # -- Begin function _Z2f1v<br>
+ .p2align 4, 0x90<br>
+ .type _Z2f1v,@function<br>
+_Z2f1v: # @_Z2f1v<br>
+.Lfunc_begin0:<br>
+ .file 0 "/home/avl" "test.cpp" md5 0xefae234cc05b45384d782316d3a5d338<br>
+ .file 1 "test.cpp" md5 0xefae234cc05b45384d782316d3a5d338<br>
+ .loc 1 1 0 # test.cpp:1:0<br>
+ .cfi_startproc<br>
+# %bb.0: # %entry<br>
+ pushq %rbp<br>
+ .cfi_def_cfa_offset 16<br>
+ .cfi_offset %rbp, -16<br>
+ movq %rsp, %rbp<br>
+ .cfi_def_cfa_register %rbp<br>
+.Ltmp0:<br>
+ .loc 1 1 12 prologue_end # test.cpp:1:12<br>
+ popq %rbp<br>
+ .cfi_def_cfa %rsp, 8<br>
+ retq<br>
+.Ltmp1:<br>
+.Lfunc_end0:<br>
+ .size _Z2f1v, .Lfunc_end0-_Z2f1v<br>
+ .cfi_endproc<br>
+ # -- End function<br>
+ .section .text._Z2f2v,"ax",@progbits<br>
+ .globl _Z2f2v # -- Begin function _Z2f2v<br>
+ .p2align 4, 0x90<br>
+ .type _Z2f2v,@function<br>
+_Z2f2v: # @_Z2f2v<br>
+.Lfunc_begin1:<br>
+ .loc 1 2 0 # test.cpp:2:0<br>
+ .cfi_startproc<br>
+# %bb.0: # %entry<br>
+ pushq %rbp<br>
+ .cfi_def_cfa_offset 16<br>
+ .cfi_offset %rbp, -16<br>
+ movq %rsp, %rbp<br>
+ .cfi_def_cfa_register %rbp<br>
+.Ltmp2:<br>
+ .loc 1 2 12 prologue_end # test.cpp:2:12<br>
+ popq %rbp<br>
+ .cfi_def_cfa %rsp, 8<br>
+ retq<br>
+.Ltmp3:<br>
+.Lfunc_end1:<br>
+ .size _Z2f2v, .Lfunc_end1-_Z2f2v<br>
+ .cfi_endproc<br>
+ # -- End function<br>
+ .section .debug_str_offsets,"",@progbits<br>
+ .long 32<br>
+ .short 5<br>
+ .short 0<br>
+.Lstr_offsets_base0:<br>
+ .section .debug_str,"MS",@progbits,1<br>
+.Linfo_string0:<br>
+ .asciz "clang version 9.0.0 (<a href="https://github.com/llvm/llvm-project.git" rel="noopener noreferrer" target="_blank">https://github.com/llvm/llvm-project.git</a> ebfc1e5af7a65381d858612517e6414ef58df482)" # string offset=0<br>
+.Linfo_string1:<br>
+ .asciz "test.cpp" # string offset=104<br>
+.Linfo_string2:<br>
+ .asciz "/home/avl" # string offset=113<br>
+.Linfo_string3:<br>
+ .asciz "_Z2f1v" # string offset=123<br>
+.Linfo_string4:<br>
+ .asciz "f1" # string offset=130<br>
+.Linfo_string5:<br>
+ .asciz "_Z2f2v" # string offset=133<br>
+.Linfo_string6:<br>
+ .asciz "f2" # string offset=140<br>
+ .section .debug_str_offsets,"",@progbits<br>
+ .long .Linfo_string0<br>
+ .long .Linfo_string1<br>
+ .long .Linfo_string2<br>
+ .long .Linfo_string3<br>
+ .long .Linfo_string4<br>
+ .long .Linfo_string5<br>
+ .long .Linfo_string6<br>
+ .section .debug_abbrev,"",@progbits<br>
+ .byte 1 # Abbreviation Code<br>
+ .byte 17 # DW_TAG_compile_unit<br>
+ .byte 1 # DW_CHILDREN_yes<br>
+ .byte 37 # DW_AT_producer<br>
+ .byte 37 # DW_FORM_strx1<br>
+ .byte 19 # DW_AT_language<br>
+ .byte 5 # DW_FORM_data2<br>
+ .byte 3 # DW_AT_name<br>
+ .byte 37 # DW_FORM_strx1<br>
+ .byte 114 # DW_AT_str_offsets_base<br>
+ .byte 23 # DW_FORM_sec_offset<br>
+ .byte 16 # DW_AT_stmt_list<br>
+ .byte 23 # DW_FORM_sec_offset<br>
+ .byte 27 # DW_AT_comp_dir<br>
+ .byte 37 # DW_FORM_strx1<br>
+ .byte 115 # DW_AT_addr_base<br>
+ .byte 23 # DW_FORM_sec_offset<br>
+ .byte 17 # DW_AT_low_pc<br>
+ .byte 1 # DW_FORM_addr<br>
+ .byte 85 # DW_AT_ranges<br>
+ .byte 35 # DW_FORM_rnglistx<br>
+ .byte 116 # DW_AT_rnglists_base<br>
+ .byte 23 # DW_FORM_sec_offset<br>
+ .byte 0 # EOM(1)<br>
+ .byte 0 # EOM(2)<br>
+ .byte 2 # Abbreviation Code<br>
+ .byte 46 # DW_TAG_subprogram<br>
+ .byte 0 # DW_CHILDREN_no<br>
+ .byte 17 # DW_AT_low_pc<br>
+ .byte 27 # DW_FORM_addrx<br>
+ .byte 18 # DW_AT_high_pc<br>
+ .byte 6 # DW_FORM_data4<br>
+ .byte 64 # DW_AT_frame_base<br>
+ .byte 24 # DW_FORM_exprloc<br>
+ .byte 110 # DW_AT_linkage_name<br>
+ .byte 37 # DW_FORM_strx1<br>
+ .byte 3 # DW_AT_name<br>
+ .byte 37 # DW_FORM_strx1<br>
+ .byte 58 # DW_AT_decl_file<br>
+ .byte 11 # DW_FORM_data1<br>
+ .byte 59 # DW_AT_decl_line<br>
+ .byte 11 # DW_FORM_data1<br>
+ .byte 63 # DW_AT_external<br>
+ .byte 25 # DW_FORM_flag_present<br>
+ .byte 0 # EOM(1)<br>
+ .byte 0 # EOM(2)<br>
+ .byte 0 # EOM(3)<br>
+ .section .debug_info,"",@progbits<br>
+.Lcu_begin0:<br>
+ .long .Ldebug_info_end0-.Ldebug_info_start0 # Length of Unit<br>
+.Ldebug_info_start0:<br>
+ .short 5 # DWARF version number<br>
+ .byte 1 # DWARF Unit Type<br>
+ .byte 8 # Address Size (in bytes)<br>
+ .long .debug_abbrev # Offset Into Abbrev. Section<br>
+ .byte 1 # Abbrev [1] 0xc:0x38 DW_TAG_compile_unit<br>
+ .byte 0 # DW_AT_producer<br>
+ .short 4 # DW_AT_language<br>
+ .byte 1 # DW_AT_name<br>
+ .long .Lstr_offsets_base0 # DW_AT_str_offsets_base<br>
+ .long .Lline_table_start0 # DW_AT_stmt_list<br>
+ .byte 2 # DW_AT_comp_dir<br>
+ .long .Laddr_table_base0 # DW_AT_addr_base<br>
+ .quad 0 # DW_AT_low_pc<br>
+ .byte 0 # DW_AT_ranges<br>
+ .long .Lrnglists_table_base0 # DW_AT_rnglists_base<br>
+ .byte 2 # Abbrev [2] 0x2b:0xc DW_TAG_subprogram<br>
+ .byte 0 # DW_AT_low_pc<br>
+ .long .Lfunc_end0-.Lfunc_begin0 # DW_AT_high_pc<br>
+ .byte 1 # DW_AT_frame_base<br>
+ .byte 86<br>
+ .byte 3 # DW_AT_linkage_name<br>
+ .byte 4 # DW_AT_name<br>
+ .byte 1 # DW_AT_decl_file<br>
+ .byte 1 # DW_AT_decl_line<br>
+ # DW_AT_external<br>
+ .byte 2 # Abbrev [2] 0x37:0xc DW_TAG_subprogram<br>
+ .byte 1 # DW_AT_low_pc<br>
+ .long .Lfunc_end1-.Lfunc_begin1 # DW_AT_high_pc<br>
+ .byte 1 # DW_AT_frame_base<br>
+ .byte 86<br>
+ .byte 5 # DW_AT_linkage_name<br>
+ .byte 6 # DW_AT_name<br>
+ .byte 1 # DW_AT_decl_file<br>
+ .byte 2 # DW_AT_decl_line<br>
+ # DW_AT_external<br>
+ .byte 0 # End Of Children Mark<br>
+.Ldebug_info_end0:<br>
+ .section .debug_rnglists,"",@progbits<br>
+ .long .Ldebug_rnglist_table_end0-.Ldebug_rnglist_table_start0 # Length<br>
+.Ldebug_rnglist_table_start0:<br>
+ .short 5 # Version<br>
+ .byte 8 # Address size<br>
+ .byte 0 # Segment selector size<br>
+ .long 1 # Offset entry count<br>
+.Lrnglists_table_base0:<br>
+ .long .Ldebug_ranges0-.Lrnglists_table_base0<br>
+.Ldebug_ranges0:<br>
+ .byte 3 # DW_RLE_startx_length<br>
+ .byte 0 # start index<br>
+ .uleb128 .Lfunc_end0-.Lfunc_begin0 # length<br>
+ .byte 3 # DW_RLE_startx_length<br>
+ .byte 1 # start index<br>
+ .uleb128 .Lfunc_end1-.Lfunc_begin1 # length<br>
+ .byte 0 # DW_RLE_end_of_list<br>
+.Ldebug_rnglist_table_end0:<br>
+.Ldebug_addr_start0:<br>
+ .short 5 # DWARF version number<br>
+ .byte 8 # Address size<br>
+ .byte 0 # Segment selector size<br>
+.Laddr_table_base0:<br>
+ .quad .Lfunc_begin0<br>
+ .quad .Lfunc_begin1<br>
+.Ldebug_addr_end0:<br>
+<br>
+ .section .debug_line,"",@progbits<br>
+.Lline_table_start0:<br>
<br>
Modified: llvm/trunk/tools/dsymutil/DwarfLinker.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/dsymutil/DwarfLinker.cpp?rev=354972&r1=354971&r2=354972&view=diff" rel="noopener noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/dsymutil/DwarfLinker.cpp?rev=354972&r1=354971&r2=354972&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/tools/dsymutil/DwarfLinker.cpp (original)<br>
+++ llvm/trunk/tools/dsymutil/DwarfLinker.cpp Wed Feb 27 05:17:36 2019<br>
@@ -1734,17 +1734,17 @@ void DwarfLinker::patchLineTableForUnit(<br>
// it is marked as end_sequence in the input (because in that<br>
// case, the relocation offset is accurate and that entry won't<br>
// serve as the start of another function).<br>
- if (CurrRange == InvalidRange || Row.Address < CurrRange.start() ||<br>
- Row.Address > CurrRange.stop() ||<br>
- (Row.Address == CurrRange.stop() && !Row.EndSequence)) {<br>
+ if (CurrRange == InvalidRange || Row.Address.Address < CurrRange.start() ||<br>
+ Row.Address.Address > CurrRange.stop() ||<br>
+ (Row.Address.Address == CurrRange.stop() && !Row.EndSequence)) {<br>
// We just stepped out of a known range. Insert a end_sequence<br>
// corresponding to the end of the range.<br>
uint64_t StopAddress = CurrRange != InvalidRange<br>
? CurrRange.stop() + CurrRange.value()<br>
: -1ULL;<br>
- CurrRange = FunctionRanges.find(Row.Address);<br>
+ CurrRange = FunctionRanges.find(Row.Address.Address);<br>
bool CurrRangeValid =<br>
- CurrRange != InvalidRange && CurrRange.start() <= Row.Address;<br>
+ CurrRange != InvalidRange && CurrRange.start() <= Row.Address.Address;<br>
if (!CurrRangeValid) {<br>
CurrRange = InvalidRange;<br>
if (StopAddress != -1ULL) {<br>
@@ -1754,13 +1754,13 @@ void DwarfLinker::patchLineTableForUnit(<br>
// for now do as dsymutil.<br>
// FIXME: Understand exactly what cases this addresses and<br>
// potentially remove it along with the Ranges map.<br>
- auto Range = Ranges.lower_bound(Row.Address);<br>
+ auto Range = Ranges.lower_bound(Row.Address.Address);<br>
if (Range != Ranges.begin() && Range != Ranges.end())<br>
--Range;<br>
<br>
- if (Range != Ranges.end() && Range->first <= Row.Address &&<br>
- Range->second.HighPC >= Row.Address) {<br>
- StopAddress = Row.Address + Range->second.Offset;<br>
+ if (Range != Ranges.end() && Range->first <= Row.Address.Address &&<br>
+ Range->second.HighPC >= Row.Address.Address) {<br>
+ StopAddress = Row.Address.Address + Range->second.Offset;<br>
}<br>
}<br>
}<br>
@@ -1768,7 +1768,7 @@ void DwarfLinker::patchLineTableForUnit(<br>
// Insert end sequence row with the computed end address, but<br>
// the same line as the previous one.<br>
auto NextLine = Seq.back();<br>
- NextLine.Address = StopAddress;<br>
+ NextLine.Address.Address = StopAddress;<br>
NextLine.EndSequence = 1;<br>
NextLine.PrologueEnd = 0;<br>
NextLine.BasicBlock = 0;<br>
@@ -1786,7 +1786,7 @@ void DwarfLinker::patchLineTableForUnit(<br>
continue;<br>
<br>
// Relocate row address and add it to the current sequence.<br>
- Row.Address += CurrRange.value();<br>
+ Row.Address.Address += CurrRange.value();<br>
Seq.emplace_back(Row);<br>
<br>
if (Row.EndSequence)<br>
<br>
Modified: llvm/trunk/tools/dsymutil/DwarfStreamer.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/dsymutil/DwarfStreamer.cpp?rev=354972&r1=354971&r2=354972&view=diff" rel="noopener noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/dsymutil/DwarfStreamer.cpp?rev=354972&r1=354971&r2=354972&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/tools/dsymutil/DwarfStreamer.cpp (original)<br>
+++ llvm/trunk/tools/dsymutil/DwarfStreamer.cpp Wed Feb 27 05:17:36 2019<br>
@@ -480,11 +480,11 @@ void DwarfStreamer::emitLineTableForUnit<br>
MS->EmitIntValue(dwarf::DW_LNS_extended_op, 1);<br>
MS->EmitULEB128IntValue(PointerSize + 1);<br>
MS->EmitIntValue(dwarf::DW_LNE_set_address, 1);<br>
- MS->EmitIntValue(Row.Address, PointerSize);<br>
+ MS->EmitIntValue(Row.Address.Address, PointerSize);<br>
LineSectionSize += 2 + PointerSize + getULEB128Size(PointerSize + 1);<br>
AddressDelta = 0;<br>
} else {<br>
- AddressDelta = (Row.Address - Address) / MinInstLength;<br>
+ AddressDelta = (Row.Address.Address - Address) / MinInstLength;<br>
}<br>
<br>
// FIXME: code copied and transformed from MCDwarf.cpp::EmitDwarfLineTable.<br>
@@ -540,7 +540,7 @@ void DwarfStreamer::emitLineTableForUnit<br>
MS->EmitBytes(EncodingOS.str());<br>
LineSectionSize += EncodingBuffer.size();<br>
EncodingBuffer.resize(0);<br>
- Address = Row.Address;<br>
+ Address = Row.Address.Address;<br>
LastLine = Row.Line;<br>
RowsSinceLastSequence++;<br>
} else {<br>
<br>
Modified: llvm/trunk/tools/llvm-cfi-verify/lib/FileAnalysis.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-cfi-verify/lib/FileAnalysis.cpp?rev=354972&r1=354971&r2=354972&view=diff" rel="noopener noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-cfi-verify/lib/FileAnalysis.cpp?rev=354972&r1=354971&r2=354972&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/tools/llvm-cfi-verify/lib/FileAnalysis.cpp (original)<br>
+++ llvm/trunk/tools/llvm-cfi-verify/lib/FileAnalysis.cpp Wed Feb 27 05:17:36 2019<br>
@@ -254,7 +254,8 @@ FileAnalysis::getDirectControlFlowXRefs(<br>
return CFCrossReferences;<br>
}<br>
<br>
-const std::set<uint64_t> &FileAnalysis::getIndirectInstructions() const {<br>
+const std::set<object::SectionedAddress> &<br>
+FileAnalysis::getIndirectInstructions() const {<br>
return IndirectInstructions;<br>
}<br>
<br>
@@ -268,8 +269,10 @@ const MCInstrAnalysis *FileAnalysis::get<br>
return MIA.get();<br>
}<br>
<br>
-Expected<DIInliningInfo> FileAnalysis::symbolizeInlinedCode(uint64_t Address) {<br>
+Expected<DIInliningInfo><br>
+FileAnalysis::symbolizeInlinedCode(object::SectionedAddress Address) {<br>
assert(Symbolizer != nullptr && "Symbolizer is invalid.");<br>
+<br>
return Symbolizer->symbolizeInlinedCode(Object->getFileName(), Address);<br>
}<br>
<br>
@@ -457,13 +460,14 @@ Error FileAnalysis::parseCodeSections()<br>
<br>
ArrayRef<uint8_t> SectionBytes((const uint8_t *)SectionContents.data(),<br>
Section.getSize());<br>
- parseSectionContents(SectionBytes, Section.getAddress());<br>
+ parseSectionContents(SectionBytes,<br>
+ {Section.getAddress(), Section.getIndex()});<br>
}<br>
return Error::success();<br>
}<br>
<br>
void FileAnalysis::parseSectionContents(ArrayRef<uint8_t> SectionBytes,<br>
- uint64_t SectionAddress) {<br>
+ object::SectionedAddress Address) {<br>
assert(Symbolizer && "Symbolizer is uninitialised.");<br>
MCInst Instruction;<br>
Instr InstrMeta;<br>
@@ -477,7 +481,7 @@ void FileAnalysis::parseSectionContents(<br>
<br>
Byte += InstructionSize;<br>
<br>
- uint64_t VMAddress = SectionAddress + Byte - InstructionSize;<br>
+ uint64_t VMAddress = Address.Address + Byte - InstructionSize;<br>
InstrMeta.Instruction = Instruction;<br>
InstrMeta.VMAddress = VMAddress;<br>
InstrMeta.InstructionSize = InstructionSize;<br>
@@ -509,8 +513,8 @@ void FileAnalysis::parseSectionContents(<br>
<br>
// Check if this instruction exists in the range of the DWARF metadata.<br>
if (!IgnoreDWARFFlag) {<br>
- auto LineInfo =<br>
- Symbolizer->symbolizeCode(Object->getFileName(), VMAddress);<br>
+ auto LineInfo = Symbolizer->symbolizeCode(<br>
+ Object->getFileName(), {VMAddress, Address.SectionIndex});<br>
if (!LineInfo) {<br>
handleAllErrors(LineInfo.takeError(), [](const ErrorInfoBase &E) {<br>
errs() << "Symbolizer failed to get line: " << E.message() << "\n";<br>
@@ -522,7 +526,7 @@ void FileAnalysis::parseSectionContents(<br>
continue;<br>
}<br>
<br>
- IndirectInstructions.insert(VMAddress);<br>
+ IndirectInstructions.insert({VMAddress, Address.SectionIndex});<br>
}<br>
}<br>
<br>
<br>
Modified: llvm/trunk/tools/llvm-cfi-verify/lib/FileAnalysis.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-cfi-verify/lib/FileAnalysis.h?rev=354972&r1=354971&r2=354972&view=diff" rel="noopener noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-cfi-verify/lib/FileAnalysis.h?rev=354972&r1=354971&r2=354972&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/tools/llvm-cfi-verify/lib/FileAnalysis.h (original)<br>
+++ llvm/trunk/tools/llvm-cfi-verify/lib/FileAnalysis.h Wed Feb 27 05:17:36 2019<br>
@@ -139,14 +139,15 @@ public:<br>
bool usesRegisterOperand(const Instr &InstrMeta) const;<br>
<br>
// Returns the list of indirect instructions.<br>
- const std::set<uint64_t> &getIndirectInstructions() const;<br>
+ const std::set<object::SectionedAddress> &getIndirectInstructions() const;<br>
<br>
const MCRegisterInfo *getRegisterInfo() const;<br>
const MCInstrInfo *getMCInstrInfo() const;<br>
const MCInstrAnalysis *getMCInstrAnalysis() const;<br>
<br>
// Returns the inlining information for the provided address.<br>
- Expected<DIInliningInfo> symbolizeInlinedCode(uint64_t Address);<br>
+ Expected<DIInliningInfo><br>
+ symbolizeInlinedCode(object::SectionedAddress Address);<br>
<br>
// Returns whether the provided Graph represents a protected indirect control<br>
// flow instruction in this file.<br>
@@ -178,7 +179,7 @@ protected:<br>
// Disassemble and parse the provided bytes into this object. Instruction<br>
// address calculation is done relative to the provided SectionAddress.<br>
void parseSectionContents(ArrayRef<uint8_t> SectionBytes,<br>
- uint64_t SectionAddress);<br>
+ object::SectionedAddress Address);<br>
<br>
// Constructs and initialises members required for disassembly.<br>
Error initialiseDisassemblyMembers();<br>
@@ -225,7 +226,7 @@ private:<br>
DenseMap<uint64_t, std::vector<uint64_t>> StaticBranchTargetings;<br>
<br>
// A list of addresses of indirect control flow instructions.<br>
- std::set<uint64_t> IndirectInstructions;<br>
+ std::set<object::SectionedAddress> IndirectInstructions;<br>
<br>
// The addresses of functions that will trap on CFI violations.<br>
SmallSet<uint64_t, 4> TrapOnFailFunctionAddresses;<br>
<br>
Modified: llvm/trunk/tools/llvm-cfi-verify/lib/GraphBuilder.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-cfi-verify/lib/GraphBuilder.cpp?rev=354972&r1=354971&r2=354972&view=diff" rel="noopener noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-cfi-verify/lib/GraphBuilder.cpp?rev=354972&r1=354971&r2=354972&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/tools/llvm-cfi-verify/lib/GraphBuilder.cpp (original)<br>
+++ llvm/trunk/tools/llvm-cfi-verify/lib/GraphBuilder.cpp Wed Feb 27 05:17:36 2019<br>
@@ -93,17 +93,19 @@ void GraphResult::printToDOT(const FileA<br>
}<br>
<br>
GraphResult GraphBuilder::buildFlowGraph(const FileAnalysis &Analysis,<br>
- uint64_t Address) {<br>
+ object::SectionedAddress Address) {<br>
GraphResult Result;<br>
- Result.BaseAddress = Address;<br>
+ Result.BaseAddress = Address.Address;<br>
DenseSet<uint64_t> OpenedNodes;<br>
<br>
const auto &IndirectInstructions = Analysis.getIndirectInstructions();<br>
<br>
- if (IndirectInstructions.find(Address) == IndirectInstructions.end())<br>
+ // check that IndirectInstructions contains specified Address<br>
+ if (IndirectInstructions.find(Address) == IndirectInstructions.end()) {<br>
return Result;<br>
+ }<br>
<br>
- buildFlowGraphImpl(Analysis, OpenedNodes, Result, Address, 0);<br>
+ buildFlowGraphImpl(Analysis, OpenedNodes, Result, Address.Address, 0);<br>
return Result;<br>
}<br>
<br>
<br>
Modified: llvm/trunk/tools/llvm-cfi-verify/lib/GraphBuilder.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-cfi-verify/lib/GraphBuilder.h?rev=354972&r1=354971&r2=354972&view=diff" rel="noopener noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-cfi-verify/lib/GraphBuilder.h?rev=354972&r1=354971&r2=354972&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/tools/llvm-cfi-verify/lib/GraphBuilder.h (original)<br>
+++ llvm/trunk/tools/llvm-cfi-verify/lib/GraphBuilder.h Wed Feb 27 05:17:36 2019<br>
@@ -102,7 +102,7 @@ public:<br>
// (i.e. the upwards traversal did not make it to a branch node) flows to the<br>
// provided node in GraphResult::OrphanedNodes.<br>
static GraphResult buildFlowGraph(const FileAnalysis &Analysis,<br>
- uint64_t Address);<br>
+ object::SectionedAddress Address);<br>
<br>
private:<br>
// Implementation function that actually builds the flow graph. Retrieves a<br>
<br>
Modified: llvm/trunk/tools/llvm-cfi-verify/llvm-cfi-verify.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-cfi-verify/llvm-cfi-verify.cpp?rev=354972&r1=354971&r2=354972&view=diff" rel="noopener noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-cfi-verify/llvm-cfi-verify.cpp?rev=354972&r1=354971&r2=354972&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/tools/llvm-cfi-verify/llvm-cfi-verify.cpp (original)<br>
+++ llvm/trunk/tools/llvm-cfi-verify/llvm-cfi-verify.cpp Wed Feb 27 05:17:36 2019<br>
@@ -130,8 +130,8 @@ void printIndirectCFInstructions(FileAna<br>
<br>
std::map<unsigned, uint64_t> BlameCounter;<br>
<br>
- for (uint64_t Address : Analysis.getIndirectInstructions()) {<br>
- const auto &InstrMeta = Analysis.getInstructionOrDie(Address);<br>
+ for (object::SectionedAddress Address : Analysis.getIndirectInstructions()) {<br>
+ const auto &InstrMeta = Analysis.getInstructionOrDie(Address.Address);<br>
GraphResult Graph = GraphBuilder::buildFlowGraph(Analysis, Address);<br>
<br>
CFIProtectionStatus ProtectionStatus =<br>
@@ -153,7 +153,7 @@ void printIndirectCFInstructions(FileAna<br>
<br>
auto InliningInfo = Analysis.symbolizeInlinedCode(Address);<br>
if (!InliningInfo || InliningInfo->getNumberOfFrames() == 0) {<br>
- errs() << "Failed to symbolise " << format_hex(Address, 2)<br>
+ errs() << "Failed to symbolise " << format_hex(Address.Address, 2)<br>
<< " with line tables from " << InputFilename << "\n";<br>
exit(EXIT_FAILURE);<br>
}<br>
@@ -164,9 +164,9 @@ void printIndirectCFInstructions(FileAna<br>
if (!Summarize) {<br>
for (uint32_t i = 0; i < InliningInfo->getNumberOfFrames(); ++i) {<br>
const auto &Line = InliningInfo->getFrame(i);<br>
- outs() << " " << format_hex(Address, 2) << " = " << Line.FileName<br>
- << ":" << Line.Line << ":" << Line.Column << " ("<br>
- << Line.FunctionName << ")\n";<br>
+ outs() << " " << format_hex(Address.Address, 2) << " = "<br>
+ << Line.FileName << ":" << Line.Line << ":" << Line.Column<br>
+ << " (" << Line.FunctionName << ")\n";<br>
}<br>
}<br>
<br>
<br>
Modified: llvm/trunk/tools/llvm-dwarfdump/llvm-dwarfdump.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-dwarfdump/llvm-dwarfdump.cpp?rev=354972&r1=354971&r2=354972&view=diff" rel="noopener noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-dwarfdump/llvm-dwarfdump.cpp?rev=354972&r1=354971&r2=354972&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/tools/llvm-dwarfdump/llvm-dwarfdump.cpp (original)<br>
+++ llvm/trunk/tools/llvm-dwarfdump/llvm-dwarfdump.cpp Wed Feb 27 05:17:36 2019<br>
@@ -379,7 +379,12 @@ static void filterByAccelName(ArrayRef<s<br>
<br>
/// Handle the --lookup option and dump the DIEs and line info for the given<br>
/// address.<br>
-static bool lookup(DWARFContext &DICtx, uint64_t Address, raw_ostream &OS) {<br>
+/// TODO: specified Address for --lookup option could relate for several<br>
+/// different sections(in case not-linked object file). llvm-dwarfdump<br>
+/// need to do something with this: extend lookup option with section<br>
+/// information or probably display all matched entries, or something else...<br>
+static bool lookup(ObjectFile &Obj, DWARFContext &DICtx, uint64_t Address,<br>
+ raw_ostream &OS) {<br>
auto DIEsForAddr = DICtx.getDIEsForAddress(Lookup);<br>
<br>
if (!DIEsForAddr)<br>
@@ -394,7 +399,10 @@ static bool lookup(DWARFContext &DICtx,<br>
DIEsForAddr.BlockDIE.dump(OS, 4, DumpOpts);<br>
}<br>
<br>
- if (DILineInfo LineInfo = DICtx.getLineInfoForAddress(Lookup))<br>
+ // TODO: it is neccessary to set proper SectionIndex here.<br>
+ // object::SectionedAddress::UndefSection works for only absolute addresses.<br>
+ if (DILineInfo LineInfo = DICtx.getLineInfoForAddress(<br>
+ {Lookup, object::SectionedAddress::UndefSection}))<br>
LineInfo.dump(OS);<br>
<br>
return true;<br>
@@ -413,7 +421,7 @@ static bool dumpObjectFile(ObjectFile &O<br>
<br>
// Handle the --lookup option.<br>
if (Lookup)<br>
- return lookup(DICtx, Lookup, OS);<br>
+ return lookup(Obj, DICtx, Lookup, OS);<br>
<br>
// Handle the --name option.<br>
if (!Name.empty()) {<br>
<br>
Modified: llvm/trunk/tools/llvm-objdump/MachODump.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-objdump/MachODump.cpp?rev=354972&r1=354971&r2=354972&view=diff" rel="noopener noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-objdump/MachODump.cpp?rev=354972&r1=354971&r2=354972&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/tools/llvm-objdump/MachODump.cpp (original)<br>
+++ llvm/trunk/tools/llvm-objdump/MachODump.cpp Wed Feb 27 05:17:36 2019<br>
@@ -7500,7 +7500,7 @@ static void DisassembleMachO(StringRef F<br>
<br>
// Print debug info.<br>
if (diContext) {<br>
- DILineInfo dli = diContext->getLineInfoForAddress(PC);<br>
+ DILineInfo dli = diContext->getLineInfoForAddress({PC, SectIdx});<br>
// Print valid line info if it changed.<br>
if (dli != lastLine && dli.Line != 0)<br>
outs() << "\t## " << dli.FileName << ':' << dli.Line << ':'<br>
<br>
Modified: llvm/trunk/tools/llvm-objdump/llvm-objdump.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-objdump/llvm-objdump.cpp?rev=354972&r1=354971&r2=354972&view=diff" rel="noopener noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-objdump/llvm-objdump.cpp?rev=354972&r1=354971&r2=354972&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/tools/llvm-objdump/llvm-objdump.cpp (original)<br>
+++ llvm/trunk/tools/llvm-objdump/llvm-objdump.cpp Wed Feb 27 05:17:36 2019<br>
@@ -508,7 +508,8 @@ public:<br>
Symbolizer.reset(new symbolize::LLVMSymbolizer(SymbolizerOpts));<br>
}<br>
virtual ~SourcePrinter() = default;<br>
- virtual void printSourceLine(raw_ostream &OS, uint64_t Address,<br>
+ virtual void printSourceLine(raw_ostream &OS,<br>
+ object::SectionedAddress Address,<br>
StringRef Delimiter = "; ");<br>
};<br>
<br>
@@ -538,7 +539,8 @@ bool SourcePrinter::cacheSource(const DI<br>
return true;<br>
}<br>
<br>
-void SourcePrinter::printSourceLine(raw_ostream &OS, uint64_t Address,<br>
+void SourcePrinter::printSourceLine(raw_ostream &OS,<br>
+ object::SectionedAddress Address,<br>
StringRef Delimiter) {<br>
if (!Symbolizer)<br>
return;<br>
@@ -599,14 +601,15 @@ class PrettyPrinter {<br>
public:<br>
virtual ~PrettyPrinter() = default;<br>
virtual void printInst(MCInstPrinter &IP, const MCInst *MI,<br>
- ArrayRef<uint8_t> Bytes, uint64_t Address,<br>
- raw_ostream &OS, StringRef Annot,<br>
- MCSubtargetInfo const &STI, SourcePrinter *SP,<br>
+ ArrayRef<uint8_t> Bytes,<br>
+ object::SectionedAddress Address, raw_ostream &OS,<br>
+ StringRef Annot, MCSubtargetInfo const &STI,<br>
+ SourcePrinter *SP,<br>
std::vector<RelocationRef> *Rels = nullptr) {<br>
if (SP && (PrintSource || PrintLines))<br>
SP->printSourceLine(OS, Address);<br>
if (!NoLeadingAddr)<br>
- OS << format("%8" PRIx64 ":", Address);<br>
+ OS << format("%8" PRIx64 ":", Address.Address);<br>
if (!NoShowRawInsn) {<br>
OS << "\t";<br>
dumpBytes(Bytes, OS);<br>
@@ -633,13 +636,13 @@ public:<br>
}<br>
}<br>
void printInst(MCInstPrinter &IP, const MCInst *MI, ArrayRef<uint8_t> Bytes,<br>
- uint64_t Address, raw_ostream &OS, StringRef Annot,<br>
- MCSubtargetInfo const &STI, SourcePrinter *SP,<br>
+ object::SectionedAddress Address, raw_ostream &OS,<br>
+ StringRef Annot, MCSubtargetInfo const &STI, SourcePrinter *SP,<br>
std::vector<RelocationRef> *Rels) override {<br>
if (SP && (PrintSource || PrintLines))<br>
SP->printSourceLine(OS, Address, "");<br>
if (!MI) {<br>
- printLead(Bytes, Address, OS);<br>
+ printLead(Bytes, Address.Address, OS);<br>
OS << " <unknown>";<br>
return;<br>
}<br>
@@ -661,9 +664,9 @@ public:<br>
std::vector<RelocationRef>::const_iterator RelCur = Rels->begin();<br>
std::vector<RelocationRef>::const_iterator RelEnd = Rels->end();<br>
auto PrintReloc = [&]() -> void {<br>
- while ((RelCur != RelEnd) && (RelCur->getOffset() <= Address)) {<br>
- if (RelCur->getOffset() == Address) {<br>
- printRelocation(*RelCur, Address, 4);<br>
+ while ((RelCur != RelEnd) && (RelCur->getOffset() <= Address.Address)) {<br>
+ if (RelCur->getOffset() == Address.Address) {<br>
+ printRelocation(*RelCur, Address.Address, 4);<br>
return;<br>
}<br>
++RelCur;<br>
@@ -675,7 +678,7 @@ public:<br>
Separator = "\n";<br>
if (SP && (PrintSource || PrintLines))<br>
SP->printSourceLine(OS, Address, "");<br>
- printLead(Bytes, Address, OS);<br>
+ printLead(Bytes, Address.Address, OS);<br>
OS << Preamble;<br>
Preamble = " ";<br>
StringRef Inst;<br>
@@ -693,7 +696,7 @@ public:<br>
OS << " } " << PacketBundle.second;<br>
PrintReloc();<br>
Bytes = Bytes.slice(4);<br>
- Address += 4;<br>
+ Address.Address += 4;<br>
}<br>
}<br>
};<br>
@@ -702,8 +705,8 @@ HexagonPrettyPrinter HexagonPrettyPrinte<br>
class AMDGCNPrettyPrinter : public PrettyPrinter {<br>
public:<br>
void printInst(MCInstPrinter &IP, const MCInst *MI, ArrayRef<uint8_t> Bytes,<br>
- uint64_t Address, raw_ostream &OS, StringRef Annot,<br>
- MCSubtargetInfo const &STI, SourcePrinter *SP,<br>
+ object::SectionedAddress Address, raw_ostream &OS,<br>
+ StringRef Annot, MCSubtargetInfo const &STI, SourcePrinter *SP,<br>
std::vector<RelocationRef> *Rels) override {<br>
if (SP && (PrintSource || PrintLines))<br>
SP->printSourceLine(OS, Address);<br>
@@ -733,7 +736,7 @@ public:<br>
}<br>
}<br>
<br>
- OS << format("// %012" PRIX64 ": ", Address);<br>
+ OS << format("// %012" PRIX64 ": ", Address.Address);<br>
if (Bytes.size() >=4) {<br>
for (auto D : makeArrayRef(reinterpret_cast<const U32*>(Bytes.data()),<br>
Bytes.size() / sizeof(U32)))<br>
@@ -754,13 +757,13 @@ AMDGCNPrettyPrinter AMDGCNPrettyPrinterI<br>
class BPFPrettyPrinter : public PrettyPrinter {<br>
public:<br>
void printInst(MCInstPrinter &IP, const MCInst *MI, ArrayRef<uint8_t> Bytes,<br>
- uint64_t Address, raw_ostream &OS, StringRef Annot,<br>
- MCSubtargetInfo const &STI, SourcePrinter *SP,<br>
+ object::SectionedAddress Address, raw_ostream &OS,<br>
+ StringRef Annot, MCSubtargetInfo const &STI, SourcePrinter *SP,<br>
std::vector<RelocationRef> *Rels) override {<br>
if (SP && (PrintSource || PrintLines))<br>
SP->printSourceLine(OS, Address);<br>
if (!NoLeadingAddr)<br>
- OS << format("%8" PRId64 ":", Address / 8);<br>
+ OS << format("%8" PRId64 ":", Address.Address / 8);<br>
if (!NoShowRawInsn) {<br>
OS << "\t";<br>
dumpBytes(Bytes, OS);<br>
@@ -1323,9 +1326,10 @@ static void disassembleObject(const Targ<br>
if (Size == 0)<br>
Size = 1;<br>
<br>
- PIP.printInst(<br>
- *IP, Disassembled ? &Inst : nullptr, Bytes.slice(Index, Size),<br>
- SectionAddr + Index + VMAAdjustment, outs(), "", *STI, &SP, &Rels);<br>
+ PIP.printInst(*IP, Disassembled ? &Inst : nullptr,<br>
+ Bytes.slice(Index, Size),<br>
+ {SectionAddr + Index + VMAAdjustment, Section.getIndex()},<br>
+ outs(), "", *STI, &SP, &Rels);<br>
outs() << CommentStream.str();<br>
Comments.clear();<br>
<br>
<br>
Modified: llvm/trunk/tools/llvm-rtdyld/llvm-rtdyld.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-rtdyld/llvm-rtdyld.cpp?rev=354972&r1=354971&r2=354972&view=diff" rel="noopener noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-rtdyld/llvm-rtdyld.cpp?rev=354972&r1=354971&r2=354972&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/tools/llvm-rtdyld/llvm-rtdyld.cpp (original)<br>
+++ llvm/trunk/tools/llvm-rtdyld/llvm-rtdyld.cpp Wed Feb 27 05:17:36 2019<br>
@@ -367,6 +367,8 @@ static int printLineInfoForInput(bool Lo<br>
}<br>
uint64_t Addr = *AddrOrErr;<br>
<br>
+ object::SectionedAddress Address;<br>
+<br>
uint64_t Size = P.second;<br>
// If we're not using the debug object, compute the address of the<br>
// symbol in memory (rather than that in the unrelocated object file)<br>
@@ -381,16 +383,20 @@ static int printLineInfoForInput(bool Lo<br>
object::section_iterator Sec = *SecOrErr;<br>
StringRef SecName;<br>
Sec->getName(SecName);<br>
+ Address.SectionIndex = Sec->getIndex();<br>
uint64_t SectionLoadAddress =<br>
LoadedObjInfo->getSectionLoadAddress(*Sec);<br>
if (SectionLoadAddress != 0)<br>
Addr += SectionLoadAddress - Sec->getAddress();<br>
- }<br>
+ } else if (auto SecOrErr = Sym.getSection())<br>
+ Address.SectionIndex = SecOrErr.get()->getIndex();<br>
<br>
outs() << "Function: " << *Name << ", Size = " << Size<br>
<< ", Addr = " << Addr << "\n";<br>
<br>
- DILineInfoTable Lines = Context->getLineInfoForAddressRange(Addr, Size);<br>
+ Address.Address = Addr;<br>
+ DILineInfoTable Lines =<br>
+ Context->getLineInfoForAddressRange(Address, Size);<br>
for (auto &D : Lines) {<br>
outs() << " Line info @ " << D.first - Addr << ": "<br>
<< D.second.FileName << ", line:" << D.second.Line << "\n";<br>
<br>
Modified: llvm/trunk/tools/llvm-symbolizer/llvm-symbolizer.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-symbolizer/llvm-symbolizer.cpp?rev=354972&r1=354971&r2=354972&view=diff" rel="noopener noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-symbolizer/llvm-symbolizer.cpp?rev=354972&r1=354971&r2=354972&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/tools/llvm-symbolizer/llvm-symbolizer.cpp (original)<br>
+++ llvm/trunk/tools/llvm-symbolizer/llvm-symbolizer.cpp Wed Feb 27 05:17:36 2019<br>
@@ -194,23 +194,54 @@ static bool parseCommand(StringRef Input<br>
return !StringRef(pos, offset_length).getAsInteger(0, ModuleOffset);<br>
}<br>
<br>
+// This routine returns section index for an address.<br>
+// Assumption: would work ambiguously for object files which have sections not<br>
+// assigned to an address(since the same address could belong to various<br>
+// sections).<br>
+static uint64_t getModuleSectionIndexForAddress(const std::string &ModuleName,<br>
+ uint64_t Address) {<br>
+<br>
+ Expected<OwningBinary<Binary>> BinaryOrErr = createBinary(ModuleName);<br>
+<br>
+ if (error(BinaryOrErr))<br>
+ return object::SectionedAddress::UndefSection;<br>
+<br>
+ Binary &Binary = *BinaryOrErr->getBinary();<br>
+<br>
+ if (ObjectFile *O = dyn_cast<ObjectFile>(&Binary)) {<br>
+ for (SectionRef Sec : O->sections()) {<br>
+ if (!Sec.isText() || Sec.isVirtual())<br>
+ continue;<br>
+<br>
+ if (Address >= Sec.getAddress() &&<br>
+ Address <= Sec.getAddress() + Sec.getSize()) {<br>
+ return Sec.getIndex();<br>
+ }<br>
+ }<br>
+ }<br>
+<br>
+ return object::SectionedAddress::UndefSection;<br>
+}<br>
+<br>
static void symbolizeInput(StringRef InputString, LLVMSymbolizer &Symbolizer,<br>
DIPrinter &Printer) {<br>
bool IsData = false;<br>
std::string ModuleName;<br>
- uint64_t ModuleOffset = 0;<br>
- if (!parseCommand(StringRef(InputString), IsData, ModuleName, ModuleOffset)) {<br>
+ uint64_t Offset = 0;<br>
+ if (!parseCommand(StringRef(InputString), IsData, ModuleName, Offset)) {<br>
outs() << InputString;<br>
return;<br>
}<br>
<br>
if (ClPrintAddress) {<br>
outs() << "0x";<br>
- outs().write_hex(ModuleOffset);<br>
+ outs().write_hex(Offset);<br>
StringRef Delimiter = ClPrettyPrint ? ": " : "\n";<br>
outs() << Delimiter;<br>
}<br>
- ModuleOffset -= ClAdjustVMA;<br>
+ Offset -= ClAdjustVMA;<br>
+ object::SectionedAddress ModuleOffset = {<br>
+ Offset, getModuleSectionIndexForAddress(ModuleName, Offset)};<br>
if (IsData) {<br>
auto ResOrErr = Symbolizer.symbolizeData(ModuleName, ModuleOffset);<br>
Printer << (error(ResOrErr) ? DIGlobal() : ResOrErr.get());<br>
<br>
Modified: llvm/trunk/tools/llvm-xray/func-id-helper.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-xray/func-id-helper.cpp?rev=354972&r1=354971&r2=354972&view=diff" rel="noopener noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-xray/func-id-helper.cpp?rev=354972&r1=354971&r2=354972&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/tools/llvm-xray/func-id-helper.cpp (original)<br>
+++ llvm/trunk/tools/llvm-xray/func-id-helper.cpp Wed Feb 27 05:17:36 2019<br>
@@ -29,7 +29,12 @@ std::string FuncIdConversionHelper::Symb<br>
return F.str();<br>
}<br>
<br>
- if (auto ResOrErr = Symbolizer.symbolizeCode(BinaryInstrMap, It->second)) {<br>
+ object::SectionedAddress ModuleAddress;<br>
+ ModuleAddress.Address = It->second;<br>
+ // TODO: set proper section index here.<br>
+ // object::SectionedAddress::UndefSection works for only absolute addresses.<br>
+ ModuleAddress.SectionIndex = object::SectionedAddress::UndefSection;<br>
+ if (auto ResOrErr = Symbolizer.symbolizeCode(BinaryInstrMap, ModuleAddress)) {<br>
auto &DI = *ResOrErr;<br>
if (DI.FunctionName == "<invalid>")<br>
F << "@(" << std::hex << It->second << ")";<br>
@@ -51,7 +56,12 @@ std::string FuncIdConversionHelper::File<br>
return "(unknown)";<br>
<br>
std::ostringstream F;<br>
- auto ResOrErr = Symbolizer.symbolizeCode(BinaryInstrMap, It->second);<br>
+ object::SectionedAddress ModuleAddress;<br>
+ ModuleAddress.Address = It->second;<br>
+ // TODO: set proper section index here.<br>
+ // object::SectionedAddress::UndefSection works for only absolute addresses.<br>
+ ModuleAddress.SectionIndex = object::SectionedAddress::UndefSection;<br>
+ auto ResOrErr = Symbolizer.symbolizeCode(BinaryInstrMap, ModuleAddress);<br>
if (!ResOrErr) {<br>
consumeError(ResOrErr.takeError());<br>
return "(unknown)";<br>
<br>
Modified: llvm/trunk/tools/sancov/sancov.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/sancov/sancov.cpp?rev=354972&r1=354971&r2=354972&view=diff" rel="noopener noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/sancov/sancov.cpp?rev=354972&r1=354971&r2=354972&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/tools/sancov/sancov.cpp (original)<br>
+++ llvm/trunk/tools/sancov/sancov.cpp Wed Feb 27 05:17:36 2019<br>
@@ -621,10 +621,17 @@ getCoveragePoints(const std::string &Obj<br>
std::set<std::string> CoveredFiles;<br>
if (ClSkipDeadFiles) {<br>
for (auto Addr : CoveredAddrs) {<br>
- auto LineInfo = Symbolizer->symbolizeCode(ObjectFile, Addr);<br>
+ // TODO: it would be neccessary to set proper section index here.<br>
+ // object::SectionedAddress::UndefSection works for only absolute<br>
+ // addresses.<br>
+ object::SectionedAddress ModuleAddress = {<br>
+ Addr, object::SectionedAddress::UndefSection};<br>
+<br>
+ auto LineInfo = Symbolizer->symbolizeCode(ObjectFile, ModuleAddress);<br>
failIfError(LineInfo);<br>
CoveredFiles.insert(LineInfo->FileName);<br>
- auto InliningInfo = Symbolizer->symbolizeInlinedCode(ObjectFile, Addr);<br>
+ auto InliningInfo =<br>
+ Symbolizer->symbolizeInlinedCode(ObjectFile, ModuleAddress);<br>
failIfError(InliningInfo);<br>
for (uint32_t I = 0; I < InliningInfo->getNumberOfFrames(); ++I) {<br>
auto FrameInfo = InliningInfo->getFrame(I);<br>
@@ -636,7 +643,12 @@ getCoveragePoints(const std::string &Obj<br>
for (auto Addr : Addrs) {<br>
std::set<DILineInfo> Infos; // deduplicate debug info.<br>
<br>
- auto LineInfo = Symbolizer->symbolizeCode(ObjectFile, Addr);<br>
+ // TODO: it would be neccessary to set proper section index here.<br>
+ // object::SectionedAddress::UndefSection works for only absolute addresses.<br>
+ object::SectionedAddress ModuleAddress = {<br>
+ Addr, object::SectionedAddress::UndefSection};<br>
+<br>
+ auto LineInfo = Symbolizer->symbolizeCode(ObjectFile, ModuleAddress);<br>
failIfError(LineInfo);<br>
if (ClSkipDeadFiles &&<br>
CoveredFiles.find(LineInfo->FileName) == CoveredFiles.end())<br>
@@ -650,7 +662,8 @@ getCoveragePoints(const std::string &Obj<br>
Infos.insert(*LineInfo);<br>
Point.Locs.push_back(*LineInfo);<br>
<br>
- auto InliningInfo = Symbolizer->symbolizeInlinedCode(ObjectFile, Addr);<br>
+ auto InliningInfo =<br>
+ Symbolizer->symbolizeInlinedCode(ObjectFile, ModuleAddress);<br>
failIfError(InliningInfo);<br>
for (uint32_t I = 0; I < InliningInfo->getNumberOfFrames(); ++I) {<br>
auto FrameInfo = InliningInfo->getFrame(I);<br>
@@ -957,7 +970,10 @@ symbolize(const RawCoverage &Data, const<br>
auto Symbolizer(createSymbolizer());<br>
<br>
for (uint64_t Addr : *Data.Addrs) {<br>
- auto LineInfo = Symbolizer->symbolizeCode(ObjectFile, Addr);<br>
+ // TODO: it would be neccessary to set proper section index here.<br>
+ // object::SectionedAddress::UndefSection works for only absolute addresses.<br>
+ auto LineInfo = Symbolizer->symbolizeCode(<br>
+ ObjectFile, {Addr, object::SectionedAddress::UndefSection});<br>
failIfError(LineInfo);<br>
if (B.isBlacklisted(*LineInfo))<br>
continue;<br>
<br>
Modified: llvm/trunk/tools/sanstats/sanstats.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/sanstats/sanstats.cpp?rev=354972&r1=354971&r2=354972&view=diff" rel="noopener noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/sanstats/sanstats.cpp?rev=354972&r1=354971&r2=354972&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/tools/sanstats/sanstats.cpp (original)<br>
+++ llvm/trunk/tools/sanstats/sanstats.cpp Wed Feb 27 05:17:36 2019<br>
@@ -84,8 +84,10 @@ const char *ReadModule(char SizeofPtr, c<br>
// As the instrumentation tracks the return address and not<br>
// the address of the call to `__sanitizer_stat_report` we<br>
// remove one from the address to get the correct DI.<br>
- if (Expected<DILineInfo> LineInfo =<br>
- Symbolizer.symbolizeCode(Filename, Addr - 1)) {<br>
+ // TODO: it would be neccessary to set proper section index here.<br>
+ // object::SectionedAddress::UndefSection works for only absolute addresses.<br>
+ if (Expected<DILineInfo> LineInfo = Symbolizer.symbolizeCode(<br>
+ Filename, {Addr - 1, object::SectionedAddress::UndefSection})) {<br>
llvm::outs() << format_hex(Addr - 1, 18) << ' ' << LineInfo->FileName<br>
<< ':' << LineInfo->Line << ' ' << LineInfo->FunctionName<br>
<< ' ';<br>
<br>
Modified: llvm/trunk/unittests/tools/llvm-cfi-verify/FileAnalysis.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/tools/llvm-cfi-verify/FileAnalysis.cpp?rev=354972&r1=354971&r2=354972&view=diff" rel="noopener noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/tools/llvm-cfi-verify/FileAnalysis.cpp?rev=354972&r1=354971&r2=354972&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/unittests/tools/llvm-cfi-verify/FileAnalysis.cpp (original)<br>
+++ llvm/trunk/unittests/tools/llvm-cfi-verify/FileAnalysis.cpp Wed Feb 27 05:17:36 2019<br>
@@ -51,8 +51,8 @@ public:<br>
<br>
// Expose this method publicly for testing.<br>
void parseSectionContents(ArrayRef<uint8_t> SectionBytes,<br>
- uint64_t SectionAddress) {<br>
- FileAnalysis::parseSectionContents(SectionBytes, SectionAddress);<br>
+ object::SectionedAddress Address) {<br>
+ FileAnalysis::parseSectionContents(SectionBytes, Address);<br>
}<br>
<br>
Error initialiseDisassemblyMembers() {<br>
@@ -106,7 +106,7 @@ TEST_F(BasicX86FileAnalysisTest, BasicDi<br>
0x41, 0x0e, // 21: rex.B (bad)<br>
0x62, 0x72, 0x65, 0x61, 0x6b, // 23: (bad) {%k1}<br>
},<br>
- 0xDEADBEEF);<br>
+ {0xDEADBEEF, 0x0});<br>
<br>
EXPECT_EQ(nullptr, Analysis.getInstruction(0x0));<br>
EXPECT_EQ(nullptr, Analysis.getInstruction(0x1000));<br>
@@ -210,7 +210,7 @@ TEST_F(BasicX86FileAnalysisTest, PrevAnd<br>
0x2f, // 1: (bad)<br>
0x90 // 2: nop<br>
},<br>
- 0xDEADBEEF);<br>
+ {0xDEADBEEF, 0x0});<br>
const auto &BadInstrMeta = Analysis.getInstructionOrDie(0xDEADBEEF + 1);<br>
const auto *GoodInstrMeta =<br>
Analysis.getPrevInstructionSequential(BadInstrMeta);<br>
@@ -240,7 +240,7 @@ TEST_F(BasicX86FileAnalysisTest, CFITrap<br>
0x62, 0x72, 0x65, 0x61, 0x6b, // 23: (bad) {%k1}<br>
0x0f, 0x0b // 28: ud2<br>
},<br>
- 0xDEADBEEF);<br>
+ {0xDEADBEEF, 0x0});<br>
<br>
EXPECT_FALSE(Analysis.isCFITrap(Analysis.getInstructionOrDie(0xDEADBEEF)));<br>
EXPECT_FALSE(<br>
@@ -275,7 +275,7 @@ TEST_F(BasicX86FileAnalysisTest, FallThr<br>
0x75, 0x00, // 17: jne +0<br>
0xc3, // 19: retq<br>
},<br>
- 0xDEADBEEF);<br>
+ {0xDEADBEEF, 0x0});<br>
<br>
EXPECT_TRUE(<br>
Analysis.canFallThrough(Analysis.getInstructionOrDie(0xDEADBEEF)));<br>
@@ -322,7 +322,7 @@ TEST_F(BasicX86FileAnalysisTest, Definit<br>
0xeb, 0xdd, // 36: jmp 3 [-35]<br>
0xeb, 0xdc, // 38: jmp 4 [-36]<br>
},<br>
- 0xDEADBEEF);<br>
+ {0xDEADBEEF, 0x0});<br>
<br>
const auto *Current = Analysis.getInstruction(0xDEADBEEF);<br>
const auto *Next = Analysis.getDefiniteNextInstruction(*Current);<br>
@@ -412,7 +412,7 @@ TEST_F(BasicX86FileAnalysisTest, Control<br>
0xeb, 0xdd, // 36: jmp 3 [-35]<br>
0xeb, 0xdc, // 38: jmp 4 [-36]<br>
},<br>
- 0xDEADBEEF);<br>
+ {0xDEADBEEF, 0x0});<br>
const auto *InstrMetaPtr = &Analysis.getInstructionOrDie(0xDEADBEEF);<br>
std::set<const Instr *> XRefs =<br>
Analysis.getDirectControlFlowXRefs(*InstrMetaPtr);<br>
@@ -503,17 +503,18 @@ TEST_F(BasicX86FileAnalysisTest, CFIProt<br>
0x0f, 0x0b, // 1: ud2<br>
0x75, 0x00, // 3: jne 5 [+0]<br>
},<br>
- 0xDEADBEEF);<br>
- GraphResult Result = GraphBuilder::buildFlowGraph(Analysis, 0xDEADBEEF);<br>
+ {0xDEADBEEF, 0x0});<br>
+ GraphResult Result =<br>
+ GraphBuilder::buildFlowGraph(Analysis, {0xDEADBEEF, 0x0});<br>
EXPECT_EQ(CFIProtectionStatus::FAIL_NOT_INDIRECT_CF,<br>
Analysis.validateCFIProtection(Result));<br>
- Result = GraphBuilder::buildFlowGraph(Analysis, 0xDEADBEEF + 1);<br>
+ Result = GraphBuilder::buildFlowGraph(Analysis, {0xDEADBEEF + 1, 0x0});<br>
EXPECT_EQ(CFIProtectionStatus::FAIL_NOT_INDIRECT_CF,<br>
Analysis.validateCFIProtection(Result));<br>
- Result = GraphBuilder::buildFlowGraph(Analysis, 0xDEADBEEF + 3);<br>
+ Result = GraphBuilder::buildFlowGraph(Analysis, {0xDEADBEEF + 3, 0x0});<br>
EXPECT_EQ(CFIProtectionStatus::FAIL_NOT_INDIRECT_CF,<br>
Analysis.validateCFIProtection(Result));<br>
- Result = GraphBuilder::buildFlowGraph(Analysis, 0x12345678);<br>
+ Result = GraphBuilder::buildFlowGraph(Analysis, {0x12345678, 0x0});<br>
EXPECT_EQ(CFIProtectionStatus::FAIL_INVALID_INSTRUCTION,<br>
Analysis.validateCFIProtection(Result));<br>
}<br>
@@ -527,8 +528,9 @@ TEST_F(BasicX86FileAnalysisTest, CFIProt<br>
0x0f, 0x0b, // 2: ud2<br>
0xff, 0x10, // 4: callq *(%rax)<br>
},<br>
- 0xDEADBEEF);<br>
- GraphResult Result = GraphBuilder::buildFlowGraph(Analysis, 0xDEADBEEF + 4);<br>
+ {0xDEADBEEF, 0x0});<br>
+ GraphResult Result =<br>
+ GraphBuilder::buildFlowGraph(Analysis, {0xDEADBEEF + 4, 0x0});<br>
EXPECT_EQ(CFIProtectionStatus::PROTECTED,<br>
Analysis.validateCFIProtection(Result));<br>
}<br>
@@ -542,8 +544,9 @@ TEST_F(BasicX86FileAnalysisTest, CFIProt<br>
0xff, 0x10, // 2: callq *(%rax)<br>
0x0f, 0x0b, // 4: ud2<br>
},<br>
- 0xDEADBEEF);<br>
- GraphResult Result = GraphBuilder::buildFlowGraph(Analysis, 0xDEADBEEF + 2);<br>
+ {0xDEADBEEF, 0x0});<br>
+ GraphResult Result =<br>
+ GraphBuilder::buildFlowGraph(Analysis, {0xDEADBEEF + 2, 0x0});<br>
EXPECT_EQ(CFIProtectionStatus::PROTECTED,<br>
Analysis.validateCFIProtection(Result));<br>
}<br>
@@ -560,8 +563,9 @@ TEST_F(BasicX86FileAnalysisTest, CFIProt<br>
0x75, 0xf9, // 7: jne 2 [-7]<br>
0x0f, 0x0b, // 9: ud2<br>
},<br>
- 0xDEADBEEF);<br>
- GraphResult Result = GraphBuilder::buildFlowGraph(Analysis, 0xDEADBEEF + 3);<br>
+ {0xDEADBEEF, 0x0});<br>
+ GraphResult Result =<br>
+ GraphBuilder::buildFlowGraph(Analysis, {0xDEADBEEF + 3, 0x0});<br>
EXPECT_EQ(CFIProtectionStatus::PROTECTED,<br>
Analysis.validateCFIProtection(Result));<br>
}<br>
@@ -577,8 +581,9 @@ TEST_F(BasicX86FileAnalysisTest, CFIProt<br>
0x75, 0xfb, // 5: jne 2 [-5]<br>
0x0f, 0x0b, // 7: ud2<br>
},<br>
- 0xDEADBEEF);<br>
- GraphResult Result = GraphBuilder::buildFlowGraph(Analysis, 0xDEADBEEF + 3);<br>
+ {0xDEADBEEF, 0x0});<br>
+ GraphResult Result =<br>
+ GraphBuilder::buildFlowGraph(Analysis, {0xDEADBEEF + 3, 0x0});<br>
EXPECT_EQ(CFIProtectionStatus::PROTECTED,<br>
Analysis.validateCFIProtection(Result));<br>
}<br>
@@ -596,12 +601,13 @@ TEST_F(BasicX86FileAnalysisTest, CFIProt<br>
0xff, 0x10, // 6: callq *(%rax)<br>
0x0f, 0x0b, // 8: ud2<br>
},<br>
- 0xDEADBEEF);<br>
+ {0xDEADBEEF, 0x0});<br>
uint64_t PrevSearchLengthForConditionalBranch =<br>
SearchLengthForConditionalBranch;<br>
SearchLengthForConditionalBranch = 2;<br>
<br>
- GraphResult Result = GraphBuilder::buildFlowGraph(Analysis, 0xDEADBEEF + 6);<br>
+ GraphResult Result =<br>
+ GraphBuilder::buildFlowGraph(Analysis, {0xDEADBEEF + 6, 0x0});<br>
EXPECT_EQ(CFIProtectionStatus::FAIL_ORPHANS,<br>
Analysis.validateCFIProtection(Result));<br>
<br>
@@ -621,11 +627,12 @@ TEST_F(BasicX86FileAnalysisTest, CFIProt<br>
0x90, // 7: nop<br>
0x0f, 0x0b, // 8: ud2<br>
},<br>
- 0xDEADBEEF);<br>
+ {0xDEADBEEF, 0x0});<br>
uint64_t PrevSearchLengthForUndef = SearchLengthForUndef;<br>
SearchLengthForUndef = 2;<br>
<br>
- GraphResult Result = GraphBuilder::buildFlowGraph(Analysis, 0xDEADBEEF + 2);<br>
+ GraphResult Result =<br>
+ GraphBuilder::buildFlowGraph(Analysis, {0xDEADBEEF + 2, 0x0});<br>
EXPECT_EQ(CFIProtectionStatus::FAIL_BAD_CONDITIONAL_BRANCH,<br>
Analysis.validateCFIProtection(Result));<br>
<br>
@@ -642,8 +649,9 @@ TEST_F(BasicX86FileAnalysisTest, CFIProt<br>
0xff, 0x10, // 4: callq *(%rax)<br>
0x0f, 0x0b, // 6: ud2<br>
},<br>
- 0xDEADBEEF);<br>
- GraphResult Result = GraphBuilder::buildFlowGraph(Analysis, 0xDEADBEEF + 4);<br>
+ {0xDEADBEEF, 0x0});<br>
+ GraphResult Result =<br>
+ GraphBuilder::buildFlowGraph(Analysis, {0xDEADBEEF + 4, 0x0});<br>
EXPECT_EQ(CFIProtectionStatus::FAIL_ORPHANS,<br>
Analysis.validateCFIProtection(Result));<br>
}<br>
@@ -658,8 +666,9 @@ TEST_F(BasicX86FileAnalysisTest, CFIProt<br>
0xff, 0x10, // 4: callq *(%rax)<br>
0x0f, 0x0b, // 6: ud2<br>
},<br>
- 0xDEADBEEF);<br>
- GraphResult Result = GraphBuilder::buildFlowGraph(Analysis, 0xDEADBEEF + 4);<br>
+ {0xDEADBEEF, 0x0});<br>
+ GraphResult Result =<br>
+ GraphBuilder::buildFlowGraph(Analysis, {0xDEADBEEF + 4, 0x0});<br>
EXPECT_EQ(CFIProtectionStatus::PROTECTED,<br>
Analysis.validateCFIProtection(Result));<br>
}<br>
@@ -685,10 +694,11 @@ TEST_F(BasicX86FileAnalysisTest, CFIProt<br>
0x90, // 21: nop<br>
0x0f, 0x0b, // 22: ud2<br>
},<br>
- 0xDEADBEEF);<br>
+ {0xDEADBEEF, 0x0});<br>
uint64_t PrevSearchLengthForUndef = SearchLengthForUndef;<br>
SearchLengthForUndef = 5;<br>
- GraphResult Result = GraphBuilder::buildFlowGraph(Analysis, 0xDEADBEEF + 9);<br>
+ GraphResult Result =<br>
+ GraphBuilder::buildFlowGraph(Analysis, {0xDEADBEEF + 9, 0x0});<br>
EXPECT_EQ(CFIProtectionStatus::FAIL_ORPHANS,<br>
Analysis.validateCFIProtection(Result));<br>
SearchLengthForUndef = PrevSearchLengthForUndef;<br>
@@ -704,10 +714,10 @@ TEST_F(BasicX86FileAnalysisTest, UndefSe<br>
0xe8, 0x09, 0x00, 0x00, 0x00, // 0x688122: callq 0x688130<br>
0x0f, 0x0b, // 0x688127: ud2<br>
},<br>
- 0x688118);<br>
+ {0x688118, 0x0});<br>
uint64_t PrevSearchLengthForUndef = SearchLengthForUndef;<br>
SearchLengthForUndef = 1;<br>
- GraphResult Result = GraphBuilder::buildFlowGraph(Analysis, 0x68811d);<br>
+ GraphResult Result = GraphBuilder::buildFlowGraph(Analysis, {0x68811d, 0x0});<br>
EXPECT_EQ(CFIProtectionStatus::PROTECTED,<br>
Analysis.validateCFIProtection(Result));<br>
SearchLengthForUndef = PrevSearchLengthForUndef;<br>
@@ -719,7 +729,7 @@ TEST_F(BasicX86FileAnalysisTest, UndefSe<br>
0x74, 0x73, // 0x7759eb: je 0x775a60<br>
0xe9, 0x1c, 0x04, 0x00, 0x00, 0x00, // 0x7759ed: jmpq 0x775e0e<br>
},<br>
- 0x7759eb);<br>
+ {0x7759eb, 0x0});<br>
<br>
Analysis.parseSectionContents(<br>
{<br>
@@ -729,24 +739,24 @@ TEST_F(BasicX86FileAnalysisTest, UndefSe<br>
0x48, 0x89, 0xde, // 0x775a65: mov %rbx,%rsi<br>
0xff, 0xd1, // 0x775a68: callq *%rcx<br>
},<br>
- 0x775a56);<br>
+ {0x775a56, 0x0});<br>
<br>
Analysis.parseSectionContents(<br>
{<br>
0x0f, 0x0b, // 0x775e0e: ud2<br>
},<br>
- 0x775e0e);<br>
+ {0x775e0e, 0x0});<br>
uint64_t PrevSearchLengthForUndef = SearchLengthForUndef;<br>
SearchLengthForUndef = 1;<br>
- GraphResult Result = GraphBuilder::buildFlowGraph(Analysis, 0x775a68);<br>
+ GraphResult Result = GraphBuilder::buildFlowGraph(Analysis, {0x775a68, 0x0});<br>
EXPECT_EQ(CFIProtectionStatus::FAIL_BAD_CONDITIONAL_BRANCH,<br>
Analysis.validateCFIProtection(Result));<br>
SearchLengthForUndef = 2;<br>
- Result = GraphBuilder::buildFlowGraph(Analysis, 0x775a68);<br>
+ Result = GraphBuilder::buildFlowGraph(Analysis, {0x775a68, 0x0});<br>
EXPECT_EQ(CFIProtectionStatus::PROTECTED,<br>
Analysis.validateCFIProtection(Result));<br>
SearchLengthForUndef = 3;<br>
- Result = GraphBuilder::buildFlowGraph(Analysis, 0x775a68);<br>
+ Result = GraphBuilder::buildFlowGraph(Analysis, {0x775a68, 0x0});<br>
EXPECT_EQ(CFIProtectionStatus::PROTECTED,<br>
Analysis.validateCFIProtection(Result));<br>
SearchLengthForUndef = PrevSearchLengthForUndef;<br>
@@ -762,8 +772,9 @@ TEST_F(BasicX86FileAnalysisTest, CFIProt<br>
0x48, 0x05, 0x00, 0x00, 0x00, 0x00, // 4: add $0x0, %rax<br>
0xff, 0x10, // 10: callq *(%rax)<br>
},<br>
- 0xDEADBEEF);<br>
- GraphResult Result = GraphBuilder::buildFlowGraph(Analysis, 0xDEADBEEF + 10);<br>
+ {0xDEADBEEF, 0x0});<br>
+ GraphResult Result =<br>
+ GraphBuilder::buildFlowGraph(Analysis, {0xDEADBEEF + 10, 0x0});<br>
EXPECT_EQ(CFIProtectionStatus::FAIL_REGISTER_CLOBBERED,<br>
Analysis.validateCFIProtection(Result));<br>
}<br>
@@ -778,8 +789,9 @@ TEST_F(BasicX86FileAnalysisTest, CFIProt<br>
0x48, 0x83, 0xc0, 0x00, // 4: add $0x0, %rax<br>
0xff, 0x10, // 8: callq *(%rax)<br>
},<br>
- 0xDEADBEEF);<br>
- GraphResult Result = GraphBuilder::buildFlowGraph(Analysis, 0xDEADBEEF + 8);<br>
+ {0xDEADBEEF, 0x0});<br>
+ GraphResult Result =<br>
+ GraphBuilder::buildFlowGraph(Analysis, {0xDEADBEEF + 8, 0x0});<br>
EXPECT_EQ(CFIProtectionStatus::FAIL_REGISTER_CLOBBERED,<br>
Analysis.validateCFIProtection(Result));<br>
}<br>
@@ -794,8 +806,9 @@ TEST_F(BasicX86FileAnalysisTest, CFIProt<br>
0x05, 0x00, 0x00, 0x00, 0x00, // 4: add $0x0, %eax<br>
0xff, 0x10, // 9: callq *(%rax)<br>
},<br>
- 0xDEADBEEF);<br>
- GraphResult Result = GraphBuilder::buildFlowGraph(Analysis, 0xDEADBEEF + 9);<br>
+ {0xDEADBEEF, 0x0});<br>
+ GraphResult Result =<br>
+ GraphBuilder::buildFlowGraph(Analysis, {0xDEADBEEF + 9, 0x0});<br>
EXPECT_EQ(CFIProtectionStatus::FAIL_REGISTER_CLOBBERED,<br>
Analysis.validateCFIProtection(Result));<br>
}<br>
@@ -812,8 +825,9 @@ TEST_F(BasicX86FileAnalysisTest, CFIProt<br>
0x75, 0xf9, // 8: jne 2 [-7]<br>
0x0f, 0x0b, // 10: ud2<br>
},<br>
- 0xDEADBEEF);<br>
- GraphResult Result = GraphBuilder::buildFlowGraph(Analysis, 0xDEADBEEF + 4);<br>
+ {0xDEADBEEF, 0x0});<br>
+ GraphResult Result =<br>
+ GraphBuilder::buildFlowGraph(Analysis, {0xDEADBEEF + 4, 0x0});<br>
EXPECT_EQ(CFIProtectionStatus::FAIL_REGISTER_CLOBBERED,<br>
Analysis.validateCFIProtection(Result));<br>
}<br>
@@ -825,8 +839,9 @@ TEST_F(BasicAArch64FileAnalysisTest, AAr<br>
{<br>
0x00, 0x01, 0x3f, 0xd6, // 0: blr x8<br>
},<br>
- 0xDEADBEEF);<br>
- GraphResult Result = GraphBuilder::buildFlowGraph(Analysis, 0xDEADBEEF);<br>
+ {0xDEADBEEF, 0x0});<br>
+ GraphResult Result =<br>
+ GraphBuilder::buildFlowGraph(Analysis, {0xDEADBEEF, 0x0});<br>
EXPECT_EQ(CFIProtectionStatus::FAIL_ORPHANS,<br>
Analysis.validateCFIProtection(Result));<br>
}<br>
@@ -840,8 +855,9 @@ TEST_F(BasicAArch64FileAnalysisTest, AAr<br>
0x20, 0x00, 0x20, 0xd4, // 4: brk #0x1<br>
0x00, 0x01, 0x3f, 0xd6, // 8: blr x8<br>
},<br>
- 0xDEADBEEF);<br>
- GraphResult Result = GraphBuilder::buildFlowGraph(Analysis, 0xDEADBEEF + 8);<br>
+ {0xDEADBEEF, 0x0});<br>
+ GraphResult Result =<br>
+ GraphBuilder::buildFlowGraph(Analysis, {0xDEADBEEF + 8, 0x0});<br>
EXPECT_EQ(CFIProtectionStatus::PROTECTED,<br>
Analysis.validateCFIProtection(Result));<br>
}<br>
@@ -856,8 +872,9 @@ TEST_F(BasicAArch64FileAnalysisTest, AAr<br>
0x08, 0x05, 0x00, 0x91, // 8: add x8, x8, #1<br>
0x00, 0x01, 0x3f, 0xd6, // 12: blr x8<br>
},<br>
- 0xDEADBEEF);<br>
- GraphResult Result = GraphBuilder::buildFlowGraph(Analysis, 0xDEADBEEF + 12);<br>
+ {0xDEADBEEF, 0x0});<br>
+ GraphResult Result =<br>
+ GraphBuilder::buildFlowGraph(Analysis, {0xDEADBEEF + 12, 0x0});<br>
EXPECT_EQ(CFIProtectionStatus::FAIL_REGISTER_CLOBBERED,<br>
Analysis.validateCFIProtection(Result));<br>
}<br>
@@ -872,8 +889,9 @@ TEST_F(BasicAArch64FileAnalysisTest, AAr<br>
0x21, 0x09, 0x40, 0xf9, // 8: ldr x1, [x9,#16]<br>
0x20, 0x00, 0x1f, 0xd6, // 12: br x1<br>
},<br>
- 0xDEADBEEF);<br>
- GraphResult Result = GraphBuilder::buildFlowGraph(Analysis, 0xDEADBEEF + 12);<br>
+ {0xDEADBEEF, 0x0});<br>
+ GraphResult Result =<br>
+ GraphBuilder::buildFlowGraph(Analysis, {0xDEADBEEF + 12, 0x0});<br>
EXPECT_EQ(CFIProtectionStatus::PROTECTED,<br>
Analysis.validateCFIProtection(Result));<br>
}<br>
@@ -889,8 +907,9 @@ TEST_F(BasicAArch64FileAnalysisTest, AAr<br>
0x21, 0x09, 0x40, 0xf9, // 12: ldr x1, [x9,#16]<br>
0x20, 0x00, 0x1f, 0xd6, // 16: br x1<br>
},<br>
- 0xDEADBEEF);<br>
- GraphResult Result = GraphBuilder::buildFlowGraph(Analysis, 0xDEADBEEF + 16);<br>
+ {0xDEADBEEF, 0x0});<br>
+ GraphResult Result =<br>
+ GraphBuilder::buildFlowGraph(Analysis, {0xDEADBEEF + 16, 0x0});<br>
EXPECT_EQ(CFIProtectionStatus::PROTECTED,<br>
Analysis.validateCFIProtection(Result));<br>
}<br>
@@ -906,8 +925,9 @@ TEST_F(BasicAArch64FileAnalysisTest, AAr<br>
0x21, 0x04, 0x00, 0x91, // 12: add x1, x1, #1<br>
0x20, 0x00, 0x1f, 0xd6, // 16: br x1<br>
},<br>
- 0xDEADBEEF);<br>
- GraphResult Result = GraphBuilder::buildFlowGraph(Analysis, 0xDEADBEEF + 16);<br>
+ {0xDEADBEEF, 0x0});<br>
+ GraphResult Result =<br>
+ GraphBuilder::buildFlowGraph(Analysis, {0xDEADBEEF + 16, 0x0});<br>
EXPECT_EQ(CFIProtectionStatus::FAIL_REGISTER_CLOBBERED,<br>
Analysis.validateCFIProtection(Result));<br>
}<br>
@@ -923,8 +943,9 @@ TEST_F(BasicAArch64FileAnalysisTest, AAr<br>
0x21, 0x09, 0x40, 0xf9, // 12: ldr x1, [x9,#16]<br>
0x20, 0x00, 0x1f, 0xd6, // 16: br x1<br>
},<br>
- 0xDEADBEEF);<br>
- GraphResult Result = GraphBuilder::buildFlowGraph(Analysis, 0xDEADBEEF + 16);<br>
+ {0xDEADBEEF, 0x0});<br>
+ GraphResult Result =<br>
+ GraphBuilder::buildFlowGraph(Analysis, {0xDEADBEEF + 16, 0x0});<br>
EXPECT_EQ(CFIProtectionStatus::FAIL_REGISTER_CLOBBERED,<br>
Analysis.validateCFIProtection(Result));<br>
}<br>
@@ -940,8 +961,9 @@ TEST_F(BasicAArch64FileAnalysisTest, AAr<br>
0x21, 0x08, 0x40, 0xf9, // 12: ldr x1, [x1,#16]<br>
0x20, 0x00, 0x1f, 0xd6, // 16: br x1<br>
},<br>
- 0xDEADBEEF);<br>
- GraphResult Result = GraphBuilder::buildFlowGraph(Analysis, 0xDEADBEEF + 16);<br>
+ {0xDEADBEEF, 0x0});<br>
+ GraphResult Result =<br>
+ GraphBuilder::buildFlowGraph(Analysis, {0xDEADBEEF + 16, 0x0});<br>
EXPECT_EQ(CFIProtectionStatus::FAIL_REGISTER_CLOBBERED,<br>
Analysis.validateCFIProtection(Result));<br>
}<br>
@@ -957,8 +979,9 @@ TEST_F(BasicAArch64FileAnalysisTest, AAr<br>
0x21, 0x09, 0x40, 0xf9, // 12: ldr x1, [x9,#16]<br>
0x20, 0x00, 0x1f, 0xd6, // 16: br x1<br>
},<br>
- 0xDEADBEEF);<br>
- GraphResult Result = GraphBuilder::buildFlowGraph(Analysis, 0xDEADBEEF + 16);<br>
+ {0xDEADBEEF, 0x0});<br>
+ GraphResult Result =<br>
+ GraphBuilder::buildFlowGraph(Analysis, {0xDEADBEEF + 16, 0x0});<br>
EXPECT_EQ(CFIProtectionStatus::PROTECTED,<br>
Analysis.validateCFIProtection(Result));<br>
}<br>
@@ -974,8 +997,9 @@ TEST_F(BasicAArch64FileAnalysisTest, AAr<br>
0x22, 0x08, 0x40, 0xf9, // 12: ldr x2, [x1,#16]<br>
0x20, 0x00, 0x1f, 0xd6, // 16: br x1<br>
},<br>
- 0xDEADBEEF);<br>
- GraphResult Result = GraphBuilder::buildFlowGraph(Analysis, 0xDEADBEEF + 16);<br>
+ {0xDEADBEEF, 0x0});<br>
+ GraphResult Result =<br>
+ GraphBuilder::buildFlowGraph(Analysis, {0xDEADBEEF + 16, 0x0});<br>
EXPECT_EQ(CFIProtectionStatus::PROTECTED,<br>
Analysis.validateCFIProtection(Result));<br>
}<br>
@@ -990,8 +1014,9 @@ TEST_F(BasicAArch64FileAnalysisTest, AAr<br>
0x20, 0x00, 0x20, 0xd4, // 8: brk #0x1<br>
0x20, 0x00, 0x1f, 0xd6, // 12: br x1<br>
},<br>
- 0xDEADBEEF);<br>
- GraphResult Result = GraphBuilder::buildFlowGraph(Analysis, 0xDEADBEEF + 12);<br>
+ {0xDEADBEEF, 0x0});<br>
+ GraphResult Result =<br>
+ GraphBuilder::buildFlowGraph(Analysis, {0xDEADBEEF + 12, 0x0});<br>
EXPECT_EQ(CFIProtectionStatus::FAIL_ORPHANS,<br>
Analysis.validateCFIProtection(Result));<br>
}<br>
@@ -1009,8 +1034,9 @@ TEST_F(BasicAArch64FileAnalysisTest, AAr<br>
0x20, 0x00, 0x1f, 0xd6, // 20: br x1<br>
0x20, 0x00, 0x20, 0xd4, // 24: brk #0x1<br>
},<br>
- 0xDEADBEEF);<br>
- GraphResult Result = GraphBuilder::buildFlowGraph(Analysis, 0xDEADBEEF + 20);<br>
+ {0xDEADBEEF, 0x0});<br>
+ GraphResult Result =<br>
+ GraphBuilder::buildFlowGraph(Analysis, {0xDEADBEEF + 20, 0x0});<br>
EXPECT_EQ(CFIProtectionStatus::PROTECTED,<br>
Analysis.validateCFIProtection(Result));<br>
}<br>
@@ -1029,8 +1055,9 @@ TEST_F(BasicAArch64FileAnalysisTest, AAr<br>
0x20, 0x00, 0x1f, 0xd6, // 24: br x1<br>
0x20, 0x00, 0x20, 0xd4, // 28: brk #0x1<br>
},<br>
- 0xDEADBEEF);<br>
- GraphResult Result = GraphBuilder::buildFlowGraph(Analysis, 0xDEADBEEF + 24);<br>
+ {0xDEADBEEF, 0x0});<br>
+ GraphResult Result =<br>
+ GraphBuilder::buildFlowGraph(Analysis, {0xDEADBEEF + 24, 0x0});<br>
EXPECT_EQ(CFIProtectionStatus::FAIL_REGISTER_CLOBBERED,<br>
Analysis.validateCFIProtection(Result));<br>
}<br>
@@ -1049,8 +1076,9 @@ TEST_F(BasicAArch64FileAnalysisTest, AAr<br>
0x20, 0x00, 0x1f, 0xd6, // 24: br x1<br>
0x20, 0x00, 0x20, 0xd4, // 28: brk #0x1<br>
},<br>
- 0xDEADBEEF);<br>
- GraphResult Result = GraphBuilder::buildFlowGraph(Analysis, 0xDEADBEEF + 24);<br>
+ {0xDEADBEEF, 0x0});<br>
+ GraphResult Result =<br>
+ GraphBuilder::buildFlowGraph(Analysis, {0xDEADBEEF + 24, 0x0});<br>
EXPECT_EQ(CFIProtectionStatus::FAIL_REGISTER_CLOBBERED,<br>
Analysis.validateCFIProtection(Result));<br>
}<br>
<br>
Modified: llvm/trunk/unittests/tools/llvm-cfi-verify/GraphBuilder.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/tools/llvm-cfi-verify/GraphBuilder.cpp?rev=354972&r1=354971&r2=354972&view=diff" rel="noopener noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/tools/llvm-cfi-verify/GraphBuilder.cpp?rev=354972&r1=354971&r2=354972&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/unittests/tools/llvm-cfi-verify/GraphBuilder.cpp (original)<br>
+++ llvm/trunk/unittests/tools/llvm-cfi-verify/GraphBuilder.cpp Wed Feb 27 05:17:36 2019<br>
@@ -113,8 +113,8 @@ public:<br>
<br>
// Expose this method publicly for testing.<br>
void parseSectionContents(ArrayRef<uint8_t> SectionBytes,<br>
- uint64_t SectionAddress) {<br>
- FileAnalysis::parseSectionContents(SectionBytes, SectionAddress);<br>
+ object::SectionedAddress Address) {<br>
+ FileAnalysis::parseSectionContents(SectionBytes, Address);<br>
}<br>
<br>
Error initialiseDisassemblyMembers() {<br>
@@ -156,8 +156,9 @@ TEST_F(BasicGraphBuilderTest, BuildFlowG<br>
0x0f, 0x0b, // 2: ud2<br>
0xff, 0x10, // 4: callq *(%rax)<br>
},<br>
- 0xDEADBEEF);<br>
- const auto Result = GraphBuilder::buildFlowGraph(Analysis, 0xDEADBEEF + 4);<br>
+ {0xDEADBEEF, 0x0});<br>
+ const auto Result =<br>
+ GraphBuilder::buildFlowGraph(Analysis, {0xDEADBEEF + 4, 0x0});<br>
<br>
EXPECT_THAT(Result.OrphanedNodes, IsEmpty());<br>
EXPECT_THAT(Result.ConditionalBranchNodes, SizeIs(1));<br>
@@ -182,8 +183,9 @@ TEST_F(BasicGraphBuilderTest, BuildFlowG<br>
0xff, 0x10, // 2: callq *(%rax)<br>
0x0f, 0x0b, // 4: ud2<br>
},<br>
- 0xDEADBEEF);<br>
- const auto Result = GraphBuilder::buildFlowGraph(Analysis, 0xDEADBEEF + 2);<br>
+ {0xDEADBEEF, 0x0});<br>
+ const auto Result =<br>
+ GraphBuilder::buildFlowGraph(Analysis, {0xDEADBEEF + 2, 0x0});<br>
<br>
EXPECT_THAT(Result.OrphanedNodes, IsEmpty());<br>
EXPECT_THAT(Result.ConditionalBranchNodes, SizeIs(1));<br>
@@ -211,8 +213,9 @@ TEST_F(BasicGraphBuilderTest, BuildFlowG<br>
0x75, 0xf9, // 7: jne 2 [-7]<br>
0x0f, 0x0b, // 9: ud2<br>
},<br>
- 0xDEADBEEF);<br>
- const auto Result = GraphBuilder::buildFlowGraph(Analysis, 0xDEADBEEF + 3);<br>
+ {0xDEADBEEF, 0x0});<br>
+ const auto Result =<br>
+ GraphBuilder::buildFlowGraph(Analysis, {0xDEADBEEF + 3, 0x0});<br>
<br>
EXPECT_THAT(Result.OrphanedNodes, IsEmpty());<br>
EXPECT_THAT(Result.ConditionalBranchNodes, SizeIs(2));<br>
@@ -249,8 +252,9 @@ TEST_F(BasicGraphBuilderTest, BuildFlowG<br>
0x75, 0xfb, // 5: jne 2 [-5]<br>
0x0f, 0x0b, // 7: ud2<br>
},<br>
- 0xDEADBEEF);<br>
- GraphResult Result = GraphBuilder::buildFlowGraph(Analysis, 0xDEADBEEF + 3);<br>
+ {0xDEADBEEF, 0x0});<br>
+ GraphResult Result =<br>
+ GraphBuilder::buildFlowGraph(Analysis, {0xDEADBEEF + 3, 0x0});<br>
<br>
EXPECT_THAT(Result.OrphanedNodes, IsEmpty());<br>
EXPECT_THAT(Result.ConditionalBranchNodes, SizeIs(2));<br>
@@ -284,16 +288,17 @@ TEST_F(BasicGraphBuilderTest, BuildFlowG<br>
0x90, // 0: nop<br>
0x75, 0xfe, // 1: jne 1 [-2]<br>
},<br>
- 0xDEADBEEF);<br>
- GraphResult Result = GraphBuilder::buildFlowGraph(Analysis, 0xDEADBEEF);<br>
+ {0xDEADBEEF, 0x0});<br>
+ GraphResult Result =<br>
+ GraphBuilder::buildFlowGraph(Analysis, {0xDEADBEEF, 0x0});<br>
EXPECT_THAT(Result.OrphanedNodes, IsEmpty());<br>
EXPECT_THAT(Result.ConditionalBranchNodes, IsEmpty());<br>
<br>
- Result = GraphBuilder::buildFlowGraph(Analysis, 0xDEADBEEF + 1);<br>
+ Result = GraphBuilder::buildFlowGraph(Analysis, {0xDEADBEEF + 1, 0x0});<br>
EXPECT_THAT(Result.OrphanedNodes, IsEmpty());<br>
EXPECT_THAT(Result.ConditionalBranchNodes, IsEmpty());<br>
<br>
- Result = GraphBuilder::buildFlowGraph(Analysis, 0xDEADC0DE);<br>
+ Result = GraphBuilder::buildFlowGraph(Analysis, {0xDEADC0DE, 0x0});<br>
EXPECT_THAT(Result.OrphanedNodes, IsEmpty());<br>
EXPECT_THAT(Result.ConditionalBranchNodes, IsEmpty());<br>
}<br>
@@ -306,8 +311,9 @@ TEST_F(BasicGraphBuilderTest, BuildFlowG<br>
0xeb, 0xfe, // 0: jmp 0 [-2]<br>
0xff, 0x10, // 2: callq *(%rax)<br>
},<br>
- 0xDEADBEEF);<br>
- GraphResult Result = GraphBuilder::buildFlowGraph(Analysis, 0xDEADBEEF + 2);<br>
+ {0xDEADBEEF, 0x0});<br>
+ GraphResult Result =<br>
+ GraphBuilder::buildFlowGraph(Analysis, {0xDEADBEEF + 2, 0x0});<br>
EXPECT_THAT(Result.ConditionalBranchNodes, IsEmpty());<br>
EXPECT_THAT(Result.OrphanedNodes, ElementsAre(0xDEADBEEF + 2));<br>
EXPECT_THAT(Result.IntermediateNodes, IsEmpty());<br>
@@ -321,8 +327,9 @@ TEST_F(BasicGraphBuilderTest, BuildFlowG<br>
0x75, 0xfe, // 0: jne 0 [-2]<br>
0xff, 0x10, // 2: callq *(%rax)<br>
},<br>
- 0xDEADBEEF);<br>
- GraphResult Result = GraphBuilder::buildFlowGraph(Analysis, 0xDEADBEEF + 2);<br>
+ {0xDEADBEEF, 0x0});<br>
+ GraphResult Result =<br>
+ GraphBuilder::buildFlowGraph(Analysis, {0xDEADBEEF + 2, 0x0});<br>
EXPECT_THAT(Result.OrphanedNodes, IsEmpty());<br>
EXPECT_THAT(Result.ConditionalBranchNodes, SizeIs(1));<br>
EXPECT_THAT(<br>
@@ -344,8 +351,9 @@ TEST_F(BasicGraphBuilderTest, BuildFlowG<br>
0xeb, 0xfc, // 2: jmp 0 [-4]<br>
0xff, 0x10, // 4: callq *(%rax)<br>
},<br>
- 0xDEADBEEF);<br>
- GraphResult Result = GraphBuilder::buildFlowGraph(Analysis, 0xDEADBEEF + 4);<br>
+ {0xDEADBEEF, 0x0});<br>
+ GraphResult Result =<br>
+ GraphBuilder::buildFlowGraph(Analysis, {0xDEADBEEF + 4, 0x0});<br>
EXPECT_THAT(Result.OrphanedNodes, IsEmpty());<br>
EXPECT_THAT(Result.ConditionalBranchNodes, SizeIs(1));<br>
EXPECT_THAT(<br>
@@ -368,8 +376,9 @@ TEST_F(BasicGraphBuilderTest, BuildFlowG<br>
0xeb, 0xfc, // 2: jmp 0 [-4]<br>
0xff, 0x10, // 4: callq *(%rax)<br>
},<br>
- 0xDEADBEEF);<br>
- GraphResult Result = GraphBuilder::buildFlowGraph(Analysis, 0xDEADBEEF + 4);<br>
+ {0xDEADBEEF, 0x0});<br>
+ GraphResult Result =<br>
+ GraphBuilder::buildFlowGraph(Analysis, {0xDEADBEEF + 4, 0x0});<br>
EXPECT_THAT(Result.OrphanedNodes, ElementsAre(0xDEADBEEF + 4));<br>
EXPECT_THAT(Result.ConditionalBranchNodes, IsEmpty());<br>
}<br>
@@ -387,12 +396,13 @@ TEST_F(BasicGraphBuilderTest, BuildFlowG<br>
0xff, 0x10, // 6: callq *(%rax)<br>
0x0f, 0x0b, // 8: ud2<br>
},<br>
- 0xDEADBEEF);<br>
+ {0xDEADBEEF, 0x0});<br>
uint64_t PrevSearchLengthForConditionalBranch =<br>
SearchLengthForConditionalBranch;<br>
SearchLengthForConditionalBranch = 2;<br>
<br>
- GraphResult Result = GraphBuilder::buildFlowGraph(Analysis, 0xDEADBEEF + 6);<br>
+ GraphResult Result =<br>
+ GraphBuilder::buildFlowGraph(Analysis, {0xDEADBEEF + 6, 0x0});<br>
EXPECT_THAT(Result.OrphanedNodes, SizeIs(1));<br>
EXPECT_THAT(Result.OrphanedNodes,<br>
Each(HasPath(Result, ElementsAre(0xDEADBEEF + 4, 0xDEADBEEF + 5,<br>
@@ -416,11 +426,12 @@ TEST_F(BasicGraphBuilderTest, BuildFlowG<br>
0x90, // 7: nop<br>
0x0f, 0x0b, // 8: ud2<br>
},<br>
- 0xDEADBEEF);<br>
+ {0xDEADBEEF, 0x0});<br>
uint64_t PrevSearchLengthForUndef = SearchLengthForUndef;<br>
SearchLengthForUndef = 2;<br>
<br>
- GraphResult Result = GraphBuilder::buildFlowGraph(Analysis, 0xDEADBEEF + 2);<br>
+ GraphResult Result =<br>
+ GraphBuilder::buildFlowGraph(Analysis, {0xDEADBEEF + 2, 0x0});<br>
EXPECT_THAT(Result.OrphanedNodes, IsEmpty());<br>
EXPECT_THAT(<br>
Result.ConditionalBranchNodes,<br>
@@ -450,8 +461,9 @@ TEST_F(BasicGraphBuilderTest, BuildFlowG<br>
0x75, 0xfb, // 5: jne 2 [-5]<br>
0x0f, 0x0b, // 7: ud2<br>
},<br>
- 0xDEADBEEF);<br>
- GraphResult Result = GraphBuilder::buildFlowGraph(Analysis, 0xDEADBEEF + 3);<br>
+ {0xDEADBEEF, 0x0});<br>
+ GraphResult Result =<br>
+ GraphBuilder::buildFlowGraph(Analysis, {0xDEADBEEF + 3, 0x0});<br>
EXPECT_THAT(Result.OrphanedNodes, IsEmpty());<br>
EXPECT_THAT(Result.ConditionalBranchNodes, SizeIs(2));<br>
EXPECT_THAT(<br>
@@ -529,11 +541,12 @@ TEST_F(BasicGraphBuilderTest, BuildFlowG<br>
0x90, // 21: nop<br>
0x0f, 0x0b, // 22: ud2<br>
},<br>
- 0x1000);<br>
+ {0x1000, 0x0});<br>
uint64_t PrevSearchLengthForUndef = SearchLengthForUndef;<br>
SearchLengthForUndef = 5;<br>
<br>
- GraphResult Result = GraphBuilder::buildFlowGraph(Analysis, 0x1000 + 9);<br>
+ GraphResult Result =<br>
+ GraphBuilder::buildFlowGraph(Analysis, {0x1000 + 9, 0x0});<br>
<br>
EXPECT_THAT(Result.OrphanedNodes, SizeIs(1));<br>
EXPECT_THAT(Result.ConditionalBranchNodes, SizeIs(3));<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="http://e.mail.ru/compose/?mailto=mailto%3allvm%2dcommits@lists.llvm.org" rel="noopener noreferrer" target="_blank">llvm-commits@lists.llvm.org</a><br>
<a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noopener noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits</a><br>
</blockquote></div>
</div></div>
</div>
</div>
</div>
</blockquote>
<br>
<br>-- <br>Alexey Lapshin<br>
</div></div>
</div>
</div></div>
</blockquote></div>