aboutsummaryrefslogtreecommitdiffstats
path: root/lib/MC
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2010-11-07 02:07:12 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2010-11-07 02:07:12 +0000
commit187d8339dbc0530850e54a86edf36f1a865a5823 (patch)
tree6c3ea25816bcfdb489a70e4063ea83c12feb5934 /lib/MC
parent689cf3cb6222652b92fdbd52e96c1d2f421ac44e (diff)
downloadexternal_llvm-187d8339dbc0530850e54a86edf36f1a865a5823.zip
external_llvm-187d8339dbc0530850e54a86edf36f1a865a5823.tar.gz
external_llvm-187d8339dbc0530850e54a86edf36f1a865a5823.tar.bz2
Relax dwarf line fragments. This fixes a crash in the included testcase.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@118365 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/MC')
-rw-r--r--lib/MC/MCAssembler.cpp31
1 files changed, 18 insertions, 13 deletions
diff --git a/lib/MC/MCAssembler.cpp b/lib/MC/MCAssembler.cpp
index 6558a1b..9dc67644 100644
--- a/lib/MC/MCAssembler.cpp
+++ b/lib/MC/MCAssembler.cpp
@@ -340,19 +340,8 @@ uint64_t MCAssembler::ComputeFragmentSize(MCAsmLayout &Layout,
case MCFragment::FT_Org:
return cast<MCOrgFragment>(F).getSize();
- case MCFragment::FT_Dwarf: {
- const MCDwarfLineAddrFragment &OF = cast<MCDwarfLineAddrFragment>(F);
-
- // The AddrDelta is really unsigned and it can only increase.
- int64_t AddrDelta;
-
- OF.getAddrDelta().EvaluateAsAbsolute(AddrDelta, &Layout);
-
- int64_t LineDelta;
- LineDelta = OF.getLineDelta();
-
- return MCDwarfLineAddr::ComputeSize(LineDelta, AddrDelta);
- }
+ case MCFragment::FT_Dwarf:
+ return cast<MCDwarfLineAddrFragment>(F).getSize();
}
assert(0 && "invalid fragment kind");
@@ -861,6 +850,18 @@ bool MCAssembler::RelaxLEB(const MCObjectWriter &Writer,
return OldSize != LF.getSize();
}
+bool MCAssembler::RelaxDwarfLineAddr(const MCObjectWriter &Writer,
+ MCAsmLayout &Layout,
+ MCDwarfLineAddrFragment &DF) {
+ int64_t AddrDelta;
+ DF.getAddrDelta().EvaluateAsAbsolute(AddrDelta, &Layout);
+ int64_t LineDelta;
+ LineDelta = DF.getLineDelta();
+ uint64_t OldSize = DF.getSize();
+ DF.setSize(MCDwarfLineAddr::ComputeSize(LineDelta, AddrDelta));
+ return OldSize != DF.getSize();
+}
+
bool MCAssembler::LayoutOnce(const MCObjectWriter &Writer,
MCAsmLayout &Layout) {
++stats::RelaxationSteps;
@@ -886,6 +887,10 @@ bool MCAssembler::LayoutOnce(const MCObjectWriter &Writer,
case MCFragment::FT_Org:
WasRelaxed |= RelaxOrg(Writer, Layout, *cast<MCOrgFragment>(it2));
break;
+ case MCFragment::FT_Dwarf:
+ WasRelaxed |= RelaxDwarfLineAddr(Writer, Layout,
+ *cast<MCDwarfLineAddrFragment>(it2));
+ break;
case MCFragment::FT_LEB:
WasRelaxed |= RelaxLEB(Writer, Layout, *cast<MCLEBFragment>(it2));
break;