This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
[PATCH] IA64 VMS (2nd Try)
- From: Douglas B Rupp <rupp at gnat dot com>
- To: binutils at sourceware dot org
- Date: Sat, 10 Jan 2009 14:04:11 -0800
- Subject: [PATCH] IA64 VMS (2nd Try)
- References: <4930BA9E.50509@gnat.com> <4937D8CA.6000703@redhat.com>
Add support for IA64 VMS.
I believe I've addressed the issues raised by Nick Clifton in his review
of my 1st try.
--Douglas Rupp
2009-01-10 Douglas B Rupp <rupp@gnat.com>
* configure.ac (ia64*-*-*vms*): Add case with no gdb or ld support.
* configure: Regenerate
* include/elf/ia64.h (SHT_IA_64_VMS_DISPLAY_NAME_INFO,
EF_IA_64_ARCHVER_1): New macros. Minor reformatting.
* bfd/Makefile.am (BFD32_BACKENDS): Add new object vmsutil.lo
(BFD32_BACKENDS_CFILES): Add new file vmsutil.c
(vmsutil.lo): Add dependency rule
* bfd/Makefile.in: Regenerate
* bfd/config.bfd (ia64*-*-*vms*): Add case.
* bfd/configure.in (bfd_elf64_ia64_vms_vec): Add case.
* bfd/configure: Regenerate
* bfd/vmsutil.[ch]: New files
* bfd/elf-bfd.h (struct bfd_elf_special_section): Change type of
attr to bfd_vma.
* bfd/elfxx-ia64.c (elfNN_vms_post_process_headers,
elfNN_vms_section_processing, elfNN_vms_final_write_processing,
elfNN_vms_close_and_cleanup, elfNN_vms_section_from_shdr,
elfNN_vms_object_p): New functions
* bfd/targets.c (bfd_elf64_ia64_vms_vec): New target.
* gas/configure.tgt(ia64-*-*vms*): New target.
* gas/dwarf2dbg.h (dwarf2_loc_mark_labels): Make extern.
* gas/tc.h (md_number_to_chars): Declare iff undefined.
* gas/config/obj-elf.c (obj_elf_change_section): Change type of
arg attr to bfd_vma.
(obj_elf_parse_section_letters): Return a bfd_vma. Change type of
variables attr, md_attr to bfd_vma.
(obj_elf_section_word): Likewise.
(obj_elf_section): Change type of variable attr to bfd_vma
* gas/config/obj-elf.h (obj_elf_change_section): Change type of
arg attr to bfd_vma
* gas/config/tc-ia64.c (bfdver.h,time.h): Include.
(ia64_elf_section_letter): Now returns a bfd_vma.
Handle VMS specific attributes.
(ia64_elf_section_flags): Arg attr now a bfd_vma.
(ia64_init): Don't turn on dependency checking for VMS.
(ia64_target_format): Check for VMS flag bit.
(do_alias): Hande decc$ functions.
(get_vms_time): New function.
(ia64_vms_note): New function.
* gas/config/tc-ia64.h (ia64_elf_section_letter): Now returns a bfd_vma.
(ia64_elf_section_flags): Arg attr now a bfd_vma.
(tc_init_after_args): Define for VMS.
* gas/config/tc-alpha.c (alpha_elf_section_letter): Return a bfd_vma.
(alpha_elf_section_flags): Change type of arg attr to bfd_vma.
* gas/config/tc-alpha.h: Likewise.
* gas/config/tc-i386.c (x86_64_section_letter): Return a bfd_vma.
(x86_64_section_word): Return a bfd_vma.
* gas/config/tc-i386.h: Likewise.
* gas/config/tc-ip2k.c (ip2k_elf_section_flags): Change type of arg
attr to bfd_vma.
* gas/config/tc-ip2k.h: Likewise.
* gas/config/tc-mep.c (mep_elf_section_letter): Return a bfd_vma.
(mep_elf_section_flags): Change type of arg attr to bfd_vma.
* gas/config/tc-mep.h: Likewise.
* gas/config/tc-ppc.c (ppc_section_letter): Return a bfd_vma.
(ppc_section_word): Return a bfd_vma.
(ppc_section_flags): Change type of arg attr to bfd_vma.
* gas/config/tc-ppc.h: Likewise.
* include/libiberty.h (basename): Test VMS
* intl/dcgettext.c (__POSIX_C_SOURCE): Define for VMS
* libiberty/fibheap.c (ULONG_MAX,LONG_MAX,LONG_MIN): Define if
necessary.
* gas/config/te-vms.h (DWARF2_DIR_SHOULD_END_WITH_SEPARATOR,
DWAR2_FILE_TIME_NAME, DWARF2_FILE_SIZE_NAME, DWARF2_FILEN_NAME):
New file with new macros
* gas/dwarf2dbg.c (get_filenum, out_file_list): Default and call new
macros
Index: configure.ac
===================================================================
RCS file: /cvs/src/src/configure.ac,v
retrieving revision 1.57
diff -u -p -r1.57 configure.ac
--- configure.ac 16 Dec 2008 12:31:18 -0000 1.57
+++ configure.ac 10 Jan 2009 06:15:05 -0000
@@ -690,6 +690,10 @@ case "${target}" in
;;
i370-*-opened*)
;;
+ ia64*-*-*vms*)
+ # No gdb or ld support yet.
+ noconfigdirs="$noconfigdirs ${libgcj} tix readline mmalloc libgui itcl gdb ld"
+ ;;
i[[3456789]]86-*-coff | i[[3456789]]86-*-elf)
noconfigdirs="$noconfigdirs ${libgcj}"
libgloss_dir=i386
Index: configure
===================================================================
RCS file: /cvs/src/src/configure,v
retrieving revision 1.311
diff -u -p -r1.311 configure
--- configure 16 Dec 2008 12:31:18 -0000 1.311
+++ configure 10 Jan 2009 06:15:04 -0000
@@ -2454,6 +2454,10 @@ case "${target}" in
;;
i370-*-opened*)
;;
+ ia64*-*-*vms*)
+ # No gdb or ld support yet.
+ noconfigdirs="$noconfigdirs ${libgcj} tix readline mmalloc libgui itcl gdb ld"
++ ;;
i[3456789]86-*-coff | i[3456789]86-*-elf)
noconfigdirs="$noconfigdirs ${libgcj}"
libgloss_dir=i386
Index: include/elf/ia64.h
===================================================================
RCS file: /cvs/src/src/include/elf/ia64.h,v
retrieving revision 1.15
diff -u -p -r1.15 ia64.h
--- include/elf/ia64.h 11 Mar 2008 23:21:08 -0000 1.15
+++ include/elf/ia64.h 10 Jan 2009 06:15:24 -0000
@@ -24,8 +24,9 @@
/* Bits in the e_flags field of the Elf64_Ehdr: */
-#define EF_IA_64_MASKOS 0x0000000f /* OS-specific flags. */
-#define EF_IA_64_ARCH 0xff000000 /* Arch. version mask. */
+#define EF_IA_64_MASKOS 0x0000000f /* OS-specific flags. */
+#define EF_IA_64_ARCH 0xff000000 /* Arch. version mask. */
+#define EF_IA_64_ARCHVER_1 (1 << 24) /* Arch. version level 1 compat. */
/* ??? These four definitions are not part of the SVR4 ABI.
They were present in David's initial code drop, so it is probable
@@ -84,22 +85,24 @@
/* OpenVMS section types. */
/* The section contains PC-to-source correlation information for use by the
VMS RTL's traceback facility. */
-#define SHT_IA_64_VMS_TRACE 0x60000000
+#define SHT_IA_64_VMS_TRACE 0x60000000
/* The section contains routine signature information for use by the
translated image executive. */
-#define SHT_IA_64_VMS_TIE_SIGNATURES 0x60000001
+#define SHT_IA_64_VMS_TIE_SIGNATURES 0x60000001
/* The section contains dwarf-3 information. */
-#define SHT_IA_64_VMS_DEBUG 0x60000002
+#define SHT_IA_64_VMS_DEBUG 0x60000002
/* The section contains the dwarf-3 string table. */
-#define SHT_IA_64_VMS_DEBUG_STR 0x60000003
+#define SHT_IA_64_VMS_DEBUG_STR 0x60000003
/* The section contains linkage information to perform consistency checking
accross object modules. */
-#define SHT_IA_64_VMS_LINKAGES 0x60000004
+#define SHT_IA_64_VMS_LINKAGES 0x60000004
/* The section allows the symbol vector in an image to be location through
the section table. */
-#define SHT_IA_64_VMS_SYMBOL_VECTOR 0x60000005
+#define SHT_IA_64_VMS_SYMBOL_VECTOR 0x60000005
/* The section contains inter-image fixups. */
-#define SHT_IA_64_VMS_FIXUP 0x60000006
+#define SHT_IA_64_VMS_FIXUP 0x60000006
+/* The section contains unmangled name info. */
+#define SHT_IA_64_VMS_DISPLAY_NAME_INFO 0x60000007
/* Bits in the p_flags field of Elf64_Phdr: */
Index: bfd/Makefile.am
===================================================================
RCS file: /cvs/src/src/bfd/Makefile.am,v
retrieving revision 1.216
diff -u -p -r1.216 Makefile.am
--- bfd/Makefile.am 23 Dec 2008 19:10:18 -0000 1.216
+++ bfd/Makefile.am 10 Jan 2009 06:15:05 -0000
@@ -371,6 +371,7 @@ BFD32_BACKENDS = \
vms-hdr.lo \
vms-misc.lo \
vms-tir.lo \
+ vmsutil.lo \
xcofflink.lo \
xsym.lo \
xtensa-isa.lo \
@@ -552,6 +553,7 @@ BFD32_BACKENDS_CFILES = \
vms-hdr.c \
vms-misc.c \
vms-tir.c \
+ vmsutil.c \
xcofflink.c \
xsym.c \
xtensa-isa.c \
@@ -1833,6 +1835,7 @@ vms-misc.lo: vms-misc.c $(INCDIR)/filena
$(INCDIR)/hashtab.h vms.h
vms-tir.lo: vms-tir.c $(INCDIR)/filenames.h $(INCDIR)/bfdlink.h \
$(INCDIR)/hashtab.h vms.h
+vmsutil.lo: vmsutil.c vmsutil.h $(INCDIR)/ansidecl.h
xcofflink.lo: xcofflink.c $(INCDIR)/filenames.h $(INCDIR)/bfdlink.h \
$(INCDIR)/hashtab.h $(INCDIR)/coff/internal.h $(INCDIR)/coff/xcoff.h \
libcoff.h libxcoff.h
Index: bfd/Makefile.in
===================================================================
RCS file: /cvs/src/src/bfd/Makefile.in,v
retrieving revision 1.240
diff -u -p -r1.240 Makefile.in
--- bfd/Makefile.in 23 Dec 2008 19:10:18 -0000 1.240
+++ bfd/Makefile.in 10 Jan 2009 06:15:06 -0000
@@ -637,6 +637,7 @@ BFD32_BACKENDS = \
vms-hdr.lo \
vms-misc.lo \
vms-tir.lo \
+ vmsutil.lo \
xcofflink.lo \
xsym.lo \
xtensa-isa.lo \
@@ -818,6 +819,7 @@ BFD32_BACKENDS_CFILES = \
vms-hdr.c \
vms-misc.c \
vms-tir.c \
+ vmsutil.c \
xcofflink.c \
xsym.c \
xtensa-isa.c \
@@ -2429,6 +2431,7 @@ vms-misc.lo: vms-misc.c $(INCDIR)/filena
$(INCDIR)/hashtab.h vms.h
vms-tir.lo: vms-tir.c $(INCDIR)/filenames.h $(INCDIR)/bfdlink.h \
$(INCDIR)/hashtab.h vms.h
+vmsutil.lo: vmsutil.c vmsutil.h $(INCDIR)/ansidecl.h
xcofflink.lo: xcofflink.c $(INCDIR)/filenames.h $(INCDIR)/bfdlink.h \
$(INCDIR)/hashtab.h $(INCDIR)/coff/internal.h $(INCDIR)/coff/xcoff.h \
libcoff.h libxcoff.h
Index: bfd/config.bfd
===================================================================
RCS file: /cvs/src/src/bfd/config.bfd,v
retrieving revision 1.243
diff -u -p -r1.243 config.bfd
--- bfd/config.bfd 6 Jan 2009 14:40:32 -0000 1.243
+++ bfd/config.bfd 10 Jan 2009 06:15:06 -0000
@@ -187,6 +187,10 @@ case "${targ}" in
targ_selvecs="bfd_elf64_ia64_hpux_big_vec"
want64=true
;;
+ ia64*-*-*vms*)
+ targ_defvec=bfd_elf64_ia64_vms_vec
+ want64=true
+ ;;
sparc64-*-freebsd* | sparc64-*-kfreebsd*-gnu)
targ_defvec=bfd_elf64_sparc_freebsd_vec
targ_selvecs="bfd_elf64_sparc_vec bfd_elf32_sparc_vec sunos_big_vec"
Index: bfd/configure.in
===================================================================
RCS file: /cvs/src/src/bfd/configure.in,v
retrieving revision 1.251
diff -u -p -r1.251 configure.in
--- bfd/configure.in 23 Dec 2008 19:10:18 -0000 1.251
+++ bfd/configure.in 10 Jan 2009 06:15:11 -0000
@@ -771,6 +771,7 @@ do
bfd_elf64_ia64_big_vec) tb="$tb elf64-ia64.lo elf64.lo $elf"; target_size=64 ;;
bfd_elf64_ia64_hpux_big_vec) tb="$tb elf64-ia64.lo elf64.lo $elf"; target_size=64 ;;
bfd_elf64_ia64_little_vec) tb="$tb elf64-ia64.lo elf64.lo $elf"; target_size=64 ;;
+ bfd_elf64_ia64_vms_vec) tb="$tb elf64-ia64.lo elf64.lo $elf vmsutil.lo"; target_size=64 ;;
bfd_elf64_little_generic_vec) tb="$tb elf64-gen.lo elf64.lo $elf"; target_size=64 ;;
bfd_elf64_littlemips_vec) tb="$tb elf64-mips.lo elf64.lo elfxx-mips.lo elf-vxworks.lo elf32.lo $elf ecofflink.lo"; target_size=64 ;;
bfd_elf64_mmix_vec) tb="$tb elf64-mmix.lo elf64.lo $elf" target_size=64 ;;
Index: bfd/configure
===================================================================
RCS file: /cvs/src/src/bfd/configure,v
retrieving revision 1.291
diff -u -p -r1.291 configure
--- bfd/configure 23 Dec 2008 19:10:18 -0000 1.291
+++ bfd/configure 10 Jan 2009 06:15:10 -0000
@@ -20834,6 +20834,7 @@ do
bfd_elf64_ia64_big_vec) tb="$tb elf64-ia64.lo elf64.lo $elf"; target_size=64 ;;
bfd_elf64_ia64_hpux_big_vec) tb="$tb elf64-ia64.lo elf64.lo $elf"; target_size=64 ;;
bfd_elf64_ia64_little_vec) tb="$tb elf64-ia64.lo elf64.lo $elf"; target_size=64 ;;
+ bfd_elf64_ia64_vms_vec) tb="$tb elf64-ia64.lo elf64.lo $elf vmsutil.lo"; target_size=64 ;;
bfd_elf64_little_generic_vec) tb="$tb elf64-gen.lo elf64.lo $elf"; target_size=64 ;;
bfd_elf64_littlemips_vec) tb="$tb elf64-mips.lo elf64.lo elfxx-mips.lo elf-vxworks.lo elf32.lo $elf ecofflink.lo"; target_size=64 ;;
bfd_elf64_mmix_vec) tb="$tb elf64-mmix.lo elf64.lo $elf" target_size=64 ;;
--- /dev/null 2005-11-30 16:42:54.000000000 -0800
+++ bfd/vmsutil.c 2008-12-15 12:15:13.000000000 -0800
@@ -0,0 +1,266 @@
+/* vmsutil.c -- Utilities for VMS.
+ Copyright 2008 Free Software Foundation, Inc.
+
+ Written by Douglas B Rupp <rupp@gnat.com>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */
+
+#include "ansidecl.h"
+#include "vmsutil.h"
+
+#ifdef VMS
+#define __NEW_STARLET 1
+#include <vms/starlet.h>
+#include <vms/rms.h>
+#include <vms/atrdef.h>
+#include <vms/fibdef.h>
+#include <vms/stsdef.h>
+#include <vms/iodef.h>
+#include <vms/fatdef.h>
+#include <errno.h>
+#include <vms/descrip.h>
+#include <string.h>
+#include <unixlib.h>
+
+#define MAXPATH 256
+
+/* Descrip.h doesn't have everything... */
+typedef struct fibdef* __fibdef_ptr32 __attribute__ (( mode (SI) ));
+struct dsc$descriptor_fib
+{
+ unsigned int fib$l_len;
+ __fibdef_ptr32 fib$l_addr;
+};
+
+/* I/O Status Block. */
+struct IOSB
+{
+ unsigned short status, count;
+ unsigned int devdep;
+};
+
+static char *tryfile;
+
+/* Variable length string. */
+struct vstring
+{
+ short length;
+ char string[NAM$C_MAXRSS+1];
+};
+
+static char filename_buff [MAXPATH];
+static char vms_filespec [MAXPATH];
+
+/* Callback function for filespec style conversion. */
+
+static int
+translate_unix (char *name, int type ATTRIBUTE_UNUSED)
+{
+ strncpy (filename_buff, name, MAXPATH);
+ filename_buff [MAXPATH - 1] = (char) 0;
+ return 0;
+}
+
+/* Wrapper for DECC function that converts a Unix filespec
+ to VMS style filespec. */
+
+static char *
+to_vms_file_spec (char *filespec)
+{
+ strncpy (vms_filespec, "", MAXPATH);
+ decc$to_vms (filespec, translate_unix, 1, 1);
+ strncpy (vms_filespec, filename_buff, MAXPATH);
+
+ vms_filespec [MAXPATH - 1] = (char) 0;
+
+ return vms_filespec;
+}
+
+#else
+#include <sys/stat.h>
+#include <time.h>
+#define VMS_EPOCH_OFFSET 35067168000000000LL
+#define VMS_GRANULARITY_FACTOR 10000000
+#endif
+
+/* Return VMS file date, size, format, version given a name. */
+
+int
+vms_file_stats_name (const char *filename,
+ long long *cdt,
+ long *siz,
+ char *rfo,
+ int *ver)
+{
+#ifdef VMS
+ struct FAB fab;
+ struct NAM nam;
+
+ unsigned long long create;
+ FAT recattr;
+ char ascnamebuff [256];
+
+ ATRDEF atrlst[]
+ = {
+ { ATR$S_CREDATE, ATR$C_CREDATE, &create },
+ { ATR$S_RECATTR, ATR$C_RECATTR, &recattr },
+ { ATR$S_ASCNAME, ATR$C_ASCNAME, &ascnamebuff },
+ { 0, 0, 0}
+ };
+
+ FIBDEF fib;
+ struct dsc$descriptor_fib fibdsc = {sizeof (fib), (void *) &fib};
+
+ struct IOSB iosb;
+
+ long status;
+ unsigned short chan;
+
+ struct vstring file;
+ struct dsc$descriptor_s filedsc
+ = {NAM$C_MAXRSS, DSC$K_DTYPE_T, DSC$K_CLASS_S, (void *) file.string};
+ struct vstring device;
+ struct dsc$descriptor_s devicedsc
+ = {NAM$C_MAXRSS, DSC$K_DTYPE_T, DSC$K_CLASS_S, (void *) device.string};
+ struct vstring result;
+ struct dsc$descriptor_s resultdsc
+ = {NAM$C_MAXRSS, DSC$K_DTYPE_VT, DSC$K_CLASS_VS, (void *) result.string};
+
+ if (strcmp (filename, "<internal>") == 0
+ || strcmp (filename, "<built-in>") == 0)
+ {
+ if (cdt)
+ *cdt = 0;
+
+ if (siz)
+ *siz = 0;
+
+ if (rfo)
+ *rfo = 0;
+
+ if (ver)
+ *ver = 0;
+
+ return 0;
+ }
+
+ tryfile = to_vms_file_spec ((char *) filename);
+
+ /* Allocate and initialize a FAB and NAM structures. */
+ fab = cc$rms_fab;
+ nam = cc$rms_nam;
+
+ nam.nam$l_esa = file.string;
+ nam.nam$b_ess = NAM$C_MAXRSS;
+ nam.nam$l_rsa = result.string;
+ nam.nam$b_rss = NAM$C_MAXRSS;
+ fab.fab$l_fna = tryfile;
+ fab.fab$b_fns = strlen (tryfile);
+ fab.fab$l_nam = &nam;
+
+ /* Validate filespec syntax and device existence. */
+ status = SYS$PARSE (&fab, 0, 0);
+ if ((status & 1) != 1)
+ return 1;
+
+ file.string[nam.nam$b_esl] = 0;
+
+ /* Find matching filespec. */
+ status = SYS$SEARCH (&fab, 0, 0);
+ if ((status & 1) != 1)
+ return 1;
+
+ file.string[nam.nam$b_esl] = 0;
+ result.string[result.length=nam.nam$b_rsl] = 0;
+
+ /* Get the device name and assign an IO channel. */
+ strncpy (device.string, nam.nam$l_dev, nam.nam$b_dev);
+ devicedsc.dsc$w_length = nam.nam$b_dev;
+ chan = 0;
+ status = SYS$ASSIGN (&devicedsc, &chan, 0, 0, 0);
+ if ((status & 1) != 1)
+ return 1;
+
+ /* Initialize the FIB and fill in the directory id field. */
+ memset (&fib, 0, sizeof (fib));
+ fib.fib$w_did[0] = nam.nam$w_did[0];
+ fib.fib$w_did[1] = nam.nam$w_did[1];
+ fib.fib$w_did[2] = nam.nam$w_did[2];
+ fib.fib$l_acctl = 0;
+ fib.fib$l_wcc = 0;
+ strcpy (file.string, (strrchr (result.string, ']') + 1));
+ filedsc.dsc$w_length = strlen (file.string);
+ result.string[result.length = 0] = 0;
+
+ /* Open and close the file to fill in the attributes. */
+ status
+ = SYS$QIOW (0, chan, IO$_ACCESS|IO$M_ACCESS, &iosb, 0, 0,
+ &fibdsc, &filedsc, &result.length, &resultdsc, &atrlst, 0);
+ if ((status & 1) != 1)
+ return 1;
+ if ((iosb.status & 1) != 1)
+ return 1;
+
+ result.string[result.length] = 0;
+ status = SYS$QIOW (0, chan, IO$_DEACCESS, &iosb, 0, 0, &fibdsc, 0, 0, 0,
+ &atrlst, 0);
+ if ((status & 1) != 1)
+ return 1;
+ if ((iosb.status & 1) != 1)
+ return 1;
+
+ /* Deassign the channel and exit. */
+ status = SYS$DASSGN (chan);
+ if ((status & 1) != 1)
+ return 1;
+
+ if (cdt) *cdt = create;
+ if (siz) *siz = (512 * 65536 * recattr.fat$w_efblkh) +
+ (512 * (recattr.fat$w_efblkl - 1)) +
+ recattr.fat$w_ffbyte;
+ if (rfo) *rfo = recattr.fat$v_rtype;
+ if (ver) *ver = strtol (strrchr (ascnamebuff, ';')+1, 0, 10);
+
+ return 0;
+#else
+ struct stat buff;
+ struct tm *ts;
+ long gmtoff;
+
+ if ((stat (filename, &buff)) != 0)
+ return 1;
+
+ if (cdt)
+ {
+ ts = localtime (&buff.st_mtime);
+ gmtoff = ts->tm_gmtoff;
+ *cdt = (long long) (((buff.st_mtim.tv_sec + gmtoff) * VMS_GRANULARITY_FACTOR)
+ + (buff.st_mtim.tv_nsec / 100))
+ + VMS_EPOCH_OFFSET;
+ }
+
+ if (siz)
+ *siz = buff.st_size;
+
+ if (rfo)
+ *rfo = 2; /* Stream LF format. */
+
+ if (ver)
+ *ver = 0;
+
+ return 0;
+#endif
+}
+
--- /dev/null 2005-11-30 16:42:54.000000000 -0800
+++ bfd/vmsutil.h 2008-12-15 12:03:47.000000000 -0800
@@ -0,0 +1,20 @@
+/* vmsutil.h -- Header file for utilities for VMS.
+ Copyright 2008 Free Software Foundation, Inc.
+
+ Written by Douglas B Rupp <rupp@gnat.com>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */
+
+int vms_file_stats_name (const char *, long long *, long *, char *, int *);
Index: bfd/elf-bfd.h
===================================================================
RCS file: /cvs/src/src/bfd/elf-bfd.h,v
retrieving revision 1.272
diff -u -p -r1.272 elf-bfd.h
--- bfd/elf-bfd.h 23 Dec 2008 09:01:45 -0000 1.272
+++ bfd/elf-bfd.h 10 Jan 2009 06:15:11 -0000
@@ -594,7 +594,7 @@ struct bfd_elf_special_section
PREFIX and finish with the last SUFFIX_LENGTH chars of PREFIX. */
int suffix_length;
int type;
- int attr;
+ bfd_vma attr;
};
enum action_discarded
Index: bfd/elfxx-ia64.c
===================================================================
RCS file: /cvs/src/src/bfd/elfxx-ia64.c,v
retrieving revision 1.208
diff -u -p -r1.208 elfxx-ia64.c
--- bfd/elfxx-ia64.c 23 Dec 2008 14:36:40 -0000 1.208
+++ bfd/elfxx-ia64.c 10 Jan 2009 06:15:13 -0000
@@ -219,6 +219,14 @@ static bfd_boolean allocate_dynrel_entri
static asection *get_pltoff
(bfd *abfd, struct bfd_link_info *info,
struct elfNN_ia64_link_hash_table *ia64_info);
+static void elfNN_vms_post_process_headers
+ (bfd *abfd, struct bfd_link_info *info);
+static bfd_boolean elfNN_vms_section_processing
+ (bfd *abfd, Elf_Internal_Shdr *hdr);
+static void elfNN_vms_final_write_processing
+ (bfd *abfd, bfd_boolean linker);
+static bfd_boolean elfNN_vms_close_and_cleanup
+ (bfd *abfd);
/* ia64-specific relocation. */
@@ -5618,6 +5626,269 @@ elfNN_hpux_backend_symbol_processing (bf
}
}
+static bfd_boolean
+elfNN_vms_section_from_shdr (bfd *abfd,
+ Elf_Internal_Shdr *hdr,
+ const char *name,
+ int shindex)
+{
+ asection *newsect;
+
+ switch (hdr->sh_type)
+ {
+ case SHT_IA_64_VMS_TRACE:
+ case SHT_IA_64_VMS_DEBUG:
+ case SHT_IA_64_VMS_DEBUG_STR:
+ break;
+
+ default:
+ return elfNN_ia64_section_from_shdr (abfd, hdr, name, shindex);
+ }
+
+ if (! _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex))
+ return FALSE;
+ newsect = hdr->bfd_section;
+
+ return TRUE;
+}
+
+static bfd_boolean
+elfNN_vms_object_p (bfd *abfd)
+{
+ Elf_Internal_Ehdr *i_ehdrp = elf_elfheader (abfd);
+ Elf_Internal_Phdr *i_phdr = elf_tdata (abfd)->phdr;
+ unsigned int i;
+ unsigned int num_text = 0;
+ unsigned int num_data = 0;
+ unsigned int num_rodata = 0;
+ char name[16];
+
+ if (!elfNN_ia64_object_p (abfd))
+ return FALSE;
+
+ for (i = 0; i < i_ehdrp->e_phnum; i++, i_phdr++)
+ {
+ /* Is there a section for this segment? */
+ bfd_vma base_vma = i_phdr->p_vaddr;
+ bfd_vma limit_vma = base_vma + i_phdr->p_filesz;
+
+ if (i_phdr->p_type != PT_LOAD)
+ continue;
+
+ again:
+ while (base_vma < limit_vma)
+ {
+ bfd_vma next_vma = limit_vma;
+ asection *nsec;
+ asection *sec;
+ flagword flags;
+ char *nname = NULL;
+
+ /* Find a section covering base_vma. */
+ for (sec = abfd->sections; sec != NULL; sec = sec->next)
+ {
+ if ((sec->flags & (SEC_ALLOC | SEC_LOAD)) == 0)
+ continue;
+ if (sec->vma <= base_vma && sec->vma + sec->size > base_vma)
+ {
+ base_vma = sec->vma + sec->size;
+ goto again;
+ }
+ if (sec->vma < next_vma && sec->vma + sec->size >= base_vma)
+ next_vma = sec->vma;
+ }
+ /* No section covering [base_vma; next_vma). Create a fake one. */
+ flags = SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS;
+ if (i_phdr->p_flags & PF_X)
+ {
+ flags |= SEC_CODE;
+ if (num_text++ == 0)
+ nname = ".text";
+ else
+ sprintf (name, ".text$%u", num_text);
+ }
+ else if ((i_phdr->p_flags & (PF_R | PF_W)) == PF_R)
+ {
+ flags |= SEC_READONLY;
+ sprintf (name, ".rodata$%u", num_rodata++);
+ }
+ else
+ {
+ flags |= SEC_DATA;
+ sprintf (name, ".data$%u", num_data++);
+ }
+
+ /* Allocate name. */
+ if (nname == NULL)
+ {
+ size_t name_len = strlen (name) + 1;
+ nname = bfd_alloc (abfd, name_len);
+ if (nname == NULL)
+ return FALSE;
+ memcpy (nname, name, name_len);
+ }
+
+ /* Create and fill new section. */
+ nsec = bfd_make_section_anyway_with_flags (abfd, nname, flags);
+ if (nsec == NULL)
+ return FALSE;
+ nsec->vma = base_vma;
+ nsec->size = next_vma - base_vma;
+ nsec->filepos = i_phdr->p_offset + (base_vma - i_phdr->p_vaddr);
+
+ base_vma = next_vma;
+ }
+ }
+ return TRUE;
+}
+
+static void
+elfNN_vms_post_process_headers (abfd, info)
+ bfd *abfd;
+ struct bfd_link_info *info ATTRIBUTE_UNUSED;
+{
+ Elf_Internal_Ehdr *i_ehdrp = elf_elfheader (abfd);
+
+ i_ehdrp->e_ident[EI_OSABI] = ELFOSABI_OPENVMS;
+ i_ehdrp->e_ident[EI_ABIVERSION] = 2;
+}
+
+static bfd_boolean
+elfNN_vms_section_processing (bfd *abfd ATTRIBUTE_UNUSED,
+ Elf_Internal_Shdr *hdr)
+{
+ if (hdr->bfd_section != NULL)
+ {
+ const char *name = bfd_get_section_name (abfd, hdr->bfd_section);
+
+ if (strcmp (name, ".text") == 0)
+ hdr->sh_flags |= SHF_IA_64_VMS_SHARED;
+ else if ((strcmp (name, ".debug") == 0)
+ || (strcmp (name, ".debug_abbrev") == 0)
+ || (strcmp (name, ".debug_aranges") == 0)
+ || (strcmp (name, ".debug_frame") == 0)
+ || (strcmp (name, ".debug_info") == 0)
+ || (strcmp (name, ".debug_loc") == 0)
+ || (strcmp (name, ".debug_macinfo") == 0)
+ || (strcmp (name, ".debug_pubnames") == 0)
+ || (strcmp (name, ".debug_pubtypes") == 0))
+ hdr->sh_type = SHT_IA_64_VMS_DEBUG;
+ else if ((strcmp (name, ".debug_line") == 0)
+ || (strcmp (name, ".debug_ranges") == 0))
+ hdr->sh_type = SHT_IA_64_VMS_TRACE;
+ else if (strcmp (name, ".debug_str") == 0)
+ hdr->sh_type = SHT_IA_64_VMS_DEBUG_STR;
+ else if (strcmp (name, ".vms_display_name_info") == 0)
+ {
+ int idx, symcount;
+ asymbol **syms;
+ struct elf_obj_tdata *t = elf_tdata (abfd);
+ int buf[2];
+ int demangler_sym_idx = -1;
+
+ symcount = bfd_get_symcount (abfd);
+ syms = bfd_get_outsymbols (abfd);
+ for (idx = 0; idx < symcount; idx++)
+ {
+ asymbol *sym;
+ sym = syms[idx];
+ if ((sym->flags & (BSF_DEBUGGING | BSF_DYNAMIC))
+ && strchr (sym->name, '@')
+ && (strcmp (sym->section->name, BFD_ABS_SECTION_NAME) == 0))
+ {
+ demangler_sym_idx = sym->udata.i;
+ break;
+ }
+ }
+
+ hdr->sh_type = SHT_IA_64_VMS_DISPLAY_NAME_INFO;
+ hdr->sh_entsize = 4;
+ hdr->sh_addralign = 0;
+ hdr->sh_link = t->symtab_section;
+
+ /* Find symtab index of demangler routine and stuff it in
+ the second long word of section data. */
+
+ if (demangler_sym_idx > -1)
+ {
+ bfd_seek (abfd, hdr->sh_offset, SEEK_SET);
+ bfd_bread (buf, hdr->sh_size, abfd);
+ buf [1] = demangler_sym_idx;
+ bfd_seek (abfd, hdr->sh_offset, SEEK_SET);
+ bfd_bwrite (buf, hdr->sh_size, abfd);
+ }
+ }
+ }
+
+ return TRUE;
+}
+
+/* The final processing done just before writing out a VMS IA-64 ELF
+ object file. */
+
+static void
+elfNN_vms_final_write_processing (abfd, linker)
+ bfd *abfd;
+ bfd_boolean linker ATTRIBUTE_UNUSED;
+{
+ Elf_Internal_Shdr *hdr;
+ asection *s;
+ int unwind_info_sect_idx = 0;
+
+ for (s = abfd->sections; s; s = s->next)
+ {
+ hdr = &elf_section_data (s)->this_hdr;
+
+ if (strcmp (bfd_get_section_name (abfd, hdr->bfd_section),
+ ".IA_64.unwind_info") == 0)
+ unwind_info_sect_idx = elf_section_data (s)->this_idx;
+
+ switch (hdr->sh_type)
+ {
+ case SHT_IA_64_UNWIND:
+ /* VMS requires sh_info to point to the unwind info section. */
+ hdr->sh_info = unwind_info_sect_idx;
+ break;
+ }
+ }
+
+ if (! elf_flags_init (abfd))
+ {
+ unsigned long flags = 0;
+
+ if (abfd->xvec->byteorder == BFD_ENDIAN_BIG)
+ flags |= EF_IA_64_BE;
+ if (bfd_get_mach (abfd) == bfd_mach_ia64_elf64)
+ flags |= EF_IA_64_ABI64;
+
+ elf_elfheader(abfd)->e_flags = flags;
+ elf_flags_init (abfd) = TRUE;
+ }
+}
+
+static bfd_boolean
+elfNN_vms_close_and_cleanup (bfd *abfd)
+{
+ if (bfd_get_format (abfd) == bfd_object)
+ {
+ long isize, irsize;
+
+ if (elf_shstrtab (abfd) != NULL)
+ _bfd_elf_strtab_free (elf_shstrtab (abfd));
+
+ /* Pad to 8 byte boundary for IPF/VMS. */
+ isize = bfd_get_size (abfd);
+ if ((irsize = isize/8*8) < isize)
+ {
+ int ishort = (irsize + 8) - isize;
+ bfd_seek (abfd, isize, SEEK_SET);
+ bfd_bwrite (bfd_zmalloc (ishort), ishort, abfd);
+ }
+ }
+
+ return _bfd_generic_close_and_cleanup (abfd);
+}
+
#define TARGET_LITTLE_SYM bfd_elfNN_ia64_little_vec
#define TARGET_LITTLE_NAME "elfNN-ia64-little"
@@ -5750,4 +6021,45 @@ elfNN_hpux_backend_symbol_processing (bf
#include "elfNN-target.h"
+/* VMS-specific vectors. */
+
+#undef TARGET_LITTLE_SYM
+#define TARGET_LITTLE_SYM bfd_elfNN_ia64_vms_vec
+#undef TARGET_LITTLE_NAME
+#define TARGET_LITTLE_NAME "elfNN-ia64-vms"
+#undef TARGET_BIG_SYM
+#undef TARGET_BIG_NAME
+
+/* These are VMS specific functions. */
+
+#undef elf_backend_object_p
+#define elf_backend_object_p elfNN_vms_object_p
+
+#undef elf_backend_section_from_shdr
+#define elf_backend_section_from_shdr elfNN_vms_section_from_shdr
+
+#undef elf_backend_post_process_headers
+#define elf_backend_post_process_headers elfNN_vms_post_process_headers
+
+#undef elf_backend_section_processing
+#define elf_backend_section_processing elfNN_vms_section_processing
+
+#undef elf_backend_final_write_processing
+#define elf_backend_final_write_processing elfNN_vms_final_write_processing
+
+#undef bfd_elfNN_close_and_cleanup
+#define bfd_elfNN_close_and_cleanup elfNN_vms_close_and_cleanup
+
+#undef elf_backend_section_from_bfd_section
+
+#undef elf_backend_symbol_processing
+
#undef elf_backend_want_p_paddr_set_to_zero
+
+#undef ELF_MAXPAGESIZE
+#define ELF_MAXPAGESIZE 0x10000 /* 64KB */
+
+#undef elfNN_bed
+#define elfNN_bed elfNN_ia64_vms_bed
+
+#include "elfNN-target.h"
Index: bfd/targets.c
===================================================================
RCS file: /cvs/src/src/bfd/targets.c,v
retrieving revision 1.165
diff -u -p -r1.165 targets.c
--- bfd/targets.c 23 Dec 2008 19:10:19 -0000 1.165
+++ bfd/targets.c 10 Jan 2009 06:15:13 -0000
@@ -680,6 +680,7 @@ extern const bfd_target bfd_elf64_hppa_v
extern const bfd_target bfd_elf64_ia64_big_vec;
extern const bfd_target bfd_elf64_ia64_hpux_big_vec;
extern const bfd_target bfd_elf64_ia64_little_vec;
+extern const bfd_target bfd_elf64_ia64_vms_vec;
extern const bfd_target bfd_elf64_little_generic_vec;
extern const bfd_target bfd_elf64_littlemips_vec;
extern const bfd_target bfd_elf64_mmix_vec;
@@ -1020,6 +1021,7 @@ static const bfd_target * const _bfd_tar
&bfd_elf64_ia64_big_vec,
&bfd_elf64_ia64_hpux_big_vec,
&bfd_elf64_ia64_little_vec,
+ &bfd_elf64_ia64_vms_vec,
&bfd_elf64_little_generic_vec,
&bfd_elf64_littlemips_vec,
&bfd_elf64_mmix_vec,
Index: gas/configure.tgt
===================================================================
RCS file: /cvs/src/src/gas/configure.tgt,v
retrieving revision 1.44
diff -u -p -r1.44 configure.tgt
--- gas/configure.tgt 23 Dec 2008 19:10:20 -0000 1.44
+++ gas/configure.tgt 10 Jan 2009 06:15:13 -0000
@@ -236,6 +236,7 @@ case ${generic_target} in
i960-*-elf*) fmt=elf ;;
ia64-*-elf*) fmt=elf ;;
+ ia64-*-*vms*) fmt=elf em=vms ;;
ia64-*-aix*) fmt=elf em=ia64aix ;;
ia64-*-linux-*) fmt=elf em=linux ;;
ia64-*-hpux*) fmt=elf em=hpux ;;
Index: gas/dwarf2dbg.h
===================================================================
RCS file: /cvs/src/src/gas/dwarf2dbg.h,v
retrieving revision 1.21
diff -u -p -r1.21 dwarf2dbg.h
--- gas/dwarf2dbg.h 19 Nov 2007 19:37:18 -0000 1.21
+++ gas/dwarf2dbg.h 10 Jan 2009 06:15:14 -0000
@@ -86,7 +86,7 @@ bfd_boolean dwarf2_loc_directive_seen;
/* True when we're supposed to set the basic block mark whenever a label
is seen. Unless the target is doing Something Weird, just call
dwarf2_emit_label. */
-bfd_boolean dwarf2_loc_mark_labels;
+extern bfd_boolean dwarf2_loc_mark_labels;
extern void dwarf2_finish (void);
Index: gas/tc.h
===================================================================
RCS file: /cvs/src/src/gas/tc.h,v
retrieving revision 1.14
diff -u -p -r1.14 tc.h
--- gas/tc.h 3 Jul 2007 11:01:03 -0000 1.14
+++ gas/tc.h 10 Jan 2009 06:15:14 -0000
@@ -31,7 +31,9 @@ int md_parse_option (int, char *);
void md_show_usage (FILE *);
void md_assemble (char *);
void md_begin (void);
+#ifndef md_number_to_chars
void md_number_to_chars (char *, valueT, int);
+#endif
void md_apply_fix (fixS *, valueT *, segT);
#ifndef WORKING_DOT_WORD
Index: gas/config/obj-elf.c
===================================================================
RCS file: /cvs/src/src/gas/config/obj-elf.c,v
retrieving revision 1.111
diff -u -p -r1.111 obj-elf.c
--- gas/config/obj-elf.c 23 Dec 2008 09:01:47 -0000 1.111
+++ gas/config/obj-elf.c 10 Jan 2009 06:15:14 -0000
@@ -524,7 +524,7 @@ get_section (bfd *abfd ATTRIBUTE_UNUSED,
void
obj_elf_change_section (const char *name,
int type,
- int attr,
+ bfd_vma attr,
int entsize,
const char *group_name,
int linkonce,
@@ -720,10 +720,10 @@ obj_elf_change_section (const char *name
#endif
}
-static int
+static bfd_vma
obj_elf_parse_section_letters (char *str, size_t len)
{
- int attr = 0;
+ bfd_vma attr = 0;
while (len > 0)
{
@@ -766,8 +766,8 @@ obj_elf_parse_section_letters (char *str
{
char *bad_msg = _("unrecognized .section attribute: want a,w,x,M,S,G,T");
#ifdef md_elf_section_letter
- int md_attr = md_elf_section_letter (*str, &bad_msg);
- if (md_attr >= 0)
+ bfd_vma md_attr = md_elf_section_letter (*str, &bad_msg);
+ if (md_attr > 0)
attr |= md_attr;
else
#endif
@@ -810,7 +810,7 @@ obj_elf_section_type (char *str, size_t
return 0;
}
-static int
+static bfd_vma
obj_elf_section_word (char *str, size_t len, int *type)
{
int ret;
@@ -826,8 +826,8 @@ obj_elf_section_word (char *str, size_t
#ifdef md_elf_section_word
{
- int md_attr = md_elf_section_word (str, len);
- if (md_attr >= 0)
+ bfd_vma md_attr = md_elf_section_word (str, len);
+ if (md_attr > 0)
return md_attr;
}
#endif
@@ -888,7 +888,8 @@ void
obj_elf_section (int push)
{
char *name, *group_name, *beg;
- int type, attr, dummy;
+ int type, dummy;
+ bfd_vma attr;
int entsize;
int linkonce;
subsegT new_subsection = -1;
Index: gas/config/obj-elf.h
===================================================================
RCS file: /cvs/src/src/gas/config/obj-elf.h,v
retrieving revision 1.33
diff -u -p -r1.33 obj-elf.h
--- gas/config/obj-elf.h 3 Jul 2007 11:01:04 -0000 1.33
+++ gas/config/obj-elf.h 10 Jan 2009 06:15:14 -0000
@@ -166,7 +166,7 @@ extern void obj_elf_common (int);
extern void obj_elf_data (int);
extern void obj_elf_text (int);
extern void obj_elf_change_section
- (const char *, int, int, int, const char *, int, int);
+ (const char *, int, bfd_vma, int, const char *, int, int);
extern struct fix *obj_elf_vtable_inherit (int);
extern struct fix *obj_elf_vtable_entry (int);
Index: gas/config/tc-ia64.c
===================================================================
RCS file: /cvs/src/src/gas/config/tc-ia64.c,v
retrieving revision 1.203
diff -u -p -r1.203 tc-ia64.c
--- gas/config/tc-ia64.c 28 Aug 2008 14:07:49 -0000 1.203
+++ gas/config/tc-ia64.c 10 Jan 2009 06:15:20 -0000
@@ -50,6 +50,8 @@
#include "opcode/ia64.h"
#include "elf/ia64.h"
+#include "bfdver.h"
+#include <time.h>
#ifdef HAVE_LIMITS_H
#include <limits.h>
@@ -834,13 +836,19 @@ set_section (char *name)
/* Map 's' to SHF_IA_64_SHORT. */
-int
+bfd_vma
ia64_elf_section_letter (int letter, char **ptr_msg)
{
if (letter == 's')
return SHF_IA_64_SHORT;
else if (letter == 'o')
return SHF_LINK_ORDER;
+#ifdef TE_VMS
+ else if (letter == 'O')
+ return SHF_IA_64_VMS_OVERLAID;
+ else if (letter == 'g')
+ return SHF_IA_64_VMS_GLOBAL;
+#endif
*ptr_msg = _("Bad .section directive: want a,o,s,w,x,M,S,G,T in string");
return -1;
@@ -850,7 +858,7 @@ ia64_elf_section_letter (int letter, cha
flagword
ia64_elf_section_flags (flagword flags,
- int attr,
+ bfd_vma attr,
int type ATTRIBUTE_UNUSED)
{
if (attr & SHF_IA_64_SHORT)
@@ -7297,7 +7305,10 @@ void
ia64_init (int argc ATTRIBUTE_UNUSED, char **argv ATTRIBUTE_UNUSED)
{
md.flags = MD_FLAGS_DEFAULT;
+#ifndef TE_VMS
+ /* Don't turn on dependency checking for VMS, doesn't work. */
md.detect_dv = 1;
+#endif
/* FIXME: We should change it to unwind_check_error someday. */
md.unwind_check = unwind_check_warning;
md.hint_b = hint_b_error;
@@ -7333,8 +7344,13 @@ ia64_target_format (void)
else
{
if (md.flags & EF_IA_64_ABI64)
-#ifdef TE_AIX50
+#if defined (TE_AIX50)
return "elf64-ia64-aix-little";
+#elif defined (TE_VMS)
+ {
+ md.flags |= EF_IA_64_ARCHVER_1;
+ return "elf64-ia64-vms";
+ }
#else
return "elf64-ia64-little";
#endif
@@ -11575,9 +11591,17 @@ do_alias (const char *alias, void *value
symbolS *sym = symbol_find (h->name);
if (sym == NULL)
- as_warn_where (h->file, h->line,
- _("symbol `%s' aliased to `%s' is not used"),
- h->name, alias);
+ {
+#ifdef TE_VMS
+ /* Uses .alias extensively to alias CRTL functions to same with
+ decc$ prefix. Sometimes function gets optimized away and a
+ warning results, which should be suppressed. */
+ if (strncmp (alias, "decc$", 5) != 0)
+#endif
+ as_warn_where (h->file, h->line,
+ _("symbol `%s' aliased to `%s' is not used"),
+ h->name, alias);
+ }
else
S_SET_NAME (sym, (char *) alias);
}
@@ -11610,3 +11634,145 @@ ia64_frob_file (void)
{
hash_traverse (secalias_hash, do_secalias);
}
+
+#ifdef TE_VMS
+#define NT_VMS_MHD 1
+#define NT_VMS_LNM 2
+
+/*
+ Integrity VMS 8.x identifies it's ELF modules with a standard ELF
+ .note section.
+*/
+
+/* Manufacture a VMS-like time string. */
+static void
+get_vms_time (char *Now)
+{
+ char *pnt;
+ time_t timeb;
+
+ time (&timeb);
+ pnt = ctime (&timeb);
+ pnt[3] = 0;
+ pnt[7] = 0;
+ pnt[10] = 0;
+ pnt[16] = 0;
+ pnt[24] = 0;
+ sprintf (Now, "%2s-%3s-%s %s", pnt + 8, pnt + 4, pnt + 20, pnt + 11);
+}
+
+void
+ia64_vms_note (void)
+{
+
+ char *p;
+ asection *seg = now_seg;
+ subsegT subseg = now_subseg;
+ Elf_Internal_Note i_note;
+ asection *secp = NULL;
+ char *basec, *bname;
+ char buf [256];
+ symbolS *sym;
+
+ /* Create the .note section. */
+
+ secp = subseg_new (".note", 0);
+ bfd_set_section_flags (stdoutput,
+ secp,
+ SEC_HAS_CONTENTS | SEC_READONLY);
+
+ /* Module header note. */
+
+ basec = xstrdup (out_file_name);
+ bname = basename (basec);
+ if ((p = strrchr (bname, '.')))
+ *p = '\0';
+
+ i_note.namesz = 8;
+ i_note.descsz = 40 + strlen (bname);
+ i_note.type = NT_VMS_MHD;
+
+ p = frag_more (sizeof (i_note.namesz));
+ number_to_chars_littleendian (p, i_note.namesz, 8);
+
+ p = frag_more (sizeof (i_note.descsz));
+ number_to_chars_littleendian (p, i_note.descsz, 8);
+
+ p = frag_more (sizeof (i_note.type));
+ number_to_chars_littleendian (p, i_note.type, 8);
+
+ p = frag_more (8);
+ strcpy (p, "IPF/VMS");
+
+ get_vms_time (buf);
+ p = frag_more (17);
+ strcpy (p, buf);
+
+ p = frag_more (17);
+ strcpy (p, "24-FEB-2005 15:00");
+
+ p = frag_more (strlen (bname) + 1);
+ strcpy (p, bname);
+
+ p = frag_more (5);
+ strcpy (p, "V1.0");
+
+ frag_align (3, 0, 0);
+
+ /* Language processor name note. */
+
+ sprintf (buf, "GNU assembler version %s (%s) using BFD version %s",
+ VERSION, TARGET_ALIAS, BFD_VERSION_STRING);
+
+ i_note.namesz = 8;
+ i_note.descsz = 1 + strlen (buf);
+ i_note.type = NT_VMS_LNM;
+
+ p = frag_more (sizeof (i_note.namesz));
+ number_to_chars_littleendian (p, i_note.namesz, 8);
+
+ p = frag_more (sizeof (i_note.descsz));
+ number_to_chars_littleendian (p, i_note.descsz, 8);
+
+ p = frag_more (sizeof (i_note.type));
+ number_to_chars_littleendian (p, i_note.type, 8);
+
+ p = frag_more (8);
+ strcpy (p, "IPF/VMS");
+
+ p = frag_more (strlen (buf) + 1);
+ strcpy (p, buf);
+
+ frag_align (3, 0, 0);
+
+ secp = subseg_new (".vms_display_name_info", 0);
+ bfd_set_section_flags (stdoutput,
+ secp,
+ SEC_HAS_CONTENTS | SEC_READONLY);
+
+ /* This symbol should be passed on the command line and be variable
+ according to language. */
+
+ sym = symbol_new ("__gnat_vms_display_name@gnat_demangler_rtl",
+ absolute_section, 0, &zero_address_frag);
+ symbol_table_insert (sym);
+ symbol_get_bfdsym (sym)->flags |= BSF_DEBUGGING | BSF_DYNAMIC;
+
+ p = frag_more (4);
+ /* Format 3 of VMS demangler Spec. */
+ number_to_chars_littleendian (p, 3, 4);
+
+ p = frag_more (4);
+ /* Place holder for symbol table index of above symbol. */
+ number_to_chars_littleendian (p, -1, 4);
+
+ frag_align (3, 0, 0);
+
+ /* We probably can't restore the current segment, for there likely
+ isn't one yet... */
+ if (seg && subseg)
+ subseg_set (seg, subseg);
+
+}
+
+#endif /* TE_VMS */
Index: gas/config/tc-ia64.h
===================================================================
RCS file: /cvs/src/src/gas/config/tc-ia64.h,v
retrieving revision 1.45
diff -u -p -r1.45 tc-ia64.h
--- gas/config/tc-ia64.h 12 Aug 2008 23:39:30 -0000 1.45
+++ gas/config/tc-ia64.h 10 Jan 2009 06:15:20 -0000
@@ -107,8 +107,8 @@ extern int ia64_force_relocation (struct
extern void ia64_cons_fix_new (fragS *, int, int, expressionS *);
extern void ia64_validate_fix (struct fix *);
extern char * ia64_canonicalize_symbol_name (char *);
-extern int ia64_elf_section_letter (int, char **);
-extern flagword ia64_elf_section_flags (flagword, int, int);
+extern bfd_vma ia64_elf_section_letter (int, char **);
+extern flagword ia64_elf_section_flags (flagword, bfd_vma, int);
extern int ia64_elf_section_type (const char *, size_t);
extern long ia64_pcrel_from_section (struct fix *, segT);
extern void ia64_md_do_align (int, const char *, int, int);
@@ -156,6 +156,10 @@ extern void ia64_convert_frag (fragS *);
#define md_after_parse_args() ia64_after_parse_args ()
#define TC_DWARF2_EMIT_OFFSET ia64_dwarf2_emit_offset
#define tc_check_label(l) ia64_check_label (l)
+#ifdef TE_VMS
+#define tc_init_after_args() ia64_vms_note ()
+void ia64_vms_note (void);
+#endif
/* Record if an alignment frag should end with a stop bit. */
#define TC_FRAG_TYPE int
Index: gas/config/tc-alpha.c
===================================================================
RCS file: /cvs/src/src/gas/config/tc-alpha.c,v
retrieving revision 1.77
diff -u -p -r1.77 tc-alpha.c
--- gas/config/tc-alpha.c 12 Aug 2008 23:39:30 -0000 1.77
+++ gas/config/tc-alpha.c 10 Jan 2009 06:15:16 -0000
@@ -4780,7 +4780,7 @@ select_gp_value (void)
#ifdef OBJ_ELF
/* Map 's' to SHF_ALPHA_GPREL. */
-int
+bfd_vma
alpha_elf_section_letter (int letter, char **ptr_msg)
{
if (letter == 's')
@@ -4793,7 +4793,7 @@ alpha_elf_section_letter (int letter, ch
/* Map SHF_ALPHA_GPREL to SEC_SMALL_DATA. */
flagword
-alpha_elf_section_flags (flagword flags, int attr, int type ATTRIBUTE_UNUSED)
+alpha_elf_section_flags (flagword flags, bfd_vma attr, int type ATTRIBUTE_UNUSED)
{
if (attr & SHF_ALPHA_GPREL)
flags |= SEC_SMALL_DATA;
Index: gas/config/tc-alpha.h
===================================================================
RCS file: /cvs/src/src/gas/config/tc-alpha.h,v
retrieving revision 1.27
diff -u -p -r1.27 tc-alpha.h
--- gas/config/tc-alpha.h 3 Jul 2007 11:01:04 -0000 1.27
+++ gas/config/tc-alpha.h 10 Jan 2009 06:15:16 -0000
@@ -1,4 +1,4 @@
-/* This file is tc-alpha.h
+ This file is tc-alpha.h
Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003
2005, 2006, 2007
Free Software Foundation, Inc.
@@ -121,9 +121,9 @@ extern void alpha_frob_file_before_adjus
#ifdef OBJ_ELF
#define md_elf_section_letter alpha_elf_section_letter
-extern int alpha_elf_section_letter (int, char **);
+extern bfd_vma alpha_elf_section_letter (int, char **);
#define md_elf_section_flags alpha_elf_section_flags
-extern flagword alpha_elf_section_flags (flagword, int, int);
+extern flagword alpha_elf_section_flags (flagword, bfd_vma, int);
#endif
/* Whether to add support for explicit !relocation_op!sequence_number. At the
Index: gas/config/tc-i386.c
===================================================================
RCS file: /cvs/src/src/gas/config/tc-i386.c,v
retrieving revision 1.361
diff -u -p -r1.361 tc-i386.c
--- gas/config/tc-i386.c 9 Jan 2009 20:32:18 -0000 1.361
+++ gas/config/tc-i386.c 10 Jan 2009 06:15:18 -0000
@@ -10096,7 +10096,7 @@ tc_pe_dwarf2_emit_offset (symbolS *symbo
#if defined (OBJ_ELF) || defined (OBJ_MAYBE_ELF)
/* For ELF on x86-64, add support for SHF_X86_64_LARGE. */
-int
+bfd_vma
x86_64_section_letter (int letter, char **ptr_msg)
{
if (flag_code == CODE_64BIT)
@@ -10111,7 +10111,7 @@ x86_64_section_letter (int letter, char
return -1;
}
-int
+bfd_vma
x86_64_section_word (char *str, size_t len)
{
if (len == 5 && flag_code == CODE_64BIT && CONST_STRNEQ (str, "large"))
Index: gas/config/tc-i386.h
===================================================================
RCS file: /cvs/src/src/gas/config/tc-i386.h,v
retrieving revision 1.99
diff -u -p -r1.99 tc-i386.h
--- gas/config/tc-i386.h 12 Oct 2008 12:37:09 -0000 1.99
+++ gas/config/tc-i386.h 10 Jan 2009 06:15:18 -0000
@@ -262,8 +262,8 @@ extern void i386_solaris_fix_up_eh_frame
#endif
/* Support for SHF_X86_64_LARGE */
-extern int x86_64_section_word (char *, size_t);
-extern int x86_64_section_letter (int, char **);
+extern bfd_vma x86_64_section_word (char *, size_t);
+extern bfd_vma x86_64_section_letter (int, char **);
#define md_elf_section_letter(LETTER, PTR_MSG) x86_64_section_letter (LETTER, PTR_MSG)
#define md_elf_section_word(STR, LEN) x86_64_section_word (STR, LEN)
Index: gas/config/tc-ip2k.c
===================================================================
RCS file: /cvs/src/src/gas/config/tc-ip2k.c,v
retrieving revision 1.16
diff -u -p -r1.16 tc-ip2k.c
--- gas/config/tc-ip2k.c 18 Oct 2007 13:03:12 -0000 1.16
+++ gas/config/tc-ip2k.c 10 Jan 2009 06:15:20 -0000
@@ -411,8 +411,8 @@ ip2k_apply_fix (fixS *fixP, valueT *valu
}
int
-ip2k_elf_section_flags (int flags,
- int attr ATTRIBUTE_UNUSED,
+ip2k_elf_section_flags (flagword flags,
+ bfd_vma attr ATTRIBUTE_UNUSED,
int type ATTRIBUTE_UNUSED)
{
/* This is used to detect when the section changes to an executable section.
Index: gas/config/tc-ip2k.h
===================================================================
RCS file: /cvs/src/src/gas/config/tc-ip2k.h,v
retrieving revision 1.7
diff -u -p -r1.7 tc-ip2k.h
--- gas/config/tc-ip2k.h 3 Jul 2007 11:01:04 -0000 1.7
+++ gas/config/tc-ip2k.h 10 Jan 2009 06:15:20 -0000
@@ -59,7 +59,7 @@ extern int ip2k_force_relocation (struct
#define tc_gen_reloc gas_cgen_tc_gen_reloc
#define md_elf_section_flags ip2k_elf_section_flags
-extern int ip2k_elf_section_flags (int, int, int);
+extern int ip2k_elf_section_flags (flagword, bfd_vma, int);
#define md_operand(x) gas_cgen_md_operand (x)
extern void gas_cgen_md_operand (expressionS *);
Index: gas/config/tc-mep.c
===================================================================
RCS file: /cvs/src/src/gas/config/tc-mep.c,v
retrieving revision 1.3
diff -u -p -r1.3 tc-mep.c
--- gas/config/tc-mep.c 17 Oct 2007 16:45:55 -0000 1.3
+++ gas/config/tc-mep.c 10 Jan 2009 06:15:21 -0000
@@ -1716,7 +1716,7 @@ mep_fix_adjustable (fixS *fixP)
return 1;
}
-int
+bfd_vma
mep_elf_section_letter (int letter, char **ptrmsg)
{
if (letter == 'v')
@@ -1727,7 +1727,7 @@ mep_elf_section_letter (int letter, char
}
flagword
-mep_elf_section_flags (flagword flags, int attr, int type ATTRIBUTE_UNUSED)
+mep_elf_section_flags (flagword flags, bfd_vma attr, int type ATTRIBUTE_UNUSED)
{
if (attr & SHF_MEP_VLIW)
flags |= SEC_MEP_VLIW;
Index: gas/config/tc-mep.h
===================================================================
RCS file: /cvs/src/src/gas/config/tc-mep.h,v
retrieving revision 1.3
diff -u -p -r1.3 tc-mep.h
--- gas/config/tc-mep.h 24 Jul 2007 12:38:35 -0000 1.3
+++ gas/config/tc-mep.h 10 Jan 2009 06:15:21 -0000
@@ -103,9 +103,9 @@ extern int mep_unrecognized_line (int);
extern void mep_cleanup (void);
#define md_elf_section_letter mep_elf_section_letter
-extern int mep_elf_section_letter (int, char **);
+extern bfd_vma mep_elf_section_letter (int, char **);
#define md_elf_section_flags mep_elf_section_flags
-extern flagword mep_elf_section_flags (flagword, int, int);
+extern flagword mep_elf_section_flags (flagword, bfd_vma, int);
#define ELF_TC_SPECIAL_SECTIONS \
{ VTEXT_SECTION_NAME, SHT_PROGBITS, SHF_ALLOC|SHF_EXECINSTR|SHF_MEP_VLIW },
Index: gas/config/tc-ppc.c
===================================================================
RCS file: /cvs/src/src/gas/config/tc-ppc.c,v
retrieving revision 1.144
diff -u -p -r1.144 tc-ppc.c
--- gas/config/tc-ppc.c 9 Jan 2009 18:50:57 -0000 1.144
+++ gas/config/tc-ppc.c 10 Jan 2009 06:15:22 -0000
@@ -2952,7 +2952,7 @@ ppc_macro (char *str, const struct power
#ifdef OBJ_ELF
/* For ELF, add support for SHF_EXCLUDE and SHT_ORDERED. */
-int
+bfd_vma
ppc_section_letter (int letter, char **ptr_msg)
{
if (letter == 'e')
@@ -2962,7 +2962,7 @@ ppc_section_letter (int letter, char **p
return -1;
}
-int
+bfd_vma
ppc_section_word (char *str, size_t len)
{
if (len == 7 && strncmp (str, "exclude", 7) == 0)
@@ -2981,7 +2981,7 @@ ppc_section_type (char *str, size_t len)
}
int
-ppc_section_flags (int flags, int attr, int type)
+ppc_section_flags (flagword flags, bfd_vma attr, int type)
{
if (type == SHT_ORDERED)
flags |= SEC_ALLOC | SEC_LOAD | SEC_SORT_ENTRIES;
Index: gas/config/tc-ppc.h
===================================================================
RCS file: /cvs/src/src/gas/config/tc-ppc.h,v
retrieving revision 1.37
diff -u -p -r1.37 tc-ppc.h
--- gas/config/tc-ppc.h 13 Jun 2008 20:16:00 -0000 1.37
+++ gas/config/tc-ppc.h 10 Jan 2009 06:15:22 -0000
@@ -207,10 +207,10 @@ extern const char ppc_symbol_chars
#ifdef OBJ_ELF
/* Support for SHF_EXCLUDE and SHT_ORDERED */
-extern int ppc_section_letter (int, char **);
+extern bfd_vma ppc_section_letter (int, char **);
extern int ppc_section_type (char *, size_t);
-extern int ppc_section_word (char *, size_t);
-extern int ppc_section_flags (int, int, int);
+extern bfd_vma ppc_section_word (char *, size_t);
+extern int ppc_section_flags (flagword, bfd_vma, int);
#define md_elf_section_letter(LETTER, PTR_MSG) ppc_section_letter (LETTER, PTR_MSG)
#define md_elf_section_type(STR, LEN) ppc_section_type (STR, LEN)
Index: include/libiberty.h
===================================================================
RCS file: /cvs/src/src/include/libiberty.h,v
retrieving revision 1.58
diff -u -p -r1.58 libiberty.h
--- include/libiberty.h 24 Jun 2008 03:01:29 -0000 1.58
+++ include/libiberty.h 10 Jan 2009 06:15:24 -0000
@@ -101,7 +101,7 @@ extern int writeargv PARAMS ((char **, F
to find the declaration so provide a fully prototyped one. If it
is 1, we found it so don't provide any declaration at all. */
#if !HAVE_DECL_BASENAME
-#if defined (__GNU_LIBRARY__ ) || defined (__linux__) || defined (__FreeBSD__) || defined (__OpenBSD__) || defined(__NetBSD__) || defined (__CYGWIN__) || defined (__CYGWIN32__) || defined (__MINGW32__) || defined (HAVE_DECL_BASENAME)
+#if defined (__GNU_LIBRARY__ ) || defined (__linux__) || defined (__FreeBSD__) || defined (__OpenBSD__) || defined(__NetBSD__) || defined (__CYGWIN__) || defined (__CYGWIN32__) || defined (__MINGW32__) || defined (VMS) || defined (HAVE_DECL_BASENAME)
extern char *basename (const char *);
#else
/* Do not allow basename to be used if there is no prototype seen. We
Index: intl/dcgettext.c
===================================================================
RCS file: /cvs/src/src/intl/dcgettext.c,v
retrieving revision 1.5
diff -u -p -r1.5 dcgettext.c
--- intl/dcgettext.c 22 May 2006 15:30:13 -0000 1.5
+++ intl/dcgettext.c 10 Jan 2009 06:15:24 -0000
@@ -20,6 +20,11 @@
# include <config.h>
#endif
+#ifdef VMS
+/* Non-posix getcwd prototype is incompatible with char *getcwd() below. */
+#define __POSIX_C_SOURCE
+#endif
+
#include "gettextP.h"
#ifdef _LIBC
# include <libintl.h>
Index: libiberty/fibheap.c
===================================================================
RCS file: /cvs/src/src/libiberty/fibheap.c,v
retrieving revision 1.7
diff -u -p -r1.7 fibheap.c
--- libiberty/fibheap.c 10 May 2005 15:33:33 -0000 1.7
+++ libiberty/fibheap.c 10 Jan 2009 06:15:25 -0000
@@ -35,6 +35,18 @@ Boston, MA 02110-1301, USA. */
#include "fibheap.h"
+#ifndef ULONG_MAX
+#define ULONG_MAX ((unsigned long)(~0L)) /* 0xFFFFFFFF */
+#endif
+
+#ifndef LONG_MAX
+#define LONG_MAX ((long)(ULONG_MAX >> 1)) /* 0x7FFFFFFF */
+#endif
+
+#ifndef LONG_MIN
+#define LONG_MIN ((long)(~LONG_MAX)) /* 0x80000000 */
+#endif
+
#define FIBHEAPKEY_MIN LONG_MIN
static void fibheap_ins_root (fibheap_t, fibnode_t);
--- /dev/null 2005-11-30 16:42:54.000000000 -0800
+++ gas/config/te-vms.h 2008-12-15 12:03:47.000000000 -0800
@@ -0,0 +1,42 @@
+#define TE_VMS
+#include "obj-format.h"
+
+int vms_file_stats_name (const char *, long long *, long *, char *, int *);
+
+/* VMS debugger expects a separator. */
+#define DWARF2_DIR_SHOULD_END_WITH_SEPARATOR 1
+
+/* VMS debugger needs the file timestamp. */
+#define DWARF2_FILE_TIME_NAME(FILENAME,DIRNAME) \
+ ({ \
+ long long cdt; \
+ char *filename = (char *) alloca (strlen (FILENAME) + strlen (DIRNAME) + 1);\
+ strcpy (filename, DIRNAME); \
+ strcat (filename, FILENAME); \
+ ((vms_file_stats_name (filename, &cdt, 0, 0, 0) == 0) ? cdt : 0); \
+ })
+
+/* VMS debugger needs the file size. */
+#define DWARF2_FILE_SIZE_NAME(FILENAME,DIRNAME) \
+ ({ \
+ long siz; \
+ char *filename = (char *) alloca (strlen (FILENAME) + strlen (DIRNAME) + 1);\
+ strcpy (filename, DIRNAME); \
+ strcat (filename, FILENAME); \
+ ((vms_file_stats_name (filename, 0, &siz, 0, 0) == 0) ? siz : 0); \
+ })
+
+/* VMS debugger needs the filename with version appended. */
+/* Longest filename on VMS is 255 characters. Largest version is 32768. */
+#define DWARF2_FILE_NAME(FILENAME,DIRNAME) \
+ ({ \
+ int ver; \
+ char buff [255 + 7]; \
+ char *filename = (char *) alloca (strlen (FILENAME) + strlen (DIRNAME) + 1);\
+ strcpy (filename, DIRNAME); \
+ strcat (filename, FILENAME); \
+ vms_file_stats_name (filename, 0, 0, 0, &ver); \
+ snprintf (buff, 255 + 7, "%s;%d", FILENAME, ver); \
+ buff; \
+ })
+
Index: gas/dwarf2dbg.c
===================================================================
RCS file: /cvs/src/src/gas/dwarf2dbg.c,v
retrieving revision 1.98
diff -u -p -r1.98 dwarf2dbg.c
--- gas/dwarf2dbg.c 5 Aug 2008 08:13:48 -0000 1.98
+++ gas/dwarf2dbg.c 10 Jan 2009 06:15:14 -0000
@@ -76,6 +76,18 @@
# define DWARF2_ADDR_SIZE(bfd) (bfd_arch_bits_per_address (bfd) / 8)
#endif
+#ifndef DWARF2_FILE_NAME
+#define DWARF2_FILE_NAME(FILENAME, DIRNAME) FILENAME
+#endif
+
+#ifndef DWARF2_FILE_TIME_NAME
+#define DWARF2_FILE_TIME_NAME(FILENAME,DIRNAME) 0
+#endif
+
+#ifndef DWARF2_FILE_SIZE_NAME
+#define DWARF2_FILE_SIZE_NAME(FILENAME,DIRNAME) 0
+#endif
+
#include "subsegs.h"
#include "elf/dwarf2.h"
@@ -434,7 +446,9 @@ get_filenum (const char *filename, unsig
dir = 0;
if (dir_len)
{
+#ifndef DWARF2_DIR_SHOULD_END_WITH_SEPARATOR
--dir_len;
+#endif
for (dir = 1; dir < dirs_in_use; ++dir)
if (strncmp (filename, dirs[dir], dir_len) == 0
&& dirs[dir][dir_len] == '\0')
@@ -1281,6 +1295,8 @@ out_file_list (void)
for (i = 1; i < files_in_use; ++i)
{
+ const char *fullfilename;
+
if (files[i].filename == NULL)
{
as_bad (_("unassigned file number %ld"), (long) i);
@@ -1289,13 +1305,19 @@ out_file_list (void)
continue;
}
- size = strlen (files[i].filename) + 1;
+ fullfilename = DWARF2_FILE_NAME (files[i].filename,
+ files[i].dir ? dirs [files [i].dir] : "");
+ size = strlen (fullfilename) + 1;
cp = frag_more (size);
- memcpy (cp, files[i].filename, size);
+ memcpy (cp, fullfilename, size);
out_uleb128 (files[i].dir); /* directory number */
- out_uleb128 (0); /* last modification timestamp */
- out_uleb128 (0); /* filesize */
+ /* Output the last modification timestamp. */
+ out_uleb128 (DWARF2_FILE_TIME_NAME (files[i].filename,
+ files[i].dir ? dirs [files [i].dir] : ""));
+ /* Output the filesize. */
+ out_uleb128 (DWARF2_FILE_SIZE_NAME (files[i].filename,
+ files[i].dir ? dirs [files [i].dir] : ""));
}
/* Terminate filename list. */