This is the mail archive of the libc-alpha@sources.redhat.com 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]

[PATCH] ppc64 libc-symbols changes


For powerpc64 the alias macros, which generate inline asm directives, need to
explicitly alias both the base (function descriptor) and "dotted" 
(branch target) symbols.  All of these changes are conditioned on the 
HAVE_ASM_GLOBAL_DOT_NAME symbol from config.h.

This impacted the definitions of the following macros: C_SYMBOL_DOT_NAME, 
_weak_extern, _strong_alias, _weak_alias, and _symbol_version.

However the introduction of the various hidden_proto/hidden_def macros adds 
another dimension to this issue. See the following for details:

http://sources.redhat.com/ml/libc-alpha/2002-08/msg00079.html
http://sources.redhat.com/ml/libc-alpha/2002-08/msg00166.html
http://sources.redhat.com/ml/libc-alpha/2002-08/msg00185.html

The issue is that the powerpc64 ABI requires "DOT_NAMEs" for functions but not
for static data. While most of these macros reference functions, here is at 
least one case (./inet/in6_addr.c) where libc_hidden_proto/libc_hidden_def is 
used to alias a static variable.

A single macro can't know (at cpp time) if the symbol is a function (which
requires the extra DOT_NAMEs) or is static variable (which does need the
extra DOT_NAMEs)? The macro processor does not know the intended type 
(function or data) of the symbol. But the generated assembler must have DOTed 
(the actual function entry) and nonDOTed (the function descriptor or odp 
entry) names defined.

The following patch takes the approach of defining separates macros 
(hidden_data_def, hidden_data_weak, hidden_data_ver) for defining hidden 
static data variables and leaving the initially defined (hidden_def, hidden_weak, 
hidden_ver) macros for hidden functions. The hidden_data_* macros are used to 
define the libc_hidden_data_*, rtld_hidden_data_* and libm_hidden_data_* macros
to complete the set.

To simplify the logic I introduced auxiliary macros hidden_dot_def1 and 
hidden_dot_weak1 for use in the definitions of hidden_def, hidden_weak, and
hidden_ver macros. If HAVE_ASM_GLOBAL_DOT_NAME is defined, these macros 
generate asm statements to define the DOT_NAMES. Otherwise (for most platforms) 
these macros are empty definitions and no additional statements are generated.

There was some discussion about getting better compiler support via 
__attribute__ that might eliminate the asm (and special DOT_NAME handling)
from libc_symbols.h. However I have seen no real movement on this topic and
I doubt that it possible to get all the required gcc support lined up in time
for glibc-2.3.

2002-07-29  Steven Munroe  <sjmunroe@us.ibm.com>

	* include/libc-symbols.h [HAVE_ASM_GLOBAL_DOT_NAME]: Update 
	weak/strong/hidden alias macros to support dot names required for 
	powerpc64.
	
	
diff -rc2PN -xCVS -x*orig -xmanual libc23-cvstip-20020906/include/libc-symbols.h libc23/include/libc-symbols.h
*** libc23-cvstip-20020906/include/libc-symbols.h	Wed Aug 28 18:11:37 2002
--- libc23/include/libc-symbols.h	Fri Sep  6 15:19:48 2002
***************
*** 83,88 ****
  #endif
  
! #ifndef C_SYMBOL_DOT_NAME
! # define C_SYMBOL_DOT_NAME(name) .##name
  #endif
  
--- 83,95 ----
  #endif
  
! #ifdef HAVE_ASM_GLOBAL_DOT_NAME
! # ifndef C_SYMBOL_DOT_NAME
! #  if defined __GNUC__ && defined __GNUC_MINOR__ \
!       && (__GNUC__ << 16) + __GNUC_MINOR__ >= (3 << 16) + 1
! #   define C_SYMBOL_DOT_NAME(name) .name
! #  else
! #   define C_SYMBOL_DOT_NAME(name) .##name
! #  endif
! # endif
  #endif
  
