From patchwork Mon Dec 11 13:09:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 176708 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:bcd1:0:b0:403:3b70:6f57 with SMTP id r17csp7034995vqy; Mon, 11 Dec 2023 05:10:00 -0800 (PST) X-Google-Smtp-Source: AGHT+IE1PPZjbILOlLgB3Zny63TRyh93tfXia5RAjIaYXb7KxcqXPdCf70Gucq0NOSYkyqqHjtXX X-Received: by 2002:a05:6830:314e:b0:6da:9f4:b8ae with SMTP id c14-20020a056830314e00b006da09f4b8aemr3632589ots.56.1702300199898; Mon, 11 Dec 2023 05:09:59 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1702300199; cv=pass; d=google.com; s=arc-20160816; b=S65Ph1pUHQfu2TZlLaYPbWuh1UHJAxsJsQ8fwld1f6ZEqdqMDxNt8Eoeic8KNx/jxW 9Z/mnnEZnbyp2mrsYE+UDCKY9MIeZzf1EpcVEO/PXrcCJgpdl3XFJIETo/qOm2JlZBqG 1txts7a13iQca953SpxVmIGYovhcAv8d5j6j33ShwQlq0BOJ8JRHcfzRWA1e73b24cUD 5S2JieVLpXagzqt6/PQSEIg0ErcveeEmRt8XzLddt69p9V40g9IojBKuR+3LOnBTXI4Q 09RY9RtHgDcIB0FreKGujoQP63U/H6cg8d+KAfPDpTe+z871k7tjYYQ5tgtpHnhR2pVS 6Ylw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :in-reply-to:autocrypt:references:cc:to:from:content-language :subject:user-agent:mime-version:date:message-id:dkim-signature :arc-filter:dmarc-filter:delivered-to; bh=4lEIbOgAqS7EelNKMF2gzF9cprWvqHHISA/USHrP6ug=; fh=5Xzgsfi+BxTA/WBX/8ajZrRB4ZtN7RJCiTegFMT79QQ=; b=WdGFAZM3TsdoPFvImY+zx9KepTMKAmPS/b5R5KgchL5IsKEeHddvRL7tCO2sfUgycI 6yqD6/kDyRlrUWacyFr9dfUMVFWt9fC+EVO+jNyca850inB0hyckKHMEIAOhbgZDuG1J uRfeWN7GzKSBjTWX0FNI0haAnfNM6leGU5PBicOROuNbkRr5RpK8mf87qAEusP3v/OjW 39uT2+AbaV402PnaxfxtrOca0DKDjKBizGX8mtrqC237GG19BswlhR0qFkc3aii81qow SkejU8xK3UT4BdoRSIaZZYpO98Aw2EsPTj82jMxHlR+it//IOJaJBoiJf+XDiTTgBtgH /PfQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@suse.com header.s=google header.b=MW2ntxQm; arc=pass (i=1); 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Received: from server2.sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id a4-20020a67f2c4000000b004648f3eaeb9si1200806vsn.138.2023.12.11.05.09.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Dec 2023 05:09:59 -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=@suse.com header.s=google header.b=MW2ntxQm; arc=pass (i=1); 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 3F8B93857B92 for ; Mon, 11 Dec 2023 13:09:59 +0000 (GMT) X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from mail-wm1-x32f.google.com (mail-wm1-x32f.google.com [IPv6:2a00:1450:4864:20::32f]) by sourceware.org (Postfix) with ESMTPS id C40A63858413 for ; Mon, 11 Dec 2023 13:09:52 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C40A63858413 Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org C40A63858413 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::32f ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1702300194; cv=none; b=udCBnGvH6PWXsS3xVVSIjblbmoawaR5dDbycMa+yQg5kVxkiirJJ93/TtdqxbecuZhNG4V4Zgud8SjhaT7Hwf0YjacIhUQ0Jk1eO8MPGEvGiIOaWcrGURZIBlRFSmaCxvfuuCGL9gYTThcSPMw0rd+7YRci1KWGXO3goFHt9Xb4= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1702300194; c=relaxed/simple; bh=VQD/YqugqTbTSz3b3w0jGOPmd2ZLv+5r/e0my3OvtMQ=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:From:To; b=YAWc6JtBbU3AGtZR1sJu3vGFEiHd4I4M9jktPbzh+2y09KqLK72B5I3b3lHQhG6nP45hWV56cxhQemtOEYawbrsErM4bKwEHac0RaJ5XhgMXJSgDvnMDbEi07m67NfSZKXnvCxJ27BmnAI4VBpVe8ggxcwltNHbLZW/zGomAHtg= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-wm1-x32f.google.com with SMTP id 5b1f17b1804b1-40c3984f0cdso27246685e9.1 for ; Mon, 11 Dec 2023 05:09:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1702300191; x=1702904991; darn=sourceware.org; h=content-transfer-encoding:in-reply-to:autocrypt:references:cc:to :from:content-language:subject:user-agent:mime-version:date :message-id:from:to:cc:subject:date:message-id:reply-to; bh=4lEIbOgAqS7EelNKMF2gzF9cprWvqHHISA/USHrP6ug=; b=MW2ntxQm3FhLAJ1B5/K2vRg6EFAluj3pbpoFXDovG4kJm9NiOijt+VRFTZV4uQXZSa E2/yEHvPtvTvKJ+N7NghweAcCjtK7g2vB69u0QLXXAEkhNbEvnQOpxjPFowNs6TyEefi MPnvufw+6nN/5kf1k787ong/bmfann/gSj0LNXao4DRbIuok4FK/6m7WATptwmVz+wpE FFT/ZA5meJ0scs4oVZRkSb07PZDUeyvqoTHgUSpWmi30OXFI10eybkWtZaqh3Tgx4hkn n5DU6hIGWDsb1YFjcgvn2KJn2p6+KQftECsw2f1zxvR54iYas4bsmCEHeZd9QmZLoN+G 4ttA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702300191; x=1702904991; h=content-transfer-encoding:in-reply-to:autocrypt:references:cc:to :from:content-language:subject:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=4lEIbOgAqS7EelNKMF2gzF9cprWvqHHISA/USHrP6ug=; b=svFS8/g2Fe4ubViExfoHtCfANNYkOzlmBnRMSca+9K5sU12CwMQdUsLBrR/EHPXdnb M/TAFnhN7REUi/TMEpDRgDBUeu+eAO+GfJWwf26VfNHB9wzk9+CwwUkxWLvTDRGfgOAj fAI5T6/qyfasjoEyEaL+aUPUmuSlFIhYkZH9ZdLIBafDIYdDoP8R5PSqmafjDO4V7qBA BechM0a3ZKoXIODCeNBHv9Wqo3qkSNixdRHLWE8JVfnz8INE1KfSZc0MWukCbtZ+VWsB KY6FN/MMVjjS3GlAOJvmHKu9nJ0rPCnD5/HUuBZlZ41FVhFDRBVGsuE+TdlyOwRwyLhh g7tA== X-Gm-Message-State: AOJu0YxH3GqOF47LCqHyYBrsUrWLU8OrUf4JFTZYUJwAqlYA8v9f2wqJ WjVV05ie7Xy6wpVlzUVhusGeMo7bTsTkIPm2bkk0 X-Received: by 2002:a7b:c8c8:0:b0:40b:5e21:dd44 with SMTP id f8-20020a7bc8c8000000b0040b5e21dd44mr2452221wml.114.1702300191593; Mon, 11 Dec 2023 05:09:51 -0800 (PST) Received: from [10.156.60.236] (ip-037-024-206-209.um08.pools.vodafone-ip.de. [37.24.206.209]) by smtp.gmail.com with ESMTPSA id he10-20020a05600c540a00b0040b3829eb50sm12829168wmb.20.2023.12.11.05.09.50 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 11 Dec 2023 05:09:51 -0800 (PST) Message-ID: <49271770-95e3-4c34-9e0a-aa9886ad6760@suse.com> Date: Mon, 11 Dec 2023 14:09:50 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: [PATCH v2 3/4] ELF: reliably invoke md_elf_section_change_hook() Content-Language: en-US From: Jan Beulich To: Binutils Cc: "H.J. Lu" , Nick Clifton , Alan Modra References: <25484cfc-e9d3-4b6b-968d-7642ae53301d@suse.com> Autocrypt: addr=jbeulich@suse.com; keydata= xsDiBFk3nEQRBADAEaSw6zC/EJkiwGPXbWtPxl2xCdSoeepS07jW8UgcHNurfHvUzogEq5xk hu507c3BarVjyWCJOylMNR98Yd8VqD9UfmX0Hb8/BrA+Hl6/DB/eqGptrf4BSRwcZQM32aZK 7Pj2XbGWIUrZrd70x1eAP9QE3P79Y2oLrsCgbZJfEwCgvz9JjGmQqQkRiTVzlZVCJYcyGGsD /0tbFCzD2h20ahe8rC1gbb3K3qk+LpBtvjBu1RY9drYk0NymiGbJWZgab6t1jM7sk2vuf0Py O9Hf9XBmK0uE9IgMaiCpc32XV9oASz6U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1085mBDZCH5Kx0cl0HVJuQKC+dV2ZY5AqjcKwAxpE75MLFkr wkkEGBECAAkFAlk3nEQCGwwACgkQoDSui/t3IH7nnwCfcJWUDUFKdCsBH/E5d+0ZnMQi+G0A nAuWpQkjM1ASeQwSHEeAWPgskBQL In-Reply-To: <25484cfc-e9d3-4b6b-968d-7642ae53301d@suse.com> X-Spam-Status: No, score=-3026.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, 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.30 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: binutils-bounces+ouuuleilei=gmail.com@sourceware.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1784991133974217852 X-GMAIL-MSGID: 1784991133974217852 ... after any (sub)section change. While certain existing target hooks only look at now_seg, for a few others it looks as if failing to do so could have caused anomalies if sub-sections were used. In any event a subsequent x86 change is going to require the sub-section to be properly in place at the time the hook is invoked. This primarily means for obj_elf_section() to pass the new subsection into change_section(), for it to be set right away (ahead of invoking the hook). Also adjust obj_elf_ident() to invoke the hook after all section changes. (Note that obj_elf_version(), which also changes sections and then changes them back, has no hook invocation at all so far, so none are added. Presumably there is a reason for this difference in behavior.) --- v2: Re-base over new earlier patch. --- a/gas/config/obj-elf.c +++ b/gas/config/obj-elf.c @@ -547,7 +547,8 @@ change_section (const char *name, int entsize, struct elf_section_match *match_p, bool linkonce, - bool push) + bool push, + subsegT new_subsection) { asection *old_sec; segT sec; @@ -585,10 +586,10 @@ change_section (const char *name, if (old_sec) { sec = old_sec; - subseg_set (sec, 0); + subseg_set (sec, new_subsection); } else - sec = subseg_force_new (name, 0); + sec = subseg_force_new (name, new_subsection); bed = get_elf_backend_data (stdoutput); ssect = (*bed->get_sec_type_attr) (stdoutput, sec); @@ -828,7 +829,7 @@ obj_elf_change_section (const char *name struct elf_section_match *match_p, bool linkonce) { - change_section (name, type, attr, entsize, match_p, linkonce, false); + change_section (name, type, attr, entsize, match_p, linkonce, false, 0); } static bfd_vma @@ -1114,8 +1115,8 @@ obj_elf_section (int push) bfd_vma attr; bfd_vma gnu_attr; int entsize; - int linkonce; - subsegT new_subsection = -1; + bool linkonce; + subsegT new_subsection = 0; struct elf_section_match match; unsigned long linked_to_section_index = -1UL; @@ -1499,7 +1500,8 @@ obj_elf_section (int push) } } - change_section (name, type, attr, entsize, &match, linkonce, push); + change_section (name, type, attr, entsize, &match, linkonce, push, + new_subsection); if (linked_to_section_index != -1UL) { @@ -1507,9 +1509,6 @@ obj_elf_section (int push) elf_section_data (now_seg)->this_hdr.sh_link = linked_to_section_index; /* FIXME: Should we perform some sanity checking on the section index ? */ } - - if (push && new_subsection != -1) - subseg_set (now_seg, new_subsection); } /* Change to the .bss section. */ @@ -2529,9 +2528,17 @@ obj_elf_ident (int ignore ATTRIBUTE_UNUS *p = 0; } else - subseg_set (comment_section, 0); + { + subseg_set (comment_section, 0); +#ifdef md_elf_section_change_hook + md_elf_section_change_hook (); +#endif + } stringer (8 + 1); subseg_set (old_section, old_subsection); +#ifdef md_elf_section_change_hook + md_elf_section_change_hook (); +#endif } #ifdef INIT_STAB_SECTION