[binutils-gdb] bfdtest1 loop check

Alan Modra amodra@sourceware.org
Wed Jan 1 12:46:20 GMT 2025


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=c5e10fb2eb81573f004aff454a81b2ef4f06a3ae

commit c5e10fb2eb81573f004aff454a81b2ef4f06a3ae
Author: Alan Modra <amodra@gmail.com>
Date:   Wed Jan 1 22:51:44 2025 +1030

    bfdtest1 loop check
    
    Add a check that next_archived_file doesn't return the same element.
    Seen with the following, which I think shows a bug with "ar r" and
    thin archives as you get two copies of artest.a in artest2.a.
    
    $ rm tmpdir/artest*
    $ ./ar rc tmpdir/artest.a tmpdir/bintest.o
    $ ./ar rcT tmpdir/artest2.a tmpdir/artest.a
    $ ./bfdtest1 tmpdir/artest.a
    $ ./bfdtest1 tmpdir/artest2.a
    $ ./ar rcT tmpdir/artest2.a tmpdir/artest.a
    $ ./bfdtest1 tmpdir/artest2.a
    oops: next_archived_file

Diff:
---
 binutils/bfdtest1.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/binutils/bfdtest1.c b/binutils/bfdtest1.c
index 9714998fa6b..ef68732e37f 100644
--- a/binutils/bfdtest1.c
+++ b/binutils/bfdtest1.c
@@ -53,6 +53,8 @@ main (int argc, char **argv)
        last = next)
     {
       next = bfd_openr_next_archived_file (archive, last);
+      if (next == last)
+	die ("next_archived_file");
       bfd_close (last);
       count++;
     }
@@ -62,6 +64,8 @@ main (int argc, char **argv)
        last = next)
     {
       next = bfd_openr_next_archived_file (archive, last);
+      if (next == last)
+	die ("next_archived_file");
       bfd_close (last);
       count--;
     }


More information about the Binutils-cvs mailing list