Exemplo n.º 1
0
ElfSegment*
CoreFile::_FindAreaSegment(uint64 address) const
{
	int32 count = fElfFile.CountSegments();
	for (int32 i = 0; i < count; i++) {
		ElfSegment* segment = fElfFile.SegmentAt(i);
		if (segment->Type() == PT_LOAD && segment->LoadAddress() == address)
			return segment;
	}

	return NULL;
}
Exemplo n.º 2
0
status_t
CoreFile::CreateSymbolLookup(const CoreFileImageInfo* imageInfo,
	ElfSymbolLookup*& _lookup)
{
	// get the needed data
	uint64 textDelta = imageInfo->TextDelta();
	uint64 symbolTable = imageInfo->SymbolTable();
	uint64 symbolHash = imageInfo->SymbolHash();
	uint64 stringTable = imageInfo->StringTable();
	CoreFileAreaInfo* textArea = imageInfo->TextArea();
	ElfSegment* textSegment = textArea != NULL ? textArea->Segment() : NULL;

	if (symbolTable == 0 || symbolHash == 0 || stringTable == 0
			|| textSegment == NULL) {
		return B_UNSUPPORTED;
	}

	// create a data source for the text segment
	ElfSymbolLookupSource* source = fElfFile.CreateSymbolLookupSource(
		textSegment->FileOffset(), textSegment->FileSize(),
		textSegment->LoadAddress());
	if (source == NULL)
		return B_NO_MEMORY;

	// get the symbol table entry size
	// TODO: This is not actually correct, since at least theoretically the
	// entry size may differ (cf. DT_SYMENT in the dynamic segment).
	size_t symbolTableEntrySize = fElfFile.Is64Bit()
		? sizeof(ElfClass64::Sym) : sizeof(ElfClass32::Sym);

	// create the symbol lookup
	return ElfSymbolLookup::Create(source, symbolTable, symbolHash, stringTable,
		ElfSymbolLookup::kGetSymbolCountFromHash, symbolTableEntrySize,
		textDelta, fElfFile.Is64Bit(), fElfFile.IsByteOrderSwapped(), true,
		_lookup);
}