From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pj1-x1044.google.com (mail-pj1-x1044.google.com [IPv6:2607:f8b0:4864:20::1044]) by server2.sourceware.org (Postfix) with ESMTPS id 2098F39490A0 for ; Mon, 9 Mar 2020 13:29:05 +0000 (GMT) Received: by mail-pj1-x1044.google.com with SMTP id d8so4451675pje.4 for ; Mon, 09 Mar 2020 06:29:05 -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=xo6O+51DA78f94ld5yhClJshETIhhsw6UNUDeJYsJ7w=; b=lfi9RF6VzZAgYths9lak92wHt+jUJXe7K/8/MCDbVsQ2ZwYp9EFsnaVBI6HJ9uCMID ifkoDn2LfJ0fTmyiToYEOInhRalrfYooIYEgfvt0sQ9kiloGTKAQ2NJKkO5ZSx5M4WmF B8NQR8/F97zqbKjj53C9Q2zA4eyUZUjPV5eXnbz202tAmVVjVVXGtq1DsXZcCMBi0eO4 vycwfFf2sf/Ha3onJZrPAL2z18DNynMGVZ3Ab4ctmIwmSbjmj1oagm3A2Kft3szAYoeV 8cbR+6uR9xqFb91octBa9rI4ILxhYictaWBg14zm4rfa8pPwMUGD0NO/hv0StQdQGmDD URQA== 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=xo6O+51DA78f94ld5yhClJshETIhhsw6UNUDeJYsJ7w=; b=AD9EJbpHqqSwJ3h7tYSQmY3pXbq5Z7XA7pEGa/Jsq3SXSkb/8/+sIyH2dX2tjzPF+o wXallU7eK2j3a6C/+dmy99bT5ZDqgxMQtKoTerarQqv0qEBnGTOyb2mPCQbcnLz6vmWS 2jGAM+BLkBDy5u/Mu72XTCzizapVH++PFGjayGexqTywn+cLg8w0dIQKd5okX+pimGxk 02LgB8v1EpTMOqsyXmh7CRkN5+3lviuoWhB4psYttkY2DMo0PuU9KECYE8zq4mYTp1Rm r0b38EsauWk+MuaqDzfDkN2ZTioyv8DslnNK/zwxpXmdDSYo8O2dXtQda/Jg1BwK87wT /FDA== X-Gm-Message-State: ANhLgQ1+tJnJtIATK9r+qnhYva6U3qs2oTZP5pFYp790SNAYqZ6Qzpaa vDiHQKOLqWZu+E8v3XvXeD9metGU X-Google-Smtp-Source: ADFU+vsBT++VYcb42l1fMruXpMHkCdFnMvWY9Qj+TPidvrip8hrGcKnVe2tl9NZ7zhvYDd3LbqXoVA== X-Received: by 2002:a17:90a:9af:: with SMTP id 44mr18792573pjo.157.1583760543925; Mon, 09 Mar 2020 06:29:03 -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 k14sm11340pje.3.2020.03.09.06.29.02 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 09 Mar 2020 06:29:03 -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> <36183da0-ed0c-13bf-2cb3-bd004e8d46f9@gmail.com> <87y2s98y94.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 S0O93f4EdJ9R7Gbs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oV6IMA EQEAAcLAZQQYAQIADwUCUSNAsQIbDAUJCWYBgAAKCRAI386DSY0JozmEB/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: Date: Mon, 9 Mar 2020 23:58:59 +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: <87y2s98y94.fsf@mid.deneb.enyo.de> Content-Type: text/plain; charset=utf-8 Content-Language: en-GB Content-Transfer-Encoding: 7bit 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:29:06 -0000 On 9/3/20 11:46 pm, Florian Weimer wrote: > * Kaylee Blake: > >> 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. > > I think that's conceptually the wrong thing to do for ELF, sorry. If > there is no section header, the object should be unlinkable. The > linker should not use the dynamic segment to locate the symbol > information, only the dynamic section (in case the link ABI and > run-time ABI are different). I'm confused by your comment about link and run-time ABIs differing; surely if the ABI at runtime differs from the ABI at link time, you are just going to crash at runtime? -- Kaylee Blake C is the worst language, except for all the others.