From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-yb1-xb29.google.com (mail-yb1-xb29.google.com [IPv6:2607:f8b0:4864:20::b29]) by sourceware.org (Postfix) with ESMTPS id CD66D3858D1E for ; Wed, 24 Jan 2024 14:42:30 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org CD66D3858D1E 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 CD66D3858D1E Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::b29 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1706107352; cv=none; b=xdXeOPJ9hT+aQJ5wys6Zb/RyBDDCjDZiCcAZ7PEqeTiywiT4TCq5p+PMK4Iynw9nlDkzVDjZsS1c3NmEB9BYUSh95mwnYnXo1r+RAewrI+FQrMZQSVhSUMqAlT2VJ/YW/jz488RSIYBV9SOp08tnnFxnAaHVwkLo7WDnrwcKOXg= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1706107352; c=relaxed/simple; bh=g5E4l1kTwIrCcv5/bIbYbTGp4hgBrdwJNgts+mc05Xw=; h=DKIM-Signature:MIME-Version:From:Date:Message-ID:Subject:To; b=RWGlzxijUK3TQWI4qyAAIq9SABEYNyaC4WcyR8k/fhyubk/146my98cRrM4xbzesMZier1FD1wZlqMkPgutWI66bfpsgkG2Caaur1wWjOvB3/1CpNZ1Jf3iULVkTyYd7kANDyZuMF7IYG7usVqFQwQsYvZhMqcWOw0VQ7aOq6xE= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-yb1-xb29.google.com with SMTP id 3f1490d57ef6-dc223f3dd5eso4621003276.2 for ; Wed, 24 Jan 2024 06:42:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1706107350; x=1706712150; darn=sourceware.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=yT/6aSVkObkYnKmMWuNnlcZOlBSadlFgCsuGFX8uEfA=; b=URc9T5yje0PsPd5O4Sfn03dbNBreErc0Wrc/DyonxWhIA7TY4Oisc2Mx/BQXtNA+Rm QIEpYoMp4vrc/ST7mgqp+UTYS2d3SxDf3GorKldrnHiwhDgeOHtT3dU/sI0m2aOqpeZZ vSGL1tVTTd3UoIivBLfO0gGrXT4Ad2O7BcBjiEXxgVOKus221/KLyvzLHGMSq1FvIZGD LAGTwZh5TVpXr0+SnPrWGBeckuhadIIQQctvhmzgWlX6uHeRaXsUWDnvZVufBEolqWky Vfsbwsv/mWWevHlDWXuRxK20NdKdXw3OOKwRogVi/C6KmWza+m6wyS+wK3UYtx4lD934 DUVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706107350; x=1706712150; 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=yT/6aSVkObkYnKmMWuNnlcZOlBSadlFgCsuGFX8uEfA=; b=Lmyt8/FJbjOEaw+l0g/mkY0rfi4mHas7ZaNiu7dKZkp4kA+YZwhuIEOC5FOCWsOCJX k40LPRKzjYj5VaPGjwHEIDWYhPJrqqhu8gGFZ/0mkxLwqzZDNXkTsyrKf6duq0uuK4xu kXKgSlb2hAJ74rdzTIhIvzbFTuvqE1D+IAO1+lhKn26OcsRnM5xPN0KRsqUazg6A4QQ6 RNh0dSaRZc1uhZXygBiyAR+/pCxtU/QPokVZ69eRs+q2pBPSYkteIcBxr8AsGi+S4tHu xU4pviMbTAOQ3acJNmlwhovw5W24GdIiHl1fBE1ukK5GcyIlWgw0YbeVHY3mJw0ntsL0 dZRQ== X-Gm-Message-State: AOJu0YzUViWzaT6GHlu8YeP+MiccDQI1N5KTROkBRcIAmRnMAQ6CDlBr lsBtpWsgbO0sYe25etKgJoHJz9fzIT4Wg/tmPyzM4RF9oz5+AJSB+K0AY3vKLqxNVnzRtjwYF2Y 8BZ7tr3lgsVDg0Vz51EiCNMxYmY/K0o8X X-Google-Smtp-Source: AGHT+IFo6v5+4p+3GAqOCO6G5hDXpwj7BP6RgjDB2Pvjud4NiwIPTXK7WXC5vHIx/g3O4me1QMONvoRLGOwqnq5H23E= X-Received: by 2002:a25:ab6a:0:b0:dc6:79d:5132 with SMTP id u97-20020a25ab6a000000b00dc6079d5132mr653172ybi.18.1706107350212; Wed, 24 Jan 2024 06:42:30 -0800 (PST) MIME-Version: 1.0 References: <20240119194552.1255481-1-hjl.tools@gmail.com> <20240119194552.1255481-2-hjl.tools@gmail.com> <038d66e4-e85c-4ca0-822c-c18a1cc6edd0@suse.com> In-Reply-To: From: "H.J. Lu" Date: Wed, 24 Jan 2024 06:41:54 -0800 Message-ID: Subject: Re: [PATCH 1/4] ld: Add --text-section-ordering-file FILE To: Noah Goldstein Cc: Jan Beulich , Fangrui Song , binutils@sourceware.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-3015.0 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 Mon, Jan 22, 2024 at 10:45=E2=80=AFAM H.J. Lu wrot= e: > > On Mon, Jan 22, 2024 at 10:22=E2=80=AFAM Noah Goldstein wrote: > > > > On Mon, Jan 22, 2024 at 12:52=E2=80=AFPM H.J. Lu = wrote: > > > > > > On Sun, Jan 21, 2024 at 11:37=E2=80=AFPM Jan Beulich wrote: > > > > > > > > On 20.01.2024 00:15, Fangrui Song wrote: > > > > > It is a shame that the new feature only applies to .text . Data > > > > > sections and other code sections should be reorderable as well. > > > > > > > > I second this remark. In fact I wonder why it is that text needs > > > > > > The perf data usually provides guidance for text section layout. > > > > > > > treating specially here. Can't the option just be > > > > --section-ordering-file and then permit covering all kinds of > > > > sections? > > > > Another issue with this approach is that it won't work for custom > > linker scripts (because the `INCLUDE` of the ordering file has > > been manually inserted in the defaults). > > Good point. I updated the documentation with > > This option is supported only for default linker scripts in ELF and PE > COFF linkers. > > > A different approach for this patch that may alleviate both concerns > > (work for custom linker scripts + for arbitrary sections) would be to > > update the logic of `section: NAME` in `ldgram.y`. > > We shouldn't do it for linker generated sections, like .plt and .got. > > > We could insert the script contents upon entering any new section. > > > > This might blowup link time (if a link script is inserted at each secti= on), > > so we could add another auxiliary option to specify which sections > > the config script should apply for and make it default to something lik= e > > `.data` and `.text`. > > Sounds like a good improvement. This approach may not be easy to implement in ld. We can't add the same INCLUDE file to more than 1 output section. The first INCLUDE will always win. --=20 H.J.