From patchwork Fri Jan 6 10:44:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alan Modra X-Patchwork-Id: 40086 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp754982wrt; Fri, 6 Jan 2023 02:44:21 -0800 (PST) X-Google-Smtp-Source: AMrXdXvXrJ5RTB0xMmNSD7mEeQ/Sdw9FS1hiXvnVT43yHhUvaA9W0O3w9M0FeOSecQhAf95hMuyu X-Received: by 2002:a05:6402:3201:b0:48e:a96c:fd64 with SMTP id g1-20020a056402320100b0048ea96cfd64mr14647367eda.25.1673001861300; Fri, 06 Jan 2023 02:44:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673001861; cv=none; d=google.com; s=arc-20160816; b=r5Jtymn7P8hFIxg+768Gm19Z1r1QdL2b2rjrgUeWAIDJXqcOv9u9uPtFGdiq67him3 4hIqL+q/MY1SvqlTDstjxTZlJypVaYeDltZuzwaqWVFsvtMknb2XpoZBE78qEEnOk91d LAXJ1z+tva+LdthrFyuhAS7Tg+fvODU07hY5yokUOm7ZH01Lg8FXb+F2pQXW8+9OXCkV 0veAPixoeGAP7jxe0k1G74JwTEZCLWjCldZiM3LEKVA9Ji1TMgvXKVi8S8eOMtHX0o/6 9KwsePjH/Y7UgcJKeQLAHNAqde/tXkpiYqxjYq/tapg8rafYvJ+xZKxTx+VzZPAlN2E8 yK3g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-disposition:mime-version:message-id:subject:to:date :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=McMVLRGG4uc2hPaq9XpFLYyPWiKIE+TcwXynwr7wEfM=; b=SXi9sWvVLEXKfdoVLwR+AYiqFMh4W0Dygwcz6YXC+qD4v2Q/BGeldQfV7Wl920/R9+ OkTeMUcMUDD94Gig7dQT9UuLGI5jTNWv73LIHaZa/Gfje90pe7tMDw3SEUNTBrZh7Uet PlvXqstsgFAhhl43Uq/w+CMA/pX9lKP3RsCRg20P/OKKLoYfMRHBLQDRHCiMfgtL1KRp pt6U/q9WzZ88/pmc/7vmVXdT0KrqaBk32Is6XUSiq+eCovZaxzaCQDfp705j0oC6EPZX mQVPShm74hPSYKSWeCJ806LK8HA1Y7GBDgmHO7AqG1fAn+kFc3AGQq6IzOVobEvN/pBm wauA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b="j6vTBa/L"; spf=pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="binutils-bounces+ouuuleilei=gmail.com@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=sourceware.org Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id q20-20020a056402519400b0046abbd721e4si1234788edd.300.2023.01.06.02.44.21 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Jan 2023 02:44:21 -0800 (PST) Received-SPF: pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b="j6vTBa/L"; spf=pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="binutils-bounces+ouuuleilei=gmail.com@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 4D9B7385840D for ; Fri, 6 Jan 2023 10:44:15 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4D9B7385840D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1673001855; bh=McMVLRGG4uc2hPaq9XpFLYyPWiKIE+TcwXynwr7wEfM=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=j6vTBa/L+t+rG1D+rCDPk4wnyCGRQY2GmbPYicLljWzYHWNO8njTCItq2YGnmgQEq xQqiipVQrJgjIwieoHgfE6YgjGJtUKPz7Lvvfr+h8CyG6X5o3seeqY8CCvoEIWemFQ OnjgMrGuZhrpBEVBsmwuy08629g8NMrSPfCI2BIM= X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from mail-pj1-x102c.google.com (mail-pj1-x102c.google.com [IPv6:2607:f8b0:4864:20::102c]) by sourceware.org (Postfix) with ESMTPS id 98C693858C39 for ; Fri, 6 Jan 2023 10:44:06 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 98C693858C39 Received: by mail-pj1-x102c.google.com with SMTP id w4-20020a17090ac98400b002186f5d7a4cso4890928pjt.0 for ; Fri, 06 Jan 2023 02:44:06 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-disposition:mime-version:message-id:subject:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=McMVLRGG4uc2hPaq9XpFLYyPWiKIE+TcwXynwr7wEfM=; b=76U+VfLH2/hgZfqUPmkh0zMTJqme87n5l99gWmeFN5VPy8TMjXtAXjcMat9il5Yjgo gvwSt7f2tO7klq3UpuqT4g7ESyXOoRfR5JxVxl8mMYlBhHPOipuTNELMzJv1jlQ/3B5k +WxDOgTM7TN79pRNTuc5NqIOASHthF12lxorN/7AAlng71e1xh4ENWbOnCOz3SbYnJag VK31NAtJQdrgyau5gczUkMpfzO3HsAO/ae4YBTlw9GuRUYpI5L7RDqpIBcMeOoGbswjp BocwwuGqhNWdKQ7SFLoDKZKIuMKBFU0+AkMVcQ/GlZg9JYJUfU9JQNnXsYYhd5MtJNB1 eLjA== X-Gm-Message-State: AFqh2krQuhsw05RpaLBUEmzSa99qai2HADECrWIa6OSIlMDL9u8mEG4M pV2en1sEc7irTNzJxpnl6y8rs1Fu9ZY= X-Received: by 2002:a17:902:ccc1:b0:189:8002:5f59 with SMTP id z1-20020a170902ccc100b0018980025f59mr88703279ple.57.1673001845367; Fri, 06 Jan 2023 02:44:05 -0800 (PST) Received: from squeak.grove.modra.org ([2406:3400:51d:8cc0:41be:7f9c:b8e8:bcf6]) by smtp.gmail.com with ESMTPSA id w23-20020a1709026f1700b00172f6726d8esm586334plk.277.2023.01.06.02.44.04 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Jan 2023 02:44:05 -0800 (PST) Received: by squeak.grove.modra.org (Postfix, from userid 1000) id B096D1142D98; Fri, 6 Jan 2023 21:14:02 +1030 (ACDT) Date: Fri, 6 Jan 2023 21:14:02 +1030 To: binutils@sourceware.org Subject: Tidy pe flag in coff_data Message-ID: MIME-Version: 1.0 Content-Disposition: inline X-Spam-Status: No, score=-3034.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 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-Patchwork-Original-From: Alan Modra via Binutils From: Alan Modra Reply-To: Alan Modra Errors-To: binutils-bounces+ouuuleilei=gmail.com@sourceware.org Sender: "Binutils" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1754269600052796653?= X-GMAIL-MSGID: =?utf-8?q?1754269600052796653?= Make it a bool, use obj_pe accessor everywhere. diff --git a/bfd/coff-arm.c b/bfd/coff-arm.c index c0b2b04b26a..694ae8daa08 100644 --- a/bfd/coff-arm.c +++ b/bfd/coff-arm.c @@ -953,7 +953,7 @@ arm_emit_base_file_entry (struct bfd_link_info *info, + input_section->output_offset + input_section->output_section->vma); - if (coff_data (output_bfd)->pe) + if (obj_pe (output_bfd)) addr -= pe_data (output_bfd)->pe_opthdr.ImageBase; if (fwrite (&addr, sizeof (addr), 1, (FILE *) info->base_file) == 1) return true; diff --git a/bfd/coff-mcore.c b/bfd/coff-mcore.c index 561333d596b..e360d5efe14 100644 --- a/bfd/coff-mcore.c +++ b/bfd/coff-mcore.c @@ -220,7 +220,7 @@ mcore_emit_base_file_entry (struct bfd_link_info *info, + input_section->output_offset + input_section->output_section->vma; - if (coff_data (output_bfd)->pe) + if (obj_pe (output_bfd)) addr -= pe_data (output_bfd)->pe_opthdr.ImageBase; if (fwrite (&addr, sizeof (addr), 1, (FILE *) info->base_file) == 1) diff --git a/bfd/coffgen.c b/bfd/coffgen.c index 74636a9e305..f21cf2ca523 100644 --- a/bfd/coffgen.c +++ b/bfd/coffgen.c @@ -1826,8 +1826,7 @@ coff_get_normalized_symtab (bfd *abfd) /* Ordinary short filename, put into memory anyway. The Microsoft PE tools sometimes store a filename in multiple AUX entries. */ - if (internal_ptr->u.syment.n_numaux > 1 - && coff_data (abfd)->pe) + if (internal_ptr->u.syment.n_numaux > 1 && obj_pe (abfd)) internal_ptr->u.syment._n._n_n._n_offset = ((uintptr_t) copy_name (abfd, @@ -1842,7 +1841,7 @@ coff_get_normalized_symtab (bfd *abfd) } /* Normalize other strings available in C_FILE aux entries. */ - if (!coff_data (abfd)->pe) + if (!obj_pe (abfd)) for (int numaux = 1; numaux < internal_ptr->u.syment.n_numaux; numaux++) { aux = internal_ptr + numaux + 1; diff --git a/bfd/cofflink.c b/bfd/cofflink.c index d6ccae4ffe2..07226882e0d 100644 --- a/bfd/cofflink.c +++ b/bfd/cofflink.c @@ -1168,7 +1168,7 @@ _bfd_coff_final_link (bfd *abfd, static char * dores_com (char *ptr, bfd *output_bfd, int heap) { - if (coff_data(output_bfd)->pe) + if (obj_pe (output_bfd)) { int val = strtoul (ptr, &ptr, 0); @@ -1400,7 +1400,7 @@ _bfd_coff_link_input_bfd (struct coff_final_link_info *flaginfo, bfd *input_bfd) output_index = syment_base; outsym = flaginfo->outsyms; - if (coff_data (output_bfd)->pe + if (obj_pe (output_bfd) && ! process_embedded_commands (output_bfd, flaginfo->info, input_bfd)) return false; @@ -3057,7 +3057,7 @@ _bfd_coff_generic_relocate_section (bfd *output_bfd, - input_section->vma + input_section->output_offset + input_section->output_section->vma); - if (coff_data (output_bfd)->pe) + if (obj_pe (output_bfd)) addr -= pe_data(output_bfd)->pe_opthdr.ImageBase; if (fwrite (&addr, 1, sizeof (bfd_vma), (FILE *) info->base_file) != sizeof (bfd_vma)) diff --git a/bfd/coffswap.h b/bfd/coffswap.h index e809deaf0ef..03f52bd0486 100644 --- a/bfd/coffswap.h +++ b/bfd/coffswap.h @@ -426,7 +426,7 @@ coff_swap_aux_in (bfd *abfd, #if FILNMLEN != E_FILNMLEN #error we need to cope with truncating or extending FILNMLEN #else - if (numaux > 1 && coff_data (abfd)->pe) + if (numaux > 1 && obj_pe (abfd)) { if (indx == 0) memcpy (in->x_file.x_n.x_fname, ext->x_file.x_fname, diff --git a/bfd/libcoff-in.h b/bfd/libcoff-in.h index d27e5d4394f..a0d286d37f4 100644 --- a/bfd/libcoff-in.h +++ b/bfd/libcoff-in.h @@ -101,7 +101,7 @@ typedef struct coff_tdata bool go32; /* Is this a PE format coff file? */ - int pe; + bool pe; /* Copy of some of the f_flags bits in the COFF filehdr structure, used by ARM code. */ diff --git a/bfd/libcoff.h b/bfd/libcoff.h index f03330fcfa0..c2c1f4add3a 100644 --- a/bfd/libcoff.h +++ b/bfd/libcoff.h @@ -105,7 +105,7 @@ typedef struct coff_tdata bool go32; /* Is this a PE format coff file? */ - int pe; + bool pe; /* Copy of some of the f_flags bits in the COFF filehdr structure, used by ARM code. */ diff --git a/bfd/peicode.h b/bfd/peicode.h index cc5a54e1843..06642c3db5a 100644 --- a/bfd/peicode.h +++ b/bfd/peicode.h @@ -1090,7 +1090,7 @@ pe_ILF_build_a_bfd (bfd * abfd, if (bfd_coff_mkobject_hook (abfd, (void *) & internal_f, NULL) == NULL) goto error_return; - coff_data (abfd)->pe = 1; + obj_pe (abfd) = true; #ifdef THUMBPEMAGIC if (vars.magic == THUMBPEMAGIC) /* Stop some linker warnings about thumb code not supporting interworking. */ diff --git a/ld/emultempl/beos.em b/ld/emultempl/beos.em index 1f3b67b6372..521d92797ec 100644 --- a/ld/emultempl/beos.em +++ b/ld/emultempl/beos.em @@ -379,7 +379,7 @@ gld${EMULATION_NAME}_after_open (void) /* Pass the wacky PE command line options into the output bfd. FIXME: This should be done via a function, rather than by including an internal BFD header. */ - if (!coff_data(link_info.output_bfd)->pe) + if (!obj_pe (link_info.output_bfd)) { einfo (_("%F%P: PE operations on non PE file\n")); } diff --git a/ld/emultempl/pe.em b/ld/emultempl/pe.em index d201a97dac1..bce1d1b9052 100644 --- a/ld/emultempl/pe.em +++ b/ld/emultempl/pe.em @@ -1515,7 +1515,7 @@ gld${EMULATION_NAME}_after_open (void) if (bfd_get_flavour (link_info.output_bfd) != bfd_target_coff_flavour || coff_data (link_info.output_bfd) == NULL - || coff_data (link_info.output_bfd)->pe == 0) + || !obj_pe (link_info.output_bfd)) einfo (_("%F%P: cannot perform PE operations on non PE output file '%pB'\n"), link_info.output_bfd); diff --git a/ld/emultempl/pep.em b/ld/emultempl/pep.em index d61cab86d75..69b1c3ec79b 100644 --- a/ld/emultempl/pep.em +++ b/ld/emultempl/pep.em @@ -1519,7 +1519,7 @@ gld${EMULATION_NAME}_after_open (void) if (bfd_get_flavour (link_info.output_bfd) != bfd_target_coff_flavour || coff_data (link_info.output_bfd) == NULL - || coff_data (link_info.output_bfd)->pe == 0) + || !obj_pe (link_info.output_bfd)) einfo (_("%F%P: cannot perform PE operations on non PE output file '%pB'\n"), link_info.output_bfd);