Skip to content

Commit

Permalink
Revert "[lldb] Use vFlash commands when writing to target's flash mem…
Browse files Browse the repository at this point in the history
…ory regions"

This reverts commit r326261 as it introduces inconsistencies in the
handling of load addresses for ObjectFileELF -- some parts of the class
use physical addresses, and some use virtual. This has manifested itself
as us not being able to set the load address of the vdso "module" on
android.

llvm-svn: 326367
  • Loading branch information
labath committed Feb 28, 2018
1 parent fde8b04 commit ec03d7e
Show file tree
Hide file tree
Showing 13 changed files with 23 additions and 505 deletions.
3 changes: 0 additions & 3 deletions lldb/include/lldb/Host/XML.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,6 @@ class XMLNode {
llvm::StringRef GetAttributeValue(const char *name,
const char *fail_value = nullptr) const;

bool GetAttributeValueAsUnsigned(const char *name, uint64_t &value,
uint64_t fail_value = 0, int base = 0) const;

XMLNode FindFirstChildElementWithName(const char *name) const;

XMLNode GetElementForPath(const NamePath &path);
Expand Down
12 changes: 1 addition & 11 deletions lldb/include/lldb/Target/MemoryRegionInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class MemoryRegionInfo {

MemoryRegionInfo()
: m_range(), m_read(eDontKnow), m_write(eDontKnow), m_execute(eDontKnow),
m_mapped(eDontKnow), m_flash(eDontKnow), m_blocksize(0) {}
m_mapped(eDontKnow) {}

~MemoryRegionInfo() {}

Expand Down Expand Up @@ -58,14 +58,6 @@ class MemoryRegionInfo {

void SetName(const char *name) { m_name = ConstString(name); }

OptionalBool GetFlash() const { return m_flash; }

void SetFlash(OptionalBool val) { m_flash = val; }

lldb::offset_t GetBlocksize() const { return m_blocksize; }

void SetBlocksize(lldb::offset_t blocksize) { m_blocksize = blocksize; }

//----------------------------------------------------------------------
// Get permissions as a uint32_t that is a mask of one or more bits from
// the lldb::Permissions
Expand Down Expand Up @@ -106,8 +98,6 @@ class MemoryRegionInfo {
OptionalBool m_execute;
OptionalBool m_mapped;
ConstString m_name;
OptionalBool m_flash;
lldb::offset_t m_blocksize;
};
}

Expand Down
7 changes: 0 additions & 7 deletions lldb/include/lldb/Target/Process.h
Original file line number Diff line number Diff line change
Expand Up @@ -556,11 +556,6 @@ class Process : public std::enable_shared_from_this<Process>,
return GetStaticBroadcasterClass();
}

struct WriteEntry {
lldb::addr_t Dest;
llvm::ArrayRef<uint8_t> Contents;
};

//------------------------------------------------------------------
/// A notification structure that can be used by clients to listen
/// for changes in a process's lifetime.
Expand Down Expand Up @@ -1955,8 +1950,6 @@ class Process : public std::enable_shared_from_this<Process>,
return LLDB_INVALID_ADDRESS;
}

virtual Status WriteObjectFile(std::vector<WriteEntry> entries);

//------------------------------------------------------------------
/// The public interface to allocating memory in the process.
///
Expand Down

This file was deleted.

12 changes: 0 additions & 12 deletions lldb/source/Host/common/XML.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,18 +151,6 @@ llvm::StringRef XMLNode::GetAttributeValue(const char *name,
return llvm::StringRef();
}

bool XMLNode::GetAttributeValueAsUnsigned(const char *name, uint64_t &value,
uint64_t fail_value, int base) const {
#if defined(LIBXML2_DEFINED)
llvm::StringRef str_value = GetAttributeValue(name, "");
#else
llvm::StringRef str_value;
#endif
bool success = false;
value = StringConvert::ToUInt64(str_value.data(), fail_value, base, &success);
return success;
}

void XMLNode::ForEachChildNode(NodeCallback const &callback) const {
#if defined(LIBXML2_DEFINED)
if (IsValid())
Expand Down
39 changes: 1 addition & 38 deletions lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -827,7 +827,7 @@ bool ObjectFileELF::SetLoadAddress(Target &target, lldb::addr_t value,
// of the sections that have SHF_ALLOC in their flag bits.
SectionSP section_sp(section_list->GetSectionAtIndex(sect_idx));
if (section_sp && section_sp->Test(SHF_ALLOC)) {
lldb::addr_t load_addr = GetSectionPhysicalAddress(section_sp);
lldb::addr_t load_addr = section_sp->GetFileAddress();
// We don't want to update the load address of a section with type
// eSectionTypeAbsoluteAddress as they already have the absolute load
// address
Expand Down Expand Up @@ -3470,40 +3470,3 @@ size_t ObjectFileELF::ReadSectionData(Section *section,
section_data.SetData(buffer_sp);
return buffer_sp->GetByteSize();
}

bool ObjectFileELF::AnySegmentHasPhysicalAddress() {
size_t header_count = ParseProgramHeaders();
for (size_t i = 1; i <= header_count; ++i) {
auto header = GetProgramHeaderByIndex(i);
if (header->p_paddr != 0)
return true;
}
return false;
}

const elf::ELFProgramHeader *
ObjectFileELF::GetSectionSegment(SectionSP section_sp) {
auto section_size = section_sp->GetFileSize();
if (section_size == 0)
section_size = 1;
size_t header_count = ParseProgramHeaders();
for (size_t i = 1; i <= header_count; ++i) {
auto header = GetProgramHeaderByIndex(i);
if (section_sp->GetFileOffset() >= header->p_offset &&
section_sp->GetFileOffset() + section_size <=
header->p_offset + header->p_filesz)
return header;
}
return nullptr;
}

addr_t ObjectFileELF::GetSectionPhysicalAddress(SectionSP section_sp) {
auto segment = GetSectionSegment(section_sp);
if (segment == nullptr)
return section_sp->GetFileAddress();
if (segment->p_type != PT_LOAD)
return LLDB_INVALID_ADDRESS;
auto base_address =
AnySegmentHasPhysicalAddress() ? segment->p_paddr : segment->p_vaddr;
return base_address + (section_sp->GetFileOffset() - segment->p_offset);
}
6 changes: 0 additions & 6 deletions lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.h
Original file line number Diff line number Diff line change
Expand Up @@ -383,12 +383,6 @@ class ObjectFileELF : public lldb_private::ObjectFile {
RefineModuleDetailsFromNote(lldb_private::DataExtractor &data,
lldb_private::ArchSpec &arch_spec,
lldb_private::UUID &uuid);

bool AnySegmentHasPhysicalAddress();

const elf::ELFProgramHeader *GetSectionSegment(lldb::SectionSP section_sp);

lldb::addr_t GetSectionPhysicalAddress(lldb::SectionSP section_sp);
};

#endif // liblldb_ObjectFileELF_h_

0 comments on commit ec03d7e

Please sign in to comment.