***************
*** 112,118 ****
  #  define weak_extern(symbol) _weak_extern (symbol)
  #  ifdef HAVE_ASM_WEAKEXT_DIRECTIVE
! #   define _weak_extern(symbol) asm (".weakext " __SYMBOL_PREFIX #symbol);
  #  else
! #   define _weak_extern(symbol)    asm (".weak " __SYMBOL_PREFIX #symbol);
  #  endif
  
--- 119,137 ----
  #  define weak_extern(symbol) _weak_extern (symbol)
  #  ifdef HAVE_ASM_WEAKEXT_DIRECTIVE
! #   ifdef HAVE_ASM_GLOBAL_DOT_NAME
! #    define _weak_extern(symbol) \
!         asm (".weakext " __SYMBOL_PREFIX #symbol "\n\t"	\
! 	     ".weakext ." __SYMBOL_PREFIX #symbol);
! #   else
! #    define _weak_extern(symbol) asm (".weakext " __SYMBOL_PREFIX #symbol);
! #   endif
  #  else
! #   ifdef HAVE_ASM_GLOBAL_DOT_NAME
! #    define _weak_extern(symbol) \
!         asm (".weak " __SYMBOL_PREFIX #symbol "\n\t"	\
! 	     ".weak ." __SYMBOL_PREFIX #symbol); 
! #   else
! #    define _weak_extern(symbol) asm (".weak " __SYMBOL_PREFIX #symbol);
! #   endif
  #  endif
  
***************
*** 127,144 ****
  
  # ifdef HAVE_ASM_SET_DIRECTIVE
! #  define strong_alias(original, alias)		\
!   ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME (alias) ASM_LINE_SEP	\
    .set C_SYMBOL_NAME (alias),C_SYMBOL_NAME (original)
  # else
  #  ifdef HAVE_ASM_GLOBAL_DOT_NAME
! #   define strong_alias(original, alias)	\
!   ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME (alias) ASM_LINE_SEP	\
!   C_SYMBOL_NAME (alias) = C_SYMBOL_NAME (original) ASM_LINE_SEP	\
!   ASM_GLOBAL_DIRECTIVE C_SYMBOL_DOT_NAME (alias) ASM_LINE_SEP	\
    C_SYMBOL_DOT_NAME (alias) = C_SYMBOL_DOT_NAME (original)
  #  else
! #   define strong_alias(original, alias)	\
!   ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME (alias) ASM_LINE_SEP	\
    C_SYMBOL_NAME (alias) = C_SYMBOL_NAME (original)
  #  endif
  # endif
--- 146,179 ----
  
  # ifdef HAVE_ASM_SET_DIRECTIVE
! #  ifdef HAVE_ASM_GLOBAL_DOT_NAME
! #   define strong_alias(original, alias)				\
!   ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME (alias) ASM_LINE_SEP		\
!   .set C_SYMBOL_NAME (alias),C_SYMBOL_NAME (original) ASM_LINE_SEP	\
!   ASM_GLOBAL_DIRECTIVE C_SYMBOL_DOT_NAME (alias) ASM_LINE_SEP		\
!   .set C_SYMBOL_DOT_NAME (alias),C_SYMBOL_DOT_NAME (original)
! #   define strong_data_alias(original, alias)				\
!   ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME (alias) ASM_LINE_SEP		\
    .set C_SYMBOL_NAME (alias),C_SYMBOL_NAME (original)
+ #  else
+ #   define strong_alias(original, alias)				\
+   ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME (alias) ASM_LINE_SEP		\
+   .set C_SYMBOL_NAME (alias),C_SYMBOL_NAME (original)
+ #   define strong_data_alias(original, alias) strong_alias(original, alias)
+ #  endif
  # else
  #  ifdef HAVE_ASM_GLOBAL_DOT_NAME
! #   define strong_alias(original, alias)				\
!   ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME (alias) ASM_LINE_SEP		\
!   C_SYMBOL_NAME (alias) = C_SYMBOL_NAME (original) ASM_LINE_SEP		\
!   ASM_GLOBAL_DIRECTIVE C_SYMBOL_DOT_NAME (alias) ASM_LINE_SEP		\
    C_SYMBOL_DOT_NAME (alias) = C_SYMBOL_DOT_NAME (original)
+ #   define strong_data_alias(original, alias)				\
+   ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME (alias) ASM_LINE_SEP		\
+   C_SYMBOL_NAME (alias) = C_SYMBOL_NAME (original)
  #  else
! #   define strong_alias(original, alias)				\
!   ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME (alias) ASM_LINE_SEP		\
    C_SYMBOL_NAME (alias) = C_SYMBOL_NAME (original)
+ #   define strong_data_alias(original, alias) strong_alias(original, alias)
  #  endif
  # endif
***************
*** 146,152 ****
  # ifdef HAVE_WEAK_SYMBOLS
  #  ifdef HAVE_ASM_WEAKEXT_DIRECTIVE
! #   define weak_alias(original, alias)	\
    .weakext C_SYMBOL_NAME (alias), C_SYMBOL_NAME (original)
! #   define weak_extern(symbol)	\
    .weakext C_SYMBOL_NAME (symbol)
  
--- 181,193 ----
  # ifdef HAVE_WEAK_SYMBOLS
  #  ifdef HAVE_ASM_WEAKEXT_DIRECTIVE
! #   ifdef HAVE_ASM_GLOBAL_DOT_NAME
! #    define weak_alias(original, alias)					\
!   .weakext C_SYMBOL_NAME (alias), C_SYMBOL_NAME (original) ASM_LINE_SEP \
!   .weakext C_SYMBOL_DOT_NAME (alias), C_SYMBOL_DOT_NAME (original)
! #   else
! #    define weak_alias(original, alias)					\
    .weakext C_SYMBOL_NAME (alias), C_SYMBOL_NAME (original)
! #   endif
! #   define weak_extern(symbol)						\
    .weakext C_SYMBOL_NAME (symbol)
  
***************
*** 154,169 ****
  
  #   ifdef HAVE_ASM_GLOBAL_DOT_NAME
! #    define weak_alias(original, alias)	\
!   .weak C_SYMBOL_NAME (alias) ASM_LINE_SEP			\
!   C_SYMBOL_NAME (alias) = C_SYMBOL_NAME (original) ASM_LINE_SEP	\
!   ASM_GLOBAL_DIRECTIVE C_SYMBOL_DOT_NAME (alias) ASM_LINE_SEP	\
    C_SYMBOL_DOT_NAME (alias) = C_SYMBOL_DOT_NAME (original)
  #   else
! #    define weak_alias(original, alias)	\
!   .weak C_SYMBOL_NAME (alias) ASM_LINE_SEP	\
    C_SYMBOL_NAME (alias) = C_SYMBOL_NAME (original)
  #   endif
  
! #   define weak_extern(symbol)	\
    .weak C_SYMBOL_NAME (symbol)
  
--- 195,210 ----
  
  #   ifdef HAVE_ASM_GLOBAL_DOT_NAME
! #    define weak_alias(original, alias)					\
!   .weak C_SYMBOL_NAME (alias) ASM_LINE_SEP				\
!   C_SYMBOL_NAME (alias) = C_SYMBOL_NAME (original) ASM_LINE_SEP		\
!   .weak C_SYMBOL_DOT_NAME (alias) ASM_LINE_SEP				\
    C_SYMBOL_DOT_NAME (alias) = C_SYMBOL_DOT_NAME (original)
  #   else
! #    define weak_alias(original, alias)					\
!   .weak C_SYMBOL_NAME (alias) ASM_LINE_SEP				\
    C_SYMBOL_NAME (alias) = C_SYMBOL_NAME (original)
  #   endif
  
! #   define weak_extern(symbol)						\
    .weak C_SYMBOL_NAME (symbol)
  
***************
*** 365,377 ****
       _default_symbol_version(real, name, version)
  # ifdef __ASSEMBLER__
! #  define _symbol_version(real, name, version) \
       .symver real, name##@##version
! #  define _default_symbol_version(real, name, version) \
       .symver real, name##@##@##version
  # else
! #  define _symbol_version(real, name, version) \
       __asm__ (".symver " #real "," #name "@" #version)
! #  define _default_symbol_version(real, name, version) \
       __asm__ (".symver " #real "," #name "@@" #version)
  # endif
  #else
--- 406,436 ----
       _default_symbol_version(real, name, version)
  # ifdef __ASSEMBLER__
! #  ifdef HAVE_ASM_GLOBAL_DOT_NAME
! #   define _symbol_version(real, name, version) \
!      .symver real, name##@##version ASM_LINE_SEP			\
!      .symver .##real, .##name##@##version
! #   define _default_symbol_version(real, name, version) \
!      .symver real, name##@##@##version ASM_LINE_SEP			\
!      .symver .##real, .##name##@##@##version
! #  else
! #   define _symbol_version(real, name, version) \
       .symver real, name##@##version
! #   define _default_symbol_version(real, name, version) \
       .symver real, name##@##@##version
+ #  endif
  # else
! #  ifdef HAVE_ASM_GLOBAL_DOT_NAME
! #   define _symbol_version(real, name, version) \
!      __asm__ (".symver " #real "," #name "@" #version "\n\t"	\
! 	      ".symver ." #real ",." #name "@" #version)
! #   define _default_symbol_version(real, name, version) \
!      __asm__ (".symver " #real "," #name "@@" #version "\n\t"	\
! 	      ".symver ." #real ",." #name "@@" #version)
! #  else
! #   define _symbol_version(real, name, version) \
       __asm__ (".symver " #real "," #name "@" #version)
! #   define _default_symbol_version(real, name, version) \
       __asm__ (".symver " #real "," #name "@@" #version)
+ #  endif
  # endif
  #else
***************
*** 440,443 ****
--- 499,517 ----
     libc_hidden_weak (foo)
  
+    Simularly for global data. If references to foo within libc.so should 
+    always go to foo defined in libc.so, then in include/foo.h you add:
+ 
+    libc_hidden_proto (foo)
+ 
+    line and after foo's definition:
+ 
+    int foo = INITIAL_FOO_VALUE;
+    libc_hidden_data_def (foo)
+ 
+    or
+ 
+    int foo = INITIAL_FOO_VALUE;
+    libc_hidden_data_weak (foo)
+ 
     If foo is normally just an alias (strong or weak) of some other function,
     you should use the normal strong_alias first, then add libc_hidden_def
***************
*** 492,506 ****
    ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME (alias) ASM_LINE_SEP	\
    .set C_SYMBOL_NAME (alias), C_SYMBOL_NAME (original)
- #  else
  #   ifdef HAVE_ASM_GLOBAL_DOT_NAME
! #    define __hidden_def1(original, alias)			\
!   ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME (alias) ASM_LINE_SEP	\
!   C_SYMBOL_NAME (alias) = C_SYMBOL_NAME (original) ASM_LINE_SEP	\
    ASM_GLOBAL_DIRECTIVE C_SYMBOL_DOT_NAME (alias) ASM_LINE_SEP	\
!   C_SYMBOL_DOT_NAME (alias) = C_SYMBOL_DOT_NAME (original)
  #   else
! #    define __hidden_def1(original, alias)			\
    ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME (alias) ASM_LINE_SEP	\
    C_SYMBOL_NAME (alias) = C_SYMBOL_NAME (original)
  #   endif
  #  endif
--- 566,586 ----
    ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME (alias) ASM_LINE_SEP	\
    .set C_SYMBOL_NAME (alias), C_SYMBOL_NAME (original)
  #   ifdef HAVE_ASM_GLOBAL_DOT_NAME
! #     define __hidden_dot_def1(original, alias)	 ASM_LINE_SEP	\
    ASM_GLOBAL_DIRECTIVE C_SYMBOL_DOT_NAME (alias) ASM_LINE_SEP	\
!   .set C_SYMBOL_DOT_NAME (alias), C_SYMBOL_DOT_NAME (original)
  #   else
! #     define __hidden_dot_def1(original, alias)
! #   endif
! #  else
! #   define __hidden_def1(original, alias)			\
    ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME (alias) ASM_LINE_SEP	\
    C_SYMBOL_NAME (alias) = C_SYMBOL_NAME (original)
+ #   ifdef HAVE_ASM_GLOBAL_DOT_NAME
+ #    define __hidden_dot_def1(original, alias)	ASM_LINE_SEP	\
+   ASM_GLOBAL_DIRECTIVE C_SYMBOL_DOT_NAME (alias) ASM_LINE_SEP	\
+   C_SYMBOL_DOT_NAME (alias) = C_SYMBOL_DOT_NAME (original)
+ #   else
+ #    define __hidden_def1(original, alias)
  #   endif
  #  endif
***************
*** 508,513 ****
--- 588,599 ----
  #  define __hidden_def3(...) __hidden_def2 (__VA_ARGS__)
  #  define hidden_def(name)					\
+   __asm__ (__hidden_def3 (__hidden_def1 (__GI_##name, name) \
+   __hidden_dot_def1 (__GI_##name, name)));
+ #  define hidden_data_def(name)					\
    __asm__ (__hidden_def3 (__hidden_def1 (__GI_##name, name)));
  #  define hidden_ver(local, name)				\
+   __asm__ (__hidden_def3 (__hidden_def1 (local, __GI_##name) \
+   __hidden_dot_def1 (local, __GI_##name)));
+ #  define hidden_data_ver(local, name)				\
    __asm__ (__hidden_def3 (__hidden_def1 (local, __GI_##name)));
  #  ifdef HAVE_WEAK_SYMBOLS
***************
*** 515,532 ****
  #    define __hidden_weak1(original, alias)			\
    .weakext C_SYMBOL_NAME (alias), C_SYMBOL_NAME (original)
- #   else /* ! HAVE_ASM_WEAKEXT_DIRECTIVE */
  #    ifdef HAVE_ASM_GLOBAL_DOT_NAME
! #     define __hidden_weak1(original, alias)			\
    .weak C_SYMBOL_NAME (alias) ASM_LINE_SEP			\
!   C_SYMBOL_NAME (alias) = C_SYMBOL_NAME (original) ASM_LINE_SEP	\
    ASM_GLOBAL_DIRECTIVE C_SYMBOL_DOT_NAME (alias) ASM_LINE_SEP	\
    C_SYMBOL_DOT_NAME (alias) = C_SYMBOL_DOT_NAME (original)
  #    else
! #     define __hidden_weak1(original, alias)			\
!   .weak C_SYMBOL_NAME (alias) ASM_LINE_SEP			\
!   C_SYMBOL_NAME (alias) = C_SYMBOL_NAME (original)
  #    endif
  #   endif
  #   define hidden_weak(name)					\
    __asm__ (__hidden_def3 (__hidden_weak1 (__GI_##name, name)));
  #  else
--- 601,626 ----
  #    define __hidden_weak1(original, alias)			\
    .weakext C_SYMBOL_NAME (alias), C_SYMBOL_NAME (original)
  #    ifdef HAVE_ASM_GLOBAL_DOT_NAME
! #     define __hidden_dot_weak1(original, alias)	ASM_LINE_SEP	\
!   .weakext C_SYMBOL_DOT_NAME (alias), C_SYMBOL_DOT_NAME (original)
! #    else
! #     define __hidden_dot_weak1(original, alias)	
! #    endif
! #   else /* ! HAVE_ASM_WEAKEXT_DIRECTIVE */
! #    define __hidden_weak1(original, alias)			\
    .weak C_SYMBOL_NAME (alias) ASM_LINE_SEP			\
!   C_SYMBOL_NAME (alias) = C_SYMBOL_NAME (original)
! #    ifdef HAVE_ASM_GLOBAL_DOT_NAME
! #     define __hidden_dot_weak1(original, alias)	ASM_LINE_SEP	\
    ASM_GLOBAL_DIRECTIVE C_SYMBOL_DOT_NAME (alias) ASM_LINE_SEP	\
    C_SYMBOL_DOT_NAME (alias) = C_SYMBOL_DOT_NAME (original)
  #    else
! #     define __hidden_dot_weak1(original, alias)	
  #    endif
  #   endif
  #   define hidden_weak(name)					\
+   __asm__ (__hidden_def3 (__hidden_weak1 (__GI_##name, name) \
+   __hidden_dot_weak1 (__GI_##name, name)));
+ #   define hidden_data_weak(name)					\
    __asm__ (__hidden_def3 (__hidden_weak1 (__GI_##name, name)));
  #  else
***************
*** 546,549 ****
--- 640,646 ----
  #  define hidden_weak(name)	hidden_def (name)
  #  define hidden_ver(local, name) strong_alias (local, __GI_##name)
+ #  define hidden_data_def(name)	strong_data_alias (name, __GI_##name)
+ #  define hidden_data_weak(name)	hidden_data_def (name)
+ #  define hidden_data_ver(local, name) strong_data_alias (local, __GI_##name)
  #  define HIDDEN_JUMPTARGET(name) __GI_##name
  # endif
***************
*** 557,560 ****
--- 654,660 ----
  # define hidden_def(name)
  # define hidden_ver(local, name)
+ # define hidden_data_weak(name)
+ # define hidden_data_def(name)
+ # define hidden_data_ver(local, name)
  #endif
  
***************
*** 564,567 ****
--- 664,670 ----
  # define libc_hidden_weak(name) hidden_weak (name)
  # define libc_hidden_ver(local, name) hidden_ver (local, name)
+ # define libc_hidden_data_def(name) hidden_data_def (name)
+ # define libc_hidden_data_weak(name) hidden_data_weak (name)
+ # define libc_hidden_data_ver(local, name) hidden_data_ver (local, name)
  #else
  # define libc_hidden_proto(name)
***************
*** 569,572 ****
--- 672,678 ----
  # define libc_hidden_weak(name)
  # define libc_hidden_ver(local, name)
+ # define libc_hidden_data_def(name)
+ # define libc_hidden_data_weak(name)
+ # define libc_hidden_data_ver(local, name)
  #endif
  
***************
*** 576,579 ****
--- 682,688 ----
  # define rtld_hidden_weak(name) hidden_weak (name)
  # define rtld_hidden_ver(local, name) hidden_ver (local, name)
+ # define rtld_hidden_data_def(name) hidden_data_def (name)
+ # define rtld_hidden_data_weak(name) hidden_data_weak (name)
+ # define rtld_hidden_data_ver(local, name) hidden_data_ver (local, name)
  #else
  # define rtld_hidden_proto(name)
***************
*** 581,584 ****
--- 690,696 ----
  # define rtld_hidden_weak(name)
  # define rtld_hidden_ver(local, name)
+ # define rtld_hidden_data_def(name)
+ # define rtld_hidden_data_weak(name)
+ # define rtld_hidden_data_ver(local, name)
  #endif
  
***************
*** 588,591 ****
--- 700,706 ----
  # define libm_hidden_weak(name) hidden_weak (name)
  # define libm_hidden_ver(local, name) hidden_ver (local, name)
+ # define libm_hidden_data_def(name) hidden_data_def (name)
+ # define libm_hidden_data_weak(name) hidden_data_weak (name)
+ # define libm_hidden_data_ver(local, name) hidden_data_ver (local, name)
  #else
  # define libm_hidden_proto(name)
***************
*** 593,596 ****
--- 708,714 ----
  # define libm_hidden_weak(name)
  # define libm_hidden_ver(local, name)
+ # define libm_hidden_data_def(name)
+ # define libm_hidden_data_weak(name)
+ # define libm_hidden_data_ver(local, name)
  #endif
  


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