From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm1-x342.google.com (mail-wm1-x342.google.com [IPv6:2a00:1450:4864:20::342]) by sourceware.org (Postfix) with ESMTPS id 6C1923861039 for ; Fri, 4 Dec 2020 15:29:10 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 6C1923861039 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=mittosystems.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=jozef.l@mittosystems.com Received: by mail-wm1-x342.google.com with SMTP id v14so5851829wml.1 for ; Fri, 04 Dec 2020 07:29:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mittosystems.com; s=google; h=date:from:to:cc:subject:message-id:mail-followup-to:references :mime-version:content-disposition:in-reply-to; bh=drYzU2MtVKr9/QO5/H9i6BrtR4eWcNdUIeoQgotGU6c=; b=Nj2BtTmkq0xsmS2mAQmMT0UUMZjl/9GQlBEojI28q30PNGB3hu7C29YJcH1j50AnI8 cX8Hj+LwWItkIV4fSMv95XaPX3xtyFYhh2xKQXfYP3781orNxOsa1l16OqhbdltEuf3S +YTxH4MturMVPaenAfYG4rFzN94Gvy/mHhxiAIFq+yD6zyY8haAPQncLJAtt4u4Ynwm+ jGZXoyaYFGDleYKPPu+Yg8DSRf7iC+sWRoWccg6OfVa57K02H0DbxW2GjXAoyHdT+5dE 2vJtWntSV+S9BbudxxGsDke0RIRwDQe++nYbwiyOYchHBCQmawemSgenXhsbnOGv7R4n SULQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id :mail-followup-to:references:mime-version:content-disposition :in-reply-to; bh=drYzU2MtVKr9/QO5/H9i6BrtR4eWcNdUIeoQgotGU6c=; b=sQj24P1/QHFyAy2TdujOkZJx08VHARUbqYZ27pjdzzi9dCCvywbK5TXXof2lvVwtaP tQlcuV1PSsguInecJEp4hCU0BhoLS2wYCQaaUUeDdbWYcCCZyLd/evrH7jDhIQG7kzWp CB58eK9L9GbSbckprbEwO/mC+w7v3rvcGTYpGVB9dxVC2yrOxrJ16QwkybRQ5XESH3h1 Quzl0PsRAjqCjqyjw38lYtMm8V1W2UatEY6+HzRHuJss1BOn6HfsimbmJWyQVMUMgD/B 54KMfxT2Qi5AlNvHuroSKXK64g0exIL92HWpAI8su5+ARL/rFHC4zT877hceJEoHbq0O srWA== X-Gm-Message-State: AOAM5306eUR46nC726Z1MLmWjdqH/HAvzLt6jMhAEoum4SKij/PXTjdx 4Sg7kro4n4/MV+fEy/qTwDgIY5eG69uKZA== X-Google-Smtp-Source: ABdhPJyTsd2lEbmR0RPSAZ8oAlOy0Fezyi3nZ6gn2xYdew0tSbazrauz2ufdiJ+rLM1ee8VU/a6D/A== X-Received: by 2002:a1c:f609:: with SMTP id w9mr4768457wmc.72.1607095749470; Fri, 04 Dec 2020 07:29:09 -0800 (PST) Received: from jozef-acer-manjaro ([2a01:4b00:87fd:900:5e1d:5c99:56da:76e8]) by smtp.gmail.com with ESMTPSA id f16sm3397861wmh.7.2020.12.04.07.29.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Dec 2020 07:29:08 -0800 (PST) Date: Fri, 4 Dec 2020 15:29:07 +0000 From: Jozef Lawrynowicz To: "H.J. Lu" Cc: binutils@sourceware.org Subject: Re: [PATCH] gas: Generate a new section for SHF_GNU_RETAIN Message-ID: <20201204152907.mhls5ilpv47bj5fq@jozef-acer-manjaro> Mail-Followup-To: "H.J. Lu" , binutils@sourceware.org References: <20201204135254.2147243-1-hjl.tools@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201204135254.2147243-1-hjl.tools@gmail.com> X-Spam-Status: No, score=-11.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) 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, 04 Dec 2020 15:29:12 -0000 On Fri, Dec 04, 2020 at 05:52:54AM -0800, H.J. Lu wrote: > For > .globl foo2 > .section .data.foo,"aR" > .align 4 > .type foo2, @object > .size foo2, 4 > foo2: > .long 2 > .globl foo1 > .section .data.foo > .align 4 > .type foo1, @object > .size foo1, 4 > foo1: > .long 1 > > generate a new section if the SHF_GNU_RETAIN bit doesn't match. > > * config/obj-elf.c (SEC_ASSEMBLER_SHF_MASK): New. > (get_section_by_match): Also check if SEC_ASSEMBLER_SHF_MASK of > sh_flags matches. Rename info to sh_info. > (obj_elf_change_section): Rename info to sh_info. > (obj_elf_section): Rename info to sh_info. Set sh_flags for > SHF_GNU_RETAIN. > * config/obj-elf.h (elf_section_match): Rename info to sh_info. > Add sh_flags. > * testsuite/gas/elf/elf.exp: Run section27. > * testsuite/gas/elf/section24b.d: Updated. > * testsuite/gas/elf/section27.d: New file. > * testsuite/gas/elf/section27.s: Likewise. > --- > gas/config/obj-elf.c | 21 ++++++++++++------ > gas/config/obj-elf.h | 3 ++- > gas/testsuite/gas/elf/elf.exp | 1 + > gas/testsuite/gas/elf/section24b.d | 10 ++++++--- > gas/testsuite/gas/elf/section27.d | 14 ++++++++++++ > gas/testsuite/gas/elf/section27.s | 34 ++++++++++++++++++++++++++++++ > 6 files changed, 73 insertions(+), 10 deletions(-) > create mode 100644 gas/testsuite/gas/elf/section27.d > create mode 100644 gas/testsuite/gas/elf/section27.s I just want to check that we are OK with the fact that a .section directive without any flags will always use the default flags, even if the section previously had the 'R' flag set. I suppose this is just standard behavior and how the .section directive has always behaved. $ cat asm-tester.s .section .data.foo,"awR" .word 0 .section .data.foo .word 0 $ as asm-tester.s -o tester.o $ readelf --wide -S tester.o ... [ 4] .data.foo PROGBITS 0000000000000000 000040 000002 00 WAR 0 0 1 [ 5] .data.foo PROGBITS 0000000000000000 000042 000002 00 WA 0 0 1 ... Also, I think the following change should be added, since the OR'ing of SHF_GNU_RETAIN flag between sections, from the original patch, is now redundant. diff --git a/gas/config/obj-elf.c b/gas/config/obj-elf.c index 54d42d9ecb..9ac53e4d0e 100644 --- a/gas/config/obj-elf.c +++ b/gas/config/obj-elf.c @@ -806,17 +806,9 @@ obj_elf_change_section (const char *name, as_bad (_("changed section attributes for %s"), name); } else - { - /* Don't overwrite a previously set SHF_GNU_RETAIN flag for the - section. The entire section must be marked retained. */ - if ((elf_tdata (stdoutput)->has_gnu_osabi & elf_gnu_osabi_retain) - && ((elf_section_flags (old_sec) & SHF_GNU_RETAIN))) - attr |= SHF_GNU_RETAIN; - - /* FIXME: Maybe we should consider removing a previously set - processor or application specific attribute as suspicious ? */ - elf_section_flags (sec) = attr; - } + /* FIXME: Maybe we should consider removing a previously set + processor or application specific attribute as suspicious ? */ + elf_section_flags (sec) = attr; if ((flags & SEC_MERGE) && old_sec->entsize != (unsigned) entsize) as_bad (_("changed section entity size for %s"), name); Thanks, Jozef