[haiku-commits] r39399 - haiku/branches/developer/bonefish/weak-symbols/src/system/runtime_loader

  • From: ingo_weinhold@xxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Thu, 11 Nov 2010 00:23:45 +0100 (CET)

Author: bonefish
Date: 2010-11-11 00:23:44 +0100 (Thu, 11 Nov 2010)
New Revision: 39399
Changeset: http://dev.haiku-os.org/changeset/39399

Modified:
   
haiku/branches/developer/bonefish/weak-symbols/src/system/runtime_loader/elf_symbol_lookup.cpp
Log:
Added support for symbolically linked objects.


Modified: 
haiku/branches/developer/bonefish/weak-symbols/src/system/runtime_loader/elf_symbol_lookup.cpp
===================================================================
--- 
haiku/branches/developer/bonefish/weak-symbols/src/system/runtime_loader/elf_symbol_lookup.cpp
      2010-11-10 23:23:21 UTC (rev 39398)
+++ 
haiku/branches/developer/bonefish/weak-symbols/src/system/runtime_loader/elf_symbol_lookup.cpp
      2010-11-10 23:23:44 UTC (rev 39399)
@@ -326,14 +326,28 @@
        image_t* candidateImage = NULL;
        Elf32_Sym* candidateSymbol = NULL;
 
-       // TODO: Support symbolically linked objects!
+       // If the requesting image is linked symbolically, look up the symbol 
there
+       // first.
+       bool symbolic = (image->flags & RFLAG_SYMBOLIC) != 0;
+       if (symbolic) {
+               candidateSymbol = find_symbol(image, lookupInfo);
+               if (candidateSymbol != NULL) {
+                       if (ELF32_ST_BIND(candidateSymbol->st_info) != 
STB_WEAK) {
+                               *_foundInImage = image;
+                               return candidateSymbol;
+                       }
 
+                       candidateImage = image;
+               }
+       }
+
        image_t* otherImage = get_loaded_images().head;
        while (otherImage != NULL) {
                if (otherImage == rootImage
-                       || (otherImage->type != B_ADD_ON_IMAGE
-                               && (otherImage->flags
-                                       & (RTLD_GLOBAL | 
RFLAG_USE_FOR_RESOLVING)) != 0)) {
+                               ? !symbolic
+                               : (otherImage->type != B_ADD_ON_IMAGE
+                                       && (otherImage->flags
+                                               & (RTLD_GLOBAL | 
RFLAG_USE_FOR_RESOLVING)) != 0)) {
                        if (Elf32_Sym* symbol = find_symbol(otherImage, 
lookupInfo)) {
                                if (ELF32_ST_BIND(symbol->st_info) != STB_WEAK) 
{
                                        *_foundInImage = otherImage;
@@ -372,8 +386,21 @@
        image_t* candidateImage = NULL;
        Elf32_Sym* candidateSymbol = NULL;
 
-       // TODO: Support symbolically linked objects!
+       // If the requesting image is linked symbolically, look up the symbol 
there
+       // first.
+       bool symbolic = (image->flags & RFLAG_SYMBOLIC) != 0;
+       if (symbolic) {
+               candidateSymbol = find_symbol(image, lookupInfo);
+               if (candidateSymbol != NULL) {
+                       if (ELF32_ST_BIND(candidateSymbol->st_info) != 
STB_WEAK) {
+                               *_foundInImage = image;
+                               return candidateSymbol;
+                       }
 
+                       candidateImage = image;
+               }
+       }
+
        image_t* otherImage = get_loaded_images().head;
        while (otherImage != NULL) {
                if (otherImage != rootImage
@@ -397,7 +424,7 @@
 
        // If the symbol has not been found and we're trying to resolve a 
reference
        // in the add-on image, we also try to look it up there.
-       if (candidateSymbol == NULL && image == rootImage) {
+       if (!symbolic && candidateSymbol == NULL && image == rootImage) {
                candidateSymbol = find_symbol(image, lookupInfo);
                candidateImage = image;
        }


Other related posts:

  • » [haiku-commits] r39399 - haiku/branches/developer/bonefish/weak-symbols/src/system/runtime_loader - ingo_weinhold