Small fixes to the DWARF relocator.
git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@107518 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/source/Expression/IRToDWARF.cpp b/source/Expression/IRToDWARF.cpp
index 055d66d..02f0d19 100644
--- a/source/Expression/IRToDWARF.cpp
+++ b/source/Expression/IRToDWARF.cpp
@@ -97,9 +97,13 @@
int16_t relative = (int16_t)target_off - (int16_t)off;
swapper.Clear();
- swapper << target_off;
+ swapper << relative;
- memcpy(temporary_buffer + off, swapper.GetData(), sizeof(uint16_t));
+ // off is intended to be the offset of the branch opcode (which is
+ // what the relative location is added to) so
+ // (temporary_buffer + off + 1) skips the opcode and writes to the
+ // relative location
+ memcpy(temporary_buffer + off + 1, swapper.GetData(), sizeof(uint16_t));
}
strm.Clear();