#include <stdio.h>
#include <stdlib.h>
#include "ld.h"

uInt32 ldFindFunc(const char *func,const char *lib) {
  int        i        = 0x0;
  int        x        = 0x0;
  uInt32    *funcPtr  = 0x0;
  ldLibrary *libPtr   = 0x0;
  
  for (x = 0; x < lib_c;x++) {
    libPtr = ldFindLibrary(lib + lib_s[x]); 
    if (libPtr == 0x0) {
      libPtr = ldAddLibrary(lib + lib_s[x]);
      }
  
    for (i=0x0;i<libPtr->linkerSectionHeader[libPtr->sym].shSize/sizeof(elfDynSym);i++) {
      if (!strcmp(func,(libPtr->linkerDynStr + libPtr->linkerRelSymTab[i].dynName))) {
        funcPtr = (uInt32 *)((uInt32)(libPtr->linkerRelSymTab[i].dynValue) + (uInt32)libPtr->output);
        if (funcPtr == 0x0) {
          printf("[%s]\n",func);
          }
        return((uInt32)funcPtr);
        break;
        }
      }
    }

  printf("ERROR COULDN'T FIND FUNCTION\n");
  return(0x0);
  }

