提交 891e6547 编写于 作者: R Rich Felker

move static-linked stub invalid dso handle checking out of dynlink.c

上级 4f8f0380
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <stdarg.h> #include <stdarg.h>
#include "pthread_impl.h" #include "pthread_impl.h"
#include "libc.h"
char *dlerror() char *dlerror()
{ {
...@@ -50,3 +51,14 @@ void __dl_seterr(const char *fmt, ...) ...@@ -50,3 +51,14 @@ void __dl_seterr(const char *fmt, ...)
__dl_vseterr(fmt, ap); __dl_vseterr(fmt, ap);
va_end(ap); va_end(ap);
} }
__attribute__((__visibility__("hidden")))
int __dl_invalid_handle(void *);
static int stub_invalid_handle(void *h)
{
__dl_seterr("Invalid library handle %p", (void *)h);
return 1;
}
weak_alias(stub_invalid_handle, __dl_invalid_handle);
...@@ -1733,7 +1733,8 @@ end: ...@@ -1733,7 +1733,8 @@ end:
return p; return p;
} }
static int invalid_dso_handle(void *h) __attribute__((__visibility__("hidden")))
int __dl_invalid_handle(void *h)
{ {
struct dso *p; struct dso *p;
for (p=head; p; p=p->next) if (h==p) return 0; for (p=head; p; p=p->next) if (h==p) return 0;
...@@ -1788,7 +1789,7 @@ static void *do_dlsym(struct dso *p, const char *s, void *ra) ...@@ -1788,7 +1789,7 @@ static void *do_dlsym(struct dso *p, const char *s, void *ra)
return def.dso->funcdescs + (def.sym - def.dso->syms); return def.dso->funcdescs + (def.sym - def.dso->syms);
return laddr(def.dso, def.sym->st_value); return laddr(def.dso, def.sym->st_value);
} }
if (invalid_dso_handle(p)) if (__dl_invalid_handle(p))
return 0; return 0;
if ((ght = p->ghashtab)) { if ((ght = p->ghashtab)) {
gh = gnu_hash(s); gh = gnu_hash(s);
...@@ -1913,11 +1914,6 @@ int dl_iterate_phdr(int(*callback)(struct dl_phdr_info *info, size_t size, void ...@@ -1913,11 +1914,6 @@ int dl_iterate_phdr(int(*callback)(struct dl_phdr_info *info, size_t size, void
return ret; return ret;
} }
#else #else
static int invalid_dso_handle(void *h)
{
error("Invalid library handle %p", (void *)h);
return 1;
}
void *dlopen(const char *file, int mode) void *dlopen(const char *file, int mode)
{ {
error("Dynamic loading not supported"); error("Dynamic loading not supported");
...@@ -1930,9 +1926,12 @@ void *__dlsym(void *restrict p, const char *restrict s, void *restrict ra) ...@@ -1930,9 +1926,12 @@ void *__dlsym(void *restrict p, const char *restrict s, void *restrict ra)
} }
#endif #endif
__attribute__((__visibility__("hidden")))
int __dl_invalid_handle(void *);
int __dlinfo(void *dso, int req, void *res) int __dlinfo(void *dso, int req, void *res)
{ {
if (invalid_dso_handle(dso)) return -1; if (__dl_invalid_handle(dso)) return -1;
if (req != RTLD_DI_LINKMAP) { if (req != RTLD_DI_LINKMAP) {
error("Unsupported request %d", req); error("Unsupported request %d", req);
return -1; return -1;
...@@ -1943,7 +1942,7 @@ int __dlinfo(void *dso, int req, void *res) ...@@ -1943,7 +1942,7 @@ int __dlinfo(void *dso, int req, void *res)
int dlclose(void *p) int dlclose(void *p)
{ {
return invalid_dso_handle(p); return __dl_invalid_handle(p);
} }
__attribute__((__visibility__("hidden"))) __attribute__((__visibility__("hidden")))
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册