diff options
author | Tristan Gingold <gingold@adacore.com> | 2010-04-01 09:47:14 +0000 |
---|---|---|
committer | Tristan Gingold <gingold@adacore.com> | 2010-04-01 09:47:14 +0000 |
commit | 4b544b64681eec335bef3d3383772a7a38278fa9 (patch) | |
tree | b6f8dad055f9e6aefab76aa5bf0db703b4445862 | |
parent | 932fd279a972e48933c461d0fc502358d57cc2ec (diff) | |
download | gdb-4b544b64681eec335bef3d3383772a7a38278fa9.zip gdb-4b544b64681eec335bef3d3383772a7a38278fa9.tar.gz gdb-4b544b64681eec335bef3d3383772a7a38278fa9.tar.bz2 |
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.
-rw-r--r-- | bfd/ChangeLog | 27 | ||||
-rw-r--r-- | bfd/Makefile.am | 2 | ||||
-rw-r--r-- | bfd/Makefile.in | 3 | ||||
-rw-r--r-- | bfd/archive.c | 6 | ||||
-rw-r--r-- | bfd/bfd-in2.h | 4 | ||||
-rw-r--r-- | bfd/bfd.c | 4 | ||||
-rw-r--r-- | bfd/config.bfd | 1 | ||||
-rwxr-xr-x | bfd/configure | 3 | ||||
-rw-r--r-- | bfd/configure.in | 3 | ||||
-rw-r--r-- | bfd/libbfd-in.h | 26 | ||||
-rw-r--r-- | bfd/libbfd.h | 26 | ||||
-rw-r--r-- | bfd/targets.c | 2 | ||||
-rw-r--r-- | bfd/vms-hdr.c | 40 | ||||
-rw-r--r-- | bfd/vms-misc.c | 91 | ||||
-rw-r--r-- | bfd/vms.c | 8 | ||||
-rw-r--r-- | bfd/vms.h | 6 |
16 files changed, 206 insertions, 46 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 68bd72c..de1ed79 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,30 @@ +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 diff --git a/bfd/Makefile.am b/bfd/Makefile.am index b1ef71e..ac38177 100644 --- a/bfd/Makefile.am +++ b/bfd/Makefile.am @@ -393,6 +393,7 @@ BFD32_BACKENDS = \ versados.lo \ vms-gsd.lo \ vms-hdr.lo \ + vms-lib.lo \ vms-misc.lo \ vms-tir.lo \ vms.lo \ @@ -577,6 +578,7 @@ BFD32_BACKENDS_CFILES = \ versados.c \ vms-gsd.c \ vms-hdr.c \ + vms-lib.c \ vms-misc.c \ vms-tir.c \ vms.c \ diff --git a/bfd/Makefile.in b/bfd/Makefile.in index 93489ba..ed626c9 100644 --- a/bfd/Makefile.in +++ b/bfd/Makefile.in @@ -690,6 +690,7 @@ BFD32_BACKENDS = \ versados.lo \ vms-gsd.lo \ vms-hdr.lo \ + vms-lib.lo \ vms-misc.lo \ vms-tir.lo \ vms.lo \ @@ -874,6 +875,7 @@ BFD32_BACKENDS_CFILES = \ versados.c \ vms-gsd.c \ vms-hdr.c \ + vms-lib.c \ vms-misc.c \ vms-tir.c \ vms.c \ @@ -1488,6 +1490,7 @@ distclean-compile: @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@ diff --git a/bfd/archive.c b/bfd/archive.c index 15eea03..e6c1e83 100644 --- a/bfd/archive.c +++ b/bfd/archive.c @@ -536,8 +536,8 @@ _bfd_generic_read_ar_hdr_mag (bfd *abfd, const char *mag) /* 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); @@ -591,7 +591,7 @@ _bfd_get_elt_at_filepos (bfd *archive, file_ptr filepos) /* 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; } diff --git a/bfd/bfd-in2.h b/bfd/bfd-in2.h index abf4c17..9cf4f64 100644 --- a/bfd/bfd-in2.h +++ b/bfd/bfd-in2.h @@ -5119,6 +5119,10 @@ struct bfd /* 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 @@ -286,6 +286,10 @@ CODE_FRAGMENT . . {* 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; .}; . */ diff --git a/bfd/config.bfd b/bfd/config.bfd index 2e29fa3..1c1c988 100644 --- a/bfd/config.bfd +++ b/bfd/config.bfd @@ -177,6 +177,7 @@ case "${targ}" in ;; alpha*-*-*vms*) targ_defvec=vms_alpha_vec + targ_selvecs=vms_lib_txt_vec want64=true ;; alpha*-*-*) diff --git a/bfd/configure b/bfd/configure index a78e770..0f73da3 100755 --- a/bfd/configure +++ b/bfd/configure @@ -15260,7 +15260,8 @@ do 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" ;; diff --git a/bfd/configure.in b/bfd/configure.in index 717ce46..dfbd0a2 100644 --- a/bfd/configure.in +++ b/bfd/configure.in @@ -919,7 +919,8 @@ do 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" ;; diff --git a/bfd/libbfd-in.h b/bfd/libbfd-in.h index d74ebbb..89d0df6 100644 --- a/bfd/libbfd-in.h +++ b/bfd/libbfd-in.h @@ -137,6 +137,8 @@ bfd_boolean _bfd_add_bfd_to_archive_cache (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 @@ -351,6 +353,30 @@ extern bfd_boolean _bfd_archive_bsd44_construct_extended_name_table #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). */ diff --git a/bfd/libbfd.h b/bfd/libbfd.h index d37f038..c02063a 100644 --- a/bfd/libbfd.h +++ b/bfd/libbfd.h @@ -142,6 +142,8 @@ bfd_boolean _bfd_add_bfd_to_archive_cache (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 @@ -356,6 +358,30 @@ extern bfd_boolean _bfd_archive_bsd44_construct_extended_name_table #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). */ diff --git a/bfd/targets.c b/bfd/targets.c index 1196b4f..5ee73c4 100644 --- a/bfd/targets.c +++ b/bfd/targets.c @@ -827,6 +827,7 @@ extern const bfd_target vaxnetbsd_vec; 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; @@ -1227,6 +1228,7 @@ static const bfd_target * const _bfd_target_vector[] = #ifdef BFD64 &vms_alpha_vec, #endif + &vms_lib_txt_vec, &vms_vax_vec, &w65_vec, &we32kcoff_vec, diff --git a/bfd/vms-hdr.c b/bfd/vms-hdr.c index 4ac5b97..343f53e 100644 --- a/bfd/vms-hdr.c +++ b/bfd/vms-hdr.c @@ -237,43 +237,9 @@ _bfd_vms_write_hdr (bfd *abfd, int objtype) /* 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"); diff --git a/bfd/vms-misc.c b/bfd/vms-misc.c index 47e5985..9646324 100644 --- a/bfd/vms-misc.c +++ b/bfd/vms-misc.c @@ -30,6 +30,7 @@ #include "bfd.h" #include "bfdlink.h" #include "libbfd.h" +#include "safe-ctype.h" #include "vms.h" @@ -1045,3 +1046,93 @@ _bfd_vms_enter_symbol (bfd * abfd, char *name) #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); +} @@ -1450,16 +1450,16 @@ const bfd_target vms_alpha_vec = 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), @@ -23,6 +23,8 @@ Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ +#include <time.h> + #undef vms #ifndef VMS_H #define VMS_H @@ -480,6 +482,10 @@ extern int _bfd_vms_write_tbt (bfd *abfd, int objtype); 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); |