diff options
author | Richard Earnshaw <rearnsha@arm.com> | 2001-12-13 14:24:03 +0000 |
---|---|---|
committer | Richard Earnshaw <rearnsha@gcc.gnu.org> | 2001-12-13 14:24:03 +0000 |
commit | 414e05cffba6eda254f91ea66e1edb04b55852a2 (patch) | |
tree | d02bbfaf0f7f2c12f79276ee2bd6883b939f8502 /gcc/config | |
parent | 3a79cccbde4a5af128debfc5f281d7a96946e10e (diff) | |
download | gcc-414e05cffba6eda254f91ea66e1edb04b55852a2.zip gcc-414e05cffba6eda254f91ea66e1edb04b55852a2.tar.gz gcc-414e05cffba6eda254f91ea66e1edb04b55852a2.tar.bz2 |
* collect2.c (COLLECT_SHARED_INIT_FUNC)
(COLLECT_SHARD_FINI_FUNC): Define default values.
(write_c_file_stat): Use them to call construtor and destructor
functions in shared libraries.
* doc/tm.texi (COLLECT_SHARED_INIT_FUNC)
(COLLECT_SHARD_FINI_FUNC): Document them.
* config/netbsd.h (COLLECT_SHARED_INIT_FUNC)
(COLLECT_SHARD_FINI_FUNC): Define.
* config/netbsd.h (LINK_SPEC): Don't pull in estart if creating a
shared library. Pass -shared through to the linker.
* config/arm/netbsd.h (LINK_SPEC): Likewise.
* config/arm/t-netbsd (TARGET_LIBGCC2_CFLAGS): Add -fpic.
(SHLIB_EXT, SHLIB_NAME, SHLIB_SONAME, SHLIB_OBJS, SHLIB_LINK)
(SHLIB_INSTALL): Define.
From-SVN: r47975
Diffstat (limited to 'gcc/config')
-rw-r--r-- | gcc/config/arm/netbsd.h | 4 | ||||
-rw-r--r-- | gcc/config/arm/t-netbsd | 19 | ||||
-rw-r--r-- | gcc/config/netbsd.h | 19 |
3 files changed, 37 insertions, 5 deletions
diff --git a/gcc/config/arm/netbsd.h b/gcc/config/arm/netbsd.h index 9684fdb..74f32e8 100644 --- a/gcc/config/arm/netbsd.h +++ b/gcc/config/arm/netbsd.h @@ -67,8 +67,8 @@ Boston, MA 02111-1307, USA. */ /* Pass -X to the linker so that it will strip symbols starting with 'L' */ #undef LINK_SPEC #define LINK_SPEC "\ --X %{!nostdlib:%{!r*:%{!e*:-e start}}} -dc -dp %{R*} \ -%{static:-Bstatic} %{assert*} \ +-X %{!shared:%{!nostdlib:%{!r*:%{!e*:-e start}}} -dc -dp %{R*} \ +%{static:-Bstatic}} %{shared} %{assert*} \ " #undef SIZE_TYPE diff --git a/gcc/config/arm/t-netbsd b/gcc/config/arm/t-netbsd index 6c59cc9..511b015 100644 --- a/gcc/config/arm/t-netbsd +++ b/gcc/config/arm/t-netbsd @@ -1,8 +1,25 @@ # Just for these, we omit the frame pointer since it makes such a big # difference. It is then pointless adding debugging. -TARGET_LIBGCC2_CFLAGS = -fomit-frame-pointer +TARGET_LIBGCC2_CFLAGS = -fomit-frame-pointer -fpic LIBGCC2_DEBUG_CFLAGS = -g0 +# Build a shared libgcc library. +SHLIB_EXT = .so +SHLIB_NAME = @shlib_base_name@.so +SHLIB_SONAME = @shlib_base_name@.so.1 +SHLIB_OBJS = @shlib_objs@ + +SHLIB_LINK = $(GCC_FOR_TARGET) $(LIBGCC2_CFLAGS) -shared -nodefaultlibs \ + -Wl,-soname,$(SHLIB_SONAME) \ + -o $(SHLIB_NAME) @multilib_flags@ $(SHLIB_OBJS) -lc && \ + rm -f $(SHLIB_SONAME) && \ + $(LN_S) $(SHLIB_NAME) $(SHLIB_SONAME) +# $(slibdir) double quoted to protect it from expansion while building +# libgcc.mk. We want this delayed until actual install time. +SHLIB_INSTALL = $(INSTALL_DATA) $(SHLIB_NAME) $$(slibdir)/$(SHLIB_SONAME); \ + rm -f $$(slibdir)/$(SHLIB_NAME); \ + $(LN_S) $(SHLIB_SONAME) $$(slibdir)/$(SHLIB_NAME) + # Don't build enquire ENQUIRE= diff --git a/gcc/config/netbsd.h b/gcc/config/netbsd.h index b76e747..35e671b 100644 --- a/gcc/config/netbsd.h +++ b/gcc/config/netbsd.h @@ -54,11 +54,26 @@ #define LIB_SPEC "%{!p:%{!pg:-lc}}%{p:-lc_p}%{pg:-lc_p}" /* Provide a LINK_SPEC appropriate for NetBSD. Here we provide support - for the special GCC options -static, -assert, and -nostdlib. */ + for the special GCC options -shared, -static, -assert, and -nostdlib. */ #undef LINK_SPEC #define LINK_SPEC \ - "%{!nostdlib:%{!r*:%{!e*:-e start}}} -dc -dp %{R*} %{static:-Bstatic} %{assert*}" + "%{!shared:%{!nostdlib:%{!r*:%{!e*:-e start}}} -dc -dp %{R*} %{static:-Bstatic}} %{shared} %{assert*}" + +/* When building shared libraries, the initialization and finalization + functions for the library are .init and .fini respectively. */ + +#define COLLECT_SHARED_INIT_FUNC(STREAM,FUNC) \ + do { \ + fprintf ((STREAM), "void __init() __asm__ (\".init\");"); \ + fprintf ((STREAM), "void __init() {\n\t%s();\n}\n", (FUNC)); \ + } while (0); + +#define COLLECT_SHARED_FINI_FUNC(STREAM,FUNC) \ + do { \ + fprintf ((STREAM), "void __fini() __asm__ (\".fini\");"); \ + fprintf ((STREAM), "void __fini() {\n\t%s();\n}\n", (FUNC)); \ + } while (0); /* This defines which switch letters take arguments. */ #undef SWITCH_TAKES_ARG |