+2010-04-01 Tristan Gingold <gingold@adacore.com>
+
+ * vms.h: Include time.h. Add prototypes for vms_get_module_name,
+ vms_time_to_time_t and vms_rawtime_to_time_t.
+ * vms.c (vms_alpha_vec): Add archives support.
+ * vms-misc.c: Include safe-ctype.h
+ (vms_get_module_name): New function.
+ (vms_time_to_time_t, vms_rawtime_to_time_t): Ditto.
+ * vms-hdr.c (_bfd_vms_write_hdr): Put module name creation to the
+ vms_get_module_name function. Use this function.
+ * targets.c: Declare vms_lib_txt_vec. Add it to _bfd_target_vector.
+ * libbfd-in.h: Add prototype for _bfd_append_relative_path.
+ Add prototypes for vms-lib.c
+ * libbfd.h: Regenerate.
+ * configure.in (TDEFINES): Add an entry for vms_lib_txt_vec. Add
+ vms-lib.lo to vms_alpha_vec.
+ * config.bfd (targ_cpu): Add targ_selvecs for alpha*-*-*vms*.
+ * configure: Regenerate.
+ * bfd.c: Add selective_search field.
+ * bfd-in2.h: Regenerate.
+ * archive.c (append_relative_path): Rename to
+ _bfd_append_relative_path and make it public.
+ (_bfd_get_elt_at_filepos): Adjust for above renaming.
+ * Makefile.am (BFD32_BACKENDS): Add vms-lib.lo
+ (BFD32_BACKENDS_CFILES): Add vms-lib.c
+ * Makefile.in: Regenerate.
+
2010-04-01 Jakub Jelinek <jakub@redhat.com>
* dwarf2.c (read_attribute_value): Handle CU version 4
versados.lo \
vms-gsd.lo \
vms-hdr.lo \
+ vms-lib.lo \
vms-misc.lo \
vms-tir.lo \
vms.lo \
versados.c \
vms-gsd.c \
vms-hdr.c \
+ vms-lib.c \
vms-misc.c \
vms-tir.c \
vms.c \
versados.lo \
vms-gsd.lo \
vms-hdr.lo \
+ vms-lib.lo \
vms-misc.lo \
vms-tir.lo \
vms.lo \
versados.c \
vms-gsd.c \
vms-hdr.c \
+ vms-lib.c \
vms-misc.c \
vms-tir.c \
vms.c \
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/versados.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vms-gsd.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vms-hdr.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vms-lib.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vms-misc.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vms-tir.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vms.Plo@am__quote@
/* Append the relative pathname for a member of the thin archive
to the pathname of the directory containing the archive. */
-static char *
-append_relative_path (bfd *arch, char *elt_name)
+char *
+_bfd_append_relative_path (bfd *arch, char *elt_name)
{
const char *arch_name = arch->filename;
const char *base_name = lbasename (arch_name);
/* This is a proxy entry for an external file. */
if (! IS_ABSOLUTE_PATH (filename))
{
- filename = append_relative_path (archive, filename);
+ filename = _bfd_append_relative_path (archive, filename);
if (filename == NULL)
return NULL;
}
/* Set if this is a thin archive. */
unsigned int is_thin_archive : 1;
+
+ /* Set if only required symbols should be added in the link hash table for
+ this object. Used by VMS linkers. */
+ unsigned int selective_search : 1;
};
typedef enum bfd_error
.
. {* Set if this is a thin archive. *}
. unsigned int is_thin_archive : 1;
+.
+. {* Set if only required symbols should be added in the link hash table for
+. this object. Used by VMS linkers. *}
+. unsigned int selective_search : 1;
.};
.
*/
;;
alpha*-*-*vms*)
targ_defvec=vms_alpha_vec
+ targ_selvecs=vms_lib_txt_vec
want64=true
;;
alpha*-*-*)
vax1knetbsd_vec) tb="$tb vax1knetbsd.lo aout32.lo" ;;
vaxbsd_vec) tb="$tb vaxbsd.lo aout32.lo" ;;
versados_vec) tb="$tb versados.lo" ;;
- vms_alpha_vec) tb="$tb vms.lo vms-hdr.lo vms-gsd.lo vms-tir.lo vms-misc.lo"; target_size=64 ;;
+ vms_alpha_vec) tb="$tb vms.lo vms-hdr.lo vms-gsd.lo vms-tir.lo vms-misc.lo vms-lib.lo"; target_size=64 ;;
+ vms_lib_txt_vec) tb="$tb vms-lib.lo vms-misc.lo" ;;
vms_vax_vec) tb="$tb vms.lo vms-hdr.lo vms-gsd.lo vms-tir.lo vms-misc.lo" ;;
w65_vec) tb="$tb coff-w65.lo reloc16.lo" ;;
we32kcoff_vec) tb="$tb coff-we32k.lo" ;;
vax1knetbsd_vec) tb="$tb vax1knetbsd.lo aout32.lo" ;;
vaxbsd_vec) tb="$tb vaxbsd.lo aout32.lo" ;;
versados_vec) tb="$tb versados.lo" ;;
- vms_alpha_vec) tb="$tb vms.lo vms-hdr.lo vms-gsd.lo vms-tir.lo vms-misc.lo"; target_size=64 ;;
+ vms_alpha_vec) tb="$tb vms.lo vms-hdr.lo vms-gsd.lo vms-tir.lo vms-misc.lo vms-lib.lo"; target_size=64 ;;
+ vms_lib_txt_vec) tb="$tb vms-lib.lo vms-misc.lo" ;;
vms_vax_vec) tb="$tb vms.lo vms-hdr.lo vms-gsd.lo vms-tir.lo vms-misc.lo" ;;
w65_vec) tb="$tb coff-w65.lo reloc16.lo" ;;
we32kcoff_vec) tb="$tb coff-we32k.lo" ;;
(bfd *, file_ptr, bfd *);
bfd_boolean _bfd_generic_mkarchive
(bfd *abfd);
+char *_bfd_append_relative_path
+ (bfd *arch, char *elt_name);
const bfd_target *bfd_generic_archive_p
(bfd *abfd);
bfd_boolean bfd_slurp_armap
#define _bfd_archive_bsd44_update_armap_timestamp \
_bfd_archive_bsd_update_armap_timestamp
+/* Routines to use for BFD_JUMP_TABLE_ARCHIVE to get VMS style
+ archives. Use BFD_JUMP_TABLE_ARCHIVE (_bfd_vms_lib). Some of them
+ are irrelevant and never called, so defined as NULL. */
+
+extern bfd_boolean _bfd_vms_lib_write_archive_contents (bfd *arch);
+#define _bfd_vms_lib_slurp_armap NULL
+#define _bfd_vms_lib_slurp_extended_name_table NULL
+#define _bfd_vms_lib_construct_extended_name_table NULL
+#define _bfd_vms_lib_truncate_arname NULL
+#define _bfd_vms_lib_write_armap NULL
+#define _bfd_vms_lib_read_ar_hdr NULL
+#define _bfd_vms_lib_write_ar_hdr NULL
+extern bfd *_bfd_vms_lib_openr_next_archived_file (bfd *, bfd *);
+extern bfd *_bfd_vms_lib_get_elt_at_index (bfd *, symindex);
+extern int _bfd_vms_lib_generic_stat_arch_elt (bfd *, struct stat *);
+#define _bfd_vms_lib_update_armap_timestamp bfd_true
+
+/* Extra routines for VMS style archives. */
+
+extern symindex _bfd_vms_lib_find_symbol (bfd *, const char *);
+extern bfd *_bfd_vms_lib_get_imagelib_file (bfd *);
+extern const bfd_target *_bfd_vms_lib_alpha_archive_p (bfd *abfd);
+extern bfd_boolean _bfd_vms_lib_mkarchive (bfd *abfd);
+
/* Routines to use for BFD_JUMP_TABLE_SYMBOLS where there is no symbol
support. Use BFD_JUMP_TABLE_SYMBOLS (_bfd_nosymbols). */
(bfd *, file_ptr, bfd *);
bfd_boolean _bfd_generic_mkarchive
(bfd *abfd);
+char *_bfd_append_relative_path
+ (bfd *arch, char *elt_name);
const bfd_target *bfd_generic_archive_p
(bfd *abfd);
bfd_boolean bfd_slurp_armap
#define _bfd_archive_bsd44_update_armap_timestamp \
_bfd_archive_bsd_update_armap_timestamp
+/* Routines to use for BFD_JUMP_TABLE_ARCHIVE to get VMS style
+ archives. Use BFD_JUMP_TABLE_ARCHIVE (_bfd_vms_lib). Some of them
+ are irrelevant and never called, so defined as NULL. */
+
+extern bfd_boolean _bfd_vms_lib_write_archive_contents (bfd *arch);
+#define _bfd_vms_lib_slurp_armap NULL
+#define _bfd_vms_lib_slurp_extended_name_table NULL
+#define _bfd_vms_lib_construct_extended_name_table NULL
+#define _bfd_vms_lib_truncate_arname NULL
+#define _bfd_vms_lib_write_armap NULL
+#define _bfd_vms_lib_read_ar_hdr NULL
+#define _bfd_vms_lib_write_ar_hdr NULL
+extern bfd *_bfd_vms_lib_openr_next_archived_file (bfd *, bfd *);
+extern bfd *_bfd_vms_lib_get_elt_at_index (bfd *, symindex);
+extern int _bfd_vms_lib_generic_stat_arch_elt (bfd *, struct stat *);
+#define _bfd_vms_lib_update_armap_timestamp bfd_true
+
+/* Extra routines for VMS style archives. */
+
+extern symindex _bfd_vms_lib_find_symbol (bfd *, const char *);
+extern bfd *_bfd_vms_lib_get_imagelib_file (bfd *);
+extern const bfd_target *_bfd_vms_lib_alpha_archive_p (bfd *abfd);
+extern bfd_boolean _bfd_vms_lib_mkarchive (bfd *abfd);
+
/* Routines to use for BFD_JUMP_TABLE_SYMBOLS where there is no symbol
support. Use BFD_JUMP_TABLE_SYMBOLS (_bfd_nosymbols). */
extern const bfd_target vax1knetbsd_vec;
extern const bfd_target versados_vec;
extern const bfd_target vms_alpha_vec;
+extern const bfd_target vms_lib_txt_vec;
extern const bfd_target vms_vax_vec;
extern const bfd_target w65_vec;
extern const bfd_target we32kcoff_vec;
#ifdef BFD64
&vms_alpha_vec,
#endif
+ &vms_lib_txt_vec,
&vms_vax_vec,
&w65_vec,
&we32kcoff_vec,
/* Create module name from filename. */
if (bfd_get_filename (abfd) != 0)
{
- /* Strip path and suffix information. */
- char *fname, *fout, *fptr;
-
- fptr = bfd_get_filename (abfd);
- fname = strdup (fptr);
-
- /* Strip VMS path. */
- fout = strrchr (fname, ']');
- if (fout == NULL)
- fout = strchr (fname, ':');
- if (fout != NULL)
- fout++;
- else
- fout = fname;
-
- /* Strip UNIX path. */
- fptr = strrchr (fout, '/');
- if (fptr != NULL)
- fout = fptr + 1;
-
- /* Strip suffix. */
- fptr = strrchr (fout, '.');
- if (fptr != 0)
- *fptr = 0;
-
- /* Convert to upper case and truncate at 31 characters.
- (VMS object file format restricts module name length to 31). */
- fptr = fout;
- while (*fptr != 0)
- {
- *fptr = TOUPPER (*fptr);
- fptr++;
- if (*fptr == ';' || (fptr - fout) >= 31)
- *fptr = 0;
- }
- _bfd_vms_output_counted (abfd, fout);
- free (fname);
+ char *module = vms_get_module_name (bfd_get_filename (abfd), TRUE);
+ _bfd_vms_output_counted (abfd, module);
+ free (module);
}
else
_bfd_vms_output_counted (abfd, "NONAME");
#include "bfd.h"
#include "bfdlink.h"
#include "libbfd.h"
+#include "safe-ctype.h"
#include "vms.h"
#endif
return entry;
}
+
+/* Create module name from filename (ie, extract the basename and convert it
+ in upper cases). Works on both VMS and UNIX pathes.
+ The result has to be free(). */
+
+char *
+vms_get_module_name (const char *filename, bfd_boolean upcase)
+{
+ char *fname, *fptr;
+ const char *fout;
+
+ /* Strip VMS path. */
+ fout = strrchr (filename, ']');
+ if (fout == NULL)
+ fout = strchr (filename, ':');
+ if (fout != NULL)
+ fout++;
+ else
+ fout = filename;
+
+ /* Strip UNIX path. */
+ fptr = strrchr (fout, '/');
+ if (fptr != NULL)
+ fout = fptr + 1;
+
+ fname = strdup (fout);
+
+ /* Strip suffix. */
+ fptr = strrchr (fname, '.');
+ if (fptr != 0)
+ *fptr = 0;
+
+ /* Convert to upper case and truncate at 31 characters.
+ (VMS object file format restricts module name length to 31). */
+ fptr = fname;
+ for (fptr = fname; *fptr != 0; fptr++)
+ {
+ if (*fptr == ';' || (fptr - fname) >= 31)
+ {
+ *fptr = 0;
+ break;
+ }
+ if (upcase)
+ *fptr = TOUPPER (*fptr);
+ }
+ return fname;
+}
+
+/* Convert a raw VMS time to a unix time. */
+
+time_t
+vms_time_to_time_t (unsigned int hi, unsigned int lo)
+{
+ const unsigned int off = 3506716800U;
+ const unsigned int factor = 10000000;
+ unsigned int tmp;
+ unsigned int rlo;
+ int i;
+
+ /* First convert to seconds. */
+ tmp = hi % factor;
+ hi = hi / factor;
+ rlo = 0;
+ for (i = 0; i < 4; i++)
+ {
+ tmp = (tmp << 8) | (lo >> 24);
+ lo <<= 8;
+
+ rlo = (rlo << 8) | (tmp / factor);
+ tmp %= factor;
+ }
+ lo = rlo;
+
+ /* Return 0 in case of overflow. */
+ if (lo > off && hi > 1)
+ return 0;
+
+ return lo - off;
+}
+
+/* Convert a raw (stored in a buffer) VMS time to a unix time. */
+
+time_t
+vms_rawtime_to_time_t (unsigned char *buf)
+{
+ unsigned int hi = bfd_getl32 (buf + 4);
+ unsigned int lo = bfd_getl32 (buf + 0);
+
+ return vms_time_to_time_t (hi, lo);
+}
bfd_getl16, bfd_getl_signed_16, bfd_putl16,
{_bfd_dummy_target, vms_object_p, /* bfd_check_format. */
- _bfd_dummy_target, _bfd_dummy_target},
+ _bfd_vms_lib_alpha_archive_p, _bfd_dummy_target},
{bfd_false, vms_mkobject, /* bfd_set_format. */
- bfd_false, bfd_false},
+ _bfd_vms_lib_mkarchive, bfd_false},
{bfd_false, vms_write_object_contents, /* bfd_write_contents. */
- bfd_false, bfd_false},
+ _bfd_vms_lib_write_archive_contents, bfd_false},
BFD_JUMP_TABLE_GENERIC (vms),
BFD_JUMP_TABLE_COPY (vms),
BFD_JUMP_TABLE_CORE (_bfd_nocore),
- BFD_JUMP_TABLE_ARCHIVE (_bfd_noarchive),
+ BFD_JUMP_TABLE_ARCHIVE (_bfd_vms_lib),
BFD_JUMP_TABLE_SYMBOLS (vms),
BFD_JUMP_TABLE_RELOCS (vms),
BFD_JUMP_TABLE_WRITE (vms),
Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
MA 02110-1301, USA. */
+#include <time.h>
+
#undef vms
#ifndef VMS_H
#define VMS_H
extern int _bfd_vms_get_object_record (bfd *abfd);
extern int _bfd_vms_get_first_record (bfd *abfd);
+extern char *vms_get_module_name (const char *filename, bfd_boolean);
+extern time_t vms_time_to_time_t (unsigned int hi, unsigned int lo);
+extern time_t vms_rawtime_to_time_t (unsigned char *buf);
+
/* vms-hdr.c. */
extern int _bfd_vms_slurp_hdr (bfd *abfd, int objtype);