From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pl1-x631.google.com (mail-pl1-x631.google.com [IPv6:2607:f8b0:4864:20::631]) by sourceware.org (Postfix) with ESMTPS id 606F4382CF2B for ; Fri, 27 May 2022 07:33:06 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 606F4382CF2B Received: by mail-pl1-x631.google.com with SMTP id f18so3495363plg.0 for ; Fri, 27 May 2022 00:33:06 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=z3vAUwVdpT8EjiZRqvucYoJD7ATqilwudHiDx9+a+2Q=; b=x5+Sna6VP3eCCywcYFUeDKdDhwFtHxJakaot0obM9Br4AtI1Rc82YnVVxfUEPY3Py9 yLtXImLOEJTjxcGPUsr6NW4jHJaoMPlYLcyIIJb3c6TFqbivcWThtZ8uXZADOzSHwM96 OJcio3KJLjYH3Ac+CqB8HFmUGRNNQ26Z264xk7cTE+rGOfE7ecd44sMe1yHoRdP42tjy 88OdCON+sYZlBeE/uuA6Be+5SPeEJMr6rpQjOisiySLpu0tXXQcqgboKMViytLasfji6 puY51m9saKiiMS1TqewCceCiXV6sHNcDbwkuTGPZAJNB6Nx6a3F4YLx5NwBzLf4hKcHR KGHQ== X-Gm-Message-State: AOAM531L/mcs5sLxnkru+UqloM23drGnb0ZXRJ0QWhko8MrQaxRZK0fm 3qOIUuG3v1KNj6d5snpQut9LPGvfM+I= X-Google-Smtp-Source: ABdhPJyrGcie+quf1o8uQd14WhbZ9Y0/ZjEN2JdcaSOsKBahZi9ugBqMqR56VguAjC4KdcG2id7KoA== X-Received: by 2002:a17:90b:4acb:b0:1df:af66:1d2 with SMTP id mh11-20020a17090b4acb00b001dfaf6601d2mr6819729pjb.181.1653636784815; Fri, 27 May 2022 00:33:04 -0700 (PDT) Received: from squeak.grove.modra.org ([2406:3400:51d:8cc0:7bdb:83ec:20ab:3eb4]) by smtp.gmail.com with ESMTPSA id b2-20020aa78ec2000000b0051868418b06sm2710564pfr.35.2022.05.27.00.33.03 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 May 2022 00:33:04 -0700 (PDT) Received: by squeak.grove.modra.org (Postfix, from userid 1000) id 8C7611140757; Fri, 27 May 2022 17:03:01 +0930 (ACST) Date: Fri, 27 May 2022 17:03:01 +0930 From: Alan Modra To: binutils@sourceware.org Subject: Replace bfd_hostptr_t with uintptr_t Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-3036.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: binutils@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 27 May 2022 07:33:09 -0000 bfd_hostptr_t is defined as a type large enough to hold either a long or a pointer. It mostly appears in the coff backend code in casts. include/coff/internal.h struct internal_syment and union internal_auxent have the only uses in data structures, where comparison with include/coff/external.h and other code reveals that the type only needs to be large enough for a 32-bit integer or a pointer. That should mean replacing with uintptr_t is OK. diff --git a/bfd/Makefile.in b/bfd/Makefile.in index 9999a07ea9b..741e08d603c 100644 --- a/bfd/Makefile.in +++ b/bfd/Makefile.in @@ -330,7 +330,6 @@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ -BFD_HOSTPTR_T = @BFD_HOSTPTR_T@ BFD_HOST_64BIT_LONG = @BFD_HOST_64BIT_LONG@ CATALOGS = @CATALOGS@ CATOBJEXT = @CATOBJEXT@ diff --git a/bfd/bfd-in.h b/bfd/bfd-in.h index 8c4c838f3f8..dce682af997 100644 --- a/bfd/bfd-in.h +++ b/bfd/bfd-in.h @@ -77,9 +77,6 @@ extern "C" { #define BFD64 #endif -/* Declaring a type wide enough to hold a host long and a host pointer. */ -typedef @BFD_HOSTPTR_T@ bfd_hostptr_t; - /* Forward declaration. */ typedef struct bfd bfd; diff --git a/bfd/bfd-in2.h b/bfd/bfd-in2.h index 8140b50f002..25061e153c7 100644 --- a/bfd/bfd-in2.h +++ b/bfd/bfd-in2.h @@ -84,9 +84,6 @@ extern "C" { #define BFD64 #endif -/* Declaring a type wide enough to hold a host long and a host pointer. */ -typedef @BFD_HOSTPTR_T@ bfd_hostptr_t; - /* Forward declaration. */ typedef struct bfd bfd; diff --git a/bfd/coff-bfd.c b/bfd/coff-bfd.c index 93ded37053d..2152bec182f 100644 --- a/bfd/coff-bfd.c +++ b/bfd/coff-bfd.c @@ -46,7 +46,7 @@ bfd_coff_get_syment (bfd *abfd, if (csym->native->fix_value) psyment->n_value = - ((psyment->n_value - (bfd_hostptr_t) obj_raw_syments (abfd)) + ((psyment->n_value - (uintptr_t) obj_raw_syments (abfd)) / sizeof (combined_entry_type)); /* FIXME: We should handle fix_line here. */ diff --git a/bfd/coffcode.h b/bfd/coffcode.h index 1ffb6032bed..36e07025c6a 100644 --- a/bfd/coffcode.h +++ b/bfd/coffcode.h @@ -4620,7 +4620,7 @@ coff_slurp_symbol_table (bfd * abfd) BFD_ASSERT (src->is_sym); dst->symbol.name = (char *) (src->u.syment._n._n_n._n_offset); /* We use the native name field to point to the cached field. */ - src->u.syment._n._n_n._n_zeroes = (bfd_hostptr_t) dst; + src->u.syment._n._n_n._n_zeroes = (uintptr_t) dst; dst->symbol.section = coff_section_from_bfd_index (abfd, src->u.syment.n_scnum); dst->symbol.flags = 0; @@ -4829,7 +4829,7 @@ coff_slurp_symbol_table (bfd * abfd) to the symbol instead of the index. FIXME: This should use a union. */ src->u.syment.n_value - = (bfd_hostptr_t) (native_symbols + src->u.syment.n_value); + = (uintptr_t) (native_symbols + src->u.syment.n_value); dst->symbol.value = src->u.syment.n_value; src->fix_value = 1; break; diff --git a/bfd/coffgen.c b/bfd/coffgen.c index 0f0a785c72e..c693cfc00cb 100644 --- a/bfd/coffgen.c +++ b/bfd/coffgen.c @@ -803,8 +803,8 @@ coff_mangle_symbols (bfd *bfd_ptr) { /* FIXME: We should use a union here. */ s->u.syment.n_value = - (bfd_hostptr_t) ((combined_entry_type *) - ((bfd_hostptr_t) s->u.syment.n_value))->offset; + (uintptr_t) ((combined_entry_type *) + (uintptr_t) s->u.syment.n_value)->offset; s->fix_value = 0; } if (s->fix_line) @@ -1833,10 +1833,12 @@ coff_get_normalized_symtab (bfd *abfd) if ((bfd_size_type)(aux->u.auxent.x_file.x_n.x_n.x_offset) >= obj_coff_strings_len (abfd)) - internal_ptr->u.syment._n._n_n._n_offset = (bfd_hostptr_t) _(""); + internal_ptr->u.syment._n._n_n._n_offset = + (uintptr_t) _(""); else internal_ptr->u.syment._n._n_n._n_offset = - (bfd_hostptr_t) (string_table + (aux->u.auxent.x_file.x_n.x_n.x_offset)); + (uintptr_t) (string_table + + aux->u.auxent.x_file.x_n.x_n.x_offset); } else { @@ -1846,13 +1848,13 @@ coff_get_normalized_symtab (bfd *abfd) if (internal_ptr->u.syment.n_numaux > 1 && coff_data (abfd)->pe) internal_ptr->u.syment._n._n_n._n_offset = - (bfd_hostptr_t) - copy_name (abfd, - aux->u.auxent.x_file.x_n.x_fname, - internal_ptr->u.syment.n_numaux * symesz); + ((uintptr_t) + copy_name (abfd, + aux->u.auxent.x_file.x_n.x_fname, + internal_ptr->u.syment.n_numaux * symesz)); else internal_ptr->u.syment._n._n_n._n_offset = - ((bfd_hostptr_t) + ((uintptr_t) copy_name (abfd, aux->u.auxent.x_file.x_n.x_fname, (size_t) bfd_coff_filnmlen (abfd))); @@ -1877,14 +1879,16 @@ coff_get_normalized_symtab (bfd *abfd) if ((bfd_size_type)(aux->u.auxent.x_file.x_n.x_n.x_offset) >= obj_coff_strings_len (abfd)) - aux->u.auxent.x_file.x_n.x_n.x_offset = (bfd_hostptr_t) _(""); + aux->u.auxent.x_file.x_n.x_n.x_offset = + (uintptr_t) _(""); else aux->u.auxent.x_file.x_n.x_n.x_offset = - (bfd_hostptr_t) (string_table + (aux->u.auxent.x_file.x_n.x_n.x_offset)); + (uintptr_t) (string_table + + (aux->u.auxent.x_file.x_n.x_n.x_offset)); } else aux->u.auxent.x_file.x_n.x_n.x_offset = - ((bfd_hostptr_t) + ((uintptr_t) copy_name (abfd, aux->u.auxent.x_file.x_n.x_fname, (size_t) bfd_coff_filnmlen (abfd))); @@ -1909,11 +1913,11 @@ coff_get_normalized_symtab (bfd *abfd) if (newstring == NULL) return NULL; strncpy (newstring, internal_ptr->u.syment._n._n_name, i); - internal_ptr->u.syment._n._n_n._n_offset = (bfd_hostptr_t) newstring; + internal_ptr->u.syment._n._n_n._n_offset = (uintptr_t) newstring; internal_ptr->u.syment._n._n_n._n_zeroes = 0; } else if (internal_ptr->u.syment._n._n_n._n_offset == 0) - internal_ptr->u.syment._n._n_n._n_offset = (bfd_hostptr_t) ""; + internal_ptr->u.syment._n._n_n._n_offset = (uintptr_t) ""; else if (!bfd_coff_symname_in_debug (abfd, &internal_ptr->u.syment)) { /* Long name already. Point symbol at the string in the @@ -1926,12 +1930,12 @@ coff_get_normalized_symtab (bfd *abfd) } if (internal_ptr->u.syment._n._n_n._n_offset >= obj_coff_strings_len (abfd) || string_table + internal_ptr->u.syment._n._n_n._n_offset < string_table) - internal_ptr->u.syment._n._n_n._n_offset = (bfd_hostptr_t) _(""); + internal_ptr->u.syment._n._n_n._n_offset = + (uintptr_t) _(""); else internal_ptr->u.syment._n._n_n._n_offset = - ((bfd_hostptr_t) - (string_table - + internal_ptr->u.syment._n._n_n._n_offset)); + ((uintptr_t) (string_table + + internal_ptr->u.syment._n._n_n._n_offset)); } else { @@ -1944,13 +1948,15 @@ coff_get_normalized_symtab (bfd *abfd) /* PR binutils/17512: Catch out of range offsets into the debug data. */ if (internal_ptr->u.syment._n._n_n._n_offset > debug_sec->size || debug_sec_data + internal_ptr->u.syment._n._n_n._n_offset < debug_sec_data) - internal_ptr->u.syment._n._n_n._n_offset = (bfd_hostptr_t) _(""); + internal_ptr->u.syment._n._n_n._n_offset = + (uintptr_t) _(""); else - internal_ptr->u.syment._n._n_n._n_offset = (bfd_hostptr_t) - (debug_sec_data + internal_ptr->u.syment._n._n_n._n_offset); + internal_ptr->u.syment._n._n_n._n_offset = + (uintptr_t) (debug_sec_data + + internal_ptr->u.syment._n._n_n._n_offset); } else - internal_ptr->u.syment._n._n_n._n_offset = (bfd_hostptr_t) ""; + internal_ptr->u.syment._n._n_n._n_offset = (uintptr_t) ""; } } internal_ptr += internal_ptr->u.syment.n_numaux; @@ -2035,8 +2041,8 @@ coff_get_symbol_info (bfd *abfd, asymbol *symbol, symbol_info *ret) && coffsymbol (symbol)->native->fix_value && coffsymbol (symbol)->native->is_sym) ret->value - = (((bfd_hostptr_t) coffsymbol (symbol)->native->u.syment.n_value - - (bfd_hostptr_t) obj_raw_syments (abfd)) + = (((uintptr_t) coffsymbol (symbol)->native->u.syment.n_value + - (uintptr_t) obj_raw_syments (abfd)) / sizeof (combined_entry_type)); } @@ -2085,8 +2091,7 @@ coff_print_symbol (bfd *abfd, if (! combined->fix_value) val = (bfd_vma) combined->u.syment.n_value; else - val = (((bfd_hostptr_t) combined->u.syment.n_value - - (bfd_hostptr_t) root) + val = (((uintptr_t) combined->u.syment.n_value - (uintptr_t) root) / sizeof (combined_entry_type)); fprintf (file, "(sec %2d)(fl 0x%02x)(ty %4x)(scl %3d) (nx %d) 0x", diff --git a/bfd/configure b/bfd/configure index a0071d97b68..3d2656229e5 100755 --- a/bfd/configure +++ b/bfd/configure @@ -656,7 +656,6 @@ zlibinc zlibdir EXEEXT_FOR_BUILD CC_FOR_BUILD -BFD_HOSTPTR_T BFD_HOST_64BIT_LONG HDEFINES MSGMERGE @@ -11088,7 +11087,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 11091 "configure" +#line 11090 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -11194,7 +11193,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 11197 "configure" +#line 11196 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -12843,18 +12842,12 @@ if test "x${ac_cv_sizeof_void_p}" = "x8"; then fi BFD_HOST_64BIT_LONG=0 -BFD_HOSTPTR_T="unsigned long" if test "x${ac_cv_sizeof_long}" = "x8"; then BFD_HOST_64BIT_LONG=1 -elif test "x${ac_cv_sizeof_long_long}" = "x8"; then - if test "x${ac_cv_sizeof_void_p}" = "x8"; then - BFD_HOSTPTR_T="unsigned long long" - fi fi - # Put a plausible default for CC_FOR_BUILD in Makefile. if test -z "$CC_FOR_BUILD"; then if test "x$cross_compiling" = "xno"; then diff --git a/bfd/configure.ac b/bfd/configure.ac index 52e9f8f8dcc..8ad0e05959d 100644 --- a/bfd/configure.ac +++ b/bfd/configure.ac @@ -219,17 +219,11 @@ if test "x${ac_cv_sizeof_void_p}" = "x8"; then fi BFD_HOST_64BIT_LONG=0 -BFD_HOSTPTR_T="unsigned long" if test "x${ac_cv_sizeof_long}" = "x8"; then BFD_HOST_64BIT_LONG=1 -elif test "x${ac_cv_sizeof_long_long}" = "x8"; then - if test "x${ac_cv_sizeof_void_p}" = "x8"; then - BFD_HOSTPTR_T="unsigned long long" - fi fi AC_SUBST(BFD_HOST_64BIT_LONG) -AC_SUBST(BFD_HOSTPTR_T) BFD_CC_FOR_BUILD diff --git a/bfd/configure.com b/bfd/configure.com index 2418bddd8af..cc8499a4589 100644 --- a/bfd/configure.com +++ b/bfd/configure.com @@ -66,12 +66,6 @@ $DECK ERASE(match_pos); COPY_TEXT('0'); ENDIF; - match_pos := SEARCH_QUIETLY('@BFD_HOSTPTR_T@', FORWARD, EXACT, rang); - IF match_pos <> 0 THEN; - POSITION(BEGINNING_OF(match_pos)); - ERASE(match_pos); - COPY_TEXT('unsigned __int64'); - ENDIF; match_pos := SEARCH_QUIETLY('@bfd_file_ptr@', FORWARD, EXACT, rang); IF match_pos <> 0 THEN; POSITION(BEGINNING_OF(match_pos)); diff --git a/bfd/elflink.c b/bfd/elflink.c index fc3a335c72d..e4f6df43042 100644 --- a/bfd/elflink.c +++ b/bfd/elflink.c @@ -8372,8 +8372,7 @@ elf_create_symbuf (size_t symcount, Elf_Internal_Sym *isymbuf) ssymhead->count++; } BFD_ASSERT ((size_t) (ssymhead - ssymbuf) == shndx_count - && (((bfd_hostptr_t) ssym - (bfd_hostptr_t) ssymbuf) - == total_size)); + && (uintptr_t) ssym - (uintptr_t) ssymbuf == total_size); free (indbuf); return ssymbuf; diff --git a/bfd/peicode.h b/bfd/peicode.h index 0346bc2174e..02573c84694 100644 --- a/bfd/peicode.h +++ b/bfd/peicode.h @@ -588,7 +588,7 @@ pe_ILF_make_a_symbol (pe_ILF_vars * vars, /* Initialise the internal symbol structure. */ ent->u.syment.n_sclass = sclass; ent->u.syment.n_scnum = section->target_index; - ent->u.syment._n._n_n._n_offset = (bfd_hostptr_t) sym; + ent->u.syment._n._n_n._n_offset = (uintptr_t) sym; ent->is_sym = true; sym->symbol.the_bfd = vars->abfd; diff --git a/gas/symbols.c b/gas/symbols.c index fb480be6f21..e3fddee8c79 100644 --- a/gas/symbols.c +++ b/gas/symbols.c @@ -3023,7 +3023,7 @@ print_symbol_value_1 (FILE *file, symbolS *sym) if (!name || !name[0]) name = "(unnamed)"; fprintf (file, "sym "); - fprintf_vma (file, (bfd_vma) ((bfd_hostptr_t) sym)); + fprintf_vma (file, (bfd_vma) (uintptr_t) sym); fprintf (file, " %s", name); if (sym->flags.local_symbol) @@ -3034,7 +3034,7 @@ print_symbol_value_1 (FILE *file, symbolS *sym) && locsym->frag != NULL) { fprintf (file, " frag "); - fprintf_vma (file, (bfd_vma) ((bfd_hostptr_t) locsym->frag)); + fprintf_vma (file, (bfd_vma) (uintptr_t) locsym->frag); } if (locsym->flags.resolved) fprintf (file, " resolved"); @@ -3045,7 +3045,7 @@ print_symbol_value_1 (FILE *file, symbolS *sym) if (sym->frag != &zero_address_frag) { fprintf (file, " frag "); - fprintf_vma (file, (bfd_vma) ((bfd_hostptr_t) sym->frag)); + fprintf_vma (file, (bfd_vma) (uintptr_t) sym->frag); } if (sym->flags.written) fprintf (file, " written"); @@ -3121,7 +3121,7 @@ void print_expr_1 (FILE *file, expressionS *exp) { fprintf (file, "expr "); - fprintf_vma (file, (bfd_vma) ((bfd_hostptr_t) exp)); + fprintf_vma (file, (bfd_vma) (uintptr_t) exp); fprintf (file, " "); switch (exp->X_op) { diff --git a/gas/write.c b/gas/write.c index f607562794a..20f5ce24d5f 100644 --- a/gas/write.c +++ b/gas/write.c @@ -3212,7 +3212,7 @@ print_fixup (fixS *fixp) { indent_level = 1; fprintf (stderr, "fix "); - fprintf_vma (stderr, (bfd_vma)((bfd_hostptr_t) fixp)); + fprintf_vma (stderr, (bfd_vma) (uintptr_t) fixp); fprintf (stderr, " %s:%d",fixp->fx_file, fixp->fx_line); if (fixp->fx_pcrel) fprintf (stderr, " pcrel"); @@ -3223,7 +3223,7 @@ print_fixup (fixS *fixp) if (fixp->fx_done) fprintf (stderr, " done"); fprintf (stderr, "\n size=%d frag=", fixp->fx_size); - fprintf_vma (stderr, (bfd_vma) ((bfd_hostptr_t) fixp->fx_frag)); + fprintf_vma (stderr, (bfd_vma) (uintptr_t) fixp->fx_frag); fprintf (stderr, " where=%ld offset=%lx addnumber=%lx", (long) fixp->fx_where, (unsigned long) fixp->fx_offset, diff --git a/include/coff/internal.h b/include/coff/internal.h index 4d2046ee090..4e031915502 100644 --- a/include/coff/internal.h +++ b/include/coff/internal.h @@ -469,8 +469,8 @@ struct internal_syment char _n_name[SYMNMLEN] ATTRIBUTE_NONSTRING; /* old COFF version */ struct { - bfd_hostptr_t _n_zeroes; /* new == 0 */ - bfd_hostptr_t _n_offset; /* offset into string table */ + uintptr_t _n_zeroes; /* new == 0 */ + uintptr_t _n_offset; /* offset into string table */ } _n_n; char *_n_nptr[2]; /* allows for overlaying */ } _n; @@ -595,11 +595,11 @@ union internal_auxent char x_fname[20]; struct { - /* PR 28630: We use bfd_hostptr_t because these fields may be + /* PR 28630: We use uintptr_t because these fields may be used to hold pointers. We assume that this type is at least - as big as the long type. */ - bfd_hostptr_t x_zeroes; - bfd_hostptr_t x_offset; + 32 bits. */ + uintptr_t x_zeroes; + uintptr_t x_offset; } x_n; } x_n; -- Alan Modra Australia Development Lab, IBM