This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: PATCH: invalid IFUNC DW_AT_linkage_name: memmove strstr time


On Wed, Aug 8, 2012 at 4:16 PM, Roland McGrath <roland@hack.frob.com> wrote:
>> diff --git a/sysdeps/i386/i686/multiarch/strstr-c.c b/sysdeps/i386/i686/multiarch/strstr-c.c
>> index 1fcb00e..cbb2d8c 100644
>> --- a/sysdeps/i386/i686/multiarch/strstr-c.c
>> +++ b/sysdeps/i386/i686/multiarch/strstr-c.c
>> @@ -5,11 +5,17 @@
>>  #undef libc_hidden_builtin_def
>>  #define libc_hidden_builtin_def(name) \
>>    __hidden_ver1 (__strstr_ia32, __GI_strstr, __strstr_ia32);
>> +#undef strstr
>> +#define strstr __redirect_strstr
>
> What are these lines doing?  I guess they are to avoid seeing the normal
> <string.h> declaration of strstr so the compiler doesn't complain about the
> type mismatch when it's defined by strong_alias.  Since it's a subtle
> weirdness, it requires a comment.  Since they aren't directly related to
> the libc_hidden_builtin_def bit, separate from that with a blank line.
>
>> -libc_ifunc (strstr, HAS_SSE4_2 ? __strstr_sse42 : __strstr_ia32);
>> +libc_ifunc (__libc_strstr, HAS_SSE4_2 ? __strstr_sse42 : __strstr_ia32);
>
> No trailing ; after libc_ifunc (it was wrong here before).
>
>> +#undef strstr
>> +strong_alias (__libc_strstr, strstr);
>
> No trailing ; after strong_alias.
>
>> +# undef time
>> +# define time __redirect_time
>> +# include <time.h>
>
> Again, needs comment.
>
>> +# include <dl-vdso.h>
>
> Why is this needed?
>
>> @@ -28,22 +28,28 @@
>>  # undef libc_hidden_builtin_def
>>  # define libc_hidden_builtin_def(name) \
>>    __hidden_ver1 (__memmove_sse2, __GI_memmove, __memmove_sse2);
>> +# undef memmove
>> +# define memmove __redirect_memmove
>
> Blank line, comment.
>
>> -extern __typeof (memmove) __memmove_sse2 attribute_hidden;
>> -extern __typeof (memmove) __memmove_ssse3 attribute_hidden;
>> -extern __typeof (memmove) __memmove_ssse3_back attribute_hidden;
>> +extern void *__memmove_sse2 (void *, const void *, size_t) attribute_hidden;
>> +extern __typeof (__memmove_sse2) __memmove_ssse3 attribute_hidden;
>> +extern __typeof (__memmove_sse2) __memmove_ssse3_back attribute_hidden;
>
> It should still use __typeof throughout.
> You can just refer to __redirect_memmove now.
>
>> +extern __typeof (__memmove_sse2) __libc_memmove;
>
> And here.
>
>> +strong_alias (__libc_memmove, memmove);
>
> No trailing ;.
>
>> @@ -5,11 +5,17 @@
>>  # undef libc_hidden_builtin_def
>>  # define libc_hidden_builtin_def(name) \
>>    __hidden_ver1 (__strstr_sse2, __GI_strstr, __strstr_sse2);
>> +# undef strstr
>> +# define strstr __redirect_strstr
>
> Blank line, comment.
>
>>  #endif
>>
>>  #include "string/strstr.c"
>>
>>  extern char *__strstr_sse42 (const char *, const char *) attribute_hidden;
>>  extern __typeof (__strstr_sse2) __strstr_sse2 attribute_hidden;
>> +extern __typeof (__strstr_sse2) __libc_strstr;
>
> Change these to all use __typeof (__redirect_strstr).
>
>> -libc_ifunc (strstr, HAS_SSE4_2 ? __strstr_sse42 : __strstr_sse2);
>> +libc_ifunc (__libc_strstr, HAS_SSE4_2 ? __strstr_sse42 : __strstr_sse2);
>> +
>> +#undef strstr
>> +strong_alias (__libc_strstr, strstr);
>
> No trailing ; on libc_ifunc and strong_alias.

