[PATCH v3 07/18] BFD: Make file offset unsigned in archive symbols
Maciej W. Rozycki
macro@orcam.me.uk
Thu Nov 20 10:56:23 GMT 2025
From: Maciej W. Rozycki <macro@redhat.com>
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.
---
No change from v2 (06/16),
<https://inbox.sourceware.org/binutils/alpine.DEB.2.21.2511060319210.25436@angie.orcam.me.uk/>.
New change in v2.
---
bfd/archive.c | 2 +-
bfd/bfd-in2.h | 2 +-
bfd/elflink.c | 4 ++--
bfd/linker.c | 2 +-
bfd/vms-lib.c | 2 +-
5 files changed, 6 insertions(+), 6 deletions(-)
binutils-bfd-carsym-ufile-ptr.diff
Index: binutils-gdb/bfd/archive.c
===================================================================
--- binutils-gdb.orig/bfd/archive.c
+++ binutils-gdb/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;
.
Index: binutils-gdb/bfd/bfd-in2.h
===================================================================
--- binutils-gdb.orig/bfd/bfd-in2.h
+++ binutils-gdb/bfd/bfd-in2.h
@@ -1285,7 +1285,7 @@ bool bfd_copy_private_symbol_data
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;
Index: binutils-gdb/bfd/elflink.c
===================================================================
--- binutils-gdb.orig/bfd/elflink.c
+++ binutils-gdb/bfd/elflink.c
@@ -6273,13 +6273,13 @@ elf_link_add_archive_symbols (bfd *abfd,
do
{
- file_ptr last;
+ ufile_ptr last;
symindex i;
carsym *symdef;
carsym *symdefend;
loop = false;
- last = -1;
+ last = ~0ULL;
symdef = symdefs;
symdefend = symdef + c;
Index: binutils-gdb/bfd/linker.c
===================================================================
--- binutils-gdb.orig/bfd/linker.c
+++ binutils-gdb/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 = ~0ULL;
bool needed = false;
bfd *element = NULL;
Index: binutils-gdb/bfd/vms-lib.c
===================================================================
--- binutils-gdb.orig/bfd/vms-lib.c
+++ binutils-gdb/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
mailing list