From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mo4-p00-ob.smtp.rzone.de (mo4-p00-ob.smtp.rzone.de [85.215.255.22]) by sourceware.org (Postfix) with ESMTPS id CFC0B3858C56 for ; Wed, 6 Dec 2023 16:44:40 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org CFC0B3858C56 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=gjlay.de Authentication-Results: sourceware.org; spf=none smtp.mailfrom=gjlay.de ARC-Filter: OpenARC Filter v1.0.0 sourceware.org CFC0B3858C56 Authentication-Results: server2.sourceware.org; arc=pass smtp.remote-ip=85.215.255.22 ARC-Seal: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1701881082; cv=pass; b=OgCzP3kM/lvmiG5pJKHcpKVkpr9CcZE4BHCqqeXcM6gy6HyrQKXZm8MxrjnrjoliMenxT+DsDqYPtQ1hy6jOWUKlRS7eQxH0Lv9USGxlORUTNSGAqqozRj9UNgQqLzaqFftWV2/IEjPy8wpW8W3hawJhoXN5pSu5TlncZg2ubiE= ARC-Message-Signature: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1701881082; c=relaxed/simple; bh=y5KDDXU0g0FxuXuvsnwtRrIhDabGBtoziy3CoSvio2I=; h=DKIM-Signature:DKIM-Signature:Message-ID:Date:MIME-Version: Subject:To:From; b=NLJ6DPLUfeJ1NsPHtJ/UL9uFOvmkD0J7N6Hvz3+UL8lO4921FhOMEkRzGBL3PU7q1enT4AO9+4PxfxmSwBws/7BGGyHJskXs/1Rn4G4J4t4Yqw9pHCMFZF8iB7dRAJZlKJ1ap5YXaxzhq/udK9HUCoIhW3hswTa4vcahITu/1a0= ARC-Authentication-Results: i=2; server2.sourceware.org ARC-Seal: i=1; a=rsa-sha256; t=1701881079; cv=none; d=strato.com; s=strato-dkim-0002; b=HC+NBiyPDWcVG2cb919UXDoGjsQWtPUHZiCmoP4P/j0xhm2w2/2uiFbxYtO/FVrkxc YAz0Kn2LjOMBbMq3V9ixvlbKxon0vMyyt99wyTlrFDuZfCUrIiYvnYQR1+dmaRR0P9UG KWHXmy5QZuXZaJOJdoCdDYMi36CZ652g38IuGUlvyCphisXEd7wMu2CdVhHkcbUpkYa8 4Jz7qbQaS8u7NJw3idJbgFKIcRZfipZNwjWPvV+DeDAC4Soesz82emnq9G707/WmH9ob XE3b+ljVkKnvyh2sW9gYlPzLCVKqU7+nH6g8B3cOPs+xj5DiLglhFAeZIBncDqhR7ABw XaWw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; t=1701881079; s=strato-dkim-0002; d=strato.com; h=In-Reply-To:From:References:To:Subject:Date:Message-ID:Cc:Date:From: Subject:Sender; bh=s1dsY+A+CJC/gBcaEpFLa2eoIMoaPQ86amj/YPop1hw=; b=VG5+8h9rzHXPES4BGDdkF5LVZIFR96LgCh3FjZr4hvu2HFiV0kmIjFUmDyIprCiR6o PkAMLSLP4K1eO8cFW6MEZhXbw4hehYQErTrvmcgNjAG0k08PwxV3GpZ0GXeMOowwhcjY Qd2b/NpyKvq36ryXScPecij6GO2rEQMEZ5/0OaaO4MxuV7a1kpR/7BISmbSexNI25cZP SSKls9rF9E0/V2530q65vi0dT6Pdqwi0FciyYsxdDLeOMXxYvvLvpHE6TjufBT/B84Jy mlBYhmjRtaP3oZR/2nvXMiuxulyj4OE/ofES3BWrFBHHZsL632n62wPF+RarBXt9GMx/ ptvQ== ARC-Authentication-Results: i=1; strato.com; arc=none; dkim=none X-RZG-CLASS-ID: mo00 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; t=1701881079; s=strato-dkim-0002; d=gjlay.de; h=In-Reply-To:From:References:To:Subject:Date:Message-ID:Cc:Date:From: Subject:Sender; bh=s1dsY+A+CJC/gBcaEpFLa2eoIMoaPQ86amj/YPop1hw=; b=AX9I2MHLQxEusPTeGMA3uAUsNZ8Vi8abbKmoANG1mWwc/pg8lzYdAZV29IdL4HD/4+ Mzh1fKiyely90O9qI418Oo0YwjbCy5gHpSPlq6Nnei6t2yWnxIgJGzR9/g5bvWVZHJvb iOI1ba8/9sZGjbrw2sYvCsCdM6LXWG0H9iRVnE5kEOlSZJBE8pM/BvSgNenj4OLs5Tag fW2rhRA6ORvKMF7XUboAlaf4gOnF3VqfD9Ruvoy3cDtW3ErFEf1hVAPTP5mdXD2ps207 sNujgfO4LGHb38ydCwiBg/stRj/WTsz4u838xI88hjArljIM5lT7ak0MADIv/38tBXZN qF4A== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; t=1701881079; s=strato-dkim-0003; d=gjlay.de; h=In-Reply-To:From:References:To:Subject:Date:Message-ID:Cc:Date:From: Subject:Sender; bh=s1dsY+A+CJC/gBcaEpFLa2eoIMoaPQ86amj/YPop1hw=; b=AMRbuUSd+31nGF2UxS4ijyn6H4mudNxuPD9ijaxTeUZdaA1u9ekHwdlyhFF6uazray HDh+wOhS1dGBzJXRgeAA== X-RZG-AUTH: ":LXoWVUeid/7A29J/hMvvT3koxZnKT7Qq0xotTetVnKkSjsSjo3O/MHXSz1aalw==" Received: from [192.168.2.102] by smtp.strato.de (RZmta 49.10.0 DYNA|AUTH) with ESMTPSA id Lf3d8bzB6GidBR3 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256 bits)) (Client did not present a certificate); Wed, 6 Dec 2023 17:44:39 +0100 (CET) Message-ID: Date: Wed, 6 Dec 2023 17:44:38 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Question: default linker scripts and emulations Content-Language: en-US To: Nick Clifton , binutils@sourceware.org References: <26f6143b-cd4c-4c7d-bf06-4265d17f417f@gjlay.de> <627688a1-176c-4a8e-984e-3848c902b273@redhat.com> From: Georg-Johann Lay In-Reply-To: <627688a1-176c-4a8e-984e-3848c902b273@redhat.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.0 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_NONE,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Ni Nick Am 06.12.23 um 12:21 schrieb Nick Clifton: > Hi Johann, > >> GCC could generate better code for some devices if it could use an >> adjusted linker description file for these devices. >> >> Is it possible to add a new option to the linker so it picks a different >> ld script, such that: >> >> o The same emulation is used. >> >> o All works a usual, e.g. when the user request -T myscript.ld, use >> myscript.ld provided it is a complete ld script and not just INSERT >> AFTER etc. > > >> In the case a new emulation is required: >> >> The compiler has currently around 60 multilib variants, and a new >> emulation >> would add yet another 6 multilibs. Therefore, it would be desirable to >> re-use the old multilib (which still has some devices in it). >> >> Say the old machine is avr:102 and the new one is avr:108, but the >> generated >> code is all the same, only difference is ld script. The compiler would >> map avr:108 to avr:102 multilibs. >> >> What's the best way to implement this in Binutils? > > Actually it might be easier to implement this using gcc's spec file syntax > rather than adding a new linker option.  For example > >   gcc [...other gcc options...] --specs=avr108.spec > > and avr108.spec could contain: > >   *self_spec: >   + %{!T{-T avr108.ld}} > > The spec file syntax allows for options to be conditionally added, so in > this > case a "-T avr108.ld" would be added to the linker command line only if the > user has not already provided a -T option of their own. > > [This is totally not tested by me, but I think that in theory it should > work]. > > Cheers >   Nick I don't see how this can work, because there is no way to inspect the contents of the provided file: * When the user provides a complete ld-script, then use his script instead of avr108.ld. * When the user provides an ld-script snipped with INSERT AFTER etc, then use avr108.ld but with the augmentation provided by the user. But the compiler (or specs handling) cannot tell which is which. Then there's the technical problem that the compiler needs to know the install path (in configure and when running) and provide the complete path to avr108.ld. Just dropping avr108.ld in $install/avr/lib/ldscripts is not enough that the linker can find it with -Tavr108.ld Then the specs would need to be able to select different ld-script flavours like *.x, *.xn, *.xr, etc depending on options like -r and whatnot. And the default ld-scripts are contained in the ld executable, so that changing the scripts on file won't have any effect (except you select them explicitly with -T). IMO specs cannot resolve that in a reasonable way, in particular the distinction between complete ld-scripts and snippets. Cheers, Johann