public inbox for gdb-testers@sourceware.org
help / color / mirror / Atom feed
From: gdb-buildbot@sergiodj.net
To: gdb-testers@sourceware.org
Subject: [binutils-gdb] ar P support
Date: Wed, 23 Oct 2019 12:37:00 -0000	[thread overview]
Message-ID: <95cc7c169c4bbb6f10e630184f527b20b83fc5c3@gdb-build> (raw)

*** TEST RESULTS FOR COMMIT 95cc7c169c4bbb6f10e630184f527b20b83fc5c3 ***

commit 95cc7c169c4bbb6f10e630184f527b20b83fc5c3
Author:     Alan Modra <amodra@gmail.com>
AuthorDate: Mon Oct 21 12:54:06 2019 +1030
Commit:     Alan Modra <amodra@gmail.com>
CommitDate: Mon Oct 21 16:13:39 2019 +1030

    ar P support
    
    This patch extends "ar P" to allow creation of normal (as distinct
    from thin) archives with full path names.
    
            PR 452
            PR 25104
    bfd/
            * archive.c (normalize): Return file unchanged when
            BFD_ARCHIVE_FULL_PATH.
            (_bfd_construct_extended_name_table): Pass abfd, the output
            bfd, to normalize.
            (_bfd_archive_bsd44_construct_extended_name_table): Likewise.
            * bfd.c (struct bfd): Make flags a full flagword.
            (BFD_ARCHIVE_FULL_PATH): Define.
            * bfd-in2.h: Regenerate.
    binutils/
            * ar.c (write_archive): Set BFD_ARCHIVE_FULL_PATH.
            * doc/binutils.texi (extract from archive): Mention
            restrictions when extracting from archives with full paths.
            (ar P): Update to current P support.
            (ar -X32_64): Fix spelling.

diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 429e423caa..f71c9aa846 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,15 @@
+2019-10-21  Alan Modra  <amodra@gmail.com>
+
+	PR 452
+	* archive.c (normalize): Return file unchanged when
+	BFD_ARCHIVE_FULL_PATH.
+	(_bfd_construct_extended_name_table): Pass abfd, the output
+	bfd, to normalize.
+	(_bfd_archive_bsd44_construct_extended_name_table): Likewise.
+	* bfd.c (struct bfd): Make flags a full flagword.
+	(BFD_ARCHIVE_FULL_PATH): Define.
+	* bfd-in2.h: Regenerate.
+
 2019-10-20  John David Anglin  <danglin@gcc.gnu.org>
 
 	* elf32-hppa.c (elf32_hppa_size_dynamic_sections): Provide 8-byte
diff --git a/bfd/archive.c b/bfd/archive.c
index ccc09ad49f..6b7a78ccd9 100644
--- a/bfd/archive.c
+++ b/bfd/archive.c
@@ -1299,6 +1299,9 @@ normalize (bfd *abfd, const char *file)
   const char *last;
   char *copy;
 
+  if (abfd->flags & BFD_ARCHIVE_FULL_PATH)
+    return file;
+
   first = file + strlen (file) - 1;
   last = first + 1;
 
@@ -1326,8 +1329,10 @@ normalize (bfd *abfd, const char *file)
 
 #else
 static const char *
-normalize (bfd *abfd ATTRIBUTE_UNUSED, const char *file)
+normalize (bfd *abfd, const char *file)
 {
+  if (abfd->flags & BFD_ARCHIVE_FULL_PATH)
+    return file;
   return lbasename (file);
 }
 #endif
@@ -1562,7 +1567,7 @@ _bfd_construct_extended_name_table (bfd *abfd,
 	  continue;
 	}
 
-      normal = normalize (current, current->filename);
+      normal = normalize (abfd, current->filename);
       if (normal == NULL)
 	return FALSE;
 
@@ -1643,7 +1648,7 @@ _bfd_construct_extended_name_table (bfd *abfd,
 	}
       else
 	{
-	  normal = normalize (current, filename);
+	  normal = normalize (abfd, filename);
 	  if (normal == NULL)
 	    return FALSE;
 	}
