From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 71194 invoked by alias); 6 Feb 2020 09:19:19 -0000 Mailing-List: contact binutils-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: binutils-owner@sourceware.org Received: (qmail 71182 invoked by uid 89); 6 Feb 2020 09:19:18 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-2.4 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,KAM_INFOUSMEBIZ,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=no version=3.3.1 spammy=H*M:google X-HELO: mail-pl1-f172.google.com Received: from mail-pl1-f172.google.com (HELO mail-pl1-f172.google.com) (209.85.214.172) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 06 Feb 2020 09:19:16 +0000 Received: by mail-pl1-f172.google.com with SMTP id b22so2092082pls.12 for ; Thu, 06 Feb 2020 01:19:16 -0800 (PST) Return-Path: Received: from localhost (c-71-204-169-238.hsd1.ca.comcast.net. [71.204.169.238]) by smtp.gmail.com with ESMTPSA id f18sm2678098pgn.2.2020.02.06.01.19.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Feb 2020 01:19:14 -0800 (PST) Date: Thu, 06 Feb 2020 09:19:00 -0000 From: Fangrui Song To: Alan Modra Cc: binutils@sourceware.org, bd1976llvm@gmail.com Subject: Re: .section directives with the same name but different fields Message-ID: <20200206091914.5docw46nvgx7om6o@google.com> References: <20200206073837.j4biw4rsbdy2siip@gmail.com> <20200206083347.GC5669@bubble.grove.modra.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: <20200206083347.GC5669@bubble.grove.modra.org> X-SW-Source: 2020-02/txt/msg00094.txt.bz2 On 2020-02-06, Alan Modra wrote: >On Wed, Feb 05, 2020@11:38:37PM -0800, Fangrui Song wrote: >> ## Different sh_entsize >> >> .section .foo,"aM",@progbits,4 >> .section .foo,"aM",@progbits,8 >> >> GNU as emits a warning `Warning: ignoring changed section entity size for .foo` > >I think this one probably should be an error rather than a warning. An error is fine, but it can bring up some implementation difficulties. If an implementation does a one-pass scan over global variables to emit .section directives and variable labels, it may not know sh_entsize when it is about the emit the first .section directive. >> The output sh_entsize is 4. If the second .section defines an object, the object may get corrupted after merging >> (https://bugs.llvm.org/show_bug.cgi?id=43457 ) >> For this case, we have several choices: >> >> 1. (Status quo) Emit one section. Set sh_entsize to 4 and emit a warning. >> 2. Emit two sections, i.e. sh_entsize is a differentiator. > >If you do, the linker won't do merging of values for those sections. > >> 3. Emit one section. Set sh_entsize to 0. Should the assembler emit a warning? > >And remove SHF_MERGE too I guess. That's an option but I think it's >better just to error. > >> >> ## Different sh_flags >> >> .section .foo,"aw" >> .section .foo,"a" # Warning: ignoring changed section attributes for .foo >> >> Shall we emit two sections? > >I don't think so. User assembly often gets section attributes wrong >or leaves them off entirely for special sections known to the >assembler. ie. the first .section .foo above is a built-in rather >than user input. > >> >> ## Different sh_type >> >> .section .foo,"a",@progbits >> .section .foo,"a",@nobits # Warning: ignoring changed section type for .foo >> >> Shall we emit two sections? > >Again we should continue to handle the case where .foo is a special >section of known type. So I think a warning rather than creating two >sections is appropriate. Do you think the warnings should be upgraded to errors (for sh_flags and sh_type)?