diff options
author | Nick Clifton <nickc@redhat.com> | 2008-03-28 06:49:44 +0000 |
---|---|---|
committer | Nick Clifton <nickc@redhat.com> | 2008-03-28 06:49:44 +0000 |
commit | a8da6403829d6f87867da6a737dfdaa736a37dfa (patch) | |
tree | 1ec52dd8f73fe0d4565bab12f81192bab0445c22 /binutils | |
parent | 5c8178309791120badd1a8d5a5223a0fcc29e85a (diff) | |
download | gdb-a8da6403829d6f87867da6a737dfdaa736a37dfa.zip gdb-a8da6403829d6f87867da6a737dfdaa736a37dfa.tar.gz gdb-a8da6403829d6f87867da6a737dfdaa736a37dfa.tar.bz2 |
Add support for thin archives.
* bfd/archive.c (_bfd_find_nested_archive): New function.
(get_extended_arelt_filename): Add origin parameter.
(_bfd_generic_read_ar_hdr_mag): Deal with extended name
combined with a file offset.
(append_relative_path): New function.
(_bfd_get_elt_at_filepos): Deal with external members and
nested archives.
(bfd_generic_openr_next_archived_file): Thin archives.
(bfd_generic_archive_p): Recognize new magic string.
(adjust_relative_path): New function.
(_bfd_construct_extended_name_table): Construct extended
names for thin archive members.
(_bfd_write_archive_contents): Emit new magic string, skip
copying files for thin archives.
* bfd/bfd-in.h (bfd_is_thin_archive): New macro.
* bfd/bfd.c (struct bfd): New fields for thin archives.
* bfd/libbfd-in.h (struct areltdata): New field for thin archives.
* bfd/opncls.c (bfd_close): Delete BFDs for nested archives.
* binutils/ar.c (make_thin_archive): New global flag.
(map_over_members): Deal with full pathnames in thin archives.
(usage, main): Add 'T' option for building thin archives.
(replace_members): Pass thin archive flag to ar_emul_append.
* binutils/arsup.c (ar_open): Initialize new flag.
* binutils/binemul.c (ar_emul_append): Add new parameter for
flattening nested archives.
(do_ar_emul_default_append): New function.
(ar_emul_default_append): Factored out recursive code.
* binutils/binemul.h (ar_emul_default_append): Add new parameter.
(struct bin_emulation_xfer_struct): New parameter for ar_append.
* binutils/dlltool.c (gen_lib_file): Initialize thin archive flag.
* binutils/emul_aix.c (ar_emul_aix_internal): Add new flatten
parameter, currently unimplemented.
All callers changed.
* binutils/objcopy.c (copy_archive): Preserve thin archive flag.
* binutils/doc/binutils.texi: Update ar documentation.
* binutils/testsuite/binutils-all/ar.exp: Add thin archive tests.
* include/aout/ar.h (ARMAGT): New magic string for thin archives.
Diffstat (limited to 'binutils')
-rw-r--r-- | binutils/ChangeLog | 22 | ||||
-rw-r--r-- | binutils/NEWS | 5 | ||||
-rw-r--r-- | binutils/ar.c | 50 | ||||
-rw-r--r-- | binutils/arsup.c | 3 | ||||
-rw-r--r-- | binutils/binemul.c | 57 | ||||
-rw-r--r-- | binutils/binemul.h | 9 | ||||
-rw-r--r-- | binutils/dlltool.c | 1 | ||||
-rw-r--r-- | binutils/doc/binutils.texi | 20 | ||||
-rw-r--r-- | binutils/emul_aix.c | 33 | ||||
-rw-r--r-- | binutils/objcopy.c | 3 | ||||
-rw-r--r-- | binutils/testsuite/ChangeLog | 4 | ||||
-rw-r--r-- | binutils/testsuite/binutils-all/ar.exp | 108 |
12 files changed, 264 insertions, 51 deletions
diff --git a/binutils/ChangeLog b/binutils/ChangeLog index 30466fe..b0e140a 100644 --- a/binutils/ChangeLog +++ b/binutils/ChangeLog @@ -1,3 +1,25 @@ +2008-03-27 Cary Coutant <ccoutant@google.com> + + Add support for thin archives. + * ar.c (make_thin_archive): New global flag. + (map_over_members): Deal with full pathnames in thin archives. + (usage, main): Add 'T' option for building thin archives. + (replace_members): Pass thin archive flag to ar_emul_append. + * arsup.c (ar_open): Initialize new flag. + * binemul.c (ar_emul_append): Add new parameter for + flattening nested archives. + (do_ar_emul_default_append): New function. + (ar_emul_default_append): Factored out recursive code. + * binutils/binemul.h (ar_emul_default_append): Add new parameter. + (struct bin_emulation_xfer_struct): New parameter for ar_append. + * dlltool.c (gen_lib_file): Initialize thin archive flag. + * emul_aix.c (ar_emul_aix_internal): Add new flatten + parameter, currently unimplemented. + All callers changed. + * objcopy.c (copy_archive): Preserve thin archive flag. + * doc/binutils.texi: Update ar documentation. + * NEWS: Mention the new feature. + 2008-03-20 H.J. Lu <hongjiu.lu@intel.com> * readelf.c (process_mips_specific): Declare addr_size as int. diff --git a/binutils/NEWS b/binutils/NEWS index a4d2433..ab836de 100644 --- a/binutils/NEWS +++ b/binutils/NEWS @@ -1,4 +1,9 @@ -*- text -*- +* Added support for "thin" archives which contain pathnames pointing to + object files rather than the files themselves and which contain a + flattened symbol index for all objects, and archives, which have been + added to the archive. + * Added -F switch to objdump to include file offsets in the disassembly. * Added -c switch to readelf to allow string dumps of archive symbol index. diff --git a/binutils/ar.c b/binutils/ar.c index 10e8889..71f4d73 100644 --- a/binutils/ar.c +++ b/binutils/ar.c @@ -40,9 +40,9 @@ #include <sys/stat.h> #ifdef __GO32___ -#define EXT_NAME_LEN 3 /* bufflen of addition to name if it's MS-DOS */ +#define EXT_NAME_LEN 3 /* Bufflen of addition to name if it's MS-DOS. */ #else -#define EXT_NAME_LEN 6 /* ditto for *NIX */ +#define EXT_NAME_LEN 6 /* Ditto for *NIX. */ #endif /* We need to open files in binary modes on system where that makes a @@ -51,12 +51,12 @@ #define O_BINARY 0 #endif -/* Kludge declaration from BFD! This is ugly! FIXME! XXX */ +/* Kludge declaration from BFD! This is ugly! FIXME! XXX */ struct ar_hdr * bfd_special_undocumented_glue (bfd * abfd, const char *filename); -/* Static declarations */ +/* Static declarations. */ static void mri_emul (void); static const char *normalize (const char *, bfd *); @@ -74,7 +74,7 @@ static int ranlib_only (const char *archname); static int ranlib_touch (const char *archname); static void usage (int); -/** Globals and flags */ +/** Globals and flags. */ static int mri_mode; @@ -134,6 +134,9 @@ static bfd_boolean ar_truncate = FALSE; program. */ static bfd_boolean full_pathname = FALSE; +/* Whether to create a "thin" archive (symbol index only -- no files). */ +static bfd_boolean make_thin_archive = FALSE; + int interactive = 0; static void @@ -176,16 +179,25 @@ map_over_members (bfd *arch, void (*function)(bfd *), char **files, int count) match_count = 0; for (head = arch->archive_next; head; head = head->archive_next) { + const char * filename; + PROGRESS (1); - if (head->filename == NULL) + filename = head->filename; + if (filename == NULL) { /* Some archive formats don't get the filenames filled in until the elements are opened. */ struct stat buf; bfd_stat_arch_elt (head, &buf); } - if ((head->filename != NULL) && - (!FILENAME_CMP (normalize (*files, arch), head->filename))) + else if (bfd_is_thin_archive (arch)) + { + /* Thin archives store full pathnames. Need to normalize. */ + filename = normalize (filename, arch); + } + + if ((filename != NULL) && + (!FILENAME_CMP (normalize (*files, arch), filename))) { ++match_count; if (counted_name_mode @@ -200,6 +212,7 @@ map_over_members (bfd *arch, void (*function)(bfd *), char **files, int count) function (head); } } + if (!found) /* xgettext:c-format */ fprintf (stderr, _("no entry %s in archive\n"), *files); @@ -242,10 +255,11 @@ usage (int help) fprintf (s, _(" [c] - do not warn if the library had to be created\n")); fprintf (s, _(" [s] - create an archive index (cf. ranlib)\n")); fprintf (s, _(" [S] - do not build a symbol table\n")); + fprintf (s, _(" [T] - make a thin archive\n")); fprintf (s, _(" [v] - be verbose\n")); fprintf (s, _(" [V] - display the version number\n")); fprintf (s, _(" @<file> - read options from <file>\n")); - + ar_emul_usage (s); } else @@ -284,6 +298,7 @@ normalize (const char *file, bfd *abfd) { /* We could have foo/bar\\baz, or foo\\bar, or d:bar. */ char *bslash = strrchr (file, '\\'); + if (filename == NULL || (bslash != NULL && bslash > filename)) filename = bslash; if (filename == NULL && file[0] != '\0' && file[1] == ':') @@ -302,7 +317,7 @@ normalize (const char *file, bfd *abfd) char *s; /* Space leak. */ - s = (char *) xmalloc (abfd->xvec->ar_max_namelen + 1); + s = xmalloc (abfd->xvec->ar_max_namelen + 1); memcpy (s, filename, abfd->xvec->ar_max_namelen); s[abfd->xvec->ar_max_namelen] = '\0'; filename = s; @@ -376,6 +391,7 @@ main (int argc, char **argv) { /* We could have foo/bar\\baz, or foo\\bar, or d:bar. */ char *bslash = strrchr (program_name, '\\'); + if (temp == NULL || (bslash != NULL && bslash > temp)) temp = bslash; if (temp == NULL && program_name[0] != '\0' && program_name[1] == ':') @@ -559,6 +575,9 @@ main (int argc, char **argv) case 'P': full_pathname = TRUE; break; + case 'T': + make_thin_archive = TRUE; + break; default: /* xgettext:c-format */ non_fatal (_("illegal option -- %c"), c); @@ -629,6 +648,9 @@ main (int argc, char **argv) arch = open_inarch (inarch_filename, files == NULL ? (char *) NULL : files[0]); + if (operation == extract && bfd_is_thin_archive (arch)) + fatal (_("`x' cannot be used on thin archives.")); + switch (operation) { case print_table: @@ -933,7 +955,7 @@ write_archive (bfd *iarch) if (new_name == NULL) bfd_fatal ("could not create temporary file whilst writing archive"); - + output_filename = new_name; obfd = bfd_openw (new_name, bfd_get_target (iarch)); @@ -956,6 +978,9 @@ write_archive (bfd *iarch) obfd->flags |= BFD_TRADITIONAL_FORMAT; } + if (make_thin_archive || bfd_is_thin_archive (iarch)) + bfd_is_thin_archive (obfd) = 1; + if (!bfd_set_archive_head (obfd, contents_head)) bfd_fatal (old_name); @@ -1189,7 +1214,8 @@ replace_members (bfd *arch, char **files_to_move, bfd_boolean quick) /* Add to the end of the archive. */ after_bfd = get_pos_bfd (&arch->archive_next, pos_end, NULL); - if (ar_emul_append (after_bfd, *files_to_move, verbose)) + if (ar_emul_append (after_bfd, *files_to_move, verbose, + make_thin_archive)) changed = TRUE; next_file:; diff --git a/binutils/arsup.c b/binutils/arsup.c index 49961b0..f7138eb 100644 --- a/binutils/arsup.c +++ b/binutils/arsup.c @@ -1,6 +1,6 @@ /* arsup.c - Archive support for MRI compatibility Copyright 1992, 1994, 1995, 1996, 1997, 1999, 2000, 2001, 2002, 2003, - 2004, 2007 Free Software Foundation, Inc. + 2004, 2007, 2008 Free Software Foundation, Inc. This file is part of GNU Binutils. @@ -207,6 +207,7 @@ ar_open (char *name, int t) bfd_set_format (obfd, bfd_archive); obfd->has_armap = 1; + obfd->is_thin_archive = 0; } } diff --git a/binutils/binemul.c b/binutils/binemul.c index 0eb1c81..74e5d9c 100644 --- a/binutils/binemul.c +++ b/binutils/binemul.c @@ -1,5 +1,5 @@ /* Binutils emulation layer. - Copyright 2002, 2003, 2007 Free Software Foundation, Inc. + Copyright 2002, 2003, 2007, 2008 Free Software Foundation, Inc. Written by Tom Rix, Red Hat Inc. This file is part of GNU Binutils. @@ -39,29 +39,58 @@ ar_emul_default_usage (FILE *fp) } bfd_boolean -ar_emul_append (bfd **after_bfd, char *file_name, bfd_boolean verbose) +ar_emul_append (bfd **after_bfd, char *file_name, bfd_boolean verbose, + bfd_boolean flatten) { if (bin_dummy_emulation.ar_append) - return bin_dummy_emulation.ar_append (after_bfd, file_name, verbose); + return bin_dummy_emulation.ar_append (after_bfd, file_name, verbose, + flatten); return FALSE; } +static bfd_boolean +do_ar_emul_default_append (bfd **after_bfd, bfd *new_bfd, + bfd_boolean verbose, bfd_boolean flatten) + { + /* When flattening, add the members of an archive instead of the + archive itself. */ + if (flatten && bfd_check_format (new_bfd, bfd_archive)) + { + bfd *elt; + bfd_boolean added = FALSE; + + for (elt = bfd_openr_next_archived_file (new_bfd, NULL); + elt; + elt = bfd_openr_next_archived_file (new_bfd, elt)) + { + if (do_ar_emul_default_append (after_bfd, elt, verbose, TRUE)) + { + added = TRUE; + after_bfd = &((*after_bfd)->archive_next); + } + } + + return added; + } + + AR_EMUL_APPEND_PRINT_VERBOSE (verbose, new_bfd->filename); + + new_bfd->archive_next = *after_bfd; + *after_bfd = new_bfd; + + return TRUE; +} + bfd_boolean ar_emul_default_append (bfd **after_bfd, char *file_name, - bfd_boolean verbose) + bfd_boolean verbose, bfd_boolean flatten) { - bfd *temp; + bfd *new_bfd; - temp = *after_bfd; - *after_bfd = bfd_openr (file_name, NULL); - - AR_EMUL_ELEMENT_CHECK (*after_bfd, file_name); - AR_EMUL_APPEND_PRINT_VERBOSE (verbose, file_name); - - (*after_bfd)->archive_next = temp; - - return TRUE; + new_bfd = bfd_openr (file_name, NULL); + AR_EMUL_ELEMENT_CHECK (new_bfd, file_name); + return do_ar_emul_default_append (after_bfd, new_bfd, verbose, flatten); } bfd_boolean diff --git a/binutils/binemul.h b/binutils/binemul.h index 4da6693..e2a1280 100644 --- a/binutils/binemul.h +++ b/binutils/binemul.h @@ -1,5 +1,5 @@ /* Binutils emulation layer. - Copyright 2002, 2003, 2007 Free Software Foundation, Inc. + Copyright 2002, 2003, 2007, 2008 Free Software Foundation, Inc. Written by Tom Rix, Red Hat Inc. This file is part of GNU Binutils. @@ -28,8 +28,9 @@ extern void ar_emul_usage (FILE *); extern void ar_emul_default_usage (FILE *); -extern bfd_boolean ar_emul_append (bfd **, char *, bfd_boolean); -extern bfd_boolean ar_emul_default_append (bfd **, char *, bfd_boolean); +extern bfd_boolean ar_emul_append (bfd **, char *, bfd_boolean, bfd_boolean); +extern bfd_boolean ar_emul_default_append (bfd **, char *, bfd_boolean, + bfd_boolean); extern bfd_boolean ar_emul_replace (bfd **, char *, bfd_boolean); extern bfd_boolean ar_emul_default_replace (bfd **, char *, bfd_boolean); extern bfd_boolean ar_emul_parse_arg (char *); @@ -54,7 +55,7 @@ typedef struct bin_emulation_xfer_struct { /* Print out the extra options. */ void (* ar_usage) (FILE *fp); - bfd_boolean (* ar_append) (bfd **, char *, bfd_boolean); + bfd_boolean (* ar_append) (bfd **, char *, bfd_boolean, bfd_boolean); bfd_boolean (* ar_replace) (bfd **, char *, bfd_boolean); bfd_boolean (* ar_parse_arg) (char *); } diff --git a/binutils/dlltool.c b/binutils/dlltool.c index cbdde7c..61361b7 100644 --- a/binutils/dlltool.c +++ b/binutils/dlltool.c @@ -2813,6 +2813,7 @@ gen_lib_file (void) bfd_set_format (outarch, bfd_archive); outarch->has_armap = 1; + outarch->is_thin_archive = 0; /* Work out a reasonable size of things to put onto one line. */ ar_head = make_head (); diff --git a/binutils/doc/binutils.texi b/binutils/doc/binutils.texi index 723c3a3..44c18dc 100644 --- a/binutils/doc/binutils.texi +++ b/binutils/doc/binutils.texi @@ -211,6 +211,18 @@ You may use @samp{nm -s} or @samp{nm --print-armap} to list this index table. If an archive lacks the table, another form of @command{ar} called @command{ranlib} can be used to add just the table. +@cindex thin archives +@sc{gnu} @command{ar} can optionally create a @emph{thin} archive, +which contains a symbol index and references to the original copies +of the member files of the archives. Such an archive is useful +for building libraries for use within a local build, where the +relocatable objects are expected to remain available, and copying the +contents of each object would only waste time and space. Thin archives +are also @emph{flattened}, so that adding one or more archives to a +thin archive will add the elements of the nested archive individually. +The paths to the elements of the archive are stored relative to the +archive itself. + @cindex compatibility, @command{ar} @cindex @command{ar} compatibility @sc{gnu} @command{ar} is designed to be compatible with two different @@ -356,6 +368,8 @@ use the @samp{v} modifier with this operation, to request that If you do not specify a @var{member}, all files in the archive are extracted. +Files cannot be extracted from a thin archive. + @end table A number of modifiers (@var{mod}) may immediately follow the @var{p} @@ -434,6 +448,12 @@ with the linker. In order to build a symbol table, you must omit the @samp{S} modifier on the last execution of @samp{ar}, or you must run @samp{ranlib} on the archive. +@item T +@cindex creating thin archive +Make the specified @var{archive} a @emph{thin} archive. If it already +exists and is a regular archive, the existing members must be present +in the same directory as @var{archive}. + @item u @cindex updating an archive Normally, @samp{ar r}@dots{} inserts all files diff --git a/binutils/emul_aix.c b/binutils/emul_aix.c index 22ff830..d68a5ec 100644 --- a/binutils/emul_aix.c +++ b/binutils/emul_aix.c @@ -1,5 +1,5 @@ /* Binutils emulation layer. - Copyright 2002, 2003, 2006, 2007 Free Software Foundation, Inc. + Copyright 2002, 2003, 2006, 2007, 2008 Free Software Foundation, Inc. Written by Tom Rix, Red Hat Inc. This file is part of GNU Binutils. @@ -35,15 +35,6 @@ static bfd_boolean X32 = TRUE; /* Whether to include 64 bit objects. */ static bfd_boolean X64 = FALSE; -static void ar_emul_aix_usage (FILE *); -static bfd_boolean ar_emul_aix_append (bfd **, char *, bfd_boolean); -static bfd_boolean ar_emul_aix5_append (bfd **, char *, bfd_boolean); -static bfd_boolean ar_emul_aix_replace (bfd **, char *, bfd_boolean); -static bfd_boolean ar_emul_aix5_replace (bfd **, char *, bfd_boolean); -static bfd_boolean ar_emul_aix_parse_arg (char *); -static bfd_boolean ar_emul_aix_internal - (bfd **, char *, bfd_boolean, const char *, bfd_boolean); - static void ar_emul_aix_usage (FILE *fp) { @@ -56,8 +47,12 @@ ar_emul_aix_usage (FILE *fp) } static bfd_boolean -ar_emul_aix_internal (bfd **after_bfd, char *file_name, bfd_boolean verbose, - const char * target_name, bfd_boolean is_append) +ar_emul_aix_internal (bfd ** after_bfd, + char * file_name, + bfd_boolean verbose, + const char * target_name, + bfd_boolean is_append, + bfd_boolean flatten ATTRIBUTE_UNUSED) { bfd *temp; bfd *try_bfd; @@ -97,31 +92,33 @@ ar_emul_aix_internal (bfd **after_bfd, char *file_name, bfd_boolean verbose, static bfd_boolean -ar_emul_aix_append (bfd **after_bfd, char *file_name, bfd_boolean verbose) +ar_emul_aix_append (bfd **after_bfd, char *file_name, bfd_boolean verbose, + bfd_boolean flatten) { return ar_emul_aix_internal (after_bfd, file_name, verbose, - "aixcoff64-rs6000", TRUE); + "aixcoff64-rs6000", TRUE, flatten); } static bfd_boolean -ar_emul_aix5_append (bfd **after_bfd, char *file_name, bfd_boolean verbose) +ar_emul_aix5_append (bfd **after_bfd, char *file_name, bfd_boolean verbose, + bfd_boolean flatten) { return ar_emul_aix_internal (after_bfd, file_name, verbose, - "aix5coff64-rs6000", TRUE); + "aix5coff64-rs6000", TRUE, flatten); } static bfd_boolean ar_emul_aix_replace (bfd **after_bfd, char *file_name, bfd_boolean verbose) { return ar_emul_aix_internal (after_bfd, file_name, verbose, - "aixcoff64-rs6000", FALSE); + "aixcoff64-rs6000", FALSE, FALSE); } static bfd_boolean ar_emul_aix5_replace (bfd **after_bfd, char *file_name, bfd_boolean verbose) { return ar_emul_aix_internal (after_bfd, file_name, verbose, - "aix5coff64-rs6000", FALSE); + "aix5coff64-rs6000", FALSE, FALSE); } static bfd_boolean diff --git a/binutils/objcopy.c b/binutils/objcopy.c index b89de46..1dd3611 100644 --- a/binutils/objcopy.c +++ b/binutils/objcopy.c @@ -1,6 +1,6 @@ /* objcopy.c -- copy object file from input to output, optionally massaging it. Copyright 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, - 2001, 2002, 2003, 2004, 2005, 2006, 2007 + 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. This file is part of GNU Binutils. @@ -1830,6 +1830,7 @@ copy_archive (bfd *ibfd, bfd *obfd, const char *output_target, strerror (errno)); obfd->has_armap = ibfd->has_armap; + obfd->is_thin_archive = ibfd->is_thin_archive; list = NULL; diff --git a/binutils/testsuite/ChangeLog b/binutils/testsuite/ChangeLog index ac5be6d..e7cc69a 100644 --- a/binutils/testsuite/ChangeLog +++ b/binutils/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2008-03-27 Cary Coutant <ccoutant@google.com> + + * binutils-all/ar.exp: Add thin archive tests. + 2008-02-26 Joseph Myers <joseph@codesourcery.com> * config/default.exp (gcc_gas_flag, dlltool_gas_flag): Define to diff --git a/binutils/testsuite/binutils-all/ar.exp b/binutils/testsuite/binutils-all/ar.exp index 67504c3..21a39f4 100644 --- a/binutils/testsuite/binutils-all/ar.exp +++ b/binutils/testsuite/binutils-all/ar.exp @@ -1,4 +1,4 @@ -# Copyright 1995, 1997, 2002, 2004, 2007 Free Software Foundation, Inc. +# Copyright 1995, 1997, 2002, 2004, 2007, 2008 Free Software Foundation, Inc. # 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 @@ -215,6 +215,110 @@ proc symbol_table { } { pass $testname } +# Test building a thin archive. + +proc thin_archive { } { + global AR + global AS + global NM + global srcdir + global subdir + + set testname "ar thin archive" + + if ![binutils_assemble $srcdir/$subdir/bintest.s tmpdir/bintest.o] { + unresolved $testname + return + } + + if [is_remote host] { + set archive artest.a + set objfile [remote_download host tmpdir/bintest.o] + remote_file host delete $archive + } else { + set archive tmpdir/artest.a + set objfile tmpdir/bintest.o + } + + remote_file build delete tmpdir/artest.a + + set got [binutils_run $AR "rcT $archive ${objfile}"] + if ![string match "" $got] { + fail $testname + return + } + + set got [binutils_run $NM "--print-armap $archive"] + if { ![string match "*text_symbol in *bintest.o*" $got] \ + || ![string match "*data_symbol in *bintest.o*" $got] \ + || ![string match "*common_symbol in *bintest.o*" $got] \ + || [string match "*static_text_symbol in *bintest.o*" $got] \ + || [string match "*static_data_symbol in *bintest.o*" $got] \ + || [string match "*external_symbol in *bintest.o*" $got] } { + fail $testname + return + } + + pass $testname +} + +# Test building a thin archive with a nested archive. + +proc thin_archive_with_nested { } { + global AR + global AS + global NM + global srcdir + global subdir + + set testname "ar thin archive with nested archive" + + if ![binutils_assemble $srcdir/$subdir/bintest.s tmpdir/bintest.o] { + unresolved $testname + return + } + + if [is_remote host] { + set archive artest.a + set archive2 artest2.a + set objfile [remote_download host tmpdir/bintest.o] + remote_file host delete $archive + } else { + set archive tmpdir/artest.a + set archive2 tmpdir/artest2.a + set objfile tmpdir/bintest.o + } + + remote_file build delete tmpdir/artest.a + + set got [binutils_run $AR "rc $archive ${objfile}"] + if ![string match "" $got] { + fail $testname + return + } + + remote_file build delete tmpdir/artest2.a + + set got [binutils_run $AR "rcT $archive2 ${archive}"] + if ![string match "" $got] { + fail $testname + return + } + + set got [binutils_run $NM "--print-armap $archive"] + if { ![string match "*text_symbol in *bintest.o*" $got] \ + || ![string match "*data_symbol in *bintest.o*" $got] \ + || ![string match "*common_symbol in *bintest.o*" $got] \ + || [string match "*static_text_symbol in *bintest.o*" $got] \ + || [string match "*static_data_symbol in *bintest.o*" $got] \ + || [string match "*external_symbol in *bintest.o*" $got] } { + fail $testname + return + } + + pass $testname +} + # Test POSIX-compatible argument parsing. proc argument_parsing { } { @@ -254,4 +358,6 @@ proc argument_parsing { } { long_filenames symbol_table +thin_archive +thin_archive_with_nested argument_parsing |