Skip to contentSkip to conversation

crti.S Nested procedures error

parisc-linux Grant Grundler 5 participants 5 messages May 1, 2000 – May 11, 2000

lore
Share & tools
lore
#0 lore raw

Sammy,

I tried the "glibc" recipe on my x86 box (running Debian potato release).
(http://puffin.external.hp.com/mailing-lists/parisc-linux/2000/04-Apr/0059.html)

"make" died with the following error:

...
hppa1.1-linux-gcc /linux/grundler/glibc/hppa1.1-linux/csu/crti.S -c -I../include -I. -I/linux/grundler/glibc/hppa1.1-linux/csu -I.. -I../libio -I/linux/grundler/glibc/hppa1.1-linux -I../sysdeps/hppa/elf -I../sysdeps/unix/sysv/linux/hppa -I../sysdeps/unix/sysv/linux -I../sysdeps/gnu -I../sysdeps/unix/common -I../sysdeps/unix/mman -I../sysdeps/unix/inet -I../sysdeps/unix/sysv -I../sysdeps/unix -I../sysdeps/posix -I../sysdeps/hppa/hppa1.1 -I../sysdeps/wordsize-32 -I../sysdeps/ieee754/flt-32 -I../sysdeps/ieee754/dbl-64 -I../sysdeps/ieee754/ldbl-128 -I../sysdeps/hppa/fpu -I../sysdeps/hppa -I../sysdeps/ieee754 -I../sysdeps/generic/elf -I../sysdeps/generic -nostdinc -isystem /opt/puffin/lib/gcc-lib/hppa1.1-linux/2.9-hppa-991112/include -isystem /opt/puffin/include -include ../include/libc-symbols.h -DHAVE_INITFINI -DASSEMBLER -I/linux/grundler/glibc/hppa1.1-linux/csu/. -g0 -o /linux/grundler/glibc/hppa1.1-linux/csu/crti.o

bc-symbols.h -DHAVE_INITFINI -DASSEMBLER -I/linux/grundler/glibc/hppa1.1-linux/csu/. -g0 -o /linux/grundler/glibc/hppa1.1-linux/csu/crti.o
/linux/grundler/glibc/hppa1.1-linux/csu/crti.S: Assembler messages:
/linux/grundler/glibc/hppa1.1-linux/csu/crti.S:42: Fatal error: Nested procedures make[2]: *** [/linux/grundler/glibc/hppa1.1-linux/csu/crti.o] Error 1 make[2]: Leaving directory `/linux/grundler/glibc/csu'
make[1]: *** [csu/subdir_lib] Error 2

Sure enough, two .PROC's have no .PROCEND in between. glibc/csu/Makefile builds crti.S with:

$(objpfx)crti.S: $(objpfx)initfini.s

        sed -n -e '1,/@HEADER_ENDS/p' \
               -e '/@_.*_PROLOG_BEGINS/,/@_.*_PROLOG_ENDS/p' \
               -e '/@TRAILER_BEGINS/,$$p' $< > $@ 

It seems either the initfini.s contents are wrong or the "sed" hack above is removing too much. Which is it?
Or should there only be one .PROC?

We get two .PROC's because initfini.s has both @_init_PROLOG_BEGINS/ENDS and @_fini_PROLOG_BEGINS/ENDS.

Appended "diff -u initfini.s crti.S" shows what sed is doing.

thanks,
grant

grundler <576>diff -u initfini.s crti.S

crti.S Mon May 1 11:20:48 2000 renamed from initfini.s Mon May 1 11:09:43 2000 +0 -80
@@ -6,38 +6,6 @@
 #include "defs.h"
 
 /*@HEADER_ENDS*/
-
-/*@TESTS_BEGIN*/
-#NO_APP
-       .text
-       .align 4
-.globl dummy
-       .EXPORT dummy,ENTRY
-       .type    dummy,@function
-dummy:
-dummy:
-       .PROC
-       .CALLINFO FRAME=64,CALLS,SAVE_RP,ENTRY_GR=3
-       .ENTRY
-       stw %r2,-20(%r30)
-       ldo 64(%r30),%r30
-       stw %r19,-32(%r30)
-       stw %r4,-64(%r30)
-       movb,= %r26,%r22,.L16
-       copy %r19,%r4
-       .CALL   ARGW0=GR
-       bl $$dyncall,%r31
-       copy %r31,%r2
-.L16:
-       ldw -84(%r30),%r2
-       bv %r0(%r2)
-       ldwm -64(%r30),%r4
-       .EXIT
-       .PROCEND
-#APP
-
-/*@TESTS_END*/
-
 /*@_init_PROLOG_BEGINS*/
        .section .init
 #NO_APP
@@ -62,35 +30,6 @@
        END_INIT
 
 /*@_init_PROLOG_ENDS*/
-
-/*@_init_EPILOG_BEGINS*/
-       .section .init
-#NO_APP
-       ldw -84(%r30),%r2
-       bv %r0(%r2)
-       ldwm -64(%r30),%r4
-       .EXIT
-       .PROCEND
-#APP
-       END_INIT
-       .section .text
-#NO_APP
-       .align 4
-       .weak   __gmon_start__
-       .EXPORT __gmon_start__,ENTRY
-       .type    __gmon_start__,@function
-__gmon_start__:
-__gmon_start__:
-       .PROC
-       .CALLINFO FRAME=0,NO_CALLS
-       .ENTRY
-       bv,n %r0(%r2)
-       .EXIT
-       .PROCEND
-#APP
-
-/*@_init_EPILOG_ENDS*/
-
 /*@_fini_PROLOG_BEGINS*/
        .section .fini
 #NO_APP
@@ -113,24 +52,5 @@
        END_FINI
 
 /*@_fini_PROLOG_ENDS*/
-#NO_APP
-       .CALL 
-       bl i_am_not_a_leaf,%r2
-       nop
-#APP
-
-/*@_fini_EPILOG_BEGINS*/
-       .section .fini
-#NO_APP
-       ldw -84(%r30),%r2
-       bv %r0(%r2)
-       ldwm -64(%r30),%r4
-       .EXIT
-       .PROCEND
-#APP
-       END_FINI
-
-/*@_fini_EPILOG_ENDS*/
-
 /*@TRAILER_BEGINS*/
        .ident  "GCC: (GNU) 2.9-hppa-991112"
#1 lore raw
Quoted 31 lines · Grant Grundler

Sammy,

I tried the "glibc" recipe on my x86 box (running Debian potato release).
(http://puffin.external.hp.com/mailing-lists/parisc-linux/2000/04-Apr/0059.html)

"make" died with the following error:

...
hppa1.1-linux-gcc /linux/grundler/glibc/hppa1.1-linux/csu/crti.S -c -I../include -I. -I/linux/grundler/glibc/hppa1.1-linux/csu -I.. -I../libio -I/linux/grundler/glibc/hppa1.1-linux -I../sysdeps/hppa/elf -I../sysdeps/unix/sysv/linux/hppa -I../sysdeps/unix/sysv/linux -I../sysdeps/gnu -I../sysdeps/unix/common -I../sysdeps/unix/mman -I../sysdeps/unix/inet -I../sysdeps/unix/sysv -I../sysdeps/unix -I../sysdeps/posix -I../sysdeps/hppa/hppa1.1 -I../sysdeps/wordsize-32 -I../sysdeps/ieee754/flt-32 -I../sysdeps/ieee754/dbl-64 -I../sysdeps/ieee754/ldbl-128 -I../sysdeps/hppa/fpu -I../sysdeps/hppa -I../sysdeps/ieee754 -I../sysdeps/generic/elf -I../sysdeps/generic -nostdinc -isystem /opt/puffin/lib/gcc-lib/hppa1.1-linux/2.9-hppa-991112/include -isystem /opt/puffin/include -include ../include/libc-symbols.h -DHAVE_INITFINI -DASSEMBLER -I/linux/grundler/glibc/hppa1.1-linux/csu/. -g0 -o /linux/grundler/glibc/hppa1.1-linux/csu/crti.o

bc-symbols.h -DHAVE_INITFINI -DASSEMBLER -I/linux/grundler/glibc/hppa1.1-linux/csu/. -g0 -o /linux/grundler/glibc/hppa1.1-linux/csu/crti.o
/linux/grundler/glibc/hppa1.1-linux/csu/crti.S: Assembler messages:
/linux/grundler/glibc/hppa1.1-linux/csu/crti.S:42: Fatal error: Nested procedures make[2]: *** [/linux/grundler/glibc/hppa1.1-linux/csu/crti.o] Error 1 make[2]: Leaving directory `/linux/grundler/glibc/csu'
make[1]: *** [csu/subdir_lib] Error 2

Sure enough, two .PROC's have no .PROCEND in between. glibc/csu/Makefile builds crti.S with:

$(objpfx)crti.S: $(objpfx)initfini.s

        sed -n -e '1,/@HEADER_ENDS/p' \
               -e '/@_.*_PROLOG_BEGINS/,/@_.*_PROLOG_ENDS/p' \
               -e '/@TRAILER_BEGINS/,$$p' $< > $@ 

It seems either the initfini.s contents are wrong or the "sed" hack above is removing too much. Which is it?
Or should there only be one .PROC?

Quoted 7 lines

We get two .PROC's because initfini.s has both @_init_PROLOG_BEGINS/ENDS and @_fini_PROLOG_BEGINS/ENDS.

Appended "diff -u initfini.s crti.S" shows what sed is doing.

thanks,
grant

ok, for a while I was dealing with this by simply hacking up initfini.s by hand, but that wasn't necessary last time I built. I think this is related to the fact that somebody had taken out .proc/.procend from the assembler entirely (well, ignored them on ELF targets). I think this was a bad idea (if I remember tc-hppa.c from gas, it depends on these to build some of the global symbol information? It did something even on an elf target).

We might need our own magic sed script for parisc.

Lemme think about this properly, I just woke up and am expected at work.

-- Sam

#2 lore raw
Quoted 7 lines · Sam Creasey

ok, for a while I was dealing with this by simply hacking up initfini.s by hand, but that wasn't necessary last time I built. I think this is related to the fact that somebody had taken out .proc/.procend from the assembler entirely (well, ignored them on ELF targets). I think this was a bad idea (if I remember tc-hppa.c from gas, it depends on these to build some of the global symbol information? It did something even on an elf target).

it was a bad idea, it broke other things. i suspect the right thing to do is move some of the global symbol information-building code which is currently invoked upon seeing a .proc or .procend to simply seeing a non-local label, like the other assemblers do. i don't see why linux/elf/pa-risc needs anything special in this regard. Alan (Modra), do you have any comments?

Quoted 1 line

We might need our own magic sed script for parisc.

i'd prefer not to..

#3 lore raw
Quoted 9 lines · On Wed, 3 May 2000 [email protected] wrote:
Quoted 7 lines · Sam Creasey

ok, for a while I was dealing with this by simply hacking up initfini.s by hand, but that wasn't necessary last time I built. I think this is related to the fact that somebody had taken out .proc/.procend from the assembler entirely (well, ignored them on ELF targets). I think this was a bad idea (if I remember tc-hppa.c from gas, it depends on these to build some of the global symbol information? It did something even on an elf target).

Quoted 6 lines

it was a bad idea, it broke other things. i suspect the right thing to do is move some of the global symbol information-building code which is currently invoked upon seeing a .proc or .procend to simply seeing a non-local label, like the other assemblers do. i don't see why linux/elf/pa-risc needs anything special in this regard. Alan (Modra), do you have any comments?

Well, I'm still coming up to speed on the parisc architecture, so maybe my comments aren't that valuable. There are quite a lot of things I don't like about the current set of puffin parisc patches though, and zapping these pseudo ops is one of them.

On another issue, can someone tell me why the assembler comment character needed to be changed from ;' to !' ? This seems a really ill-advised change to me.

Signature · 1 line
Linuxcare.  Support for the Revolution.
#4 lore raw
In reply to Grant Grundler

= "make" died with the following error:
=
= /linux/grundler/glibc/hppa1.1-linux/csu/crti.S: Assembler messages:
= /linux/grundler/glibc/hppa1.1-linux/csu/crti.S:42: Fatal error: Nested proced ures
=
= Sure enough, two .PROC's have no .PROCEND in between.

I think I've figured this out, and it'll take a glibc expert to do the *right* thing vis-a-vis the complex glibc structure.

Let's ignore the .fini section and just deal with .init. This is the section where code which needs to execute prior to main() is placed. It is in effect a normal assembly-language procedure whose contents are created at link-time. The procedure looks like this (somewhat simplified):

    .globl _init
	    .EXPORT _init,ENTRY
	    .type    _init,@function
    _init:
	    .PROC
	    .CALLINFO FRAME=64,CALLS,SAVE_RP,ENTRY_GR=3
	    .ENTRY
	    a few assembly statements

	    /***** pre-main() code to be inserted here *******/

	    a few more assembly statements
	    .EXIT
	    .PROCEND

glibc wants to place the first part (up to the comment) into crti.S, and the second part into crtn.S, then at link time something like this happens:

ld -o a.out crti.o users's-object-files crtn.o

Inside the user's object files, if they need something called before main(), like a C++ static constructor, you might find code like this:

.section .init
bl,n my-static-constructor,%r2

Thus the _init procedure is created is link time, but that's not the problem.

The problem is that the neither the first scrap of code nor the second will assemble, because there's a .PROC without .PROCEND and .ENTRY without .EXIT. .ENTRY and .EXIT both produce code, .ENTRY depends on .CALLINFO which depends a tad upon .PROC.

If we hand-code the .ENTRY and .EXIT sequences, we can nuke all the troublesome assembler directives and fix this... simple!...

except for the way this code got generated in the first place. It's generated in glibc/csu by 'gcc -S initfini.c' and then hacking the generated assembly, which contains the .PROC,.ENTRY,etc...

So one thing we could do is hack gcc to produce its own entry/exit assembly code generation. Another thing we could do is make the assembler very forgiving. Perhaps the best thing we could do is find a way to insert PA-specific handwritten assembly for these two files into the glibc build. I can't figure out how to do this without making glibc specific only to PA. Help!

-Paul Bame