Here is the updated patch.  OK to install?

Thanks.

-- 
H.J.
---	[BZ #14166]
	* sysdeps/i386/i686/multiarch/strstr-c.c (strstr): Redefined
	to __redirect_strstr.
	(__strstr_sse42): Use typeof __redirect_strstr.
	(__strstr_ia32): Likewise.
	(__libc_strstr): New prototype.
	(strstr): Renamed to ...
	(__libc_strstr): This.
	(strstr): New strong alias of __libc_strstr.
	* sysdeps/x86_64/multiarch/strstr-c.c: Likewise.
	* sysdeps/unix/sysv/linux/x86_64/time.c (time): Redefined to
	__redirect_time.
	Include <time.h>.
	(__GI_time): New prototype.
	(time_ifunc): Replace time with __GI_time.
	(time): New strong alias of __GI_time.
	(__GI_time): Remove strong alias.
	* sysdeps/x86_64/multiarch/memmove.c: Don't include <string.h>.
	Include <stddef.h>.
	(memmove): Redefined to __redirect_memmove.
	(__memmove_sse2): Use typeof __redirect_memmove.
	(__memmove_ssse3): Likewise.
	(__memmove_ssse3_back): Likewise.
	(__libc_memmove): New prototype.
	(memmove): Renamed to ...
	(__libc_memmove): This.
	(memmove): New strong alias of __libc_memmove.

diff --git a/sysdeps/i386/i686/multiarch/strstr-c.c
b/sysdeps/i386/i686/multiarch/strstr-c.c
index 1fcb00e..d1922df 100644
--- a/sysdeps/i386/i686/multiarch/strstr-c.c
+++ b/sysdeps/i386/i686/multiarch/strstr-c.c
@@ -7,9 +7,20 @@
   __hidden_ver1 (__strstr_ia32, __GI_strstr, __strstr_ia32);
 #endif

+/* Redefine strstr so that compiler won't complain the type mismatch
+   from strong_alias below.  */
+#undef strstr
+#define strstr __redirect_strstr
+
 #include "string/strstr.c"

-extern char *__strstr_sse42 (const char *, const char *) attribute_hidden;
-extern __typeof (__strstr_ia32) __strstr_ia32 attribute_hidden;
+extern __typeof (__redirect_strstr) __strstr_sse42 attribute_hidden;
+extern __typeof (__redirect_strstr) __strstr_ia32 attribute_hidden;
+
+/* Avoid DWARF definition DIE on ifunc symbol so that GDB can handle
+   ifunc symbol properly.  */
+extern __typeof (__redirect_strstr) __libc_strstr;
+libc_ifunc (__libc_strstr, HAS_SSE4_2 ? __strstr_sse42 : __strstr_ia32)

-libc_ifunc (strstr, HAS_SSE4_2 ? __strstr_sse42 : __strstr_ia32);
+#undef strstr
+strong_alias (__libc_strstr, strstr)
diff --git a/sysdeps/unix/sysv/linux/x86_64/time.c
b/sysdeps/unix/sysv/linux/x86_64/time.c
index 0e05ddd..c9b34bd 100644
--- a/sysdeps/unix/sysv/linux/x86_64/time.c
+++ b/sysdeps/unix/sysv/linux/x86_64/time.c
@@ -16,11 +16,20 @@
    <http://www.gnu.org/licenses/>.  */

 #ifdef SHARED
+/* Redefine time so that compiler won't complain the type mismatch
+   from strong_alias below.  */
+#undef time
+#define time __redirect_time
+#include <time.h>
+
 #include <dl-vdso.h>

 #define VSYSCALL_ADDR_vtime	0xffffffffff600400

-void *time_ifunc (void) __asm__ ("time");
+/* Avoid DWARF definition DIE on ifunc symbol so that GDB can handle
+   ifunc symbol properly.  */
+extern time_t __GI_time (time_t *);
+void *time_ifunc (void) __asm__ ("__GI_time");

 void *
 time_ifunc (void)
@@ -30,7 +39,10 @@ time_ifunc (void)
   /* If the vDSO is not available we fall back on the old vsyscall.  */
   return _dl_vdso_vsym ("__vdso_time", &linux26) ?: (void *)
VSYSCALL_ADDR_vtime;
 }
