Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp1830853rwl; Sun, 26 Mar 2023 09:53:36 -0700 (PDT) X-Google-Smtp-Source: AKy350ZrGPuPMBCXzeAvbQNNzaewx5QqqiApyxjggeWDo5kdmkHiVmqIldh6swNrglZueU5KJ+8w X-Received: by 2002:a17:902:fb08:b0:1a2:1fb9:3b2 with SMTP id le8-20020a170902fb0800b001a21fb903b2mr7347053plb.11.1679849616145; Sun, 26 Mar 2023 09:53:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679849616; cv=none; d=google.com; s=arc-20160816; b=TQgrqtKfEb3iuXv9/Tc2z34LvQrcV0Y7Cal3o6ZvvQnod+B870PJiObmMrErKdl6+8 g52tC5DqDsXHJtKvwMvHkx0gXNrLYWtJalcc1sJ4xUqMtqbtYCcU0qeOseCr7Tnsu6Ay wWDOcdP4gl69GDx2hF1mfD3W1ibOqozZve2xqk/JRma3rOv4M/8oCnSWuINR/RrtnAAa rdSV3FINHxyvzHN2mJn5HQtLOxhItd6pNEBWxeDoBQZYWICkW5akdVJpSY5MKQ/Bcn9K snpHNqqdCVKNwTJN27/NiaYtiWVX/DEElsNihh3Ffl7w4J/1xKw091ymJytbOaHDsrpb 2eiA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=SOOh5ylGciS8r1LLveU70ssf4eo4Db6eqihZ0xNvHJg=; b=OK/QHdPsWcUKFFRsByOCwlDBBSIwYjqq3+BLZktuA0kbPp/+xW6yza9LwrIwwhM/OM 7QHPa8XS4noY0AgsJxHjQH4ymvMOza+R3Yx/JOw72FwDbNmEmxRLFueB9m9K3W9NARCX QHQj9SBaudxs4Im5xaRhw6Z0aBiMSYbkKKXANC01ceHp6dWoSiQv5usySJcJsOiwJApN KGOOUl3bzszVHCrv88Hl2BbC3i5fwns4eY6+UUqRZNGQSXZFYb1YV68fBoGBuGlq9eYu zvRamJpAr1WqB6YNWfpD9ckQupQNbB8hBpnGmhl5uxS+ADmUnYjO9t9qlJ0/QXYx4iFl oJKg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="W/cw9lVy"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d11-20020a630e0b000000b004faf341b31asi26433299pgl.196.2023.03.26.09.53.24; Sun, 26 Mar 2023 09:53:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="W/cw9lVy"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232019AbjCZQtz (ORCPT + 99 others); Sun, 26 Mar 2023 12:49:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39318 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229621AbjCZQty (ORCPT ); Sun, 26 Mar 2023 12:49:54 -0400 Received: from mail-ed1-x532.google.com (mail-ed1-x532.google.com [IPv6:2a00:1450:4864:20::532]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1A42D4EE3; Sun, 26 Mar 2023 09:49:53 -0700 (PDT) Received: by mail-ed1-x532.google.com with SMTP id w9so26592557edc.3; Sun, 26 Mar 2023 09:49:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1679849391; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=SOOh5ylGciS8r1LLveU70ssf4eo4Db6eqihZ0xNvHJg=; b=W/cw9lVyy0aMeqCqFFfIwehE7BTu1FoS62XMLn2p4e8aY2PKc1X3eWqZzNNo/gKewP APZ8kNlFiCZyWKFmA0wYXWMzVbfEVqhWb+i7M6cca+BHuD9rO8PUKvgZddPTV7v9GIMd 2XdJuK23yKxY0kz3F/NERPDPg8INB8JOaQspchwsoro70MPKQb4JbOAQ2a+NlN96wAqn 7b5rMLdikbYqWlQTcZ5I7hncR601fNVNa7mXrW5mzR8W5dGSGxvzKZVz+8tZt1uw/vMW +JDXB6hCJ4oOyGsiOgNXoBB5Nnt5vSZDTWBoJSnGKPnlZZuB3TGZ0ZETSAkeWkpPM44E cb4Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679849391; 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=SOOh5ylGciS8r1LLveU70ssf4eo4Db6eqihZ0xNvHJg=; b=BdSkUmQR0dI2RupsAOTxFgwoZIXwq7xhOLJGYtAF2WOJkImndsFrKaVJda4nvVI8lu XcZNPnnKZVz9gQkzPQVK/D6ywleTv1ekHEH5KfqOedM4wOGnIXQeIqFUuaBy3hG+ktSC eIYxi3ifZ+vQnB8ZGm66m16cTFI8V5EW389fLlXITWGPLReq4T/UxSxFsIBNKCjTs9+b Wzj+orPLviXh5I5bvNL8sVlItwnUnmXGHkBm/bsa4/bBhJKBkhtcS0Kc5bDQovgLQbB+ j08Hnh30TTxBQ7LTfSXxfsIWUCnATuY44GgODwwPIOJTyCOklPOy5ZDdABureJHKkr7T c8eA== X-Gm-Message-State: AAQBX9dVZt/qCHh2c8p2nT8Rj2ld8PiwJgd1obG5MVfJf79SaSRGlVO3 GltaUx09PyRMp8pUL/+nNdmug3vFmg== X-Received: by 2002:aa7:d885:0:b0:4fd:2155:74ef with SMTP id u5-20020aa7d885000000b004fd215574efmr9437605edq.19.1679849391532; Sun, 26 Mar 2023 09:49:51 -0700 (PDT) Received: from p183 ([46.53.253.224]) by smtp.gmail.com with ESMTPSA id c5-20020a170906924500b0092be625d981sm13165557ejx.91.2023.03.26.09.49.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Mar 2023 09:49:51 -0700 (PDT) Date: Sun, 26 Mar 2023 19:49:49 +0300 From: Alexey Dobriyan To: akpm@linux-foundation.org Cc: linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, Jonathan Corbet , Randy Dunlap , Bagas Sanjaya Subject: [PATCH v2] ELF: document some de-facto PT_* ABI quirks Message-ID: References: <2acb586c-08a9-42d9-a41e-7986cc1383ea@p183> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-0.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Turns out rules about PT_INTERP, PT_GNU_STACK and PT_GNU_PROPERTY program headers are slightly different. Signed-off-by: Alexey Dobriyan --- v2: integrate into documentation build system Documentation/ELF/ELF.rst | 32 ++++++++++++++++++++++++++++++++ Documentation/ELF/index.rst | 10 ++++++++++ Documentation/index.rst | 1 + 3 files changed, 43 insertions(+) new file mode 100644 --- /dev/null +++ b/Documentation/ELF/ELF.rst @@ -0,0 +1,32 @@ +.. SPDX-License-Identifier: GPL-2.0 + +================================= +Linux-specific ELF idiosyncrasies +================================= + +Definitions +=========== + +"First" program header is the one with the smallest offset in the file: +e_phoff. "Last" program header is the one with the biggest offset: +e_phoff + (e_phnum - 1) * sizeof(Elf_Phdr). + +PT_INTERP +========= + +First PT_INTERP program header is used to locate the filename of ELF +interpreter. Other PT_INTERP headers are ignored (since Linux 2.4.11). + +PT_GNU_STACK +============ + +Last PT_GNU_STACK program header defines userspace stack executability +(since Linux 2.6.6). Other PT_GNU_STACK headers are ignored. + +PT_GNU_PROPERTY +=============== + +ELF interpreter's last PT_GNU_PROPERTY program header is used (since +Linux 5.8). If interpreter doesn't have one, then the last PT_GNU_PROPERTY +program header of an executable is used. Other PT_GNU_PROPERTY headers +are ignored. new file mode 100644 --- /dev/null +++ b/Documentation/ELF/index.rst @@ -0,0 +1,10 @@ +.. SPDX-License-Identifier: GPL-2.0 + +=== +ELF +=== + +.. toctree:: + :maxdepth: 1 + + ELF --- a/Documentation/index.rst +++ b/Documentation/index.rst @@ -113,6 +113,7 @@ to ReStructured Text format, or are simply too old. :maxdepth: 1 staging/index + ELF/index Translations