From ab25a423870db96a5e0b7f1c589b8445a6b596ed Mon Sep 17 00:00:00 2001 From: Augustin Cavalier Date: Sat, 25 Jan 2025 15:36:38 -0500 Subject: [PATCH] kernel/elf: Fix handling of the commpage in UserSymbolLookup. We now will find its image struct using the standard iteration, so just check for its address specifically. Fixes commpage symbols printing in KDL after the recent refactor. --- src/system/kernel/elf.cpp | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/src/system/kernel/elf.cpp b/src/system/kernel/elf.cpp index 3785f6a0a3..1eef20b5c4 100644 --- a/src/system/kernel/elf.cpp +++ b/src/system/kernel/elf.cpp @@ -1376,20 +1376,19 @@ public: // get the image for the address struct image *image; status_t error = _FindImageAtAddress(address, image); - if (error != B_OK) { + if (error != B_OK) + return error; + + if (image->info.basic_info.text == fTeam->commpage_address) { // commpage requires special treatment since kernel stores symbol // information - addr_t commPageAddress = (addr_t)fTeam->commpage_address; - if (address >= commPageAddress - && address < commPageAddress + COMMPAGE_SIZE) { - if (*_imageName) - *_imageName = "commpage"; - address -= (addr_t)commPageAddress; - error = elf_debug_lookup_symbol_address(address, _baseAddress, - _symbolName, NULL, _exactMatch); - if (_baseAddress) - *_baseAddress += (addr_t)fTeam->commpage_address; - } + if (*_imageName != NULL) + *_imageName = "commpage"; + address -= (addr_t)fTeam->commpage_address; + error = elf_debug_lookup_symbol_address(address, _baseAddress, + _symbolName, NULL, _exactMatch); + if (_baseAddress != NULL) + *_baseAddress += (addr_t)fTeam->commpage_address; return error; }