From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-yw1-f175.google.com (mail-yw1-f175.google.com [209.85.128.175]) by sourceware.org (Postfix) with ESMTPS id 87C01384AB53 for ; Fri, 26 Apr 2024 03:01:05 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 87C01384AB53 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=maskray.me Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 87C01384AB53 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=209.85.128.175 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1714100468; cv=none; b=cthLXUNflPU/vUpR+YHTjEY8dTxafEakfGG7fBh1jpDWFcq4xPg/4fJL+u+1JWo6Yl0IjMVUUx407GRCkjScof0aXkttVL+w2gjvzg3aOyIG9iI21fHrVRpH3MaExzbMuTu9jqNLT3ecuJxzpE/aphLfTGlxemgru6TRnkXtneA= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1714100468; c=relaxed/simple; bh=HBcX48Pw/HcQ3QXVu74Qy5lrfaLLsMhggdP0F8m2/bo=; h=Date:From:To:Subject:Message-ID:MIME-Version; b=N/EgTwnGht1y8WdGU388BwGgHj4vBFMsXavmOraZkcFjYvJDK96kZ66zXy+taqSot1p3MZVCKuUDFQa8g1tIMiQnWPFoZJca3IKbTrAeF6HgmLlSSRY2PVy/ps4xp0uzvVsFRU7V9xQ1fyPrM9Z8Sm/N5pUOari9clXRYqtW7s8= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-yw1-f175.google.com with SMTP id 00721157ae682-617d411a6b3so13449097b3.3 for ; Thu, 25 Apr 2024 20:01:05 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714100465; x=1714705265; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=E4enNyLQyTWxomsTjPmyqtnUrMjwKRrh5/xYeiUSxL8=; b=ZfmOyEKjYWk6uKiQmV+1nFEyk+ofWyOF14HCWSdMc4ff+RxNYegwLh1UmhHsxh7z0c by3NGSNbOVHrTAY54PaW4olxl1f6ho5l/CpDcc1FL0IYtw8rE6bdS4zBsankttJ4c6gw 3Xhyp60leeWo07oZllOSDRXdP0rhNsxaBYhTVKCvagpNDWfqrrW3riTK/d+JbR1K7D/A 7G7Oy+1rbMyDvTpn48EwcE1GJS6B8nATr1tid5/leaKy0y/cuJLurGLT4VKL+mrDBNCb oJN5V//kyKeYCgagBR/n1KxMENdGwxk2+2F92DVFpHZ1Url42wOu9lETN3H22KzWBSgF hmcQ== X-Forwarded-Encrypted: i=1; AJvYcCXMxNsb7vdfJh3LBEb8dL3vHweErGHp/5osRhyH72yrRusMNQXvKukNs/OuPR5fnf/TmdeKtf6TIof5uTmavqSVP6ZuZH3vWQ== X-Gm-Message-State: AOJu0YxIdzDf02B6FBcCjIcUxvaJi7cOy4cO0tr+g7GfyzTCJfYD08Pi g/b0y3O832re6sbpBHswcWdIbWowoTVbFOQOjOsmI7AHDhVsZrer X-Google-Smtp-Source: AGHT+IFIIzJi++Cz66kFANghncn85JNLmZKbkmkZiv8hNpwl5UVEKF8b9Yv5T6yEFT+7Axu+6YQDIA== X-Received: by 2002:a05:690c:d86:b0:618:8900:8105 with SMTP id da6-20020a05690c0d8600b0061889008105mr1689452ywb.0.1714100464703; Thu, 25 Apr 2024 20:01:04 -0700 (PDT) Received: from localhost ([2600:1700:5b70:4260:44ad:c183:5c9a:c778]) by smtp.gmail.com with ESMTPSA id y67-20020a81a146000000b00615556f99dfsm3418658ywg.36.2024.04.25.20.01.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Apr 2024 20:01:04 -0700 (PDT) Date: Thu, 25 Apr 2024 20:01:03 -0700 From: Fangrui Song To: Nick Clifton Cc: "H.J. Lu" , Binutils Subject: Re: RFC: syntax for a section ordering file Message-ID: <20240426030103.g62e3r7heuavejzp@google.com> References: <3f373229-b7cf-4229-9591-922838577652@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: <3f373229-b7cf-4229-9591-922838577652@redhat.com> X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,KAM_DMARC_STATUS,KAM_INFOUSMEBIZ,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=no 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 2024-04-24, Nick Clifton wrote: >Hi H.J. Hi Fangrui, > > Is there a defined syntax for the contents of a section ordering file ? > IE one passed to the linker via the --section-ordering= option ? > > I am attempting to take H.J.'s bfd linker text section ordering file > patch and extend it to cover other sections. In doing so, I need to > be sure that I have the syntax right. Hi Nick, * Apple ld -order_file. lld's MachO port ld64.lld has ported the option. The feature is like ld.lld --section-ordering-file='s superset with filename support. The syntax also supports "x86_64:" prefix, but this design seems quite unusual in linker features. This option is used by iOS mobile applications. example: https://github.com/llvm/llvm-project/blob/main/lld/test/MachO/order-file.s * gold --section-ordering-file=: which might be most similar to this patch. I believe this option is effectively unused in the wild. People find the section-based naming approach too inconvenient. This is incompatible with sections that are not suffixed and clang -fno-unique-section-names. * ld.lld --symbol-ordering-file=: This option is used by Android and regular Linux folks focusing on server performance. example: https://github.com/llvm/llvm-project/blob/main/lld/test/ELF/symbol-ordering-file.s I have some notes at https://maskray.me/blog/2020-11-15-explain-gnu-linker-options#symbol-ordering-filefile The default linker script contains an input section description. *(.text .stub .text.* .gnu.linkonce.t.*) I'm still curious whether it is feasible to implement --symbol-ordering-file that decides how to sort the .text.* pattern. > To my mind if the section ordering file contains the following: > > # A comment > .text.hot .text.cold,.text.warm > .data.big > .data.small > .text.foo* If we are going to implement --section-ordering-file=, perhaps be rigid and disallow space or comma separated patterns? I believe the aforementioned implementations do not split the line. > Then this should be roughly equivalent to: > > SECTIONS > { > .text : { > *(.text.hot) > *(.text.cold) > *(.text.warm) > *(.text.foo*) > *(.text) > } > .data : { > *(.data.big) > *(.data.small) > *(.data) > } > } > > So all of the .text. entries in the section ordering > file are placed at the start of the output .text section (even > if some of them occur after entries for other output sections) > and all of the .data. entries are placed at the start > of the .data section. > > This will require co-operation from the linker script to have > the "INCLUDE config.section-ordering-file" statements at the > correct places, but I think that it could work. Hmm. I am curious why the first INCLUDE (in .text) does not append .data.big/.data.small (as requested). > But obviously I want the option to be compatible with GOLD and > LLD and I could not find any clear definitions or examples of > the syntax used. > >Cheers > Nick >