[08/58] Mark __dso_handle as hidden [BZ #18822]
Commit Message
Since __dso_handle is always defined by either crtbegin.o from GCC or
dso_handle.c, it should be marked as hidden and be passed directly.
[BZ #18822]
* dlfcn/modatexit.c (foo): Remove __dso_handle check.
* dlfcn/modcxaatexit.c (__dso_handle): Remove declaration.
* dlfcn/tstatexit.c (__dso_handle): Removed.
(main): Don't check __dso_handle.
* dlfcn/tstcxaatexit.c (__dso_handle): Removed.
(main): Don't check __dso_handle.
* include/stdlib.h (__dso_handle): New.
* malloc/mtrace.c (__dso_handle): Remove declaration.
(mtrace): Pass __dso_handle directly.
* nptl/pthread_atfork.c (__dso_handle): Remove declaration.
(__pthread_atfork): Pass __dso_handle directly.
* nptl/tst-atfork2mod.c (__dso_handle): Removed.
* posix/wordexp-test.c (__dso_handle): Remove declaration.
(__app_register_atfork): Pass __dso_handle directly.
* stdlib/at_quick_exit.c (__dso_handle): Remove declaration.
(at_quick_exit): Pass __dso_handle directly.
* stdlib/atexit.c (__dso_handle): Remove declaration.
(atexit): Pass __dso_handle directly.
* stdlib/tst-tls-atexit-lib.c (__dso_handle): Removed.
---
dlfcn/modatexit.c | 2 --
dlfcn/modcxaatexit.c | 1 -
dlfcn/tstatexit.c | 8 --------
dlfcn/tstcxaatexit.c | 8 --------
include/stdlib.h | 4 ++++
malloc/mtrace.c | 3 +--
nptl/pthread_atfork.c | 7 +------
nptl/tst-atfork2mod.c | 1 -
posix/wordexp-test.c | 4 +---
stdlib/at_quick_exit.c | 7 +------
stdlib/atexit.c | 8 +-------
stdlib/tst-tls-atexit-lib.c | 2 --
12 files changed, 9 insertions(+), 46 deletions(-)
Comments
On 09/01/2017 07:59 PM, H.J. Lu wrote:
> diff --git a/include/stdlib.h b/include/stdlib.h
> index 2274790a2e..d0dcbf81c3 100644
> --- a/include/stdlib.h
> +++ b/include/stdlib.h
> @@ -5,6 +5,10 @@
> #endif
> #include <stdlib/stdlib.h>
>
> +/* __dso_handle is always defined by either crtbegin.o from GCC or our
> + dso_handle.c. */
> +extern void *__dso_handle __attribute__ ((visibility ("hidden")));
This causes conform test failures. You need to use __visibility__ here.
Thanks,
Florian
On 09/03/2017 10:21 AM, Florian Weimer wrote:
> On 09/01/2017 07:59 PM, H.J. Lu wrote:
>> diff --git a/include/stdlib.h b/include/stdlib.h
>> index 2274790a2e..d0dcbf81c3 100644
>> --- a/include/stdlib.h
>> +++ b/include/stdlib.h
>> @@ -5,6 +5,10 @@
>> #endif
>> #include <stdlib/stdlib.h>
>>
>> +/* __dso_handle is always defined by either crtbegin.o from GCC or our
>> + dso_handle.c. */
>> +extern void *__dso_handle __attribute__ ((visibility ("hidden")));
>
> This causes conform test failures. You need to use __visibility__ here.
Or alternatively, move the declaration under #ifndef _ISOMAC. That's
probably the better approach because __dso_handle is not part of the
installed headers.
Thanks,
Florian
On Sun, Sep 3, 2017 at 2:11 AM, Florian Weimer <fweimer@redhat.com> wrote:
> On 09/03/2017 10:21 AM, Florian Weimer wrote:
>> On 09/01/2017 07:59 PM, H.J. Lu wrote:
>>> diff --git a/include/stdlib.h b/include/stdlib.h
>>> index 2274790a2e..d0dcbf81c3 100644
>>> --- a/include/stdlib.h
>>> +++ b/include/stdlib.h
>>> @@ -5,6 +5,10 @@
>>> #endif
>>> #include <stdlib/stdlib.h>
>>>
>>> +/* __dso_handle is always defined by either crtbegin.o from GCC or our
>>> + dso_handle.c. */
>>> +extern void *__dso_handle __attribute__ ((visibility ("hidden")));
>>
>> This causes conform test failures. You need to use __visibility__ here.
I am testing it.
> Or alternatively, move the declaration under #ifndef _ISOMAC. That's
> probably the better approach because __dso_handle is not part of the
> installed headers.
>
No, we can't do that. Some tests reference __dso_handle and _ISOMAC
isn't defined for tests.
BTW, hjl/pr18822 branch is what I am using.
On 09/03/2017 03:42 PM, H.J. Lu wrote:
> On Sun, Sep 3, 2017 at 2:11 AM, Florian Weimer <fweimer@redhat.com> wrote:
>> On 09/03/2017 10:21 AM, Florian Weimer wrote:
>>> On 09/01/2017 07:59 PM, H.J. Lu wrote:
>>>> diff --git a/include/stdlib.h b/include/stdlib.h
>>>> index 2274790a2e..d0dcbf81c3 100644
>>>> --- a/include/stdlib.h
>>>> +++ b/include/stdlib.h
>>>> @@ -5,6 +5,10 @@
>>>> #endif
>>>> #include <stdlib/stdlib.h>
>>>>
>>>> +/* __dso_handle is always defined by either crtbegin.o from GCC or our
>>>> + dso_handle.c. */
>>>> +extern void *__dso_handle __attribute__ ((visibility ("hidden")));
>>>
>>> This causes conform test failures. You need to use __visibility__ here.
>> Or alternatively, move the declaration under #ifndef _ISOMAC. That's
>> probably the better approach because __dso_handle is not part of the
>> installed headers.
>>
>
> No, we can't do that. Some tests reference __dso_handle and _ISOMAC
> isn't defined for tests.
These tests should be moved to tests-internal, or __dso_handle should be
declared in a different header and the tests should include it.
As far as I understand it, the _ISOMAC mechanism is there to make the
include/ headers as close as possible to the installed headers, so
declaring things there which are not available after installation
partially invalidates in-tree testing.
Thanks,
Florian
@@ -35,9 +35,7 @@ dummy (void)
void
foo (void *p)
{
- extern void *__dso_handle __attribute__ ((__weak__));
printf ("This is %s\n", __FUNCTION__);
atexit (dummy);
- if (&__dso_handle) puts ("have dso handle"); else puts ("no dso handle");
ip = p;
}
@@ -34,7 +34,6 @@ fluffy (void *p)
void
bar (void *p)
{
- extern void *__dso_handle;
printf ("This is %s\n", __FUNCTION__);
__cxa_atexit (fluffy, p, __dso_handle);
}
@@ -20,8 +20,6 @@
#include <stdlib.h>
-extern void *__dso_handle __attribute__ ((__weak__));
-
int
main (void)
{
@@ -30,12 +28,6 @@ main (void)
void (*fp) (void *);
int v = 0;
- if (&__dso_handle == NULL)
- {
- puts ("__dso_handle not available, cannot perform the test");
- exit (0);
- }
-
h = dlopen (fname, RTLD_NOW);
if (h == NULL)
{
@@ -19,8 +19,6 @@
#include <stdio.h>
#include <stdlib.h>
-extern void *__dso_handle __attribute__ ((__weak__));
-
int
main (void)
{
@@ -29,12 +27,6 @@ main (void)
void (*fp) (void *);
int v = 0;
- if (&__dso_handle == NULL)
- {
- puts ("__dso_handle not available, cannot perform the test");
- exit (0);
- }
-
h = dlopen (fname, RTLD_LAZY);
if (h == NULL)
{
@@ -5,6 +5,10 @@
#endif
#include <stdlib/stdlib.h>
+/* __dso_handle is always defined by either crtbegin.o from GCC or our
+ dso_handle.c. */
+extern void *__dso_handle __attribute__ ((visibility ("hidden")));
+
/* Now define the internal interfaces. */
#if !defined _ISOMAC
# include <sys/stat.h>
@@ -315,10 +315,9 @@ mtrace (void)
#ifdef _LIBC
if (!added_atexit_handler)
{
- extern void *__dso_handle __attribute__ ((__weak__));
added_atexit_handler = 1;
__cxa_atexit ((void (*)(void *))release_libc_mem, NULL,
- &__dso_handle ? __dso_handle : NULL);
+ __dso_handle);
}
#endif
}
@@ -36,10 +36,6 @@
#include "pthreadP.h"
#include <fork.h>
-/* This is defined by newer gcc version unique for each module. */
-extern void *__dso_handle __attribute__ ((__weak__,
- __visibility__ ("hidden")));
-
/* Hide the symbol so that no definition but the one locally in the
executable or DSO is used. */
@@ -51,8 +47,7 @@ attribute_hidden
__pthread_atfork (void (*prepare) (void), void (*parent) (void),
void (*child) (void))
{
- return __register_atfork (prepare, parent, child,
- &__dso_handle == NULL ? NULL : __dso_handle);
+ return __register_atfork (prepare, parent, child, __dso_handle);
}
#ifndef __pthread_atfork
extern int pthread_atfork (void (*prepare) (void), void (*parent) (void),
@@ -46,7 +46,6 @@ static void
__attribute__ ((constructor))
init (void)
{
- extern void *__dso_handle;
printf ("dsohandle = %p\n", __dso_handle);
if (pthread_atfork (prepare, parent, child) != 0)
@@ -30,13 +30,11 @@
#define IFS " \n\t"
-extern void *__dso_handle __attribute__ ((__weak__, __visibility__ ("hidden")));
extern int __register_atfork (void (*) (void), void (*) (void), void (*) (void), void *);
static int __app_register_atfork (void (*prepare) (void), void (*parent) (void), void (*child) (void))
{
- return __register_atfork (prepare, parent, child,
- &__dso_handle == NULL ? NULL : __dso_handle);
+ return __register_atfork (prepare, parent, child, __dso_handle);
}
/* Number of forks seen. */
@@ -36,15 +36,10 @@
#include "exit.h"
-/* This is defined by newer gcc version unique for each module. */
-extern void *__dso_handle __attribute__ ((__weak__));
-
-
/* Register FUNC to be executed by `quick_exit'. */
int
attribute_hidden
at_quick_exit (void (*func) (void))
{
- return __cxa_at_quick_exit ((void (*) (void *)) func,
- &__dso_handle == NULL ? NULL : __dso_handle);
+ return __cxa_at_quick_exit ((void (*) (void *)) func, __dso_handle);
}
@@ -35,11 +35,6 @@
#include <stdlib.h>
#include "exit.h"
-
-/* This is defined by newer gcc version unique for each module. */
-extern void *__dso_handle __attribute__ ((__weak__));
-
-
/* Register FUNC to be executed by `exit'. */
int
#ifndef atexit
@@ -47,6 +42,5 @@ attribute_hidden
#endif
atexit (void (*func) (void))
{
- return __cxa_atexit ((void (*) (void *)) func, NULL,
- &__dso_handle == NULL ? NULL : __dso_handle);
+ return __cxa_atexit ((void (*) (void *)) func, NULL, __dso_handle);
}
@@ -18,8 +18,6 @@
#include <stdlib.h>
-extern void *__dso_handle;
-
typedef struct
{
void *val;