Message ID | c1a3a253-5b8f-025d-0a3a-a92fe49583a9@redhat.com |
---|---|
State | New, archived |
Headers |
Received: (qmail 113699 invoked by alias); 14 Jan 2020 15:37:09 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: <gdb-patches.sourceware.org> List-Unsubscribe: <mailto:gdb-patches-unsubscribe-##L=##H@sourceware.org> List-Subscribe: <mailto:gdb-patches-subscribe@sourceware.org> List-Archive: <http://sourceware.org/ml/gdb-patches/> List-Post: <mailto:gdb-patches@sourceware.org> List-Help: <mailto:gdb-patches-help@sourceware.org>, <http://sourceware.org/ml/#faqs> Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 113689 invoked by uid 89); 14 Jan 2020 15:37:09 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 spammy=Obviously, norbert, Norbert X-HELO: us-smtp-1.mimecast.com Received: from us-smtp-delivery-1.mimecast.com (HELO us-smtp-1.mimecast.com) (205.139.110.120) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 14 Jan 2020 15:36:59 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1579016217; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=1q68FaOWZNSNaW1P0mCgTMxmicPt+nAbs3zXpRqU0WQ=; b=MYMTchynMlyqPivqq0H5cLOkRz70zGa8jwbfbFfYVU7bjSyMwPDCNE+ZDQwbMAAVXB//nv 794M8zDut2z2KjfDK9nP7JbgoF4lMfTFYShRjE6U91uhTPrHH6hWKzrasrB8o2iw5B5CmD yNjBmmvZbX3kwy5gaC7CTQoG2NeX31Q= Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-264-YUQopg7AOFql4sxV-8uGeA-1; Tue, 14 Jan 2020 10:36:56 -0500 Received: by mail-wr1-f71.google.com with SMTP id v17so6595589wrm.17 for <gdb-patches@sourceware.org>; Tue, 14 Jan 2020 07:36:56 -0800 (PST) Return-Path: <palves@redhat.com> Received: from ?IPv6:2001:8a0:f913:f700:56ee:75ff:fe8d:232b? ([2001:8a0:f913:f700:56ee:75ff:fe8d:232b]) by smtp.gmail.com with ESMTPSA id n14sm18327661wmi.26.2020.01.14.07.36.53 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 14 Jan 2020 07:36:54 -0800 (PST) Subject: Re: [PATCH][PR build/24805] Explicitly export symbols from gdb_proc_service To: Norbert Lange <nolange79@gmail.com> References: <20200104202004.83439-1-nolange79@gmail.com> <466b1cd0-ce93-15f2-6986-aae17cbee6cf@redhat.com> <CADYdroOYYikB6bsi1J5+4HqVviDKdVF7OzzR4HYRaAWG0bqLOA@mail.gmail.com> Cc: gdb-patches@sourceware.org From: Pedro Alves <palves@redhat.com> Message-ID: <c1a3a253-5b8f-025d-0a3a-a92fe49583a9@redhat.com> Date: Tue, 14 Jan 2020 15:36:53 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.2.1 MIME-Version: 1.0 In-Reply-To: <CADYdroOYYikB6bsi1J5+4HqVviDKdVF7OzzR4HYRaAWG0bqLOA@mail.gmail.com> X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit |
Commit Message
Pedro Alves
Jan. 14, 2020, 3:36 p.m. UTC
On 1/6/20 11:39 PM, Norbert Lange wrote: > Am Mo., 6. Jan. 2020 um 20:21 Uhr schrieb Pedro Alves <palves@redhat.com>: >> >> On 1/4/20 8:20 PM, Norbert Lange wrote: >>> Compiling GDB with '-fvisibility=hidden' will remove the >>> symbols that should be exported. >>> This patch explicitly marks them as visible. >> >> Curious. We have gdb/proc-service.list supposedly for this, >> doesn't -Wl,--dynamic-list work with -fvisibility=hidden then? >> > > Obviously it doesn't, else I would not have spent time figuring out > why libthread_db wont load. OK. Haven't looked at visibility issues in years. It also wasn't clear to me whether the issue could be that -Wl,--dynamic-list wasn't used in your build for some reason, maybe related to how you're configuring GDB. > -Wl,--dynamic-list merely filters the visible symbols, it does not see > "hidden" ones. BTW, you didn't post an actual patch to the list: https://sourceware.org/ml/gdb-patches/2020-01/msg00083.html I found it in bugzilla, though. We can't drop support for the glibc header, since that would mean to also drop support for the Solaris version of the header, and also for whatever other libcs that people build gdb with (e.g., does musl have its own version of the header with different types?). Up until not so long ago, glibc didn't use to install the header, that's why we keep a local copy, IIRC. How about something like this? It's similar to your #2 at <https://sourceware.org/bugzilla/show_bug.cgi?id=24805#c3>, but I'm using typeof to avoid issues with different systems using different prototypes. From 224b74b0fab67cdf25119f16be98a80ada071a09 Mon Sep 17 00:00:00 2001 From: Pedro Alves <palves@redhat.com> Date: Tue, 14 Jan 2020 15:30:49 +0000 Subject: [PATCH] Ensure proc-service symbols have default visibility --- gdb/gdbsupport/gdb_proc_service.h | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) base-commit: 7da6a5b938b426379f61e56e259a925bedfe242b
Comments
On 1/14/20 3:36 PM, Pedro Alves wrote: > On 1/6/20 11:39 PM, Norbert Lange wrote: >> Am Mo., 6. Jan. 2020 um 20:21 Uhr schrieb Pedro Alves <palves@redhat.com>: >>> >>> On 1/4/20 8:20 PM, Norbert Lange wrote: >>>> Compiling GDB with '-fvisibility=hidden' will remove the >>>> symbols that should be exported. >>>> This patch explicitly marks them as visible. >>> >>> Curious. We have gdb/proc-service.list supposedly for this, >>> doesn't -Wl,--dynamic-list work with -fvisibility=hidden then? >>> >> >> Obviously it doesn't, else I would not have spent time figuring out >> why libthread_db wont load. > > OK. Haven't looked at visibility issues in years. It also wasn't clear > to me whether the issue could be that -Wl,--dynamic-list wasn't used > in your build for some reason, maybe related to how you're configuring GDB. > >> -Wl,--dynamic-list merely filters the visible symbols, it does not see >> "hidden" ones. > > BTW, you didn't post an actual patch to the list: > https://sourceware.org/ml/gdb-patches/2020-01/msg00083.html I knew I must have been confused. I found your patch on the list, as a reply to that... > > I found it in bugzilla, though. > > How about something like this? It's similar to your #2 at > <https://sourceware.org/bugzilla/show_bug.cgi?id=24805#c3>, but > I'm using typeof to avoid issues with different systems using > different prototypes. BTW, I forgot to mention why I suggested this as alternative to the push/pop approach. It was that the push/pop approach makes everything indirectly included by <proc_service.h> have default visibility too. I don't know whether that ends up being any function in practice, though. Thanks, Pedro Alves
Am Di., 14. Jan. 2020 um 16:36 Uhr schrieb Pedro Alves <palves@redhat.com>: > > We can't drop support for the glibc header, since that would mean > to also drop support for the Solaris version of the header, and > also for whatever other libcs that people build gdb with (e.g., > does musl have its own version of the header with different types?). > Up until not so long ago, glibc didn't use to install the header, > that's why we keep a local copy, IIRC. No, you don't get what I am trying to say. Commonly you only use external headers for function calls, and the exact definition can vary a bit. What you are doing, for ex. in proc-service.c is implementing the function. like: > ps_err_e > ps_pdread (struct ps_prochandle *ph, psaddr_t addr, void *buf, size_t size) you don't get much, if any, information from the header that's not replicated in the source. The only upside would be to be able to detect mismatches (but that could be done in a separate test_external_proc_header.c, potentially even during configuration). Whatever other libc's (musl doesnt provide/use this AFAIK) or OS's do, including their header does not help at all? You get no mismatch: Don't need it. You get a mismatch: you need to fix that in your c file aswell. > > How about something like this? It's similar to your #2 at > <https://sourceware.org/bugzilla/show_bug.cgi?id=24805#c3>, but > I'm using typeof to avoid issues with different systems using > different prototypes. Yeah, that's better, unless typeof is not supported by the compiler (or its C++ mode). Am Di., 14. Jan. 2020 um 16:47 Uhr schrieb Pedro Alves <palves@redhat.com>: > > On 1/14/20 3:36 PM, Pedro Alves wrote: > > On 1/6/20 11:39 PM, Norbert Lange wrote: > >> Am Mo., 6. Jan. 2020 um 20:21 Uhr schrieb Pedro Alves <palves@redhat.com>: > >>> > >>> On 1/4/20 8:20 PM, Norbert Lange wrote: > >>>> Compiling GDB with '-fvisibility=hidden' will remove the > >>>> symbols that should be exported. > >>>> This patch explicitly marks them as visible. > >>> > >>> Curious. We have gdb/proc-service.list supposedly for this, > >>> doesn't -Wl,--dynamic-list work with -fvisibility=hidden then? > >>> > >> > >> Obviously it doesn't, else I would not have spent time figuring out > >> why libthread_db wont load. > > > > OK. Haven't looked at visibility issues in years. It also wasn't clear > > to me whether the issue could be that -Wl,--dynamic-list wasn't used > > in your build for some reason, maybe related to how you're configuring GDB. > > > >> -Wl,--dynamic-list merely filters the visible symbols, it does not see > >> "hidden" ones. > > > > BTW, you didn't post an actual patch to the list: > > https://sourceware.org/ml/gdb-patches/2020-01/msg00083.html > > I knew I must have been confused. I found your patch on the list, > as a reply to that... NP > > > How about something like this? It's similar to your #2 at > > <https://sourceware.org/bugzilla/show_bug.cgi?id=24805#c3>, but > > I'm using typeof to avoid issues with different systems using > > different prototypes. > > BTW, I forgot to mention why I suggested this as alternative > to the push/pop approach. It was that the push/pop approach > makes everything indirectly included by <proc_service.h> > have default visibility too. I don't know whether that ends > up being any function in practice, though. Yes I am aware of this issue, and its a latent problem I guess. Normally you don't implement header definitions, so you might be ok. Adding tests whether the functions are exported would be nice. Norbert.
On 1/14/20 4:56 PM, Norbert Lange wrote: > Am Di., 14. Jan. 2020 um 16:36 Uhr schrieb Pedro Alves <palves@redhat.com>: >> >> We can't drop support for the glibc header, since that would mean >> to also drop support for the Solaris version of the header, and >> also for whatever other libcs that people build gdb with (e.g., >> does musl have its own version of the header with different types?). >> Up until not so long ago, glibc didn't use to install the header, >> that's why we keep a local copy, IIRC. > > No, you don't get what I am trying to say. > Commonly you only use external headers for function calls, > and the exact definition can vary a bit. > > What you are doing, for ex. in proc-service.c is implementing the function. > > like: >> ps_err_e >> ps_pdread (struct ps_prochandle *ph, psaddr_t addr, void *buf, size_t size) > > you don't get much, if any, information from the header that's not replicated > in the source. The only upside would be to be able to detect mismatches > (but that could be done in a separate test_external_proc_header.c, > potentially even during configuration). > > Whatever other libc's (musl doesnt provide/use this AFAIK) or OS's do, > including their header does not help at all? Well, there's also typedefs, enums, structures. ps_err_e, for example. > > You get no mismatch: Don't need it. > You get a mismatch: you need to fix that in your c file aswell. Or in the header, if the mismatch is in the (non-function) types. > >> >> How about something like this? It's similar to your #2 at >> <https://sourceware.org/bugzilla/show_bug.cgi?id=24805#c3>, but >> I'm using typeof to avoid issues with different systems using >> different prototypes. > > Yeah, that's better, unless typeof is not supported by the compiler > (or its C++ mode). AFAIK, all relevant compilers support it. >>> How about something like this? It's similar to your #2 at >>> <https://sourceware.org/bugzilla/show_bug.cgi?id=24805#c3>, but >>> I'm using typeof to avoid issues with different systems using >>> different prototypes. >> >> BTW, I forgot to mention why I suggested this as alternative >> to the push/pop approach. It was that the push/pop approach >> makes everything indirectly included by <proc_service.h> >> have default visibility too. I don't know whether that ends >> up being any function in practice, though. > > Yes I am aware of this issue, and its a latent problem I guess. > Normally you don't implement header definitions, so you might be ok. > > Adding tests whether the functions are exported would be nice. Agreed. I've merged this to master now. Thanks, Pedro Alves
diff --git a/gdb/gdbsupport/gdb_proc_service.h b/gdb/gdbsupport/gdb_proc_service.h index 3ce2ee80fa9..9872ab2bca4 100644 --- a/gdb/gdbsupport/gdb_proc_service.h +++ b/gdb/gdbsupport/gdb_proc_service.h @@ -170,4 +170,33 @@ EXTERN_C_POP #endif /* HAVE_PROC_SERVICE_H */ +/* Make sure we export the needed symbols, in case GDB is built with + -fvisibility=hidden. */ + +#define PS_EXPORT(SYM) \ + __attribute__((visibility ("default"))) typeof (SYM) SYM + +PS_EXPORT (ps_get_thread_area); +PS_EXPORT (ps_getpid); +PS_EXPORT (ps_lcontinue); +PS_EXPORT (ps_lgetfpregs); +PS_EXPORT (ps_lgetregs); +PS_EXPORT (ps_lsetfpregs); +PS_EXPORT (ps_lsetregs); +PS_EXPORT (ps_lstop); +PS_EXPORT (ps_pcontinue); +PS_EXPORT (ps_pdread); +PS_EXPORT (ps_pdwrite); +PS_EXPORT (ps_pglobal_lookup); +PS_EXPORT (ps_pstop); +PS_EXPORT (ps_ptread); +PS_EXPORT (ps_ptwrite); + +#ifdef __sun__ +PS_EXPORT (ps_lgetxregs); +PS_EXPORT (ps_lgetxregsize); +PS_EXPORT (ps_lsetxregs); +PS_EXPORT (ps_plog); +#endif + #endif /* COMMON_GDB_PROC_SERVICE_H */