http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47558
--- Comment #9 from Iain Sandoe <iains at gcc dot gnu.org> 2011-02-01 09:08:53
UTC ---
Jack,
The linkage of libs (with trunk darwin.h) is like this:
libgcc_ext.dylib ---> exports our additional symbols (ONLY)**
libSystem ---- > contains the annotated system symbols.
** this causes the reference to /my/install/path/libgcc_s.1.dylib to be
inserted into the exe.
As below:
===
mini-02-sno:gcc-4-6-trunk-build$ uname -a
Darwin mini-02-sno.local 10.6.0 Darwin Kernel Version 10.6.0: Wed Nov 10
18:13:17 PST 2010; root:xnu-1504.9.26~3/RELEASE_I386 i386 i386
====
mini-02-sno:gcc-4-6-trunk-build$ cat /Volumes/ScratchCS/tests/linkage.c
/* This is not meant to work or do anything useful !!!
-- sole purpose is to allow examination of linkage. */
int main (void)
{
static __thread i; <<=== make it link our ext lib.
i+i;
_Unwind_Resume ((void *)0); <<== make it link libSystem (we expect - NOT from
our ext.)
return i;
}
======
mini-02-sno:gcc-4-6-trunk-build$ ./gcc/xgcc -Bgcc
/Volumes/ScratchCS/tests/linkage.c -o tt
mini-02-sno:gcc-4-6-trunk-build$ nm -mv tt
0000000100000f80 (__TEXT,__stub_helper) non-external (was a private external)
stub helpers
0000000100001060 (__DATA,__data) external _NXArgc
0000000100001068 (__DATA,__data) external _NXArgv
(undefined [lazy bound]) external __Unwind_Resume (from
libSystem) <<<=== correct
(undefined [lazy bound]) external ___emutls_get_address (from
libgcc) <<<=== correct
0000000100001080 (__DATA,__data) non-external ___emutls_v.i.1606
0000000100001078 (__DATA,__data) external ___progname
0000000100000f38 (__TEXT,__text) non-external __dyld_func_lookup
0000000100000000 (absolute) [referenced dynamically] external
__mh_execute_header
0000000100001070 (__DATA,__data) external _environ
(undefined [lazy bound]) external _exit (from libSystem)
0000000100000f3e (__TEXT,__text) external _main
(undefined) external dyld_stub_binder (from libSystem)
0000000100000f24 (__TEXT,__text) non-external dyld_stub_binding_helper
0000000100000ee8 (__TEXT,__text) external start
====
mini-02-sno:gcc-4-6-trunk-build$ DYLD_PRINT_LIBRARIES=1 ./tt
dyld: loaded: /Volumes/GCC/gcc-4-6-trunk-build/./tt
dyld: loaded:
/GCC/gcc-4-6-install/lib/gcc/x86_64-apple-darwin10/4.6.0/libgcc_s.1.dylib
dyld: loaded: /usr/lib/libSystem.B.dylib
dyld: loaded: /usr/lib/system/libmathCommon.A.dylib
Segmentation fault <<<< === no surprise, the program is not meant to work
====
although the program does not work - you can
(a) install your built gcc [without modifying darwin.h]
(b) compile the prog with debug and step through to find that the
_Unwind_Resume that is called __is__ the one from libSystem.