From e979f4bac7f7dce837390ed124b48c25398b5496 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Fri, 6 Oct 2006 12:17:06 +0000 Subject: [PATCH] get_image_symbol() and get_nth_image_symbol() now accept NULL arguments for the location and type parameters. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19010 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/system/runtime_loader/elf.c | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/src/system/runtime_loader/elf.c b/src/system/runtime_loader/elf.c index e6a136e0a3..59ca39aec4 100644 --- a/src/system/runtime_loader/elf.c +++ b/src/system/runtime_loader/elf.c @@ -1367,15 +1367,18 @@ get_nth_symbol(image_id imageID, int32 num, char *nameBuffer, int32 *_nameLength strlcpy(nameBuffer, SYMNAME(image, symbol), *_nameLength); *_nameLength = strlen(SYMNAME(image, symbol)); - // ToDo: check with the return types of that BeOS function - if (ELF32_ST_TYPE(symbol->st_info) == STT_FUNC) - *_type = B_SYMBOL_TYPE_TEXT; - else if (ELF32_ST_TYPE(symbol->st_info) == STT_OBJECT) - *_type = B_SYMBOL_TYPE_DATA; - else - *_type = B_SYMBOL_TYPE_ANY; + if (_type != NULL) { + // ToDo: check with the return types of that BeOS function + if (ELF32_ST_TYPE(symbol->st_info) == STT_FUNC) + *_type = B_SYMBOL_TYPE_TEXT; + else if (ELF32_ST_TYPE(symbol->st_info) == STT_OBJECT) + *_type = B_SYMBOL_TYPE_DATA; + else + *_type = B_SYMBOL_TYPE_ANY; + } - *_location = (void *)(symbol->st_value + image->regions[0].delta); + if (_location != NULL) + *_location = (void *)(symbol->st_value + image->regions[0].delta); goto out; } count++; @@ -1407,9 +1410,10 @@ get_symbol(image_id imageID, char const *symbolName, int32 symbolType, void **_l // get the symbol in the image symbol = find_symbol(image, symbolName, symbolType); - if (symbol) - *_location = (void *)(symbol->st_value + image->regions[0].delta); - else + if (symbol) { + if (_location != NULL) + *_location = (void *)(symbol->st_value + image->regions[0].delta); + } else status = B_ENTRY_NOT_FOUND; } else status = B_BAD_IMAGE_ID;