From patchwork Sat Apr 15 17:37:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexey Dobriyan X-Patchwork-Id: 83759 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp1163008vqo; Sat, 15 Apr 2023 10:39:50 -0700 (PDT) X-Google-Smtp-Source: AKy350a+dLQ9gzKipOtGqIqAg267JbqzEqd5MeVIa2hAV9uv1C9/JdjhKNHxJtbcbUFDT25KIg4q X-Received: by 2002:a17:90b:1e02:b0:246:aebf:21f5 with SMTP id pg2-20020a17090b1e0200b00246aebf21f5mr9863637pjb.41.1681580390523; Sat, 15 Apr 2023 10:39:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681580390; cv=none; d=google.com; s=arc-20160816; b=LaNZJkhtNNcGpQLf18Yt8GFbWb6P68nSSAMaLKwmAPuwUU28RFGYZUCzXjz2ba+UmF rmejRrfCmZ7NeIz60jlMMKsWz84oPAzC6MsM4XVDw3jChATmQDlZ7RsOypCoUoQ+jh2L WZAucF/kTlI+LLyusKxGBIqdU7H6VtFCORe6l/JlVWxqzkj/NAem2KH+fQ4vUDRCcXm/ qNQSdU5R7V9OiPgD9rRAzhRZTyo4zWtX+P9RBTZA6nFxpzzOphLwjd4cz8LIQ+fi/57P 6Ge/z8FnJ9RuiQvW+qQdnHC2RUrNG9AA2Qrc0R2yTlS2kogOTYnb9/f8OMe4oOwMlEHu DLRg== 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=LjLF8YJVlIoAVrd1Wc6EQsJn6IlLs+osyJa+45a2H+4=; b=t38z4X+Sqw0KL/fDEmGuMYrIRvWWuHbXrCmNXyLlIaANBGNA/HZdjPgNf3nclrpXza B6r4TL2IWwC2gLKrcD+UB0Muy3mNIZhbWUpcArv7KB35p03eLUBGfZwxB4lpL4E3L6Wf DXOiJVT56iJL53JxTj4IKgaxk46wb0cirwSoOMq1WnDQnsutg7j9FeXfeEGjq8RB90oZ /WICBMHQW6LZWdivXFNiYVxr0Om9wa8G0DlzI+IBF7lw1Af++NDHpsjzAySrlkuupvFM OTFDgWdPbW8OOaPGLKLga6IHXc+43Ztctu8p2l5P3BAJLh9dI92l9P7Brw7t84uV5QY1 X0Yg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=oUXO8xfk; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l10-20020a17090a850a00b0024695095bb3si9980382pjn.189.2023.04.15.10.39.37; Sat, 15 Apr 2023 10:39:50 -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=20221208 header.b=oUXO8xfk; 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 S230131AbjDORiV (ORCPT + 99 others); Sat, 15 Apr 2023 13:38:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49350 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229720AbjDORiT (ORCPT ); Sat, 15 Apr 2023 13:38:19 -0400 Received: from mail-ej1-x62c.google.com (mail-ej1-x62c.google.com [IPv6:2a00:1450:4864:20::62c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 058E755B1; Sat, 15 Apr 2023 10:37:35 -0700 (PDT) Received: by mail-ej1-x62c.google.com with SMTP id xd13so19666674ejb.4; Sat, 15 Apr 2023 10:37:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1681580252; x=1684172252; 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=LjLF8YJVlIoAVrd1Wc6EQsJn6IlLs+osyJa+45a2H+4=; b=oUXO8xfkcdjlTNarUAttjz4iKfRgUqUoQF8hZnkRSGRMulnqzN1ut6yrYdLXtnwixu mMa/b0DQ0aMcpVVtf+IFKipOSGtpHMU0fD2ZyarfAx1hL7bYGl5P3SmuHmjAoi45L2LF obhlm32zXABsQKFRaQgth1xFqG//E9loWeTS3oejfcLgUhCSN3DdPFtcKKM3YDlx4zZd +N3V5h7h4iPDWekAd4OGFdXHNLwJkxNt4oInz7qboX9vdhGSOKBILc/KhTmhQoyVdW1v sIOAnLsCb+Tv9pUyayQcXub6wWZk+kq+JYilPIIQ3Drp8xYNIaXy9HMTD8Ss+uLtskeO nw9g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681580252; x=1684172252; 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=LjLF8YJVlIoAVrd1Wc6EQsJn6IlLs+osyJa+45a2H+4=; b=UYyqaeAqN8gKVyZ6KvleCiuFVG+Ef2K/J6NDJ6r8xOFdhGliKq3S+DrwK2QlCgJcmw IkPNvsL5MBRyr3xhrqBieN7BxYVv1c1F6m4rru0akOLOqtTa1WAoisgUWVKJhxrHcxmi Laum8ir1eosDAl1ngLoMfMF9aDDFtqUHCUsyOFZ5yf7dz4GvZor5sKzV4jg3zdtvgnos xrDEV10kkAbb+t+ZJIa4vpIJAEEypSGtrkkz3PNGYE0Pl8BgOpmkO/zvBwbq5X5/J/Iy 4D6H1ncrlaOBPw982Kjc7EBIew64BlPMCNpCzGE8/hw8E0n6j6aW/7+JwGgurmhnXfKO EESg== X-Gm-Message-State: AAQBX9dzR0vxSvArO4i6aIgycT0/GufHx4VdDDK8fYfD/a7pRxCFB+O4 3zg3QnR55KZugB4vcZSeMg== X-Received: by 2002:a17:906:5502:b0:94f:ca5:c437 with SMTP id r2-20020a170906550200b0094f0ca5c437mr2818304ejp.24.1681580251723; Sat, 15 Apr 2023 10:37:31 -0700 (PDT) Received: from p183 ([46.53.250.148]) by smtp.gmail.com with ESMTPSA id p25-20020a17090635d900b0094e75d3ba1bsm4054490ejb.131.2023.04.15.10.37.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 15 Apr 2023 10:37:31 -0700 (PDT) Date: Sat, 15 Apr 2023 20:37:29 +0300 From: Alexey Dobriyan To: akpm@linux-foundation.org Cc: linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, Randy Dunlap , Bagas Sanjaya , Jonathan Corbet Subject: [PATCH v3] ELF: document some de-facto PT_* ABI quirks Message-ID: <88d3f1bb-f4e0-4c40-9304-3843513a1262@p183> References: <2acb586c-08a9-42d9-a41e-7986cc1383ea@p183> <87edp7jyu4.fsf@meer.lwn.net> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <87edp7jyu4.fsf@meer.lwn.net> X-Spam-Status: No, score=-2.1 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 autolearn=ham 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1760365561083902985?= X-GMAIL-MSGID: =?utf-8?q?1763264839817911869?= Turns out rules about PT_INTERP, PT_GNU_STACK and PT_GNU_PROPERTY program headers are slightly different. Signed-off-by: Alexey Dobriyan --- v3: move to Documentation/userspace-api/ v2: integrate into documentation build system Documentation/userspace-api/ELF.rst | 34 ++++++++++++++++++++++++++++++++++ Documentation/userspace-api/index.rst | 1 + 2 files changed, 35 insertions(+) new file mode 100644 --- /dev/null +++ b/Documentation/userspace-api/ELF.rst @@ -0,0 +1,34 @@ +.. 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 in the file: +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. --- a/Documentation/userspace-api/index.rst +++ b/Documentation/userspace-api/index.rst @@ -23,6 +23,7 @@ place where this information is gathered. spec_ctrl accelerators/ocxl ebpf/index + ELF ioctl/index iommu iommufd