runtime_loader: keep symbol DSO in SymbolLookupCache
While resolving TLS related relocations it is necessary to know the DSO that defines the symbol. Without proper support in caching that information is available only when the symbol is resolved first time. That works well for TLS since TLS_DTPMOD is guaranteed to be before TLS_DTPOFF relocation. This patch makes the newly introduced parts of the interface work in a general case.
This commit is contained in:
@@ -480,7 +480,7 @@ resolve_symbol(image_t* rootImage, image_t* image, elf_sym* sym,
|
||||
|
||||
// check the cache first
|
||||
if (cache->IsSymbolValueCached(index)) {
|
||||
*symAddress = cache->SymbolValueAt(index);
|
||||
*symAddress = cache->SymbolValueAt(index, symbolImage);
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
@@ -579,7 +579,7 @@ resolve_symbol(image_t* rootImage, image_t* image, elf_sym* sym,
|
||||
return B_MISSING_SYMBOL;
|
||||
}
|
||||
|
||||
cache->SetSymbolValueAt(index, (addr_t)location);
|
||||
cache->SetSymbolValueAt(index, (addr_t)location, sharedImage);
|
||||
|
||||
if (symbolImage)
|
||||
*symbolImage = sharedImage;
|
||||
|
||||
@@ -64,6 +64,7 @@ struct SymbolLookupCache {
|
||||
{
|
||||
if (fTableSize > 0) {
|
||||
fValues = (addr_t*)malloc(sizeof(addr_t) * fTableSize);
|
||||
fDSOs = (image_t**)malloc(sizeof(image_t*) * fTableSize);
|
||||
|
||||
size_t elementCount = (fTableSize + 31) / 32;
|
||||
fValuesResolved = (uint32*)malloc(4 * elementCount);
|
||||
@@ -81,6 +82,7 @@ struct SymbolLookupCache {
|
||||
{
|
||||
free(fValuesResolved);
|
||||
free(fValues);
|
||||
free(fDSOs);
|
||||
}
|
||||
|
||||
bool IsSymbolValueCached(size_t index) const
|
||||
@@ -94,18 +96,27 @@ struct SymbolLookupCache {
|
||||
return fValues[index];
|
||||
}
|
||||
|
||||
void SetSymbolValueAt(size_t index, addr_t value)
|
||||
addr_t SymbolValueAt(size_t index, image_t** image) const
|
||||
{
|
||||
if (image)
|
||||
*image = fDSOs[index];
|
||||
return fValues[index];
|
||||
}
|
||||
|
||||
void SetSymbolValueAt(size_t index, addr_t value, image_t* image)
|
||||
{
|
||||
if (index < fTableSize) {
|
||||
fValues[index] = value;
|
||||
fDSOs[index] = image;
|
||||
fValuesResolved[index / 32] |= 1 << (index % 32);
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
size_t fTableSize;
|
||||
addr_t* fValues;
|
||||
uint32* fValuesResolved;
|
||||
size_t fTableSize;
|
||||
addr_t* fValues;
|
||||
image_t** fDSOs;
|
||||
uint32* fValuesResolved;
|
||||
};
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user