From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pl1-x644.google.com (mail-pl1-x644.google.com [IPv6:2607:f8b0:4864:20::644]) by server2.sourceware.org (Postfix) with ESMTPS id B1765394442F for ; Mon, 9 Mar 2020 12:54:50 +0000 (GMT) Received: by mail-pl1-x644.google.com with SMTP id g12so3953950plo.3 for ; Mon, 09 Mar 2020 05:54:50 -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=4jpOIw7MT9LpLuCiMTym8ODQm22U8TKpKoxov00o/Ws=; b=JHIYDq+cuIBFFyft/i+C+UXWOftZAqSQu6mtlN3sVe0cJcijuj1jQEJdQlUYB3bcB4 GrRz4Vqrq2/RfIFnyD1YhatWUIiBAQT4S5GudAifGRwAe3q2GsnToBU86pupZdxhAtJz nlRST6qbDvO4XLPgVo08Ppa+Ag7iM9HCTPiV8w5vbvZ0t67jZoHV6ycSKW7UElMO+spx zMwS9+0wruwwK8x9uZ9VqOXhOu1H0iE3XBe7SYNzsTqOQNi7cQAAln8hBwX0dD56l14L ILb2o4AgVwjycNyq/QX/5CCqOPts5aP/kVxjrNB6rQpXJ9KRg3HcmrzsxE0yvyYERRMZ DODw== 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=4jpOIw7MT9LpLuCiMTym8ODQm22U8TKpKoxov00o/Ws=; b=ky1xdUg7OBdiQV0klgZkxaMSswsTs2yss5VK98olArik+9X/zFt3SKxmwVI2wdSxAl DRbG/ku4KGEm9exNFiYof+e9dZHAc3C2laMWH3WIRtSOVjG1rNVXZFTA4arBlkR+gL6o cc59/tndthpAEslF3THLFRjJ48xCUi9aQrJcNCQmpygs3nlp1L3ndRpb5ZMMiA0mMSH8 yPXH6sUTUHjCmHT+Ww8Ni7gu42uwsody+JyW1TzaTmTDZLyiV3XkOxKG5IENFqmb9HII 30G71qCLgR+rqs1FZ2OxUyfjQQoMV/nKta9gnvkd+9Qws1RQtpqkfhvmgfF4KXbdncON WusQ== X-Gm-Message-State: ANhLgQ3m2F96VcsH0m57Hk5K6qQ3BYed92SYayIxZM9IZb/cBBU9XBMs 31/+ayid1ORBjT4ZI3kgipIkDanB X-Google-Smtp-Source: ADFU+vv8Akzqvbev7zg1CP4vdQcuSHoXHTA2NMlHSc3blMXEZcnKFh3S0ikfjXxeEqTvqf1At4MJ+w== X-Received: by 2002:a17:90a:8d86:: with SMTP id d6mr18587069pjo.119.1583758489411; Mon, 09 Mar 2020 05:54:49 -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 fz3sm4753636pjb.41.2020.03.09.05.54.47 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 09 Mar 2020 05:54:48 -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> From: Kaylee Blake Openpgp: preference=signencrypt Autocrypt: addr=klkblake@gmail.com; prefer-encrypt=mutual; keydata= xsBNBFEjQLEBCADjjSJEqGgOWM+dK6wvOi5B/i1LFM00hy9x1bZZCj34Z7/6H60KhI00yRaj bJzPzmlAO402Ac69NZMXV+mmFFBAabIg70R0VyJKPxX7QyZ4GM9K9w2+LZM+9OgKhOzoypMa S0O93f4EdJ9R7GbsbnWf4SOhv7tKAnJr3jZwp55YkQDnZBHvLw4r8vHykTd6E198CGy4zOYj z2T09rVBmuuklUOea+zj3M6N6zVOcl3JPYM1t2a53x1tuuNtRW1uJNkw37vOuv27jE4UCFBh WA+0NGMq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si6dWI6maHw1Xd 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: <79bc289f-9202-9aff-61c3-92c7190d2f7d@gmail.com> Date: Mon, 9 Mar 2020 23:24:44 +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: <87y2sac5er.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 12:54:51 -0000 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. 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? This could also actually result in the dynamic linker rejecting attempting to load through DT_NEEDED entry. -- Kaylee Blake C is the worst language, except for all the others.