From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-io1-xd44.google.com (mail-io1-xd44.google.com [IPv6:2607:f8b0:4864:20::d44]) by sourceware.org (Postfix) with ESMTPS id 9C5C23857C57; Tue, 29 Sep 2020 19:55:28 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 9C5C23857C57 Received: by mail-io1-xd44.google.com with SMTP id g128so6127761iof.11; Tue, 29 Sep 2020 12:55:28 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=+lejgaPTf0/G7f0WxglO7V3BeLlayu6Wwg8gqtP6IJs=; b=Ga5BY/01YLGhlEdcTeOKH13RLGo73Q5JrKxdhUTbmc6c2TKYL+Kdfo/im9NpWLCxeR qK2kLnsu8XuWYDmr3uojUbZN8l6ziffS5olkMX3luMBkFk+BUM2qj6c7cyyMXkhJJuOe hxUr2c+lt/S+aKyZLzTtYQB0nOdQHQHW8zT6gQkuKsRtf0idgx4IxcEkaSL0vkTQ3OSv 0Lp0IX5suF5XN0BpNj3/mNph6gsGS3ZTkxWU2go+iZjCR4rGVI1wiMz1eLsS2RcNIoIA ytmZESUh38XBMfV5u7Ar/Bd/zdQbnrTQe9c15MChOgGJEWtxlwTS2/AgbgnuucRnlqd7 VC6w== X-Gm-Message-State: AOAM531DZcoZCJ9SnFDem0stjxm7llN7HEbPRyDAna5iV+ghS6JGC5P1 rRIRIbgQ6h4jTawEUkw8kWU4UaNlM2Q2JTidh1+pAsY8KE0= X-Google-Smtp-Source: ABdhPJzSnQHuqNk3fn1Rmj0bEUZPuJZE5dO4NuSoqENnH5lR7GYsGV7Equ+cDDPbtPkbZz25iiIUywuWaOPEx6pN3uA= X-Received: by 2002:a5e:881a:: with SMTP id l26mr3677663ioj.51.1601409328086; Tue, 29 Sep 2020 12:55:28 -0700 (PDT) MIME-Version: 1.0 References: <20200928132613.btkqaoomv4fdnupn@jozef-acer-manjaro> <20200929044353.vx26ypc2oioqbmfb@gmail.com> <20200929100442.o3e66jbmqpv5cajh@jozef-acer-manjaro> <20200929193806.m6u6ra6oijqkstfo@gmail.com> In-Reply-To: <20200929193806.m6u6ra6oijqkstfo@gmail.com> From: "H.J. Lu" Date: Tue, 29 Sep 2020 12:54:52 -0700 Message-ID: Subject: Re: [PATCH v2] Support for SHF_GNU_RETAIN ELF Section Flag To: Fangrui Song Cc: Binutils , GNU gABI gnu-gabi Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-3031.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, 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: gnu-gabi@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gnu-gabi mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 29 Sep 2020 19:55:30 -0000 On Tue, Sep 29, 2020 at 12:38 PM Fangrui Song wrote: > > >> > >> // a.h > >> __attribute__((section("sec"))) > >> inline void bar() { ... } > >> // a.c > >> #include "a.h" > >> __attribute__((section("sec"), retain)) > >> void foo() { > >> } > >> > >> compiles to > >> > >> .section sec,"a",@progbits > >> ... > >> .section sec,"aR",@progbits > >> ... > >> > >> You will get a gas error for changing section flags > >> (https://sourceware.org/pipermail/binutils/2020-February/109945.html) > >> > > > >There is no error in this case. > >The original patch handled it, and it has been further improved in v2. > >There's even a testcase testing exactly the functionality you say is > >broken. > > > > gas/testsuite/gas/elf/section22.s: > > .section .bss,"aw" > > ... > > .section .bss,"awR",%nobits > > > >I already gave a detailed response to your reloc proposal: > >https://sourceware.org/pipermail/binutils/2020-September/113450.html > > Letting the following assembly creates two .bss sections adds an exception to > "gas: error for section type, attr, or entsize change" > (https://sourceware.org/pipermail/binutils/2020-February/109945.html) > for which I have achieved consensus with Alan Modra and some LLVM > toolchain folks. That is why I hope we could re-consider this design > choice. > > .section .bss,"aw" > .section .bss,"awR",%nobits > FWIW, GNU assembler has been able to create multiple sections with the same section name for a while. For SHF_GNU_RETAIN, we added +/* Create unique input sections for sections with the same name, but different + values for the flags in this mask. */ +#define SEC_ASSEMBLER_SHF_MASK SHF_GNU_RETAIN to control when to create a new section with the same section name. For other cases, no new section is created. -- H.J.