This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Shared library building on Alpha/VMS
- From: Douglas B Rupp <rupp at gnat dot com>
- To: gcc-patches at gcc dot gnu dot org, Richard Henderson <rth at redhat dot com>
- Date: Sat, 08 Aug 2009 13:29:47 -0700
- Subject: [PATCH] Shared library building on Alpha/VMS
OK to commit?
--Douglas B Rupp
AdaCore
2009-08-08 Douglas B Rupp <rupp@gnat.com>
* config/alpha/alpha.c (TARGET_ASM_UNALIGNED_*_OP): Define if on VMS.
* config/alpha/vms.h (OBJECT_FORMAT_ELF): Define.
(ASM_WEAKEN_LABEL): Define.
(CRT_CALL_STATIC_FUNCTION): Define.
(STARTFILE_SPEC): Add crtbegin.o crtbeginS.o.
(ENDFILE_SPEC): Define.
(INIT_SECTION_ASM_OP): Define.
* config/alpha/vms-dwarf2eh.asm (__EH_FRAME_BEGIN__): Remove.
* config/alpha/t-vms (EXTRA_PARTS): Add crtbegin.o crtbeginS.o
crtend.o crtendS.o.
(MULTILIB_OSDIRNAMES): Define.
(shlib_version): Define.
(SHLIB_EXT): Define.
(SHLIB_OBJS): Define.
(SHLIB_NAME): Define.
(SHLIB_MULTILIB): Define.
(SHLIB_INSTALL): Define.
(SHLIB_SYMVEC): Define.
(SHLIB_SYMVECX2): Define.
(SHLIB_LINK): Define.
diff -rupN gcc/config/alpha/alpha.c gcc/config/alpha/alpha.c
--- gcc/config/alpha/alpha.c 2009-01-13 00:04:11.000000000 -0800
+++ gcc/config/alpha/alpha.c 2009-01-24 10:44:47.000000000 -0800
@@ -10752,7 +10752,7 @@ alpha_init_libfuncs (void)
/* Default unaligned ops are provided for ELF systems. To get unaligned
data for non-ELF systems, we have to turn off auto alignment. */
-#ifndef OBJECT_FORMAT_ELF
+#if !defined (OBJECT_FORMAT_ELF) || TARGET_ABI_OPEN_VMS
#undef TARGET_ASM_UNALIGNED_HI_OP
#define TARGET_ASM_UNALIGNED_HI_OP "\t.align 0\n\t.word\t"
#undef TARGET_ASM_UNALIGNED_SI_OP
diff -rupN gcc/config/alpha/vms-dwarf2eh.asm gcc/config/alpha/vms-dwarf2eh.asm
--- gcc/config/alpha/vms-dwarf2eh.asm 2005-11-09 00:09:38.000000000 -0800
+++ gcc/config/alpha/vms-dwarf2eh.asm 2009-01-23 19:46:37.000000000 -0800
@@ -33,5 +33,3 @@ Boston, MA 02110-1301, USA. */
.section .eh_frame,NOWRT
.align 0
- .global __EH_FRAME_BEGIN__
-__EH_FRAME_BEGIN__:
diff -rupN gcc/config/alpha/vms.h gcc/config/alpha/vms.h
--- gcc/config/alpha/vms.h 2008-04-08 01:59:34.000000000 -0700
+++ gcc/config/alpha/vms.h 2009-01-23 22:33:42.000000000 -0800
@@ -21,6 +21,10 @@ along with GCC; see the file COPYING3.
#define TARGET_OBJECT_SUFFIX ".obj"
#define TARGET_EXECUTABLE_SUFFIX ".exe"
+/* Alpha/VMS object format is not really Elf, but this makes compiling
+ crtstuff.c and dealing with shared library initialization much easier. */
+#define OBJECT_FORMAT_ELF
+
/* This enables certain macros in alpha.h, which will make an indirect
reference to an external symbol an invalid address. This needs to be
defined before we include alpha.h, since it determines which macros
@@ -201,9 +205,17 @@ typedef struct {int num_args; enum avms_
#undef STACK_CHECK_BUILTIN
#define STACK_CHECK_BUILTIN 0
+#undef ASM_WEAKEN_LABEL
+#define ASM_WEAKEN_LABEL(FILE, NAME) \
+ do { fputs ("\t.weak\t", FILE); assemble_name (FILE, NAME); \
+ fputc ('\n', FILE); } while (0)
+
#define READONLY_DATA_SECTION_ASM_OP "\t.rdata"
#define CTORS_SECTION_ASM_OP "\t.ctors"
#define DTORS_SECTION_ASM_OP "\t.dtors"
+#define SDATA_SECTION_ASM_OP "\t.sdata"
+#define CRT_CALL_STATIC_FUNCTION(SECTION_OP, FUNC) \
+ asm (SECTION_OP "\n\t.long " #FUNC"\n");
#undef ASM_OUTPUT_ADDR_DIFF_ELT
#define ASM_OUTPUT_ADDR_DIFF_ELT(FILE, BODY, VALUE, REL) gcc_unreachable ()
@@ -334,8 +346,13 @@ do { \
%{g2:-g2 vms-dwarf2.o%s} %{g3:-g3 vms-dwarf2.o%s} %{shared} %{v} %{map}"
#undef STARTFILE_SPEC
-#define STARTFILE_SPEC "%{!shared:%{mvms-return-codes:vcrt0.o%s} \
-%{!mvms-return-codes:pcrt0.o%s}}"
+#define STARTFILE_SPEC \
+"%{!shared:%{mvms-return-codes:vcrt0.o%s} %{!mvms-return-codes:pcrt0.o%s} \
+ crtbegin.o%s} \
+ %{!static:%{shared:crtbeginS.o%s}}"
+
+#define ENDFILE_SPEC \
+"%{!shared:crtend.o%s} %{!static:%{shared:crtendS.o%s}}"
#undef LIB_SPEC
#define LIB_SPEC "-lc"
@@ -343,4 +360,6 @@ do { \
#define NAME__MAIN "__gccmain"
#define SYMBOL__MAIN __gccmain
+#define INIT_SECTION_ASM_OP "\t.section LIB$INITIALIZE,GBL,NOWRT"
+
#define LONGLONG_STANDALONE 1
diff -rupN gcc/config/alpha/t-vms gcc/config/alpha/t-vms
--- gcc/config/alpha/t-vms 2007-01-04 18:30:31.000000000 -0800
+++ gcc/config/alpha/t-vms 2009-01-23 20:18:26.000000000 -0800
@@ -19,8 +19,6 @@
-# VMS_EXTRA_PARTS is defined in x-vms and represent object files that
-# are only needed for VMS targets, but can only be compiled on a VMS host
-# (because they need DEC C).
-EXTRA_PARTS = vms-dwarf2.o vms-dwarf2eh.o $(VMS_EXTRA_PARTS)
+EXTRA_PARTS = vms-dwarf2.o vms-dwarf2eh.o $(VMS_EXTRA_PARTS) \
+ crtbegin.o crtbeginS.o crtend.o crtendS.o
# This object must be linked with in order to make the executable debuggable.
# vms-ld handles it automatically when passed -g.
@@ -34,5 +32,34 @@ $(T)vms-dwarf2eh.o : $(srcdir)/config/al
MULTILIB_OPTIONS = mcpu=ev6
MULTILIB_DIRNAMES = ev6
+MULTILIB_OSDIRNAMES = ev6
LIBGCC = stmp-multilib
INSTALL_LIBGCC = install-multilib
+
+shlib_version:=$(shell echo $(BASEVER_c) | sed -e 's/\./,/' -e 's/\.//g')
+SHLIB_EXT = .exe
+SHLIB_OBJS = @shlib_objs@
+SHLIB_NAME = @shlib_base_name@.exe
+SHLIB_MULTILIB =
+SHLIB_INSTALL = $(INSTALL_DATA) $(SHLIB_NAME) $$(DESTDIR)$$(libsubdir)/$(SHLIB_NAME)
+SHLIB_SYMVEC = \
+ grep -F -e "\$$BSS\$$" -e "\$$DATA\$$" -e " sdata " -e " data.rel " -e " data.rel.ro " -e " sbss " \
+ -e "\$$LINK\$$" -e "\$$READONLY\$$" | \
+ sed -e "s/.*\$$LINK\$$ \(.*\)/SYMBOL_VECTOR=(\1=PROCEDURE)/" \
+ -e "s/.*\$$DATA\$$ \(.*\)/SYMBOL_VECTOR=(\1=DATA)/" \
+ -e "s/.* sbss \(.*\)/SYMBOL_VECTOR=(\1=DATA)/" \
+ -e "s/.* sdata \(.*\)/SYMBOL_VECTOR=(\1=DATA)/" \
+ -e "s/.* data.rel \(.*\)/SYMBOL_VECTOR=(\1=DATA)/" \
+ -e "s/.* data.rel.ro \(.*\)/SYMBOL_VECTOR=(\1=DATA)/" \
+ -e "s/.*\$$BSS\$$ \(.*\)/SYMBOL_VECTOR=(\1=DATA)/" \
+ -e "s/.*\$$READONLY\$$ \(.*\)/SYMBOL_VECTOR=(\1=DATA)/"
+SHLIB_SYMVECX2 := $(subst $$,$$$$,$(SHLIB_SYMVEC))
+SHLIB_LINK = \
+ echo "case_sensitive=yes" > SYMVEC_$$$$$$$$.opt; \
+ objdump --syms $(SHLIB_OBJS) | \
+ $(SHLIB_SYMVECX2) >> SYMVEC_$$$$$$$$.opt ; \
+ echo "case_sensitive=NO" >> SYMVEC_$$$$$$$$.opt; \
+ $(GCC_FOR_TARGET) $(LIBGCC2_CFLAGS) -nodefaultlibs \
+ -shared --for-linker=/noinform -o $(SHLIB_NAME) $(SHLIB_OBJS) \
+ --for-linker=SYMVEC_$$$$$$$$.opt \
+ --for-linker=gsmatch=equal,$(shlib_version)