[lld] r322259 - [ELF] Fix SysV hash tables with --no-rosegment

Rui Ueyama via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 10 23:05:15 PST 2018


Approved.

On Wed, Jan 10, 2018 at 10:58 PM, Shoaib Meenai <smeenai at fb.com> wrote:

> Requesting a merge to 6.0.
>
>
>
> *From: *llvm-commits <llvm-commits-bounces at lists.llvm.org> on behalf of
> Shoaib Meenai via llvm-commits <llvm-commits at lists.llvm.org>
> *Reply-To: *Shoaib Meenai <smeenai at fb.com>
> *Date: *Wednesday, January 10, 2018 at 10:58 PM
> *To: *"llvm-commits at lists.llvm.org" <llvm-commits at lists.llvm.org>
> *Subject: *[lld] r322259 - [ELF] Fix SysV hash tables with --no-rosegment
>
>
>
> Author: smeenai
>
> Date: Wed Jan 10 22:57:01 2018
>
> New Revision: 322259
>
>
>
> URL: https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.
> org_viewvc_llvm-2Dproject-3Frev-3D322259-26view-3Drev&d=DwIGaQ&c=
> 5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=
> TzrIlS-6umMNRBVgupRbtxnFD-cXXbaxjd-gc8JgZcw&s=
> 3Y89oPU0NvdG7K6lOFdJV5V8EZeTYfpNxkgb3JOIiEQ&e=
>
> Log:
>
> [ELF] Fix SysV hash tables with --no-rosegment
>
>
>
> When setting up the chain, we copy over the bucket's previous symbol
>
> index, assuming that this index will be 0 (STN_UNDEF) for an unused
>
> bucket (marking the end of the chain). When linking with --no-rosegment,
>
> however, unused buckets will in fact contain the padding value, and so
>
> the hash table will end up containing invalid chains. Zero out the hash
>
> table section explicitly to avoid this, similar to what's already done
>
> for GNU hash sections.
>
>
>
> Differential Revision: https://urldefense.proofpoint.
> com/v2/url?u=https-3A__reviews.llvm.org_D41928&d=DwIGaQ&c=
> 5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=
> TzrIlS-6umMNRBVgupRbtxnFD-cXXbaxjd-gc8JgZcw&s=8qLiJg_
> KJkyadNiH7iVdh1Ab9J2tTu3wPrSxx_VYhGk&e=
>
>
>
> Added:
>
>     lld/trunk/test/ELF/sysv-hash-no-rosegment.s
>
> Modified:
>
>     lld/trunk/ELF/SyntheticSections.cpp
>
>
>
> Modified: lld/trunk/ELF/SyntheticSections.cpp
>
> URL: https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.
> org_viewvc_llvm-2Dproject_lld_trunk_ELF_SyntheticSections.
> cpp-3Frev-3D322259-26r1-3D322258-26r2-3D322259-26view-3Ddiff&d=DwIGaQ&c=
> 5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=
> TzrIlS-6umMNRBVgupRbtxnFD-cXXbaxjd-gc8JgZcw&s=Csr47xs-
> UR1RtF4_oipHeeHvguaFAWBjbu_BF-eGMmY&e=
>
> ============================================================
> ==================
>
> --- lld/trunk/ELF/SyntheticSections.cpp (original)
>
> +++ lld/trunk/ELF/SyntheticSections.cpp Wed Jan 10 22:57:01 2018
>
> @@ -1836,6 +1836,9 @@ void HashTableSection::finalizeContents(
>
> }
>
> void HashTableSection::writeTo(uint8_t *Buf) {
>
> +  // See comment in GnuHashTableSection::writeTo.
>
> +  memset(Buf, 0, Size);
>
> +
>
>    unsigned NumSymbols = InX::DynSymTab->getNumSymbols();
>
>    uint32_t *P = reinterpret_cast<uint32_t *>(Buf);
>
>
>
> Added: lld/trunk/test/ELF/sysv-hash-no-rosegment.s
>
> URL: https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.
> org_viewvc_llvm-2Dproject_lld_trunk_test_ELF_sysv-2Dhash-
> 2Dno-2Drosegment.s-3Frev-3D322259-26view-3Dauto&d=DwIGaQ&c=
> 5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=
> TzrIlS-6umMNRBVgupRbtxnFD-cXXbaxjd-gc8JgZcw&s=
> 0bbiAHcIR4yTXv2MSkubnqN6lLXgm4QYw7TElwgAPKk&e=
>
> ============================================================
> ==================
>
> --- lld/trunk/test/ELF/sysv-hash-no-rosegment.s (added)
>
> +++ lld/trunk/test/ELF/sysv-hash-no-rosegment.s Wed Jan 10 22:57:01 2018
>
> @@ -0,0 +1,13 @@
>
> +# REQUIRES: x86
>
> +# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o
>
> +# RUN: ld.lld -shared --no-rosegment -o %t %t.o
>
> +# RUN: llvm-readobj -hash-table %t | FileCheck %s
>
> +
>
> +# CHECK:      HashTable {
>
> +# CHECK-NEXT:   Num Buckets: 2
>
> +# CHECK-NEXT:   Num Chains: 2
>
> +# CHECK-NEXT:   Buckets: [1, 0]
>
> +# CHECK-NEXT:   Chains: [0, 0]
>
> +# CHECK-NEXT: }
>
> +
>
> +callq undef at PLT
>
>
>
>
>
> _______________________________________________
>
> llvm-commits mailing list
>
> llvm-commits at lists.llvm.org
>
> https://urldefense.proofpoint.com/v2/url?u=http-3A__lists.
> llvm.org_cgi-2Dbin_mailman_listinfo_llvm-2Dcommits&d=DwIGaQ&c=
> 5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=
> TzrIlS-6umMNRBVgupRbtxnFD-cXXbaxjd-gc8JgZcw&s=
> jcgUz94QCn22TBZVnEgVpJ7NSgqjghv1AjGNKpmlbmk&e=
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180110/9eda6a2c/attachment.html>


More information about the llvm-commits mailing list