[PATCH v4 06/14] BFD: Make file offset unsigned in archive symbols
Maciej W. Rozycki
macro@orcam.me.uk
Tue Jan 13 01:44:44 GMT 2026
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.
---
Changes from v3 (07/18),
<https://inbox.sourceware.org/binutils/alpine.DEB.2.21.2511192125460.57987@angie.orcam.me.uk/>:
- Retain the starting archive member file pointer value at -1, discarding
the change previously made.
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 | 2 +-
bfd/linker.c | 2 +-
bfd/vms-lib.c | 2 +-
5 files changed, 5 insertions(+), 5 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
@@ -1278,7 +1278,7 @@ void bfd_symbol_info (asymbol *symbol, s
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
@@ -6285,7 +6285,7 @@ elf_link_add_archive_symbols (bfd *abfd,
do
{
- file_ptr last;
+ ufile_ptr last;
symindex i;
carsym *symdef;
carsym *symdefend;
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 = -1;
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