rt-thread/components/libc/libdl/dlsym.c

34 lines
639 B
C
Raw Normal View History

2013-01-08 22:40:58 +08:00
/*
2018-08-30 20:27:45 +08:00
* Copyright (c) 2006-2018, RT-Thread Development Team
2013-01-08 22:40:58 +08:00
*
2018-08-30 20:27:45 +08:00
* SPDX-License-Identifier: Apache-2.0
2013-01-08 22:40:58 +08:00
*
* Change Logs:
2018-08-30 20:27:45 +08:00
* Date Author Notes
* 2010-11-17 yi.qiu first version
2013-01-08 22:40:58 +08:00
*/
#include <rtthread.h>
#include <rtm.h>
2018-08-30 20:27:45 +08:00
#include "dlmodule.h"
2013-01-08 22:40:58 +08:00
void* dlsym(void *handle, const char* symbol)
{
2018-08-30 20:27:45 +08:00
int i;
struct rt_dlmodule *module;
RT_ASSERT(handle != RT_NULL);
2013-01-08 22:40:58 +08:00
2018-08-30 20:27:45 +08:00
module = (struct rt_dlmodule *)handle;
2013-01-08 22:40:58 +08:00
2018-08-30 20:27:45 +08:00
for(i=0; i<module->nsym; i++)
{
if (rt_strcmp(module->symtab[i].name, symbol) == 0)
return (void*)module->symtab[i].addr;
}
2013-01-08 22:40:58 +08:00
2018-08-30 20:27:45 +08:00
return RT_NULL;
2013-01-08 22:40:58 +08:00
}
RTM_EXPORT(dlsym)