xcoff dependency list for static libraries
authorAlan Modra <amodra@gmail.com>
Mon, 9 Nov 2020 02:34:04 +0000 (13:04 +1030)
committerAlan Modra <amodra@gmail.com>
Mon, 9 Nov 2020 03:39:01 +0000 (14:09 +1030)
This patch fixes fails adding library dependencies for xcoff, and
improves the error message should stat fail for an archive member.
"tmpdir/artest.a: File not found" is plainly wrong.

Fixes these fails:
powerpc-aix5.1  +FAIL: ar adding library dependencies
powerpc-aix5.2  +FAIL: ar adding library dependencies
rs6000-aix4.3.3  +FAIL: ar adding library dependencies
rs6000-aix5.1  +FAIL: ar adding library dependencies
rs6000-aix5.2  +FAIL: ar adding library dependencies

* archive.c (bfd_ar_hdr_from_filesystem): Use bfd_set_input_error
when stat of archive member fails.
* coff-rs6000.c (xcoff_write_archive_contents_old),
(xcoff_write_archive_contents_big): Likewise, and handle in-memory
bfd.

bfd/ChangeLog
bfd/archive.c
bfd/coff-rs6000.c

index 5ba165075cb65ddd2090bb2a685efc97c7b1f038..0d1d63d5fed65aca8ff556d939aad21608c38064 100644 (file)
@@ -1,3 +1,11 @@
+2020-11-09  Alan Modra  <amodra@gmail.com>
+
+       * archive.c (bfd_ar_hdr_from_filesystem): Use bfd_set_input_error
+       when stat of archive member fails.
+       * coff-rs6000.c (xcoff_write_archive_contents_old),
+       (xcoff_write_archive_contents_big): Likewise, and handle in-memory
+       bfd.
+
 2020-11-03  Alan Modra  <amodra@gmail.com>
 
        * elf.c (bfd_section_from_shdr): Free sections_being_created.
index 9d63849a483d5cd5c5ad40eb6b811bae2c9ae813..1836b9b47e26d9ccbe455a0042a7a24494f4e878 100644 (file)
@@ -1875,7 +1875,7 @@ bfd_ar_hdr_from_filesystem (bfd *abfd, const char *filename, bfd *member)
     }
   else if (stat (filename, &status) != 0)
     {
-      bfd_set_error (bfd_error_system_call);
+      bfd_set_input_error (member, bfd_error_system_call);
       return NULL;
     }
 
index 48c583bfd02c20df4b898266fe6ef8b003684407..5e5b182da9c0b5ae0bc65254f335429ccd35e992 100644 (file)
@@ -2096,11 +2096,23 @@ xcoff_write_archive_contents_old (bfd *abfd)
          struct xcoff_ar_hdr *ahdrp;
          struct stat s;
 
-         if (stat (bfd_get_filename (sub), &s) != 0)
+         if ((sub->flags & BFD_IN_MEMORY) != 0)
            {
-             bfd_set_error (bfd_error_system_call);
+             /* Assume we just "made" the member, and fake it.  */
+             struct bfd_in_memory *bim
+               = (struct bfd_in_memory *) sub->iostream;
+             time (&s.st_mtime);
+             s.st_uid = getuid ();
+             s.st_gid = getgid ();
+             s.st_mode = 0644;
+             s.st_size = bim->size;
+           }
+         else if (stat (bfd_get_filename (sub), &s) != 0)
+           {
+             bfd_set_input_error (sub, bfd_error_system_call);
              return FALSE;
            }
+
          if ((abfd->flags & BFD_DETERMINISTIC_OUTPUT) != 0)
            {
              s.st_mtime = 0;
@@ -2320,14 +2332,23 @@ xcoff_write_archive_contents_big (bfd *abfd)
          struct xcoff_ar_hdr_big *ahdrp;
          struct stat s;
 
-         /* XXX This should actually be a call to stat64 (at least on
-            32-bit machines).
-            XXX This call will fail if the original object is not found.  */
-         if (stat (bfd_get_filename (current_bfd), &s) != 0)
+         if ((current_bfd->flags & BFD_IN_MEMORY) != 0)
            {
-             bfd_set_error (bfd_error_system_call);
+             /* Assume we just "made" the member, and fake it.  */
+             struct bfd_in_memory *bim
+               = (struct bfd_in_memory *) current_bfd->iostream;
+             time (&s.st_mtime);
+             s.st_uid = getuid ();
+             s.st_gid = getgid ();
+             s.st_mode = 0644;
+             s.st_size = bim->size;
+           }
+         else if (stat (bfd_get_filename (current_bfd), &s) != 0)
+           {
+             bfd_set_input_error (current_bfd, bfd_error_system_call);
              return FALSE;
            }
+
          if ((abfd->flags & BFD_DETERMINISTIC_OUTPUT) != 0)
            {
              s.st_mtime = 0;