From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pl1-x642.google.com (mail-pl1-x642.google.com [IPv6:2607:f8b0:4864:20::642]) by server2.sourceware.org (Postfix) with ESMTPS id 40BC0389F4E8 for ; Mon, 9 Mar 2020 13:14:55 +0000 (GMT) Received: by mail-pl1-x642.google.com with SMTP id w3so3975355plz.5 for ; Mon, 09 Mar 2020 06:14:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:from:openpgp:autocrypt:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=SbsntQpQGNdkQ0+NmHETS7gme+TlYBWa97kQYN7+v9w=; b=r81Ft/QgqFMuyikMl/P4bi2pfKFdLLwbcleOpiq1bVzYsW3nlCMkHwp1R2eEcQlttR mvErFpJ1Rtpg5rxi3KPTVM0Ct2wqfhtqDsdwUnjER73uTIDBGsqwgcY1Odx8Ij3DK2b1 xb2z8/mLFMK+HERptmKwyr0negJcbXKeXD/xxz2XAdz47TiyWpy+nc+yjGF5rLtkmoHd mnXxFNELnvWL1VMLKV+fbF/gPhi2ErMlzJgIQkuCpO3101fxvnGZZr9MVSngb4yuKtx0 SxDVJOEVqcL2mtlI6OmtEiB9YK7eYPHJRARomfmVrRL7IIbx1fNxJo9vTmfbY42wkasV 1byA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:openpgp:autocrypt :message-id:date:user-agent:mime-version:in-reply-to :content-language:content-transfer-encoding; bh=SbsntQpQGNdkQ0+NmHETS7gme+TlYBWa97kQYN7+v9w=; b=emSI5qKLMGBHe+2/t79xXMjTJv2J0CjzJ0ZJpBv28Z6kcuRjz60UKt57FGqAsm78vs r+xQ4gsX9d8BJqeA24ucyEd3S+LenpyRy5z5KWM1DeebzmXGJ3QMZNvUf0VT0lb32ASD lqu8K4P6SiLdsaKYJ74WYUoF76Yz+CzRuizIrIGeuk7Q2NNydU90DbuVwT2lelC9ojyl At+ORSVfqHGBbiSk6eLwCUqJk8IvdcO2qIE2fhV1HhA5FSb41ZWXCZYkcqrkd0fEapg0 f+Ity4C7pajy0Eygab7c2NWu/3Ka16OOATHmYmrMnDZxjb0bNZgX/D72YP0z8DeWg1S2 2U7Q== X-Gm-Message-State: ANhLgQ32xUOq4bo2mMmSycfiVfYIPJimKCus8odU/vmnVU92JylXjeHb VfBjS9C8vtS1Y+v3m6puXvEl16zh X-Google-Smtp-Source: ADFU+vtuM/EO+Q3Cn6jFiTul1wqSFSDkLjF+9p9ui7790j7ys1haHOobxmOp3RkqjbFbrBM628vvCw== X-Received: by 2002:a17:90a:8d16:: with SMTP id c22mr18430727pjo.192.1583759694126; Mon, 09 Mar 2020 06:14:54 -0700 (PDT) Received: from [10.0.2.1] (61-245-154-180.3df59a.adl.nbn.aussiebb.net. [61.245.154.180]) by smtp.googlemail.com with ESMTPSA id bb13sm5258926pjb.43.2020.03.09.06.14.52 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 09 Mar 2020 06:14:53 -0700 (PDT) Subject: Re: RFC: [PATCH] ELF: Don't require section header on ELF objects To: binutils@sourceware.org References: <20200308175947.GA911529@gmail.com> <87y2sac5er.fsf@mid.deneb.enyo.de> <79bc289f-9202-9aff-61c3-92c7190d2f7d@gmail.com> <875zfdad9j.fsf@mid.deneb.enyo.de> From: Kaylee Blake Openpgp: preference=signencrypt Autocrypt: addr=klkblake@gmail.com; prefer-encrypt=mutual; keydata= xsBNBFEjQLEBCADjjSJEqGgOWM+dK6wvOi5B/i1LFM00hy9x1bZZCj34Z7/6H60KhI00yRaj bJzPzmlAO402Ac69NZMXV+mmFFBAabIg70R0VyJKPxX7QyZ4GM9K9w2+LZM+9OgKhOzoypMa S0O93f4EdJ9R7GbsbnWf4SOhv7tKAnJr3jZwp55YkQDnZBHvLw4r8vHykTd6E198CGy4zOYj z2T09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mEB/9k0s1wDQagXUMw 1HAX0R86QtrIChHINkaD1xhquuNpCD1vkIqbZSfw50jR+unBpqNOTcJcuBsi6dWI6maHw1Xd 27T6Jgm/5C2sgUD6dYFFATGlotID2jNRhYe7PfzL38RDIkx9qi5o7b3/zh20Tm+CLZm1bX7T X7D2TANhpl1S2IusNJUBk2ZMXft3ADeIThYd4xEWiT27zYdV1dBOQLiS4qYW1v+EojnnmoIP xoHvXdSGfLyJTTwqLw1yXxL9yMVfNEl/AGPhMHtwbtWTMofGbLCTrHp03pqCTNaF2VHE0HuO eUz1vhRCYch06svzICIRcrn7NyJvcGhil4f5SF/dwsB8BBgBAgAmAhsMFiEEo7CtRavdB/21 tGFZCN/Og0mNCaMFAl4qYhwFCQ7oVOsACgkQCN/Og0mNCaMiZgf+IZZV5fg1mNscH90Py/k2 I5zznzXqdnCd5DmocX3t9Z26/mcTI0hQhiY8UZFkDxI3E0LFu8hDaRB+ioXNidVNdWZAhpr2 zDMjjwVmlx/Jt3+MI/RygsidIRuYYGy94RLvYTQh6qfuHy/5GDIwgsq+S0MfjdcPCO5NLpPH 8pYowlZiehA0QT5hwNzFR1S2YvxHr+nN99jxhOnQZ2TUt5+mQfXwfCQVHoSiJKrwU6z8Q85o ClHHtbUpOY+W6S2I9lRgeaF/fiDo6nZeKRaF5enwxLHuz6tXkdv04vDx5lJevqjtvUUCglQ1 EdpFPEpbpgoe5SmlCrB+cO0ATaAAA06SxQ== Message-ID: <36183da0-ed0c-13bf-2cb3-bd004e8d46f9@gmail.com> Date: Mon, 9 Mar 2020 23:44:49 +1030 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.0 MIME-Version: 1.0 In-Reply-To: <875zfdad9j.fsf@mid.deneb.enyo.de> Content-Type: text/plain; charset=utf-8 Content-Language: en-GB Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-6.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_1, HK_RANDOM_ENVFROM, HK_RANDOM_FROM, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: binutils@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 09 Mar 2020 13:14:56 -0000 On 9/3/20 11:36 pm, Florian Weimer wrote: > * Kaylee Blake: > >> On 9/3/20 6:43 pm, Florian Weimer wrote: >>> * H. J. Lu: >>> >>>> Section header isn't mandatory on ELF executable nor shared library. >>>> This patch adds a new linker option, -z nosectionheader, to omit ELF >>>> section header when building an executable or shared library, adds >>>> an objcopy and strip option, --remove-section-header, to remove ELF >>>> section header from an executable or shared library. >>>> >>>> The PT_DYNAMIC segment contains DT_HASH/DT_GNU_HASH/DT_MIPS_XHASH, >>>> DT_STRTAB, DT_SYMTAB, DT_STRSZ and DT_SYMENT, which can be used to >>>> reconstruct dynamic symbol table when section header isn't available. >>>> For DT_HASH, the number of dynamic symbol table entries equals the >>>> number of chains. For DT_GNU_HASH/DT_MIPS_XHASH, only defined symbols >>>> with non-STB_LOCAL indings are in hash table. Since in dynamic symbol >>>> table, all symbols with STB_LOCAL binding are placed before symbols with >>>> other bindings and all defined symbols are placed before undefined ones, >>>> the highest symbol index in DT_GNU_HASH/DT_MIPS_XHASH is the highest >>>> dynamic symbol table index. >>> >>> Does this patch enable ld to use shared objects without a section >>> header for linking? >>> >>> I think the NEWS and manual update should clarify this. >>> >>> In my opinion, it should NOT be possible to link against objects >>> without section headers. Lack of section headers clearly marks the >>> object as a run-time only object. This is useful if you want to >>> prevent developers to create DT_NEEDED dependencies on internal >>> libraries, for example. >> >> For shared objects without debug symbols, the section header table is >> ~2kB on average of redundant data. I'm also not a fan of the >> inconsistency of having shared libraries that the dynamic linker is >> perfectly happy to load, but ld can't link against, especially since >> this seems like an oversight rather than an intended design decision. > > You didn't answer my question. 8-) Ah, yes, sorry. It does enable that; that was my primary motivation for my part in it. >> If the internal library use case is worth supporting, adding a note >> tagging said internal library as not meant to be linked against seems >> like a better (and much more efficient) approach? > > The dynamic linker does not look at section headers at all. I was thinking of using the PT_NOTE program header, as that's already used by the dynamic linker to check some things. >> This could also actually result in the dynamic linker rejecting >> attempting to load through DT_NEEDED entry. > > No, DT_NEEDED entries would be how the library is loaded. -- Kaylee Blake C is the worst language, except for all the others.