-__asm (".type time, %gnu_indirect_function");
+__asm (".type __GI_time, %gnu_indirect_function");
+
+#undef time
+strong_alias (__GI_time, time)

 #else

@@ -45,5 +57,3 @@ time (time_t *t)
 }

 #endif
-
-strong_alias (time, __GI_time)
diff --git a/sysdeps/x86_64/multiarch/memmove.c
b/sysdeps/x86_64/multiarch/memmove.c
index ca16263..93e8399 100644
--- a/sysdeps/x86_64/multiarch/memmove.c
+++ b/sysdeps/x86_64/multiarch/memmove.c
@@ -17,7 +17,7 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */

-#include <string.h>
+#include <stddef.h>

 #ifndef NOT_IN_libc
 #include <shlib-compat.h>
@@ -29,20 +29,31 @@
 # define libc_hidden_builtin_def(name) \
   __hidden_ver1 (__memmove_sse2, __GI_memmove, __memmove_sse2);
 #endif
-#endif

-extern __typeof (memmove) __memmove_sse2 attribute_hidden;
-extern __typeof (memmove) __memmove_ssse3 attribute_hidden;
-extern __typeof (memmove) __memmove_ssse3_back attribute_hidden;
+/* Redefine memmove so that compiler won't complain the type mismatch
+   from strong_alias below.  */
+#undef memmove
+#define memmove __redirect_memmove
+#endif

 #include "string/memmove.c"

 #ifndef NOT_IN_libc
-libc_ifunc (memmove,
+extern __typeof (__redirect_memmove) __memmove_sse2 attribute_hidden;
+extern __typeof (__redirect_memmove) __memmove_ssse3 attribute_hidden;
+extern __typeof (__redirect_memmove) __memmove_ssse3_back attribute_hidden;
+
+/* Avoid DWARF definition DIE on ifunc symbol so that GDB can handle
+   ifunc symbol properly.  */
+extern __typeof (__redirect_memmove) __libc_memmove;
+libc_ifunc (__libc_memmove,
 	    HAS_SSSE3
 	    ? (HAS_FAST_COPY_BACKWARD
 	       ? __memmove_ssse3_back : __memmove_ssse3)
-	    : __memmove_sse2);
+	    : __memmove_sse2)
+
+#undef memmove
+strong_alias (__libc_memmove, memmove)

 #if SHLIB_COMPAT (libc, GLIBC_2_2_5, GLIBC_2_14)
 compat_symbol (libc, memmove, memcpy, GLIBC_2_2_5);
diff --git a/sysdeps/x86_64/multiarch/strstr-c.c
b/sysdeps/x86_64/multiarch/strstr-c.c
index b8ed316..fd3d324 100644
--- a/sysdeps/x86_64/multiarch/strstr-c.c
+++ b/sysdeps/x86_64/multiarch/strstr-c.c
@@ -7,9 +7,20 @@
   __hidden_ver1 (__strstr_sse2, __GI_strstr, __strstr_sse2);
 #endif

+/* Redefine strstr so that compiler won't complain the type mismatch
+   from strong_alias below.  */
+#undef strstr
+#define strstr __redirect_strstr
+
 #include "string/strstr.c"

-extern char *__strstr_sse42 (const char *, const char *) attribute_hidden;
-extern __typeof (__strstr_sse2) __strstr_sse2 attribute_hidden;
+extern __typeof (__redirect_strstr) __strstr_sse42 attribute_hidden;
+extern __typeof (__redirect_strstr) __strstr_sse2 attribute_hidden;
+
+/* Avoid DWARF definition DIE on ifunc symbol so that GDB can handle
+   ifunc symbol properly.  */
+extern __typeof (__redirect_strstr) __libc_strstr;
+libc_ifunc (__libc_strstr, HAS_SSE4_2 ? __strstr_sse42 : __strstr_sse2)

-libc_ifunc (strstr, HAS_SSE4_2 ? __strstr_sse42 : __strstr_sse2);
+#undef strstr
+strong_alias (__libc_strstr, strstr)


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]