ec679267a274ad1d8fc882afa8751f6b3a67fa5e
[openwrt/openwrt.git] / tools / mklibs / patches / 009-uclibc_libpthread_symbols.patch
1 --- a/src/mklibs
2 +++ b/src/mklibs
3 @@ -162,9 +162,10 @@
4 return result
5
6 class ProvidedSymbol(Symbol):
7 - def __init__(self, name, version, library, default_version):
8 + def __init__(self, name, version, library, default_version, weak):
9 super(ProvidedSymbol, self).__init__(name, version, library)
10 self.default_version = default_version
11 + self.weak = weak
12
13 def base_names(self):
14 ret = []
15 @@ -205,11 +206,15 @@
16 if version_string.lower() not in ('base', 'none'):
17 version = version_string
18
19 + weak = False
20 + if weak_string.lower() == 'true':
21 + weak = True
22 +
23 default_version = False
24 if default_version_string.lower() == 'true':
25 default_version = True
26
27 - result.append(ProvidedSymbol(name, version, library, default_version))
28 + result.append(ProvidedSymbol(name, version, library, default_version, weak))
29
30 return result
31
32 @@ -498,6 +503,9 @@
33 debug(DEBUG_SPAM, "present_symbols adding %s" % symbol)
34 names = symbol.base_names()
35 for name in names:
36 + if name in present_symbols:
37 + if symbol.library != present_symbols[name].library:
38 + needed_symbols[name] = UndefinedSymbol(name, True, symbol.version, symbol.library)
39 present_symbols[name] = symbol
40
41 # are we finished?
42 @@ -589,12 +597,16 @@
43 # may segfault in ptmalloc_init due to undefined weak reference
44 extra_pre_obj.append(sysroot + libc_extras_dir + "/soinit.o")
45 extra_post_obj.append(sysroot + libc_extras_dir + "/sofini.o")
46 - symbols.add(ProvidedSymbol('__dso_handle', None, None, True))
47 + symbols.add(ProvidedSymbol('__dso_handle', None, None, True, True))
48
49 - if soname in ("libc.so.0"):
50 - symbols.add(ProvidedSymbol('__uClibc_init', None, None, True))
51 - symbols.add(ProvidedSymbol('__uClibc_fini', None, None, True))
52 - extra_flags.append("-Wl,-init,__uClibc_init")
53 + if soname == "libc.so.0":
54 + symbols.add(ProvidedSymbol('__uClibc_init', None, None, True, True))
55 + symbols.add(ProvidedSymbol('__uClibc_fini', None, None, True, True))
56 + extra_pre_obj.append("-Wl,-init,__uClibc_init")
57 +
58 + if soname == "libpthread.so.0":
59 + symbols.add(ProvidedSymbol('__pthread_initialize_minimal_internal', None, None, True, True))
60 + extra_flags.append("-Wl,-z,nodelete,-z,initfirst,-init=__pthread_initialize_minimal_internal")
61
62 map_file = find_pic_map(library)
63 if map_file: