Received: by 2002:a05:6358:53a8:b0:117:f937:c515 with SMTP id z40csp2059793rwe; Sat, 15 Apr 2023 10:39:42 -0700 (PDT) X-Google-Smtp-Source: AKy350a1f6aWqycLdmzBf1oddMc4627Q2E4zI4mdtq19iVO8gk1hm/ygoHS6xlcfMgRhgra6BzyF X-Received: by 2002:a05:6a00:1a16:b0:63b:646d:9165 with SMTP id g22-20020a056a001a1600b0063b646d9165mr8279931pfv.26.1681580382511; Sat, 15 Apr 2023 10:39:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681580382; cv=none; d=google.com; s=arc-20160816; b=Nc7IVLUrayElIW1V5QhGm+36PN10QVUbNhpvCwnNNa1Gq+IoG9DxxFnv1jPgD+e6Vk UFmOtcy4XxCET7tupkBgotMpie666+fH1uNXd6SoXT2DI0A8AfinaveMsMuXL5yBTT1B tVKya9H+FTH76uTPkSs41/Uu8oPbgE4VeGcR32zylQYOvYbSz9x7db9Sf+1vmB+BUEcG MoXcEEAOuA5ojVbTVf79So3E8N5OyHzygM1pwiK2LtYIAlAHk2cB5aON+iLKrWEpIHau QVMsVTGImWQEfcwpAmpcV6Zsin6GY1nlkxxCm0R7EyimuPpr+EbilSdg8BQWW4ZIsq0o Datg== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h188-20020a6253c5000000b0062d781f1f87si7112661pfb.355.2023.04.15.10.39.29; Sat, 15 Apr 2023 10:39:42 -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 S230128AbjDORiV (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-Type: text/plain; charset=utf-8 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 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