bool isFormClass(FormClass FC) const;
void dump(raw_ostream &OS, const DWARFUnit *U) const;
+
+ /// \brief extracts a value in data at offset *offset_ptr.
+ ///
+ /// The passed DWARFUnit is allowed to be nullptr, in which
+ /// case no relocation processing will be performed and some
+ /// kind of forms that depend on Unit information are disallowed.
+ /// \returns wether the extraction succeeded.
bool extractValue(DataExtractor data, uint32_t *offset_ptr,
const DWARFUnit *u);
bool isInlinedCStr() const {
switch (Form) {
case DW_FORM_addr:
case DW_FORM_ref_addr: {
+ if (!cu)
+ return false;
uint16_t AddrSize =
(Form == DW_FORM_addr)
? cu->getAddressByteSize()
break;
case DW_FORM_data4:
case DW_FORM_ref4: {
- RelocAddrMap::const_iterator AI = cu->getRelocMap()->find(*offset_ptr);
Value.uval = data.getU32(offset_ptr);
+ if (!cu)
+ break;
+ RelocAddrMap::const_iterator AI = cu->getRelocMap()->find(*offset_ptr-4);
if (AI != cu->getRelocMap()->end())
Value.uval += AI->second.second;
break;
Value.sval = data.getSLEB128(offset_ptr);
break;
case DW_FORM_strp: {
- RelocAddrMap::const_iterator AI
- = cu->getRelocMap()->find(*offset_ptr);
- if (AI != cu->getRelocMap()->end()) {
- const std::pair<uint8_t, int64_t> &R = AI->second;
- Value.uval = data.getU32(offset_ptr) + R.second;
- } else
- Value.uval = data.getU32(offset_ptr);
+ Value.uval = data.getU32(offset_ptr);
+ if (!cu)
+ break;
+ RelocAddrMap::const_iterator AI = cu->getRelocMap()->find(*offset_ptr-4);
+ if (AI != cu->getRelocMap()->end())
+ Value.uval += AI->second.second;
break;
}
case DW_FORM_udata:
break;
case DW_FORM_sec_offset: {
// FIXME: This is 64-bit for DWARF64.
- RelocAddrMap::const_iterator AI
- = cu->getRelocMap()->find(*offset_ptr);
- if (AI != cu->getRelocMap()->end()) {
- const std::pair<uint8_t, int64_t> &R = AI->second;
- Value.uval = data.getU32(offset_ptr) + R.second;
- } else
- Value.uval = data.getU32(offset_ptr);
+ Value.uval = data.getU32(offset_ptr);
+ if (!cu)
+ break;
+ RelocAddrMap::const_iterator AI = cu->getRelocMap()->find(*offset_ptr-4);
+ if (AI != cu->getRelocMap()->end())
+ Value.uval += AI->second.second;
break;
}
case DW_FORM_flag_present: