Bug 26656 - power10 libstdc++.so segfault in __cxxabiv1::__cxa_throw
Summary: power10 libstdc++.so segfault in __cxxabiv1::__cxa_throw
Status: RESOLVED FIXED
Alias: None
Product: binutils
Classification: Unclassified
Component: ld (show other bugs)
Version: 2.36
: P2 normal
Target Milestone: 2.36
Assignee: Alan Modra
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-09-23 09:29 UTC by Alan Modra
Modified: 2020-09-28 00:17 UTC (History)
0 users

See Also:
Host:
Target: powerpc64*-*
Build:
Last reconfirmed:


Attachments
patch under test (5.49 KB, patch)
2020-09-23 09:34 UTC, Alan Modra
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Alan Modra 2020-09-23 09:29:43 UTC
__cxa_get_globals returns a value of 0x1001, due to __tls_get_addr caching without the required __tls_get_addr_opt plt call stub.
Comment 1 Alan Modra 2020-09-23 09:34:54 UTC
Created attachment 12858 [details]
patch under test
Comment 2 Sourceware Commits 2020-09-23 22:42:31 UTC
The master branch has been updated by Alan Modra <amodra@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=294338867c268b6da43327b6cbe70e746bff1a04

commit 294338867c268b6da43327b6cbe70e746bff1a04
Author: Alan Modra <amodra@gmail.com>
Date:   Tue Sep 22 22:51:42 2020 +0930

    PR26656, power10 libstdc++.so segfault in __cxxabiv1::__cxa_throw
    
    This adds missing support for a power10 version of the __tls_get_addr
    call stub implementing DT_PPC64_OPT PPC64_OPT_TLS.  Without this,
    power10 code using __tls_get_addr fails miserably at runtime unless
    the --no-tls-get-addr-optimize option is given.
    
            PR 26656
            * elf64-ppc.c (plt_stub_size): Add "odd" param.  Use it with
            size_power10_offset rather than calculating from start of stub.
            Add size for notoc tls_get_addr_opt stub.
            (plt_stub_pad): Add "odd" param, pass to plt_stub_size.
            (build_tls_get_addr_head, build_tls_get_addr_tail): New functions.
            (build_tls_get_addr_stub): Delete.
            (ppc_build_one_stub): Use a temp for htab->params->stub_bfd.
            Emit notoc tls_get_addr_opt stub.  Move eh_frame code to
            suit.  Adjust code to use bfd_tls_get_addr_head/tail in place
            of build_tls_get_addr_stub.
            (ppc_size_one_stub): Size notoc tls_get_addr_opt stub.
            Adjust plt_stub_size and plt_stub_pad calls.  Correct "odd"
            when padding stub.  Size eh_frame for notoc stub too.
            Correct lr_restore value.
            (ppc64_elf_relocate_section): Don't skip over first insn of
            notoc tls_get_addr_opt stub.
Comment 3 Sourceware Commits 2020-09-24 02:45:51 UTC
The binutils-2_35-branch branch has been updated by Alan Modra <amodra@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=6f9a6c28850f6839ff61af22c277b2abbf7895da

commit 6f9a6c28850f6839ff61af22c277b2abbf7895da
Author: Alan Modra <amodra@gmail.com>
Date:   Tue Sep 22 22:51:42 2020 +0930

    PR26656, power10 libstdc++.so segfault in __cxxabiv1::__cxa_throw
    
    This adds missing support for a power10 version of the __tls_get_addr
    call stub implementing DT_PPC64_OPT PPC64_OPT_TLS.  Without this,
    power10 code using __tls_get_addr fails miserably at runtime unless
    the --no-tls-get-addr-optimize option is given.
    
            PR 26656
            * elf64-ppc.c (plt_stub_size): Add "odd" param.  Use it with
            size_power10_offset rather than calculating from start of stub.
            Add size for notoc tls_get_addr_opt stub.
            (plt_stub_pad): Add "odd" param, pass to plt_stub_size.
            (build_tls_get_addr_head, build_tls_get_addr_tail): New functions.
            (build_tls_get_addr_stub): Delete.
            (ppc_build_one_stub): Use a temp for htab->params->stub_bfd.
            Emit notoc tls_get_addr_opt stub.  Move eh_frame code to
            suit.  Adjust code to use bfd_tls_get_addr_head/tail in place
            of build_tls_get_addr_stub.
            (ppc_size_one_stub): Size notoc tls_get_addr_opt stub.
            Adjust plt_stub_size and plt_stub_pad calls.  Correct "odd"
            when padding stub.  Size eh_frame for notoc stub too.
            Correct lr_restore value.
            (ppc64_elf_relocate_section): Don't skip over first insn of
            notoc tls_get_addr_opt stub.
    
    (cherry picked from commit 294338867c268b6da43327b6cbe70e746bff1a04)
Comment 4 Alan Modra 2020-09-24 02:48:28 UTC
Fixed
Comment 5 Sourceware Commits 2020-09-28 00:12:24 UTC
The master branch has been updated by Alan Modra <amodra@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=12cf8b93da0ae155643d262235486fde5af72a80

commit 12cf8b93da0ae155643d262235486fde5af72a80
Author: Alan Modra <amodra@gmail.com>
Date:   Mon Sep 28 09:30:19 2020 +0930

    Re: PR26656, power10 libstdc++.so segfault in __cxxabiv1::__cxa_throw
    
    Some missing NULL checks meant a stub for a local symbol used a stub
    looking like the __tls_get_addr_opt stub.
    
            PR 26656
            * elf64-ppc.c (ppc_build_one_stub, ppc_size_one_stub): Check for
            NULL stub_entry->h before calling is_tls_get_addr.
Comment 6 Sourceware Commits 2020-09-28 00:17:28 UTC
The binutils-2_35-branch branch has been updated by Alan Modra <amodra@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=39f2c1f7b80a30297e93f04c885b444e5a874372

commit 39f2c1f7b80a30297e93f04c885b444e5a874372
Author: Alan Modra <amodra@gmail.com>
Date:   Mon Sep 28 09:30:19 2020 +0930

    Re: PR26656, power10 libstdc++.so segfault in __cxxabiv1::__cxa_throw
    
    Some missing NULL checks meant a stub for a local symbol used a stub
    looking like the __tls_get_addr_opt stub.
    
            PR 26656
            * elf64-ppc.c (ppc_build_one_stub, ppc_size_one_stub): Check for
            NULL stub_entry->h before calling is_tls_get_addr.
    
    (cherry picked from commit 12cf8b93da0ae155643d262235486fde5af72a80)