mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-24 22:24:54 +00:00
Allow DWARFFormValue::extractValue to be called with a null CU.
Currently FormValues are only used for attributes of DIEs and thus uers always have a CU lying around when calling into the FormValue API. Accelerator tables encode their information using the same Forms as the attributes, thus it is natural to use DWARFFormValue to extract/dump them. There is no CU in that case though. Allow the API to be called with a null CU arguemnt by making the RelocMap lookup conditional on the CU pointer validity. And document this new behvior in the header. (Test coverage for this use of the API comes in the DwarfAccelTable support patch) git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@221835 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -57,6 +57,13 @@ public:
|
|||||||
bool isFormClass(FormClass FC) const;
|
bool isFormClass(FormClass FC) const;
|
||||||
|
|
||||||
void dump(raw_ostream &OS, const DWARFUnit *U) 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,
|
bool extractValue(DataExtractor data, uint32_t *offset_ptr,
|
||||||
const DWARFUnit *u);
|
const DWARFUnit *u);
|
||||||
bool isInlinedCStr() const {
|
bool isInlinedCStr() const {
|
||||||
|
@@ -139,6 +139,8 @@ bool DWARFFormValue::extractValue(DataExtractor data, uint32_t *offset_ptr,
|
|||||||
switch (Form) {
|
switch (Form) {
|
||||||
case DW_FORM_addr:
|
case DW_FORM_addr:
|
||||||
case DW_FORM_ref_addr: {
|
case DW_FORM_ref_addr: {
|
||||||
|
if (!cu)
|
||||||
|
return false;
|
||||||
uint16_t AddrSize =
|
uint16_t AddrSize =
|
||||||
(Form == DW_FORM_addr)
|
(Form == DW_FORM_addr)
|
||||||
? cu->getAddressByteSize()
|
? cu->getAddressByteSize()
|
||||||
@@ -179,8 +181,10 @@ bool DWARFFormValue::extractValue(DataExtractor data, uint32_t *offset_ptr,
|
|||||||
break;
|
break;
|
||||||
case DW_FORM_data4:
|
case DW_FORM_data4:
|
||||||
case DW_FORM_ref4: {
|
case DW_FORM_ref4: {
|
||||||
RelocAddrMap::const_iterator AI = cu->getRelocMap()->find(*offset_ptr);
|
|
||||||
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())
|
if (AI != cu->getRelocMap()->end())
|
||||||
Value.uval += AI->second.second;
|
Value.uval += AI->second.second;
|
||||||
break;
|
break;
|
||||||
@@ -193,13 +197,12 @@ bool DWARFFormValue::extractValue(DataExtractor data, uint32_t *offset_ptr,
|
|||||||
Value.sval = data.getSLEB128(offset_ptr);
|
Value.sval = data.getSLEB128(offset_ptr);
|
||||||
break;
|
break;
|
||||||
case DW_FORM_strp: {
|
case DW_FORM_strp: {
|
||||||
RelocAddrMap::const_iterator AI
|
Value.uval = data.getU32(offset_ptr);
|
||||||
= cu->getRelocMap()->find(*offset_ptr);
|
if (!cu)
|
||||||
if (AI != cu->getRelocMap()->end()) {
|
break;
|
||||||
const std::pair<uint8_t, int64_t> &R = AI->second;
|
RelocAddrMap::const_iterator AI = cu->getRelocMap()->find(*offset_ptr-4);
|
||||||
Value.uval = data.getU32(offset_ptr) + R.second;
|
if (AI != cu->getRelocMap()->end())
|
||||||
} else
|
Value.uval += AI->second.second;
|
||||||
Value.uval = data.getU32(offset_ptr);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case DW_FORM_udata:
|
case DW_FORM_udata:
|
||||||
@@ -215,13 +218,12 @@ bool DWARFFormValue::extractValue(DataExtractor data, uint32_t *offset_ptr,
|
|||||||
break;
|
break;
|
||||||
case DW_FORM_sec_offset: {
|
case DW_FORM_sec_offset: {
|
||||||
// FIXME: This is 64-bit for DWARF64.
|
// FIXME: This is 64-bit for DWARF64.
|
||||||
RelocAddrMap::const_iterator AI
|
Value.uval = data.getU32(offset_ptr);
|
||||||
= cu->getRelocMap()->find(*offset_ptr);
|
if (!cu)
|
||||||
if (AI != cu->getRelocMap()->end()) {
|
break;
|
||||||
const std::pair<uint8_t, int64_t> &R = AI->second;
|
RelocAddrMap::const_iterator AI = cu->getRelocMap()->find(*offset_ptr-4);
|
||||||
Value.uval = data.getU32(offset_ptr) + R.second;
|
if (AI != cu->getRelocMap()->end())
|
||||||
} else
|
Value.uval += AI->second.second;
|
||||||
Value.uval = data.getU32(offset_ptr);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case DW_FORM_flag_present:
|
case DW_FORM_flag_present:
|
||||||
|
Reference in New Issue
Block a user