From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pf1-f180.google.com (mail-pf1-f180.google.com [209.85.210.180]) by sourceware.org (Postfix) with ESMTPS id 1767A3887024 for ; Mon, 13 Apr 2020 21:32:56 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 1767A3887024 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=maskray.me Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=emacsray@gmail.com Received: by mail-pf1-f180.google.com with SMTP id b8so5112270pfp.8 for ; Mon, 13 Apr 2020 14:32:56 -0700 (PDT) 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:references :mime-version:content-disposition:in-reply-to; bh=0EyOxg9pc1choHH7kM/99O4HPDUB2kFQ6qYzPU1uDi8=; b=MReJQXFIUOVu5ja23Cx82BCM/KbV2Lgq8MqlyMVlqkB7kvCDpQP3JO1Oo/R6frINB9 +KG6yOsWGkDXDyYgIlpQlbtV7oCBlqL2bCzgQz5tN0TH9gNNDW6YMx4vUu2ILPaJVVEq KXGrDvXtqGOKivTncowuH3sLa6QL+xgarasGJT9/4aTmuyIHxxesWl3Yc/WBCiy/Ozkn apkVYBf1o9/tyNl0OT2yzAso5+TvDGBCP2UL5JZuE0KpxunCo0aHy39MJTQfCr9/vnv4 A3GZb0f4T0yVPQ7F62vMHSHaX5oNtsvyeksvDXunOgsNJSlGfAeXAUWjRb+vgTVvsU9S ynAA== X-Gm-Message-State: AGi0Puad+AiSxVpJFuxPDWG8PNHAmwKwXDa8STJSA9yV+MnbTqgJkbpy p2doNXRRthi/fBOb6JBXIg1rFodS X-Google-Smtp-Source: APiQypK8TlM/e4+oZdk9r8aJJtbkYcuvV6Ln7Zg96c6Pm9ymi9HTpA33GzSpg6sUSBemsSQ1EInOQg== X-Received: by 2002:a62:502:: with SMTP id 2mr20027096pff.324.1586813575169; Mon, 13 Apr 2020 14:32:55 -0700 (PDT) Received: from localhost ([2601:647:4b01:ae80::51fb]) by smtp.gmail.com with ESMTPSA id x26sm973911pfo.218.2020.04.13.14.32.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Apr 2020 14:32:54 -0700 (PDT) Date: Mon, 13 Apr 2020 14:32:53 -0700 From: Fangrui Song To: "H.J. Lu" Cc: Alan Modra , bd1976 llvm , Binutils Subject: Re: Empty section flags Message-ID: <20200413213253.poraem3yhwahra4c@gmail.com> References: <20200206073837.j4biw4rsbdy2siip@gmail.com> <20200206083347.GC5669@bubble.grove.modra.org> <20200206091914.5docw46nvgx7om6o@google.com> <20200206140912.GE5669@bubble.grove.modra.org> <20200210052104.GQ5669@bubble.grove.modra.org> <20200404163828.abhvjv5p26mobuda@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, KAM_INFOUSMEBIZ, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=no 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: Mon, 13 Apr 2020 21:32:57 -0000 On 2020-04-04, H.J. Lu wrote: >On Sat, Apr 4, 2020 at 9:38 AM Fangrui Song wrote: >> >> On 2020-04-04, H.J. Lu wrote: >> >On Tue, Mar 3, 2020 at 1:20 PM Fangrui Song wrote: >> >> >> >> On Sun, Feb 9, 2020 at 9:21 PM Alan Modra wrote: >> >> > >> >> > On Thu, Feb 06, 2020 at 05:25:33PM +0000, bd1976 llvm wrote: >> >> > > Hi Alan, thanks for the input here. I wonder if it wouldn't be more >> >> > > consistent to error in all cases - even in the case of different group >> >> > > signatures. The only exception would need to be for the special section >> >> > > names (.text, .debug_str, etc...) that the assembler has special knowledge >> >> > > of (as you explained). >> >> > >> >> > Yes, let's see how that goes. >> >> > https://sourceware.org/ml/binutils/2020-02/msg00129.html >> >> > >> >> > > I wonder why creating multiple sections with the >> >> > > same name for section directives with different group signatures was >> >> > > implemented - why not just require the use of a distinct section name for >> >> > > these? >> >> > >> >> > I think plain ".text" for a group's text section is fine. Distict >> >> > names would just be yet another thing to track for a group. >> >> > >> >> > > Or, now that GNU has the ",unique,N" assembly extension ( >> >> > > https://sourceware.org/ml/binutils/2020-02/msg00028.html) that could be >> >> > > used if the section name is fixed - it would then be explicit in the source >> >> > > code that another section with the same name will be created. >> >> > >> >> > Perhaps, but we aren't designing a new toolchain. Backwards >> >> > compatibility can't be discarded without compelling reasons. >> >> > >> >> > -- >> >> > Alan Modra >> >> > Australia Development Lab, IBM >> >> >> >> For empty flags, should there be an error as well? >> >> >> >> .section .foo,"ax",@progbits; .byte 1 >> >> .section .foo,"",@progbits; .byte 2 # no diagnostic >> >> .section .foo,"a",@progbits; .byte 3 # Error: changed section >> >> attributes for .foo >> >> >> >> Context: https://github.com/ClangBuiltLinux/linux/issues/913 >> >> >> >> I lean toward an error for consistency, and I will try making the LLVM >> >> MC side rule stick. >> > >> >[hjl@gnu-cfl-2 tmp]$ cat x.s >> >.section .foo,"",@progbits; .byte 2 >> >[hjl@gnu-cfl-2 tmp]$ gcc -c x.s >> >[hjl@gnu-cfl-2 tmp]$ readelf -SW x.o | grep foo >> > [ 4] .foo PROGBITS 0000000000000000 000040 >> >000001 00 0 0 1 >> >[hjl@gnu-cfl-2 tmp]$ >> > >> >Unless it is disallowed by gABI/psABI, assembler should allow it. >> >Sometimes, I found a need to create odd object files, like zero-sized >> >relocation section, for linker test. Assembler should have more >> >flexibilities within gABI/psABI. >> > >> >-- >> >H.J. >> >> Declaring a section with empty flags is fine. >> My question is about re-declaring with empty flags when the first declaration has other flags: >> >> .section .foo,"ax",@progbits; .byte 1 >> .section .foo,"",@progbits; .byte 2 # no diagnostic >> .section .foo,"a",@progbits; .byte 3 # Error: changed section >> >> This is about the follow-up of >> https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=33176d912add7680277ad5e18af0e6303d9a7af8 > >[hjl@gnu-cfl-2 tmp]$ cat y.s >.section .foo,"ax",@progbits >.byte 1 >.section .foo >.byte 2 >.section .foo,"",@progbits >.byte 3 >.section .foo,"ax" >.byte 3 >[hjl@gnu-cfl-2 tmp]$ gcc -c y.s >[hjl@gnu-cfl-2 tmp]$ readelf -SW y.o | grep foo > [ 4] .foo PROGBITS 0000000000000000 000040 >000004 00 AX 0 0 1 >[hjl@gnu-cfl-2 tmp]$ > >If section flags or type is unspecified/empty, GNU assembler uses the >previous one if it exists. I think this behavior is quite reasonable. > >-- >H.J. When sh_flags is unspecified, I can accept that it will use the previous one (ideally I hope it does not do this) .section .foo But when sh_flags is specified as an empty string, I find it quite unintuitive to be different from a non-empty string .section .foo,"" # different from .section .foo,"a" , which checks compatibility