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]

powerpc64 glibc vs gcc4.1


gcc-4.1 exposes a bug in the PowerPC64 definition of RTLD_START,
resulting in assembly errors like the following.
Error: can't resolve `.toc' {.toc section} - `.Ltext0' {.text section}
Error: expression too complex

The problem is that RTLD_START leaves the current section as .toc, a
consequence of these section directives:

.section ".text"
.section ".opd","aw"
.previous
.section ".opd","aw"
.previous
.section ".toc","aw"
.previous
.previous

So gcc-4.1 starts emitting code for the next function to .toc instead of
.text.  Simply removing the last ".previous" would cure the problem, but
might yield unexpected resuls in some future gcc release.  I think the
proper behaviour for RTLD_START is to restore the section active at the
point the macro is expanded, which is what this patch does.

2005-05-09  Alan Modra  <amodra@bigpond.net.au>

	* sysdeps/powerpc/powerpc64/dl-machine.h (RTLD_START): Use
	.pushsection/.popsection in place of .section/.previous.

Index: sysdeps/powerpc/powerpc64/dl-machine.h
===================================================================
RCS file: /cvs/glibc/libc/sysdeps/powerpc/powerpc64/dl-machine.h,v
retrieving revision 1.23
diff -u -p -r1.23 dl-machine.h
--- sysdeps/powerpc/powerpc64/dl-machine.h	17 Feb 2005 01:16:34 -0000	1.23
+++ sysdeps/powerpc/powerpc64/dl-machine.h	9 May 2005 07:33:47 -0000
@@ -122,16 +122,16 @@ elf_machine_dynamic (void)
    `_dl_start' is the real entry point; its return value is the user
    program's entry point.  */
 #define RTLD_START \
-  asm (".section \".text\"\n"						\
+  asm (".pushsection \".text\"\n"					\
 "	.align	2\n"							\
 "	.type	" BODY_PREFIX "_start,@function\n"			\
-"	.section \".opd\",\"aw\"\n"					\
+"	.pushsection \".opd\",\"aw\"\n"					\
 "	.align	3\n"							\
 "	.globl	_start\n"						\
 "	" ENTRY_2(_start) "\n"						\
 "_start:\n"								\
 "	" OPD_ENT(_start) "\n"						\
-"	.previous\n"							\
+"	.popsection\n"							\
 BODY_PREFIX "_start:\n"							\
 /* We start with the following on the stack, from top:			\
    argc (4 bytes);							\
@@ -157,11 +157,11 @@ BODY_PREFIX "_start:\n"							\
 "	.align 2\n"							\
 "	" END_2(_start) "\n"						\
 "	.globl	_dl_start_user\n"					\
-"	.section \".opd\",\"aw\"\n"					\
+"	.pushsection \".opd\",\"aw\"\n"					\
 "_dl_start_user:\n"							\
 "	" OPD_ENT(_dl_start_user) "\n"					\
-"	.previous\n"							\
-"	.section	\".toc\",\"aw\"\n"				\
+"	.popsection\n"							\
+"	.pushsection	\".toc\",\"aw\"\n"				\
 DL_STARTING_UP_DEF							\
 ".LC__rtld_global:\n"							\
 "	.tc _rtld_global[TC],_rtld_global\n"				\
@@ -171,7 +171,7 @@ DL_STARTING_UP_DEF							\
 "	.tc _dl_argv_internal[TC],_dl_argv_internal\n"			\
 ".LC__dl_fini:\n"							\
 "	.tc _dl_fini[TC],_dl_fini\n"					\
-"	.previous\n"							\
+"	.popsection\n"							\
 "	.type	" BODY_PREFIX "_dl_start_user,@function\n"		\
 "	" ENTRY_2(_dl_start_user) "\n"					\
 /* Now, we do our main work of calling initialisation procedures.	\
@@ -245,7 +245,7 @@ BODY_PREFIX "_dl_start_user:\n"						\
 ".LT__dl_start_user_name_end:\n"					\
 "	.align 2\n"							\
 "	" END_2(_dl_start_user) "\n"					\
-"	.previous");
+"	.popsection");
 
 /* Nonzero iff TYPE should not be allowed to resolve to one of
    the main executable's symbols, as for a COPY reloc.  */

-- 
Alan Modra
IBM OzLabs - Linux Technology Centre


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