diff options
author | Eric Christopher <echristo@gmail.com> | 2012-11-07 23:22:07 +0000 |
---|---|---|
committer | Eric Christopher <echristo@gmail.com> | 2012-11-07 23:22:07 +0000 |
commit | 7c678de8614720999d1346b89e73480e4bdc6f87 (patch) | |
tree | bba75fe39b0ea5aa51f888c990e6ed915cff6bd9 /llvm/lib/DebugInfo/DWARFFormValue.cpp | |
parent | 84afacd253b4c4da7691153c3f0d07237cc0b21d (diff) | |
download | bcm5719-llvm-7c678de8614720999d1346b89e73480e4bdc6f87.tar.gz bcm5719-llvm-7c678de8614720999d1346b89e73480e4bdc6f87.zip |
Add a relocation visitor to lib object. This works via caching relocated
values in a map that can be passed to consumers. Add a testcase that
ensures this works for llvm-dwarfdump.
llvm-svn: 167558
Diffstat (limited to 'llvm/lib/DebugInfo/DWARFFormValue.cpp')
-rw-r--r-- | llvm/lib/DebugInfo/DWARFFormValue.cpp | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/llvm/lib/DebugInfo/DWARFFormValue.cpp b/llvm/lib/DebugInfo/DWARFFormValue.cpp index c9ecbbbbd4b..fea9fd7f7d3 100644 --- a/llvm/lib/DebugInfo/DWARFFormValue.cpp +++ b/llvm/lib/DebugInfo/DWARFFormValue.cpp @@ -10,6 +10,7 @@ #include "DWARFFormValue.h" #include "DWARFCompileUnit.h" #include "DWARFContext.h" +#include "llvm/Support/Debug.h" #include "llvm/Support/Dwarf.h" #include "llvm/Support/Format.h" #include "llvm/Support/raw_ostream.h" @@ -98,8 +99,16 @@ DWARFFormValue::extractValue(DataExtractor data, uint32_t *offset_ptr, indirect = false; switch (Form) { case DW_FORM_addr: - case DW_FORM_ref_addr: - Value.uval = data.getUnsigned(offset_ptr, cu->getAddressByteSize()); + case DW_FORM_ref_addr: { + RelocAddrMap::const_iterator AI + = cu->getContext().relocMap().find(*offset_ptr); + if (AI != cu->getContext().relocMap().end()) { + const std::pair<uint8_t, int64_t> &R = AI->second; + Value.uval = R.second; + *offset_ptr += R.first; + } else + Value.uval = data.getUnsigned(offset_ptr, cu->getAddressByteSize()); + } break; case DW_FORM_exprloc: case DW_FORM_block: @@ -138,9 +147,17 @@ DWARFFormValue::extractValue(DataExtractor data, uint32_t *offset_ptr, case DW_FORM_sdata: Value.sval = data.getSLEB128(offset_ptr); break; - case DW_FORM_strp: - Value.uval = data.getU32(offset_ptr); + case DW_FORM_strp: { + RelocAddrMap::const_iterator AI + = cu->getContext().relocMap().find(*offset_ptr); + if (AI != cu->getContext().relocMap().end()) { + const std::pair<uint8_t, int64_t> &R = AI->second; + Value.uval = R.second; + *offset_ptr += R.first; + } else + Value.uval = data.getU32(offset_ptr); break; + } case DW_FORM_udata: case DW_FORM_ref_udata: Value.uval = data.getULEB128(offset_ptr); |