Rather use the new _kern_read_kernel_image_symbols() syscall to use
kernel image symbol tables. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27688 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -15,6 +15,7 @@
|
||||
#include <new>
|
||||
|
||||
#include <runtime_loader.h>
|
||||
#include <syscalls.h>
|
||||
|
||||
|
||||
#undef TRACE
|
||||
@@ -208,8 +209,12 @@ ImageFile::ImageFile(const image_info& info)
|
||||
|
||||
ImageFile::~ImageFile()
|
||||
{
|
||||
if (fMappedFile != MAP_FAILED)
|
||||
if (fMappedFile != MAP_FAILED) {
|
||||
munmap(fMappedFile, fFileSize);
|
||||
} else {
|
||||
delete[] fSymbolTable;
|
||||
delete[] fStringTable;
|
||||
}
|
||||
|
||||
if (fFD >= 0)
|
||||
close(fFD);
|
||||
@@ -297,9 +302,8 @@ ImageFile::Load()
|
||||
return B_BAD_DATA;
|
||||
}
|
||||
|
||||
fSymbolTable
|
||||
= (const Elf32_Sym*)(fMappedFile + sectionHeader->sh_offset);
|
||||
fStringTable = (const char*)(fMappedFile + stringHeader.sh_offset);
|
||||
fSymbolTable = (Elf32_Sym*)(fMappedFile + sectionHeader->sh_offset);
|
||||
fStringTable = (char*)(fMappedFile + stringHeader.sh_offset);
|
||||
fSymbolCount = sectionHeader->sh_size / sizeof(Elf32_Sym);
|
||||
fStringTableSize = stringHeader.sh_size;
|
||||
|
||||
@@ -311,6 +315,30 @@ ImageFile::Load()
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
ImageFile::LoadKernel()
|
||||
{
|
||||
// get the table sizes
|
||||
fSymbolCount = 0;
|
||||
fStringTableSize = 0;
|
||||
status_t error = _kern_read_kernel_image_symbols(fInfo.id,
|
||||
NULL, &fSymbolCount, NULL, &fStringTableSize, NULL);
|
||||
if (error != B_OK)
|
||||
return error;
|
||||
|
||||
// allocate the tables
|
||||
fSymbolTable = new(std::nothrow) Elf32_Sym[fSymbolCount];
|
||||
fStringTable = new(std::nothrow) char[fStringTableSize];
|
||||
if (fSymbolTable == NULL || fStringTable == NULL)
|
||||
return B_NO_MEMORY;
|
||||
|
||||
// get the info
|
||||
return _kern_read_kernel_image_symbols(fInfo.id,
|
||||
fSymbolTable, &fSymbolCount, fStringTable, &fStringTableSize,
|
||||
&fLoadDelta);
|
||||
}
|
||||
|
||||
|
||||
const Elf32_Sym*
|
||||
ImageFile::LookupSymbol(addr_t address, addr_t* _baseAddress,
|
||||
const char** _symbolName, size_t *_symbolNameLen, bool *_exactMatch) const
|
||||
@@ -474,8 +502,12 @@ SymbolLookup::Init()
|
||||
if (imageFile == NULL)
|
||||
break;
|
||||
|
||||
if (imageFile->Load() != B_OK)
|
||||
error = fTeam == B_SYSTEM_TEAM
|
||||
? imageFile->LoadKernel() : imageFile->Load();
|
||||
if (error != B_OK) {
|
||||
delete imageFile;
|
||||
continue;
|
||||
}
|
||||
|
||||
fImageFiles.Add(imageFile);
|
||||
}
|
||||
|
||||
@@ -132,6 +132,7 @@ public:
|
||||
const image_info& Info() const { return fInfo; }
|
||||
|
||||
status_t Load();
|
||||
status_t LoadKernel();
|
||||
|
||||
const Elf32_Sym* LookupSymbol(addr_t address, addr_t* _baseAddress,
|
||||
const char** _symbolName, size_t *_symbolNameLen,
|
||||
@@ -149,8 +150,8 @@ private:
|
||||
off_t fFileSize;
|
||||
uint8* fMappedFile;
|
||||
addr_t fLoadDelta;
|
||||
const Elf32_Sym* fSymbolTable;
|
||||
const char* fStringTable;
|
||||
Elf32_Sym* fSymbolTable;
|
||||
char* fStringTable;
|
||||
int32 fSymbolCount;
|
||||
size_t fStringTableSize;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user