From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 89114 invoked by alias); 18 Oct 2019 12:51:43 -0000 Mailing-List: contact gcc-help-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-help-owner@gcc.gnu.org Received: (qmail 89106 invoked by uid 89); 18 Oct 2019 12:51:43 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-2.3 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 spammy=lance, Taylor X-HELO: gate.crashing.org Received: from gate.crashing.org (HELO gate.crashing.org) (63.228.1.57) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 18 Oct 2019 12:51:41 +0000 Received: from gate.crashing.org (localhost.localdomain [127.0.0.1]) by gate.crashing.org (8.14.1/8.14.1) with ESMTP id x9ICpd0s000677; Fri, 18 Oct 2019 07:51:39 -0500 Received: (from segher@localhost) by gate.crashing.org (8.14.1/8.14.1/Submit) id x9ICpcMq000674; Fri, 18 Oct 2019 07:51:38 -0500 Date: Fri, 18 Oct 2019 12:51:00 -0000 From: Segher Boessenkool To: Florian Weimer Cc: Josef Wolf , gcc-help@gcc.gnu.org Subject: Re: Propagating addresses from linker to the runtie Message-ID: <20191018125138.GM28442@gate.crashing.org> References: <20191016131759.GA11171@raven.inka.de> <5b75d9aa-9f33-2ec6-ff46-713b113b3539@gmail.com> <20191017113157.GC11171@raven.inka.de> <20191018090705.GF11171@raven.inka.de> <87d0euv2hh.fsf@oldenburg2.str.redhat.com> <20191018094353.GG11171@raven.inka.de> <8736fquy7e.fsf@oldenburg2.str.redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <8736fquy7e.fsf@oldenburg2.str.redhat.com> User-Agent: Mutt/1.4.2.3i X-IsSubscribed: yes X-SW-Source: 2019-10/txt/msg00080.txt.bz2 On Fri, Oct 18, 2019 at 12:47:49PM +0200, Florian Weimer wrote: > > #define symbol_set_declare(set) \ > > extern char const __start_##set[] __symbol_set_attribute; \ > > extern char const __stop_##set[] __symbol_set_attribute; > > > > Due to symbol_set_declare, those symbols expand to two unrelated > > symbols. Using unrelated symbols for pointer arithmetic again violates the > > standard. > > Ah. So we need more uintptr_t casts here. Using reserved names (like those starting with two underscores) is UB already. And those particular names actually clash with names GNU LD already creates! > > Thus, the issue that Martin mentioned applies here, too. > > > > To get this conforming, the linker would need to export a symbol to the start > > of the section and the length of the section, IMHO. > > Right, but we do not have that today. 8-( We have had it since over 25 years: Thu Aug 18 15:37:45 1994 Ian Lance Taylor (ian@sanguine.cygnus.com) Make the ELF linker handle orphaned sections reasonably. Also, define __start_SECNAME and __stop_SECNAME around sections whose names can be represented in C, for the benefit of symbol sets in glibc. You just need to have linker scripts that do not sabotage this :-) > An explicit size also helps targets where there are restrictions on > alignment for global symbols, and the section size is actually measured > in bytes. (Which of course leads to the old question whether an object > can have a size which is not a multiple of its alignment.) It can. This is common, even, for example a .rodata.str1.8 section has alignment 8, but its size can be anything. Segher