mirror of
https://review.haiku-os.org/haiku
synced 2025-01-18 12:38:51 +01:00
Debug Kit: Fix LoadedImage SymbolLookup for multiple TEXT segments.
Similar fixes to the previous commits: we need to take the size of all the text segments into account. In userspace we already have this value in the image_info, in the kernel we'd have to compute it. Also add TODOs to the kernel to adjust things in UserSymbolLookup. At present we don't fetch any image infos other than [0], but we should probably store this data differently in the runtime_loader structure anyway. Change-Id: Ife72a8fc18d3139bf2f1606782181ec0006aaf81 Reviewed-on: https://review.haiku-os.org/c/haiku/+/8825 Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org> Reviewed-by: waddlesplash <waddlesplash@gmail.com>
This commit is contained in:
parent
c3ff6461e5
commit
e68498c7c9
@ -597,10 +597,7 @@ SymbolLookup::LoadedImage::LookupSymbol(addr_t address, addr_t* _baseAddress,
|
||||
bool exactMatch = false;
|
||||
const char *symbolName = NULL;
|
||||
|
||||
int32 symbolCount = fSymbolLookup->Read(fImage->symhash[1]);
|
||||
const elf_region_t *textRegion = fImage->regions; // local
|
||||
|
||||
for (int32 i = 0; i < symbolCount; i++) {
|
||||
for (int32 i = 0; i < fSymbolCount; i++) {
|
||||
const elf_sym *symbol = &fSymbolLookup->Read(fImage->syms[i]);
|
||||
|
||||
// The symbol table contains not only symbols referring to functions
|
||||
@ -612,13 +609,12 @@ SymbolLookup::LoadedImage::LookupSymbol(addr_t address, addr_t* _baseAddress,
|
||||
// though).
|
||||
if ((symbol->Type() != STT_FUNC && symbol->Type() != STT_OBJECT)
|
||||
|| symbol->st_value == 0
|
||||
|| symbol->st_value + symbol->st_size + textRegion->delta
|
||||
> textRegion->vmstart + textRegion->size) {
|
||||
|| (symbol->st_value + symbol->st_size) > (size_t)fInfo.text_size) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// skip symbols starting after the given address
|
||||
addr_t symbolAddress = symbol->st_value + textRegion->delta;
|
||||
addr_t symbolAddress = symbol->st_value + fLoadDelta;
|
||||
|
||||
if (symbolAddress > address)
|
||||
continue;
|
||||
@ -646,7 +642,7 @@ SymbolLookup::LoadedImage::LookupSymbol(addr_t address, addr_t* _baseAddress,
|
||||
|
||||
if (symbolFound != NULL) {
|
||||
if (_baseAddress)
|
||||
*_baseAddress = symbolFound->st_value + textRegion->delta;
|
||||
*_baseAddress = symbolFound->st_value + fLoadDelta;
|
||||
if (_symbolName)
|
||||
*_symbolName = symbolName;
|
||||
if (_exactMatch)
|
||||
|
@ -1420,7 +1420,9 @@ public:
|
||||
const uint32* hashBuckets = image.symhash + 2;
|
||||
const uint32* hashChains = image.symhash + 2 + hashTabSize;
|
||||
|
||||
const elf_region_t& textRegion = image.regions[0];
|
||||
const addr_t loadDelta = image.regions[0].delta;
|
||||
// TODO: add a way to get other text regions' size!
|
||||
size_t regionsSize = image.regions[0].size;
|
||||
|
||||
// search the image for the symbol
|
||||
elf_sym symbolFound;
|
||||
@ -1452,13 +1454,12 @@ public:
|
||||
// -- couldn't verify that in the specs though).
|
||||
if ((symbol.Type() != STT_FUNC && symbol.Type() != STT_OBJECT)
|
||||
|| symbol.st_value == 0
|
||||
|| symbol.st_value + symbol.st_size + textRegion.delta
|
||||
> textRegion.vmstart + textRegion.size) {
|
||||
|| (symbol.st_value + symbol.st_size) > regionsSize) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// skip symbols starting after the given address
|
||||
addr_t symbolAddress = symbol.st_value + textRegion.delta;
|
||||
addr_t symbolAddress = symbol.st_value + loadDelta;
|
||||
if (symbolAddress > address)
|
||||
continue;
|
||||
addr_t symbolDelta = address - symbolAddress;
|
||||
@ -1495,9 +1496,9 @@ public:
|
||||
|
||||
if (_baseAddress) {
|
||||
if (deltaFound < INT_MAX)
|
||||
*_baseAddress = symbolFound.st_value + textRegion.delta;
|
||||
*_baseAddress = symbolFound.st_value + loadDelta;
|
||||
else
|
||||
*_baseAddress = textRegion.vmstart;
|
||||
*_baseAddress = image.regions[0].vmstart;
|
||||
}
|
||||
|
||||
if (_exactMatch)
|
||||
@ -1517,6 +1518,7 @@ public:
|
||||
if (!_Read(imageAddress, image))
|
||||
return B_BAD_ADDRESS;
|
||||
|
||||
// TODO: text may be more than just the first region.
|
||||
if (image.regions[0].vmstart <= address
|
||||
&& address < image.regions[0].vmstart + image.regions[0].size) {
|
||||
return B_OK;
|
||||
|
Loading…
Reference in New Issue
Block a user