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 2993A3945043 for ; Mon, 9 Mar 2020 01:59:53 +0000 (GMT) Received: by mail-pl1-x644.google.com with SMTP id f16so1183826plj.4 for ; Sun, 08 Mar 2020 18:59:53 -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=ufEFAa2hzqXnGRaKuKiW3QmcGrBPldes024Z3LOQZIM=; b=dqdWCpoVU2+ZdxZJ/H5J/xYokKzEisxW0GikwEt4A09wUbq93ETyr4pgQj31nH23Iw UIbMB00Sm3Yw3OpzqSvMEVAPWjxbfl2DtbXQ0gsPOLE4ZixxlVKsnMIyatn/HEYinTWq BYLIcLN8/Fx7rkQD1bOKRXtTtldeTMU472CIDsSPS24Icd2IJ9t+wxpYvgHD78a1jVJV GLs2kr8jC9mPSrAFVkr2jAwiUofTfrFsaU7z9aAUnXjPcba9gr0OLD28Q8L7gOpqElc5 zgegkqNBd54DvHvrSvok5kYNuH+PhEE9CALTdGyJKCR7cShNZs996Prw317kAW5obSfg /Hzg== 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=ufEFAa2hzqXnGRaKuKiW3QmcGrBPldes024Z3LOQZIM=; b=YVLoO1e20GEY8UrK0WwQ38l4u2S00fce1yERBnEGIzu3ZSiDnwi4QkaYYgvzgIcTau LxMmMbRcOuJgvVP1LyvnKHaZOkmnasVnlXHPQaA8yXqPf6Sq3znIQU3X8dfe7KqQ0HOD dyyZy2pK1rb4VArYwUNvZRBSK4wR5DICIIuYcAAXvRq951LybCWMA0lpUPf3I+6H918y mUlqi3Yr8nEOBtRUh81VtkNxi33iRUE3XwaoWQQ2wRNiLOYDkbwdL/Bs3QVs06EIsUEs yBIpiAJFldjnKhJkKEP/A2k0mJsb/PnpKSyG/F5vv8ETVPEKGze/q24ZgiIBxgLOB8/G XJBg== X-Gm-Message-State: ANhLgQ1KICTH+MWBir44kniUV/i8tD47e37Z6PHkddYSBAWIFW7WEnJb qMOVJorFI958Qa6M8oulZ1YMmtLd X-Google-Smtp-Source: ADFU+vsYIp5cx/cPotoPtFkKFVzSmfjzMRkZjiEyhzpDN11EEUD5s7nMjpvMGKvLSTzicu4dh6IO5A== X-Received: by 2002:a17:90a:858c:: with SMTP id m12mr15892080pjn.127.1583719192058; Sun, 08 Mar 2020 18:59:52 -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 h2sm12411596pjc.7.2020.03.08.18.59.50 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 08 Mar 2020 18:59:51 -0700 (PDT) Subject: Re: RFC: [PATCH] ELF: Don't require section header on ELF objects To: Binutils References: <20200308175947.GA911529@gmail.com> <20200308233553.GG5384@bubble.grove.modra.org> <20200309000543.GJ5384@bubble.grove.modra.org> 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+zj3M6N6zVOcl3JPYM1t2a53x1tuuNtRW1uJNkw37vOuv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w50jR+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: <0ad58560-3dd4-badd-5661-9f74905a7df3@gmail.com> Date: Mon, 9 Mar 2020 12:29:48 +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: 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_2, 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 01:59:54 -0000 On 9/3/20 12:06 pm, H.J. Lu wrote: > On Sun, Mar 8, 2020 at 5:05 PM Alan Modra wrote: >> >> On Sun, Mar 08, 2020 at 04:46:51PM -0700, H.J. Lu wrote: >>> On Sun, Mar 8, 2020 at 4:35 PM Alan Modra wrote: >>>> >>>> On Sun, Mar 08, 2020 at 11:06:33AM -0700, H.J. Lu wrote: >>>>> On Sun, Mar 8, 2020 at 10:59 AM H.J. Lu wrote: >>>>>> >>>>>> Any comments? >>>>>> >>>>>> Kaylee, do you have copyright paper with FSF? >>>>>> >>>>>> H.J. >>>>>> --- >>>>>> 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, >>>>> >>>>> It should read >>>>> >>>>> --- >>>>> all symbols with STB_LOCAL binding are placed >>>>> before symbols with other bindings and all undefined symbols are placed >>>>> before defined ones, >>>>> --- >>>> >>>> That's new to me. I don't think there is any ordering in .dynsym >>>> among non-local symbols. >>> >>> I will get clarification from gABI group. >> >> Well we certainly don't do such sorting. For example, from a freshly >> build ld/ld-new --enable-targets=all >> >> 148: 0000000000f08380 4 OBJECT GLOBAL DEFAULT 25 opterr@GLIBC_2.2.5 (3) >> 149: 0000000000402f80 0 FUNC GLOBAL DEFAULT UND calloc@GLIBC_2.2.5 (3) >> 150: 0000000000881536 35 FUNC GLOBAL DEFAULT 13 _obstack_allocated_p >> > > I will make 2 changes: > > 1. Update -z nosectionheader to guarantee that the last entry in > dynamic symbol table > is defined. > 2. Update --remove-section-header to issue an error if the last entry > in dynamic symbol > table is undefined. > With some testing, it seems like ld will emit an ordered symbol table iff it's using the DT_GNU_HASH hash table style, and my understanding is that DT_GNU_HASH in fact requires this behaviour. So in that case, we don't need to do an additional check, because we only need the ordering if we are looking up through DT_GNU_HASH instead of DT_HASH. -- Kaylee Blake C is the worst language, except for all the others.