[PATCH 4/8] BFD: Add BFD pointer member to `struct carsym'

Jan Beulich jbeulich@suse.com
Fri Oct 17 13:09:36 GMT 2025


On 27.09.2025 01:53, Maciej W. Rozycki wrote:
> From: Maciej W. Rozycki <macro@redhat.com>
> 
> Replace the file offset with a union of one and a BFD pointer in `struct 
> carsym', as a preparation to handle symbol maps built on the fly rather 
> than fetched from a file.  No functional change.
> 
> NB there's a note on `struct carsym' being a type pun on `struct symdef' 
> as in include/aout/ranlib.h (or `struct ranlib'; no idea where it comes 
> from).  With this code update in place it is possibly not true anymore, 
> depending on the underlying type of `file_ptr'.  This is not a problem 
> however, because we always process `struct carsym' data by hand and only 
> use it internally rather than reading/writing from/to a file.  Therefore 
> only remove the note, as no longer applicable.

It wasn't quite true already before, as file_ptr != unsigned long (in the
general case).

> --- binutils-gdb.orig/bfd/archive.c
> +++ binutils-gdb/bfd/archive.c
> @@ -149,12 +149,19 @@ extern int errno;
>  
>  /*
>  EXTERNAL
> +.{* Holds a file position or bfd* depending on context.  *}
> +.typedef union file_ptr_or_bfd
> +.{
> +.  file_ptr file_offset;
> +.  bfd *abfd;
> +.}
> +.file_ptr_or_bfd;

The comment is too little for my taste, I'm afraid. How would one know which
of the two it is, merely seeing an instance of this type?

Jan


More information about the Binutils mailing list