From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pj1-x102d.google.com (mail-pj1-x102d.google.com [IPv6:2607:f8b0:4864:20::102d]) by sourceware.org (Postfix) with ESMTPS id B62C93857C50 for ; Wed, 20 Apr 2022 14:32:39 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org B62C93857C50 Received: by mail-pj1-x102d.google.com with SMTP id u5-20020a17090a6a8500b001d0b95031ebso2192093pjj.3 for ; Wed, 20 Apr 2022 07:32:39 -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:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to; bh=NbAZf8pLVDkTTcYyF22Z+8X9CLQkTfMpYsPEBTgTcvs=; b=OER+8UQkJkQj7c2CFSLRRXg5mMt/zsncRye7/DjMjLIiaJu4H59h0lLPMjh7N0o4dh fPGKSTOGxvWFEx8nFQJMoW/lXIZ8NE0DuiotvxuzDouBL5wRS+kdG3CyWBz7ZMkm7L38 faxTll15AZXxMM4lg0JVAWs8k36WuQ+LLWYWbch3zVScik6UDzNKJTkbwQbnrLQlIv00 ZXq8Afa2QTBqYsI5kRqKk2wG+6njLMKU+qQZhtSwyGekq5p0R9HUfcH75cGH2SXvUOSS SDUF0ojJCZdhJrU7MWyd+8oENF7SVPXnY/U1fkvL97GATRtEs0S+vwI+R13TOzTP1zzF Xymg== X-Gm-Message-State: AOAM530AX/lEC+eLZkA2qiK+OU96c1Yk3IAFEmfah5rrfwx9TRu1HgSh qn+bIW+un2tw+wW4F5k4UyY= X-Google-Smtp-Source: ABdhPJwVFisC6a3ZIlxC21TUmTsw8kzU5bQ+TcxgbV8jmbJzpVKv2FeHYgljY5csOd7pPNi+HhFwxg== X-Received: by 2002:a17:90b:1b01:b0:1d2:ef4a:98e1 with SMTP id nu1-20020a17090b1b0100b001d2ef4a98e1mr4772501pjb.163.1650465158789; Wed, 20 Apr 2022 07:32:38 -0700 (PDT) Received: from squeak.grove.modra.org ([2406:3400:51d:8cc0:58c9:bdee:9ae5:d611]) by smtp.gmail.com with ESMTPSA id k7-20020aa788c7000000b0050a553bcf80sm16224721pff.18.2022.04.20.07.32.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Apr 2022 07:32:37 -0700 (PDT) Received: by squeak.grove.modra.org (Postfix, from userid 1000) id 295061140617; Thu, 21 Apr 2022 00:02:33 +0930 (ACST) Date: Thu, 21 Apr 2022 00:02:33 +0930 From: Alan Modra To: Nick Clifton Cc: "pro@helflym.eu" , Ayappan P2 , Kavana N Bhat , "CHIGOT, CLEMENT" , "binutils@sourceware.org" Subject: Re: [PATCH 2/2] xcoff: implement linker relaxation Message-ID: References: <5149-625fd800-1df-4c0aa900@128699948> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Spam-Status: No, score=-3036.7 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.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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: Wed, 20 Apr 2022 14:32:41 -0000 On Wed, Apr 20, 2022 at 03:13:25PM +0100, Nick Clifton via Binutils wrote: > Hi Clément, > > > As I said to the previous patch, I can't do it right now. Thus, if you find a bit of time I woudl be grateful if you can make these changes yourself and apply the patch for me. > > Patch applied. And a few fixes. * xcofflink.c (xcoff_stub_csect_name): Increase buffer size. (xcoff_stub_get_csect_in_range, xcoff_build_one_stub): Whitespace. (bfd_xcoff_size_stubs): Cast PRIx64 arg to required type. Don't use freed stub_name. diff --git a/bfd/xcofflink.c b/bfd/xcofflink.c index 6dbcd299b88..83469775208 100644 --- a/bfd/xcofflink.c +++ b/bfd/xcofflink.c @@ -4316,9 +4316,10 @@ bfd_xcoff_link_generate_rtinit (bfd *abfd, /* Get the name of a csect which will contain stubs. It has the same pattern as AIX linker: @FIX"number". */ -static char * xcoff_stub_csect_name (unsigned int n) +static char * +xcoff_stub_csect_name (unsigned int n) { - char buf[6]; + char buf[8]; size_t len; char *csect_name; @@ -4360,30 +4361,30 @@ xcoff_stub_get_csect_in_range (asection *section, csect = csect->next, it++) { /* A csect is in range if everything instructions in SECTION - can branch to every stubs in the stub csect. This can + can branch to every stubs in the stub csect. This can be simplify by saying that the first entry of each sections (ie the vma of this section) can reach the last entry of the stub csect (ie the vma of the csect + its size). - However, as the stub csect might be growing its size isn't - fixed. Thus, the last entry of SECTION might not be able - to reach the first entry of the stub csect anymore. - If this case happens, the following condition will be - false during the next pass of bfd_xcoff_size_stubs and - another csect will be used. - This means we might create more stubs than needed. */ + However, as the stub csect might be growing its size isn't + fixed. Thus, the last entry of SECTION might not be able + to reach the first entry of the stub csect anymore. + If this case happens, the following condition will be + false during the next pass of bfd_xcoff_size_stubs and + another csect will be used. + This means we might create more stubs than needed. */ bfd_vma csect_vma, section_vma; bfd_vma csect_last_vma, section_last_vma; csect_vma = (csect->output_section->vma - + csect->output_offset); + + csect->output_offset); csect_last_vma = (csect->output_section->vma + csect->output_offset + csect->size); section_vma = (section->output_section->vma + section->output_offset); section_last_vma = (section->output_section->vma - + section->output_offset - + section->size); + + section->output_offset + + section->size); if (csect_last_vma - section_vma + (1 << 25) < 2 * (1 << 25) && section_last_vma - csect_vma + (1 << 25) < 2 * (1 << 25)) @@ -4703,7 +4704,7 @@ xcoff_build_one_stub (struct bfd_hash_entry *gen_entry, void *in_arg) BFD_ASSERT (hstub->htarget->toc_section != NULL); /* The first instruction in the stub code needs to be cooked to hold the correct offset in the toc. It will - be filled by xcoff_stub_create_relocations. */ + be filled by xcoff_stub_create_relocations. */ for (i = 0; i < bfd_xcoff_stub_indirect_call_size(output_bfd) / 4; i++) bfd_put_32 (stub_bfd, (bfd_vma) bfd_xcoff_stub_indirect_call_code(output_bfd, i), @@ -4714,7 +4715,7 @@ xcoff_build_one_stub (struct bfd_hash_entry *gen_entry, void *in_arg) BFD_ASSERT (hstub->htarget->toc_section != NULL); /* The first instruction in the glink code needs to be cooked to hold the correct offset in the toc. It will - be filled by xcoff_stub_create_relocations. */ + be filled by xcoff_stub_create_relocations. */ for (i = 0; i < bfd_xcoff_stub_shared_call_size(output_bfd) / 4; i++) bfd_put_32 (stub_bfd, (bfd_vma) bfd_xcoff_stub_shared_call_code(output_bfd, i), @@ -4871,7 +4872,7 @@ bfd_xcoff_size_stubs (struct bfd_link_info *info) _bfd_error_handler (_("%pB: Unable to find a stub csect in range" "of relocation at %#" PRIx64 " targeting" "'%s'"), - section->owner, irel->r_vaddr, + section->owner, (uint64_t) irel->r_vaddr, hsym->root.root.string); goto error_ret; } @@ -4896,10 +4897,10 @@ bfd_xcoff_size_stubs (struct bfd_link_info *info) hstub = xcoff_add_stub (stub_name, hstub_csect, hsym, info, stub_type); if (hstub == NULL) { - free (stub_name); /* xgettext:c-format */ _bfd_error_handler (_("%pB: Cannot create stub entry '%s'"), section->owner, stub_name); + free (stub_name); goto error_ret; } @@ -4999,7 +5000,7 @@ xcoff_stub_create_relocations (struct bfd_hash_entry *bh, void * inf) return false; /* The first instruction of this stub code need - a R_TOC relocation. */ + a R_TOC relocation. */ case xcoff_stub_indirect_call: case xcoff_stub_shared_call: irel->r_size = 0xf; -- Alan Modra Australia Development Lab, IBM