[binutils-gdb] BFD: Make file offset unsigned in archive symbols

Maciej W. Rozycki macro@sourceware.org
Fri Feb 20 17:42:32 GMT 2026


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

commit 7de6c7fcb0517f76f178115dca20f8c218d16983
Author: Maciej W. Rozycki <macro@redhat.com>
Date:   Fri Feb 20 17:29:50 2026 +0000

    BFD: Make file offset unsigned in archive symbols
    
    We seem to be quite lax in flipping between signed and unsigned file
    offsets in archive handling.  As member positions within an archive
    cannot be negative it makes little to no sense to keep such values in
    structures, as their existence is supposed to be transient only where a
    function call returns one to indicate a failure.  Such failures need to
    be handled appropriately of course, but there's no point in storing the
    error indicator as a symbol location reference.
    
    Switch the data type for the file offset embedded in the archive symbol
    structure from signed to unsigned then, in preparation to unify archive
    location references with a later change.  Update code where necessary
    accordingly.  No functional change.

Diff:
---
 bfd/archive.c | 2 +-
 bfd/bfd-in2.h | 2 +-
 bfd/elflink.c | 2 +-
 bfd/linker.c  | 2 +-
 bfd/vms-lib.c | 2 +-
 5 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/bfd/archive.c b/bfd/archive.c
index fc1f1ac5685..c92ad519e24 100644
--- a/bfd/archive.c
+++ b/bfd/archive.c
@@ -154,7 +154,7 @@ EXTERNAL
 .typedef struct carsym
 .{
 .  const char *name;
-.  file_ptr file_offset;	{* Look here to find the file.  *}
+.  ufile_ptr file_offset;	{* Look here to find the file.  *}
 .}
 .carsym;
 .
diff --git a/bfd/bfd-in2.h b/bfd/bfd-in2.h
index d4e4f8e4375..b0eaafec98d 100644
--- a/bfd/bfd-in2.h
+++ b/bfd/bfd-in2.h
@@ -1278,7 +1278,7 @@ void bfd_symbol_info (asymbol *symbol, symbol_info *ret);
 typedef struct carsym
 {
   const char *name;
-  file_ptr file_offset;        /* Look here to find the file.  */
+  ufile_ptr file_offset;       /* Look here to find the file.  */
 }
 carsym;
 
diff --git a/bfd/elflink.c b/bfd/elflink.c
index 78751f957c4..29ebe41204e 100644
--- a/bfd/elflink.c
+++ b/bfd/elflink.c
@@ -6286,7 +6286,7 @@ elf_link_add_archive_symbols (bfd *abfd, struct bfd_link_info *info)
 
   do
     {
-      file_ptr last;
+      ufile_ptr last;
       symindex i;
       carsym *symdef;
       carsym *symdefend;
diff --git a/bfd/linker.c b/bfd/linker.c
index 3e0beb04c33..b905749d777 100644
--- a/bfd/linker.c
+++ b/bfd/linker.c
@@ -960,7 +960,7 @@ _bfd_generic_link_add_archive_symbols
       carsym *arsym_end;
       carsym *arsym;
       unsigned int indx;
-      file_ptr last_ar_offset = -1;
+      ufile_ptr last_ar_offset = -1;
       bool needed = false;
       bfd *element = NULL;
 
diff --git a/bfd/vms-lib.c b/bfd/vms-lib.c
index 038c83344b4..ca82f2a63ac 100644
--- a/bfd/vms-lib.c
+++ b/bfd/vms-lib.c
@@ -1479,7 +1479,7 @@ bfd *
 _bfd_vms_lib_get_elt_at_index (bfd *abfd, symindex symidx)
 {
   struct lib_tdata *tdata = bfd_libdata (abfd);
-  file_ptr file_off;
+  ufile_ptr file_off;
   unsigned int modidx;
 
   /* Check symidx.  */


More information about the Binutils-cvs mailing list