This is the mail archive of the
libc-alpha@sources.redhat.com
mailing list for the glibc project.
Re: __builtin_return_address in dlsym.c
- To: Andreas Schwab <schwab at suse dot de>
- Subject: Re: __builtin_return_address in dlsym.c
- From: schwidefsky at de dot ibm dot com
- Date: Tue, 18 Jul 2000 10:17:30 +0200
- cc: libc-alpha at sourceware dot cygnus dot com
>|> What I did to fix the dlsym bug for S/390 was to replace every call to
>|> __builtin_return_address(?) by
>|> __builtin_extract_return_addr(__builtin_return_address(?)).
>|>
>|> Now the question: is this safe to do for all architectures ?
>
>On targets that define neither RETURN_ADDR_OFFSET nor MASK_RETURN_ADDR
>this is a no-op. From reading the implementation that seems to be exactly
>the right thing to do. Could you please send a patch?
Sure, here it is:
diff -u -r1.3 dlfcn/dlopen.c
--- dlfcn/dlopen.c 2000/03/27 05:18:34 1.3
+++ dlfcn/dlopen.c 2000/07/17 17:34:04
@@ -46,7 +46,7 @@
struct dlopen_args args;
args.file = file;
args.mode = mode;
- args.caller = __builtin_return_address (0);
+ args.caller = __builtin_extract_return_addr(__builtin_return_address
(0));
return _dlerror_run (dlopen_doit, &args) ? NULL : args.new;
}
diff -u -r1.3 dlfcn/dlopenold.c
--- dlfcn/dlopenold.c 2000/03/27 05:18:34 1.3
+++ dlfcn/dlopenold.c 2000/07/17 17:34:04
@@ -50,7 +50,7 @@
{
struct dlopen_args args;
args.file = file;
- args.caller = __builtin_return_address (0);
+ args.caller = __builtin_extract_return_addr(__builtin_return_address
(0));
if ((mode & RTLD_BINDING_MASK) == 0)
/* By default assume RTLD_LAZY. */
diff -u -r1.2 dlfcn/dlsym.c
--- dlfcn/dlsym.c 2000/02/23 22:08:10 1.2
+++ dlfcn/dlsym.c 2000/07/17 17:34:04
@@ -44,7 +44,7 @@
dlsym (void *handle, const char *name)
{
struct dlsym_args args;
- args.who = __builtin_return_address (0);
+ args.who = __builtin_extract_return_addr(__builtin_return_address (0));
args.handle = handle;
args.name = name;
diff -u -r1.2 dlfcn/dlvsym.c
--- dlfcn/dlvsym.c 2000/02/23 22:08:10 1.2
+++ dlfcn/dlvsym.c 2000/07/17 17:34:04
@@ -48,7 +48,7 @@
args.handle = handle;
args.name = name;
- args.who = __builtin_return_address (0);
+ args.who = __builtin_extract_return_addr(__builtin_return_address (0));
args.version = version_str;
return (_dlerror_run (dlvsym_doit, &args) ? NULL : args.sym);
diff -u -r1.4 elf/dl-profstub.c
--- elf/dl-profstub.c 2000/03/23 20:12:00 1.4
+++ elf/dl-profstub.c 2000/07/17 17:34:04
@@ -30,7 +30,8 @@
void
_dl_mcount_wrapper (void *selfpc)
{
- _dl_mcount ((ElfW(Addr)) __builtin_return_address (0),
+ _dl_mcount ((ElfW(Addr)) __builtin_extract_return_addr(
+ __builtin_return_address (0)),
(ElfW(Addr)) selfpc);
}
@@ -39,6 +40,7 @@
_dl_mcount_wrapper_check (void *selfpc)
{
if (_dl_profile_map != NULL)
- _dl_mcount ((ElfW(Addr)) __builtin_return_address (0),
+ _dl_mcount ((ElfW(Addr)) __builtin_extract_return_addr(
+ __builtin_return_address (0)),
(ElfW(Addr)) selfpc);
}
diff -u -r1.63 malloc/malloc.c
--- malloc/malloc.c 2000/06/28 23:27:03 1.63
+++ malloc/malloc.c 2000/07/17 17:34:13
@@ -2678,7 +2678,8 @@
Void_t* result;
#if defined __GNUC__ && __GNUC__ >= 2
- result = (*__malloc_hook)(bytes, __builtin_return_address (0));
+ result = (*__malloc_hook)(bytes, __builtin_extract_return_addr(
+ __builtin_return_address (0)));
#else
result = (*__malloc_hook)(bytes, NULL);
#endif
@@ -2996,7 +2997,8 @@
#if defined _LIBC || defined MALLOC_HOOKS
if (__free_hook != NULL) {
#if defined __GNUC__ && __GNUC__ >= 2
- (*__free_hook)(mem, __builtin_return_address (0));
+ (*__free_hook)(mem, __builtin_extract_return_addr(
+ __builtin_return_address (0)));
#else
(*__free_hook)(mem, NULL);
#endif
@@ -3201,7 +3203,8 @@
Void_t* result;
#if defined __GNUC__ && __GNUC__ >= 2
- result = (*__realloc_hook)(oldmem, bytes, __builtin_return_address
(0));
+ result = (*__realloc_hook)(oldmem, bytes,
__builtin_extract_return_addr(
+ __builtin_return_address
(0)));
#else
result = (*__realloc_hook)(oldmem, bytes, NULL);
#endif
@@ -3479,7 +3482,8 @@
#if defined __GNUC__ && __GNUC__ >= 2
result = (*__memalign_hook)(alignment, bytes,
- __builtin_return_address (0));
+ __builtin_extract_return_addr(
+ __builtin_return_address (0)));
#else
result = (*__memalign_hook)(alignment, bytes, NULL);
#endif
@@ -3671,7 +3675,8 @@
if (__malloc_hook != NULL) {
sz = n * elem_size;
#if defined __GNUC__ && __GNUC__ >= 2
- mem = (*__malloc_hook)(sz, __builtin_return_address (0));
+ mem = (*__malloc_hook)(sz, __builtin_extract_return_addr(
+ __builtin_return_address (0)));
#else
mem = (*__malloc_hook)(sz, NULL);
#endif
diff -u -r1.8 sysdeps/generic/machine-gmon.h
--- sysdeps/generic/machine-gmon.h 1997/07/26 02:27:31 1.8
+++ sysdeps/generic/machine-gmon.h 2000/07/17 17:34:17
@@ -50,6 +50,8 @@
#define MCOUNT \
void _mcount (void) \
{ \
- mcount_internal ((u_long) __builtin_return_address (1), \
- (u_long) __builtin_return_address (0)); \
+ mcount_internal ((u_long) __builtin_extract_return_addr(
\
+ __builtin_return_address (1),
\
+ (u_long) __builtin_extract_return_addr( \
+ __builtin_return_address (0));
\
}
blue skies,
Martin
Linux/390 Design & Development, IBM Deutschland Entwicklung GmbH
Schönaicherstr. 220, D-71032 Böblingen, Telefon: 49 - (0)7031 - 16-2247
E-Mail: schwidefsky@de.ibm.com