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 [81.169.146.216]) by sourceware.org (Postfix) with ESMTPS id 470AC3857340 for ; Tue, 19 Dec 2023 11:16:24 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 470AC3857340 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 470AC3857340 Authentication-Results: server2.sourceware.org; arc=pass smtp.remote-ip=81.169.146.216 ARC-Seal: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1702984585; cv=pass; b=O2wZavmr7czLO6wwnWvdT8ixeE85jIoNCng/pUqDBJtGsnNpx/xF6DrxvwlELgnfw1ZCzjPzRpzBNAhCD5gB3lwMpS1ci2dOLwlljPle5QU4li5TSJwTwApC8TENUJ10TCjL+31a0q676swpMiNIBdhImaH61f/B4V6GkviA3W4= ARC-Message-Signature: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1702984585; c=relaxed/simple; bh=pPWRGjP60l25KsO8c82ot1BdxNhbuOPSTf8CdAs0wi0=; h=DKIM-Signature:DKIM-Signature:Message-ID:Date:MIME-Version:To: From:Subject; b=cj/o9hYUzhzEKFGZPCABib/e3FfomW8a9r5ytskSR44jNh9RyVL8jHpJgf8W/JKxknLnlpwmwwj7O7i+2CQvzrOzd+QZF+28nc+ux37RwRzwazN8c9omEZzuO8CPieaZIoJrOzj5zeYrA5hDEB9YRZHY4k2zH+mrr7JAjEU3fbU= ARC-Authentication-Results: i=2; server2.sourceware.org ARC-Seal: i=1; a=rsa-sha256; t=1702984583; cv=none; d=strato.com; s=strato-dkim-0002; b=R8qGiNid/IgcRxv0VXywkgyGZOAtuSBUivf5m3Y9OnVLmnasfgo2xp6f6tikB+hHNV ViLLVKb4/qYggiS8gfpLC1bDna9I6Ob8c4OwSl1gBg79Lh1SPJBgMuWHon38uM5MVdlF c85oNTaVC2dM4JYNurHky5Q3RtcgHTUsR5mopAokp0yjGfzd3iVOkcOqJLrTwXN+wUVf DXl4ixjCqJV3syIpf3+a89/Lsg34gR0+Y4yeDKLxsJ+rIM9TgNpIrtCWlQzWxOw4cl1l hFc/UJbV3swIrwHdbhS7SZxALN5qwXZG75f3HXR2gPZqIny0r0+/oRIwvlE+x+1jnWQp 2xjQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; t=1702984583; s=strato-dkim-0002; d=strato.com; h=Subject:From:To:Date:Message-ID:Cc:Date:From:Subject:Sender; bh=7otRbv4QWqLMtRtV589wxxrHLZ1NMmzAgWSGCB8WRjo=; b=SQqE8iAv1KaWmVDf+GJ1PqVJtvXcSU1hLa1yJXkuP1/VOxvph2+y7rpy5EiXOKxH4N QXGS3hqkuc6peENEs01ZnKyy3OazoxepXI9PQm4Bbu/h0CvxgbyPeYlWpLLM/8/tXbNm jVzfbhXA5SR+UkqYVwXWMgxaGsVN/mOybZ/exTDkkAJ22CwrYCWkZg/yip80zURMDP6d E0+FGrVuk5rW8zezBxU+GToPS6AVm7c1K7TsI+N3gDGLG6CDqb16YYAkJujQ2tAJiXJF RtPQr7qnGPTCnK1UJZqS0MfzqB8X22gzu22RqOm18nMw580hKghl2Ae6qixWqSqzh5UR nQOg== 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=1702984583; s=strato-dkim-0002; d=gjlay.de; h=Subject:From:To:Date:Message-ID:Cc:Date:From:Subject:Sender; bh=7otRbv4QWqLMtRtV589wxxrHLZ1NMmzAgWSGCB8WRjo=; b=ooIzNlIaSHFAsAzjDq5XIq37tXAtgGxvEGs0AxxzKLDski2IN12Rq/QeT0hrPdx11+ Bvxq040wJszWajz9DF6yk+A68vIiXk+29uVCJougoZIZFekbFjqJbV5/W/h6Bf0JoXC/ MxO28A64mnyIfdDss2Wo6MXeoEwwgNmMv5/SXOgoaae9UKFvmP351je/bp9sgb4+a2u/ VozmLD8Zw6OUuPwzY1tNC23QtVCzWWpvuNi6mHHkpFIyhp22ueokz8j/FO2yrUlKenJj L3ZI/+KCAQBHzI8ZEI69FVOeNHl9VthPZYCb1ELrFjYGhGVAhjeN2fWoCgIKKBPwZUw+ 3Uyg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; t=1702984583; s=strato-dkim-0003; d=gjlay.de; h=Subject:From:To:Date:Message-ID:Cc:Date:From:Subject:Sender; bh=7otRbv4QWqLMtRtV589wxxrHLZ1NMmzAgWSGCB8WRjo=; b=AJz2OtWKmkm282YjpbGr2BC/4gIf85HfMMGjuPYynMj5E8zJJICnj8zeTcRmruTIRL 9WkOs9is5LY4X+rLk+BA== 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 Lf3d8bzBJBGMMEC (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256 bits)) (Client did not present a certificate) for ; Tue, 19 Dec 2023 12:16:22 +0100 (CET) Message-ID: <96157ecf-48e9-40a9-88be-9d97cccd0c9b@gjlay.de> Date: Tue, 19 Dec 2023 12:16:22 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Content-Language: en-US To: gcc@gcc.gnu.org From: Georg-Johann Lay Subject: varasm.cc: how to hook in assemble_variable ? Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.9 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,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: The avr backend supports variable attributes like the following that allow to define symbols: __attribute__((address(1234)) char a_symbol; would produce assembly .global a_symbol a_symbol = 1234 This works except for -fdata-sections -fno-common (PR112952), and I am struggling to find a fix. Currently, the asm out happens in ASM_OUTPUT_ALIGNED_DECL_LOCAL and ASM_OUTPUT_ALIGNED_DECL_COMMON, which is bypassed with above options. With -fdata-sections -fno-common there is no way to output the code in the way as required by the attributes. The only way I found is to output in TARGET_ENCODE_SECTION_INFO (resp. cache for later output) and set TREE_ASM_WRITTEN(decl) = 1 in order to bypass the rest of assemble_variable(). However, varasm.cc::assemble_variable() would require an extension: The function currently reads something like below, where lines marked with ! are needed to make it work: void assemble_variable (tree decl, int top_level ATTRIBUTE_UNUSED, int at_end ATTRIBUTE_UNUSED, int dont_output_data) { ... /* The first declaration of a variable that comes through this function decides whether it is global (in C, has external linkage) or local (in C, has internal linkage). So do nothing more if this function has already run. */ if (TREE_ASM_WRITTEN (decl)) return; /* Make sure targetm.encode_section_info is invoked before we set ASM_WRITTEN. */ decl_rtl = DECL_RTL (decl); TREE_ASM_WRITTEN (decl) = 1; ! /* Allow targetm.encode_section_info to output all of decl ! including alignment, globalizing and initializer its own ! way. */ ! if (TREE_ASM_WRITTEN (decl)) ! return; /* Do no output if -fsyntax-only. */ if (flag_syntax_only) return; What's the proposed way to fix this? Thanks in advance, Johann FYI, what won't work is to set TREE_ASM_WRITTEN in insert_attributes for several reasons.