浏览代码

fix static linking for FDPIC toolchains

Fixes following problem, when trying to compile a simple
C application statically with a FDPIC toolchain (for example
with Blackfin architecture):
lib/libc.a(libdl.os): In function `do_dlclose':
(.text+0x6be): undefined reference to `_dl_free'
..
Waldemar Brodkorb 7 年之前
父节点
当前提交
569914be2e
共有 1 个文件被更改,包括 8 次插入3 次删除
  1. 8 3
      ldso/libdl/libdl.c

+ 8 - 3
ldso/libdl/libdl.c

@@ -30,6 +30,14 @@
  */
 
 
+/* When libdl is linked in statically into libc.a, we need to replace
+ * these symbols that otherwise would have been loaded in from ldso.
+ * This must be before including ldso.h */
+#ifndef SHARED
+#define _dl_malloc malloc
+#define _dl_free free
+#endif
+
 #include <ldso.h>
 #include <stdio.h>
 #include <string.h>
@@ -86,9 +94,6 @@ extern char *_dl_debug;
 
 #else /* !SHARED */
 
-#define _dl_malloc malloc
-#define _dl_free free
-
 /* When libdl is linked as a static library, we need to replace all
  * the symbols that otherwise would have been loaded in from ldso... */