This is the mail archive of the libc-hacker@sourceware.cygnus.com mailing list for the glibc project.

Note that libc-hacker is a closed list. You may look at the archives of this list, but subscription and posting are not open.


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

[PATCH] Problems with the .section workaround


Hi!

This one just replaces one warning with another one about unterminated
string.

        * include/libc-symbols.h (link_warning): Work around a change in
        GAS which warns about changing section attributes.
        Proposed by Nick Clifton <nickc@redhat.com>.

The issue is that some gcc ports output
.section foo,"ax"
and some
.section "foo","ax"
for __attribute__((section("foo")))
so with \n\t# at the end of section name, one ends up with
.section "foo
	#","ax"

This patch tries to check for this in configure and act upon what it found.
autoconf misses AC_TRY_ASSEMBLE :((.

2000-06-14  Jakub Jelinek  <jakub@redhat.com>

	* include/libc-symbols.h (link_warning): If
	HAVE_SECTION_QUOTES is defined, terminate quotes and readd them
	after the comment char.
	* configure.in (HAVE_SECTION_QUOTES): Test whether
	__attribute__((section ("x"))) puts quotes around x or not.
	* config.h.in (HAVE_SECTION_QUOTES): Add.
	* configure: Rebuilt.

--- libc/include/libc-symbols.h.jj	Tue Jun 13 07:29:14 2000
+++ libc/include/libc-symbols.h	Wed Jun 14 09:38:59 2000
@@ -178,8 +178,13 @@
 
 #  define link_warning(symbol, msg)			\
   __make_section_unallocated (".gnu.warning." #symbol)	\
+#  ifdef HAVE_SECTION_QUOTES
+  static const char __evoke_link_warning_##symbol[]	\
+    __attribute__ ((section (".gnu.warning." #symbol "\"\n\t#\""))) = msg;
+#  else
   static const char __evoke_link_warning_##symbol[]	\
     __attribute__ ((section (".gnu.warning." #symbol "\n\t#"))) = msg;
+#  endif
 # else
 #  define link_warning(symbol, msg)		\
   asm(".stabs \"" msg "\",30,0,0,0\n"	\
--- libc/configure.in.jj	Tue Jun 13 07:29:03 2000
+++ libc/configure.in	Wed Jun 14 10:17:19 2000
@@ -905,6 +905,29 @@ if test $elf != yes; then
   fi
 fi
 
+if test $elf = yes -a $gnu_ld = yes; then
+  AC_CACHE_CHECK(whether cc puts quotes around section names,
+		 libc_cv_have_section_quotes,
+		 [cat > conftest.c <<EOF
+		  static const int foo
+		  __attribute__ ((section ("bar"))) = 1;
+EOF
+		  if ${CC-cc} -S conftest.c -o conftest.s; then
+		    if grep '\.section.*"bar"' conftest.s >/dev/null; then
+		      libc_cv_have_section_quotes=yes
+		    else
+		      libc_cv_have_section_quotes=no
+		    fi
+		  else
+		    libc_cv_have_section_quotes=unknown
+		  fi
+		  rm -f conftest.[cs]
+		 ])
+  if test $libc_cv_have_section_quotes = yes; then
+    AC_DEFINE(HAVE_SECTION_QUOTES)
+  fi
+fi
+
 dnl AC_CHECK_ASM_UNDERSCORE([ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]])
 AC_DEFUN(AC_CHECK_ASM_UNDERSCORE,
 [cat > conftest.$ac_ext <<EOF
--- libc/config.h.in.jj	Wed Mar 22 22:36:03 2000
+++ libc/config.h.in	Wed Jun 14 09:50:03 2000
@@ -21,6 +21,9 @@
 /* Define if not using ELF, but `.init' and `.fini' sections are available.  */
 #undef	HAVE_INITFINI
 
+/* Define if __attribute__((section("foo"))) puts quotes around foo.  */
+#undef  HAVE_SECTION_QUOTES
+
 /* Define if using the GNU assembler, gas.  */
 #undef	HAVE_GNU_AS
 
--- libc/configure.jj	Tue Jun 13 07:29:03 2000
+++ libc/configure	Wed Jun 14 10:17:21 2000
@@ -2633,6 +2633,38 @@ EOF
   fi
 fi
 
+if test $elf = yes -a $gnu_ld = yes; then
+  echo $ac_n "checking whether cc puts quotes around section names""... $ac_c" 1>&6
+echo "configure:2639: checking whether cc puts quotes around section names" >&5
+if eval "test \"`echo '$''{'libc_cv_have_section_quotes'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
+else
+  cat > conftest.c <<EOF
+		  static const int foo
+		  __attribute__ ((section ("bar"))) = 1;
+EOF
+		  if ${CC-cc} -S conftest.c -o conftest.s; then
+		    if grep '\.section.*"bar"' conftest.s >/dev/null; then
+		      libc_cv_have_section_quotes=yes
+		    else
+		      libc_cv_have_section_quotes=no
+		    fi
+		  else
+		    libc_cv_have_section_quotes=unknown
+		  fi
+		  rm -f conftest.cs
+		 
+fi
+
+echo "$ac_t""$libc_cv_have_section_quotes" 1>&6
+  if test $libc_cv_have_section_quotes = yes; then
+    cat >> confdefs.h <<\EOF
+#define HAVE_SECTION_QUOTES 1
+EOF
+
+  fi
+fi
+
 
 
 if test $elf = yes; then

	Jakub

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