From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pl1-x62d.google.com (mail-pl1-x62d.google.com [IPv6:2607:f8b0:4864:20::62d]) by sourceware.org (Postfix) with ESMTPS id 3F5143858D20 for ; Sat, 18 Nov 2023 00:18:24 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 3F5143858D20 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 3F5143858D20 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::62d ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700266714; cv=none; b=WR9g8gL07d/OOPKKm5wX99YludfuX1rcsCbIuBFLgZCsKIhtkhpiiX2P21wDqLerBeeddN4EjHQX6T3dHuioJbrgHv3YNxLeTSx8GqFtxFrtBwegA7ravLyJ1vnNq6Vva8QhOt8j4CbSW7fQuD9tlMaz2+u4sCuO6wq0TRipaWw= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700266714; c=relaxed/simple; bh=Z/evecOnks1eqDDuiIykW+C/+24SYt50AbBl9GaJCuw=; h=DKIM-Signature:Date:Message-ID:From:To:Subject; b=eHR3/rJQgQ01PLCsa/OXaIZxOVIkNhGghGNv89ijftbvpmZiGGC+q6PwMN77d6YDyhhJ3t4CghWxHA8fwyKE5sEPUSdE8rAsgLMtoudykTQkiEKUTcL6nZdJGEjnL2XRUGM0v6dWXX+fAT9jnAvAhF4oPUAGYFtGQljA60d/0nU= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pl1-x62d.google.com with SMTP id d9443c01a7336-1ce656b9780so5317745ad.2 for ; Fri, 17 Nov 2023 16:18:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1700266703; x=1700871503; darn=sourceware.org; h=in-reply-to:subject:to:from:message-id:date:from:to:cc:subject:date :message-id:reply-to; bh=E8ZYiVv0Tnvw0KdjxnvqVJRI7er1EaPKFWZ1YRraVgE=; b=AIg1jBkjgH/YBX7l7u8mOJBOXyq91MADQJbeYAmuBy4xCAPjWO/UNV7hQVyEG9RWTi uKbHK/7G9dZfm3MJ5wqLJ7URiQbovQVuQN9YCeXLxZKiaOOz7bb4umjAIdqzHUE8gwpC p5Fv707oQK8dAiG1vdS0CTk55n6glRrSGtc2Gbc3IYt7jNUPJPJtG9VIUaP2Y7mKQmNk JgSYojnOr5gOqQugF15uhIyyeI1N+eRDOgJGZkj7nRyhdc1QbucJcC8DGk7zAj4Li05G Z7iYiinOCucJIZePLdvz6EBxvOYD+qu//sQ0uBG/WrTKo+6GV4P8XDdKHgLW0ww16ukG j0CA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700266703; x=1700871503; h=in-reply-to:subject:to:from:message-id:date:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=E8ZYiVv0Tnvw0KdjxnvqVJRI7er1EaPKFWZ1YRraVgE=; b=hupanQRMqutyaABjHhujLKLDtGXr0YasjKwbB2aOWE93F1R1MluSYtO+sD0FsH3JD9 TCqEC4uIMdSBBpnX7iuY0k01cZdX5Sau/l+UqsaCFsEQR1WD+IQbwo9P4f8tL9ReoDMx VkedZJ5fasvZEl+VT4lPEEblU6rLO0Oiy0SBYxhM6Z8jIFUyt0hIVTtUocRPsJSREhw+ /9xOeXX88wf0C8scC3EE0fNWcIYI703xNccp6YKrYG1hJg9sse85w6P0MMErOFQAgTly UyjaxOQiJXrO/r8jLJpnOSozpiiXDNiaR9bXkZxWRihD5r2mpvDwnMnmg6GMKDdMSv62 bswA== X-Gm-Message-State: AOJu0Yw7CKNEQbf18B9HgiqNKfTFajK1E/AH7bptdNUqog4YiGqy62rL 5o6Sj4Eu8iVutxCsDe2iRSHiJtjr4UM= X-Google-Smtp-Source: AGHT+IEvUTD3nMXx3pIi95tobBZC9/HETwhpq4KuzJx1DLPqFe1x3zfml3nrplGvMzdLK43Pp4g8xg== X-Received: by 2002:a17:902:ab86:b0:1c7:49dd:2df with SMTP id f6-20020a170902ab8600b001c749dd02dfmr1228173plr.32.1700266702940; Fri, 17 Nov 2023 16:18:22 -0800 (PST) Received: from localhost ([2804:7f0:3990:c9ca:64ee:c181:1da6:e88a]) by smtp.gmail.com with ESMTPSA id je6-20020a170903264600b001b8a3e2c241sm1956355plb.14.2023.11.17.16.18.21 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Nov 2023 16:18:22 -0800 (PST) Date: Fri, 17 Nov 2023 21:18:21 -0300 Message-ID: From: Matheus Afonso Martins Moreira To: binutils@sourceware.org Subject: Feature request: spare program headers In-Reply-To: <765a162a-e44d-45c2-95d0-28c0ca47114f@hogyros.de> X-Spam-Status: No, score=-1.4 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: > You can specify PHDRs in your linker script. That's true but I ran into complications when I tried to use the PHDRS directive. I described my attempt in a previous email: https://sourceware.org/pipermail/binutils/2023-November/130561.html > I copied ld's internal linker script > and customized it with a PHDRS command: > > PHDRS > { > headers PT_PHDR FILEHDR PHDRS; > text PT_LOAD; > rodata PT_LOAD; > data PT_LOAD; > bss PT_LOAD; > extra PT_LOAD; /* meant to be empty */ > /* size/offset will be set later */ > } > > I was not successful. I keep getting the following error: > > error: could not allocate headers Perhaps it is possible to do it via linker script but I couldn't get it to work no matter what I tried. It's also not possible to do *only* this. Using PHDRS disables the linker's defaults and forces users to specify all the segments. https://sourceware.org/binutils/docs-2.41/ld/PHDRS.html > The linker will create reasonable program headers by default. > When the linker sees the PHDRS command in the linker script, > it will not create any program headers other than the ones specified. As a result of inhibiting those defaults, it also requires us to map all the sections to all the custom segments we created instead of simply letting the linker do it. The result is we have to maintain customized copies of the linker's default scripts in our repositories. An option that adds PT_NULL segments would be much easier to use. Custom post processing tools can later customize those segments with much greater flexibility after the link. I just implemented such a tool for my project.