[committed v2 3/8] BFD: Remove unused file position member of `struct orl'

Maciej W. Rozycki macro@redhat.com
Wed Nov 5 19:05:06 GMT 2025


The `pos' member of `struct orl' has never been used.  Remove it along 
with the enclosing union so as not to propagate clutter with a later 
change, which adds that union as a distinct type.  No functional change.
---
On Mon, 20 Oct 2025, Jan Beulich wrote:

> >> Seeing this change and ...
> >>
> >>> @@ -2434,7 +2430,7 @@ _bfd_compute_and_write_armap (bfd *arch,
> >>>  		      if (*(map[orl_count].name) == NULL)
> >>>  			goto error_return;
> >>>  		      strcpy (*(map[orl_count].name), syms[src_count]->name);
> >>> -		      map[orl_count].u.abfd = current;
> >>> +		      map[orl_count].abfd = current;
> >>
> >> ... use of the "abfd" member here, do you perhaps mean the "pos" member in
> >> title and description? Otherwise I fear I'm confused.
> > 
> >  And right you are!  It seems like a mental slip of mine.  Oh well, I'll 
> > repost with the required corrections applied.  Thanks for catching.
> 
> No real need to re-post though - the patch is okay with that adjustment.

 This is what I have committed now.  Thank you for your review.

  Maciej

Changes from v1:

- Refer to the `pos' rather than `abfd' member being removed across the 
  change heading and description, matching what the change actually does.

- Reworded the description to refer to "a later" rather than "the next" 
  change, as it's obvious at this point 4/8 won't be pushed next.
---
 bfd/archive.c     |   20 ++++++++------------
 bfd/archive64.c   |    2 +-
 bfd/coff-rs6000.c |   12 ++++++------
 bfd/ecoff.c       |    4 ++--
 bfd/libbfd.h      |    6 +-----
 5 files changed, 18 insertions(+), 26 deletions(-)

binutils-bfd-orl-pos.diff
Index: binutils-gdb/bfd/archive.c
===================================================================
--- binutils-gdb.orig/bfd/archive.c
+++ binutils-gdb/bfd/archive.c
@@ -168,11 +168,7 @@ INTERNAL
 .struct orl		{* Output ranlib.  *}
 .{
 .  char **name;		{* Symbol name.  *}
-.  union
-.  {
-.    file_ptr pos;
-.    bfd *abfd;
-.  } u;			{* bfd* or file position.  *}
+.  bfd *abfd;		{* Containing BFD.  *}
 .  int namidx;		{* Index into string table.  *}
 .};
 .
@@ -2434,7 +2430,7 @@ _bfd_compute_and_write_armap (bfd *arch,
 		      if (*(map[orl_count].name) == NULL)
 			goto error_return;
 		      strcpy (*(map[orl_count].name), syms[src_count]->name);
-		      map[orl_count].u.abfd = current;
+		      map[orl_count].abfd = current;
 		      map[orl_count].namidx = stridx;
 
 		      stridx += namelen + 1;
@@ -2500,7 +2496,7 @@ _bfd_bsd_write_armap (bfd *arch,
     {
       unsigned int offset;
 
-      if (map[count].u.abfd != last_elt)
+      if (map[count].abfd != last_elt)
 	{
 	  do
 	    {
@@ -2511,7 +2507,7 @@ _bfd_bsd_write_armap (bfd *arch,
 	      firstreal += firstreal % 2;
 	      current = current->archive_next;
 	    }
-	  while (current != map[count].u.abfd);
+	  while (current != map[count].abfd);
 	}
 
       /* The archive file format only has 4 bytes to store the offset
@@ -2576,7 +2572,7 @@ _bfd_bsd_write_armap (bfd *arch,
       unsigned int offset;
       bfd_byte buf[BSD_SYMDEF_SIZE];
 
-      if (map[count].u.abfd != last_elt)
+      if (map[count].abfd != last_elt)
 	{
 	  do
 	    {
@@ -2587,7 +2583,7 @@ _bfd_bsd_write_armap (bfd *arch,
 	      firstreal += firstreal % 2;
 	      current = current->archive_next;
 	    }
-	  while (current != map[count].u.abfd);
+	  while (current != map[count].abfd);
 	}
 
       /* The archive file format only has 4 bytes to store the offset
@@ -2744,7 +2740,7 @@ _bfd_coff_write_armap (bfd *arch,
       /* For each symbol which is used defined in this object, write
 	 out the object file's address in the archive.  */
 
-      while (count < symbol_count && map[count].u.abfd == current)
+      while (count < symbol_count && map[count].abfd == current)
 	{
 	  unsigned int offset = (unsigned int) archive_member_file_ptr;
 
@@ -2802,7 +2798,7 @@ _bfd_coff_write_armap (bfd *arch,
       /* For each symbol which is used defined in this object, write
 	 out the object file's address in the archive.  */
 
-      while (count < symbol_count && map[count].u.abfd == current)
+      while (count < symbol_count && map[count].abfd == current)
 	{
 	  unsigned int offset = (unsigned int) archive_member_file_ptr;
 
Index: binutils-gdb/bfd/archive64.c
===================================================================
--- binutils-gdb.orig/bfd/archive64.c
+++ binutils-gdb/bfd/archive64.c
@@ -226,7 +226,7 @@ _bfd_archive_64_bit_write_armap (bfd *ar
 	 the object file's address in the archive.  */
 
       for (;
-	   count < symbol_count && map[count].u.abfd == current;
+	   count < symbol_count && map[count].abfd == current;
 	   count++)
 	{
 	  bfd_putb64 ((bfd_vma) archive_member_file_ptr, buf);
Index: binutils-gdb/bfd/coff-rs6000.c
===================================================================
--- binutils-gdb.orig/bfd/coff-rs6000.c
+++ binutils-gdb/bfd/coff-rs6000.c
@@ -1929,7 +1929,7 @@ xcoff_write_armap_old (bfd *abfd, unsign
   i = 0;
   archive_iterator_begin (&iterator, abfd);
   while (i < orl_count && archive_iterator_next (&iterator))
-    while (map[i].u.abfd == iterator.current.member)
+    while (map[i].abfd == iterator.current.member)
       {
 	H_PUT_32 (abfd, iterator.current.offset, buf);
 	if (bfd_write (buf, 4, abfd) != 4)
@@ -2054,7 +2054,7 @@ xcoff_write_armap_big (bfd *abfd, unsign
        current_bfd = current_bfd->archive_next)
     {
       arch_info = bfd_get_arch_info (current_bfd);
-      while (map[i].u.abfd == current_bfd)
+      while (map[i].abfd == current_bfd)
 	{
 	  string_length = strlen (*map[i].name) + 1;
 	  if (arch_info->bits_per_address == 64)
@@ -2151,7 +2151,7 @@ xcoff_write_armap_big (bfd *abfd, unsign
       while (i < orl_count && archive_iterator_next (&iterator))
 	{
 	  arch_info = bfd_get_arch_info (iterator.current.member);
-	  while (map[i].u.abfd == iterator.current.member)
+	  while (map[i].abfd == iterator.current.member)
 	    {
 	      if (arch_info->bits_per_address == 32)
 		{
@@ -2169,7 +2169,7 @@ xcoff_write_armap_big (bfd *abfd, unsign
 	   current_bfd = current_bfd->archive_next)
 	{
 	  arch_info = bfd_get_arch_info (current_bfd);
-	  while (map[i].u.abfd == current_bfd)
+	  while (map[i].abfd == current_bfd)
 	    {
 	      if (arch_info->bits_per_address == 32)
 		{
@@ -2235,7 +2235,7 @@ xcoff_write_armap_big (bfd *abfd, unsign
       while (i < orl_count && archive_iterator_next (&iterator))
 	{
 	  arch_info = bfd_get_arch_info (iterator.current.member);
-	  while (map[i].u.abfd == iterator.current.member)
+	  while (map[i].abfd == iterator.current.member)
 	    {
 	      if (arch_info->bits_per_address == 64)
 		{
@@ -2253,7 +2253,7 @@ xcoff_write_armap_big (bfd *abfd, unsign
 	   current_bfd = current_bfd->archive_next)
 	{
 	  arch_info = bfd_get_arch_info (current_bfd);
-	  while (map[i].u.abfd == current_bfd)
+	  while (map[i].abfd == current_bfd)
 	    {
 	      if (arch_info->bits_per_address == 64)
 		{
Index: binutils-gdb/bfd/ecoff.c
===================================================================
--- binutils-gdb.orig/bfd/ecoff.c
+++ binutils-gdb/bfd/ecoff.c
@@ -3174,7 +3174,7 @@ _bfd_ecoff_write_armap (bfd *abfd,
 
       /* Advance firstreal to the file position of this archive
 	 element.  */
-      if (map[i].u.abfd != last_elt)
+      if (map[i].abfd != last_elt)
 	{
 	  do
 	    {
@@ -3182,7 +3182,7 @@ _bfd_ecoff_write_armap (bfd *abfd,
 	      firstreal += firstreal % 2;
 	      current = current->archive_next;
 	    }
-	  while (current != map[i].u.abfd);
+	  while (current != map[i].abfd);
 	}
 
       last_elt = current;
Index: binutils-gdb/bfd/libbfd.h
===================================================================
--- binutils-gdb.orig/bfd/libbfd.h
+++ binutils-gdb/bfd/libbfd.h
@@ -1014,11 +1014,7 @@ extern const struct bfd_iovec _bfd_memor
 struct orl             /* Output ranlib.  */
 {
   char **name;         /* Symbol name.  */
-  union
-  {
-    file_ptr pos;
-    bfd *abfd;
-  } u;                 /* bfd* or file position.  */
+  bfd *abfd;           /* Containing BFD.  */
   int namidx;          /* Index into string table.  */
 };
 



More information about the Binutils mailing list