@@ -1714,7 +1719,7 @@ _bfd_archive_bsd44_construct_extended_name_table (bfd *abfd,
        current != NULL;
        current = current->archive_next)
     {
-      const char *normal = normalize (current, current->filename);
+      const char *normal = normalize (abfd, current->filename);
       int has_space = 0;
       unsigned int len;
 
diff --git a/bfd/bfd-in2.h b/bfd/bfd-in2.h
index 1c468dc68b..30b195a6cf 100644
--- a/bfd/bfd-in2.h
+++ b/bfd/bfd-in2.h
@@ -6498,7 +6498,7 @@ struct bfd
   ENUM_BITFIELD (bfd_direction) direction : 2;
 
   /* Format_specific flags.  */
-  flagword flags : 20;
+  flagword flags;
 
   /* Values that may appear in the flags field of a BFD.  These also
      appear in the object_flags field of the bfd_target structure, where
@@ -6585,6 +6585,9 @@ struct bfd
   /* Use the ELF STT_COMMON type in this BFD.  */
 #define BFD_USE_ELF_STT_COMMON  0x80000
 
+  /* Put pathnames into archives (non-POSIX).  */
+#define BFD_ARCHIVE_FULL_PATH  0x100000
+
   /* Flags bits to be saved in bfd_preserve_save.  */
 #define BFD_FLAGS_SAVED \
   (BFD_IN_MEMORY | BFD_COMPRESS | BFD_DECOMPRESS | BFD_LINKER_CREATED \
diff --git a/bfd/bfd.c b/bfd/bfd.c
index b3078eaa52..94e9f27e9d 100644
--- a/bfd/bfd.c
+++ b/bfd/bfd.c
@@ -92,7 +92,7 @@ CODE_FRAGMENT
 .  ENUM_BITFIELD (bfd_direction) direction : 2;
 .
 .  {* Format_specific flags.  *}
-.  flagword flags : 20;
+.  flagword flags;
 .
 .  {* Values that may appear in the flags field of a BFD.  These also
 .     appear in the object_flags field of the bfd_target structure, where
@@ -179,6 +179,9 @@ CODE_FRAGMENT
 .  {* Use the ELF STT_COMMON type in this BFD.  *}
 .#define BFD_USE_ELF_STT_COMMON  0x80000
 .
+.  {* Put pathnames into archives (non-POSIX).  *}
+.#define BFD_ARCHIVE_FULL_PATH  0x100000
+.
 .  {* Flags bits to be saved in bfd_preserve_save.  *}
 .#define BFD_FLAGS_SAVED \
 .  (BFD_IN_MEMORY | BFD_COMPRESS | BFD_DECOMPRESS | BFD_LINKER_CREATED \
diff --git a/binutils/ChangeLog b/binutils/ChangeLog
index e47c145764..74a223bfc8 100644
--- a/binutils/ChangeLog
+++ b/binutils/ChangeLog
@@ -1,3 +1,13 @@
+2019-10-21  Alan Modra  <amodra@gmail.com>
+
+	PR 452
+	PR 25104
+	* ar.c (write_archive): Set BFD_ARCHIVE_FULL_PATH.
+	* doc/binutils.texi (extract from archive): Mention
+	restrictions when extracting from archives with full paths.
+	(ar P): Update to current P support.
+	(ar -X32_64): Fix spelling.
+
 2019-10-14  Alan Modra  <amodra@gmail.com>
 
 	* objcopy.c (compare_section_lma): Correct comment.  Dereference
diff --git a/binutils/ar.c b/binutils/ar.c
index b99afff1c7..38c54c9fa8 100644
--- a/binutils/ar.c
+++ b/binutils/ar.c
@@ -1200,6 +1200,9 @@ write_archive (bfd *iarch)
   if (deterministic)
     obfd->flags |= BFD_DETERMINISTIC_OUTPUT;
 
+  if (full_pathname)
+    obfd->flags |= BFD_ARCHIVE_FULL_PATH;
+
   if (make_thin_archive || bfd_is_thin_archive (iarch))
     bfd_set_thin_archive (obfd, TRUE);
 
diff --git a/binutils/doc/binutils.texi b/binutils/doc/binutils.texi
index 4e10cdcf69..2edd7e1aa1 100644
--- a/binutils/doc/binutils.texi
+++ b/binutils/doc/binutils.texi
@@ -387,7 +387,10 @@ 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.
+Files cannot be extracted from a thin archive, and there are
+restrictions on extracting from archives created with @option{P}: The
+paths must not be absolute, may not contain @code{..}, and any
+subdirectories in the paths must exist.
 @end table
 
 A number of modifiers (@var{mod}) may immediately follow the @var{p}
@@ -463,12 +466,20 @@ Display member offsets inside the archive. Use together with the @samp{t}
 option.
 
 @item P
-Use the full path name when matching names in the archive.  @sc{gnu}
-@command{ar} can not create an archive with a full path name (such archives
-are not POSIX compliant), but other archive creators can.  This option
-will cause @sc{gnu} @command{ar} to match file names using a complete path
-name, which can be convenient when extracting a single file from an
-archive created by another tool.
+Use the full path name when matching or storing names in the archive.
+Archives created with full path names are not POSIX compliant, and
+thus may not work with tools other than up to date @sc{gnu} tools.
+Modifying such archives with @sc{gnu} @command{ar} without using
+@option{P} will remove the full path names unless the archive is a
+thin archive.  Note that @option{P} may be useful when adding files to
+a thin archive since @option{r} without @option{P} ignores the path
+when choosing which element to replace.  Thus
+@smallexample
+ar rcST archive.a subdir/file1 subdir/file2 file1
+@end smallexample
+will result in the first @code{subdir/file1} being replaced with
+@code{file1} from the current directory.  Adding @option{P} will
+prevent this replacement.
 
 @item s
 @cindex writing archive index
@@ -533,7 +544,7 @@ and then exits.
 Displays the version information of @command{ar} and then exits.
 
 @item -X32_64
-@command{ar} ignores an initial option spelt @samp{-X32_64}, for
+@command{ar} ignores an initial option spelled @samp{-X32_64}, for
 compatibility with AIX.  The behaviour produced by this option is the
 default for @sc{gnu} @command{ar}.  @command{ar} does not support any
 of the other @samp{-X} options; in particular, it does not support


             reply	other threads:[~2019-10-23 12:37 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-23 12:37 gdb-buildbot [this message]
2019-10-23 12:37 ` Failures on Ubuntu-Aarch64-m64, branch master gdb-buildbot
2019-10-23 13:11 ` Failures on Ubuntu-Aarch64-native-extended-gdbserver-m64, " gdb-buildbot
2019-10-23 13:42 ` Failures on Ubuntu-Aarch64-native-gdbserver-m64, " gdb-buildbot
2019-11-07 13:48 ` Failures on Fedora-i686, " gdb-buildbot
2019-11-07 15:46 ` Failures on Fedora-x86_64-cc-with-index, " gdb-buildbot
2019-11-07 16:49 ` Failures on Fedora-x86_64-native-extended-gdbserver-m32, " gdb-buildbot
2019-11-07 18:17 ` Failures on Fedora-x86_64-native-gdbserver-m64, " gdb-buildbot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=95cc7c169c4bbb6f10e630184f527b20b83fc5c3@gdb-build \
    --to=gdb-buildbot@sergiodj.net \
    --cc=gdb-testers@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).