From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-yb1-xb35.google.com (mail-yb1-xb35.google.com [IPv6:2607:f8b0:4864:20::b35]) by sourceware.org (Postfix) with ESMTPS id 59123385C6DD for ; Wed, 31 Jan 2024 17:39:49 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 59123385C6DD Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 59123385C6DD Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::b35 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1706722791; cv=none; b=Pe5GeXsfLyfYne2897UPPX8YKBqW020rdbFxqwL0sLvR3LK1uP5L/GfTUeViwACYcwMOj6U2zmgP5FtkmsUbMvfnvSgt6hsl4b9XHvspYC96F0D1sfcxtQsrV6kMxJNaZg4djD+Fua51mExL/Fz4mHppkzdWvUnAtgNggqPnkIg= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1706722791; c=relaxed/simple; bh=9Fu7D+S2PwYvMwJ3W1oy9mL4BLyBKGWP/TSg8FydROQ=; h=DKIM-Signature:MIME-Version:From:Date:Message-ID:Subject:To; b=mrulyPwI/uKwydIiAU68Z3JHitzjgnDZhfajQt2JirjALvh9kUp0DO5KRJsS3g2+QvJY/CpisSq4jwy94wXYS/s9xZgSKhnnJfF8lVxbDoPCS+vnXqdY/2QHaffqCELBkj73Io3Brx5hlMkdHbBaHVN32w3yJfp8rpiMVh9bQHE= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-yb1-xb35.google.com with SMTP id 3f1490d57ef6-dc6933a46efso2940596276.0 for ; Wed, 31 Jan 2024 09:39:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1706722788; x=1707327588; darn=gcc.gnu.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=iiHAiJpESq+rogjBXMmXKn99xh9LKyIn9JDvJU/JUGM=; b=Me8FOz4wdRznq5kwweL8kEmx0GBAgvqVkjvK4WEN3amiRij/xmDC0P15dV4aVZ1yxo QD3Hy5xmfqiS4xN0XjOuNtT/OWtfigY8jL/dQ6ojd/ML9CZ5croc4Nd7mbgVFGUVq/ZX Ytuc+fqUwjsP/oiM8/upIR2LlwEVwGYJ/eVBKrUDCm1cZCwrZbbUpXVQN+QLJecYNvx2 vQXShgCPraRhy5P8Y/cgc3f7nnGWMbeKOr83CBgi/hSDLpSV8JlnZVoH5ABXFtdMB1di UZG5aGGnBHcThqobnhoI0EZhv4t3mNpOlCSHft2CqAwJO6cfJpWaLQnBBPN1KBrI84m0 KC+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706722788; x=1707327588; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=iiHAiJpESq+rogjBXMmXKn99xh9LKyIn9JDvJU/JUGM=; b=G0myin7+FQ7hKhD1tsHc36OEp67F6aYWRD9B4OlTWqPSodxBIbFUlmeeQI/AoF0CL0 aHpe1Zh0hgvkLDrYTJKxd2gm+jmdcN4mwbsDCLBdxCGU78DIn82T0UJpfZoKCv0EInBh Ghr1MAarzvYpB8SjHqVjYRIKb4Pp/uAernxxktIKltqS1dhaP7lhdTIj+pnT9m5KFJ3o ABY+ZuOc8LDbXoBaCdwc9To2EzuTg6XtApVe1ffXYgqHz1o42ejVk542SO2ybrMwyZk/ QbtD8vN9W2/oH1XZu7+wz0Fo/O7PxJFmcE98bwdwupMWVROLQNy3DzngRknCjwrGFOZz GeFg== X-Gm-Message-State: AOJu0YyqJmZX/Nj1wnsP9jR7uGblh7BDHUnU5xdiXx0s1NkscWAJpxE9 CjXOnlfNSXfdkNUFn+q/EMfD5+OZKxiHbYTzgd+phKsg3E8eQGc6yYrJ/un1ekTMIa98NURL2xa INycEP8od7RpTb+/VhZ1YC7Xguis= X-Google-Smtp-Source: AGHT+IFUJqwkO/fPsJQud0G3sj2J6pMH9qdm2t/HKDEooY9KQccT9JEe+wCXaI2GUFKtU3hgcDs+OFLIhJyeQ12GqLU= X-Received: by 2002:a5b:90e:0:b0:dc2:48af:bf0f with SMTP id a14-20020a5b090e000000b00dc248afbf0fmr2457376ybq.51.1706722788636; Wed, 31 Jan 2024 09:39:48 -0800 (PST) MIME-Version: 1.0 References: <20240131022136.572689-1-hjl.tools@gmail.com> In-Reply-To: From: "H.J. Lu" Date: Wed, 31 Jan 2024 09:39:12 -0800 Message-ID: Subject: Re: [PATCH v2] Handle private COMDAT function symbol reference in readonly data section To: Jakub Jelinek Cc: gcc-patches@gcc.gnu.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-3014.5 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,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: On Wed, Jan 31, 2024 at 9:10=E2=80=AFAM Jakub Jelinek wr= ote: > > On Wed, Jan 31, 2024 at 08:48:33AM -0800, H.J. Lu wrote: > > Which function (target hook) can I use to generate > > > > .section .data.rel.ro.local,"awG",@progbits,_ZN1AIxE3fooExx,com= dat > > Just > if (decl) > return get_section (reloc =3D=3D 1 > ? ".data.rel.ro.local" : ".data.rel.ro", > SECTION_WRITE | SECTION_RELRO | SECTION_LINKO= NCE, > decl); > for the first hunk and > else if (decl) > return get_section (".rodata", SECTION_LINKONCE, decl); > in the second case? > > Haven't tried it though, maybe the get_section section conflict stuff > isn't able to handle it (and perhaps that is the reason why we simply don= 't > emit functions into > .section .text,"axG",@progbits,whatever,comdat > sections instead of > .section .text.function_name,"axG",@progbits,whatever,comd= at GNU binutils has no issues with it: [hjl@gnu-cfl-3 tmp]$ cat x.s .section .text,"axG",@progbits,whatever,comdat nop .text nop [hjl@gnu-cfl-3 tmp]$ gcc -c x.s [hjl@gnu-cfl-3 tmp]$ readelf -SW x.o | grep text [ 2] .text PROGBITS 0000000000000000 000048 000001 00 AX 0 0 1 [ 5] .text PROGBITS 0000000000000000 000049 000001 00 AXG 0 0 1 [hjl@gnu-cfl-3 tmp]$ If it doesn't work for some targets, we can use targetm.asm_out.function_rodata_section. > In such case, we could append something to those section names, > like const.pool (or whatever else that couldn't clash with function names= , > so needs probably a dot somewhere). Could be > .data.rel.ro.local.const.pool > .data.rel.ro.const.pool > or > .data.rel.ro.local..shared > .data.rel.ro..shared > or something similar, but .data.rel.ro.local.shared would not be ok, > because it could clash with .data.rel.ro.local section for shared functio= n. > > > > Another question is if we need to do anything about the > > > DECL_COMDAT_GROUP (decl) && DECL_SECTION_NAME (decl) > > > && startswith (DECL_SECTION_NAME (decl), ".gnu.linkonce.t.") > > > case (older linkers) (i.e. when using years old GNU linkers). > > > > > > > Should we support such targets? It is not easy for me to test it. > > Perhaps let's wait if somebody files an issue with such configuration. > > Jakub > --=20 H.J.