[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#215913: gcc: arm: preprocessor spuriously adds line breaks when processing assembler code



Package: gcc
Severity: important

Hi,

(sid)pape@debussy:~/dietlibc-0.23/arm$ gcc -v
Reading specs from /usr/lib/gcc-lib/arm-linux/3.3.2/specs
Configured with: ../src/configure -v --enable-languages=c,c++,java,f77,pascal,objc,treelang --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-gxx-include-dir=/usr/include/c++/3.3 --enable-shared --with-system-zlib --enable-nls --without-included-gettext --enable-__cxa_atexit --enable-clocale=gnu --enable-debug --enable-java-gc=boehm --enable-java-awt=xlib --enable-objc-gc arm-linux
Thread model: posix
gcc version 3.3.2 20031005 (Debian prerelease)

The dietlibc_0.23-1 fails to build on arm because of bad preprocessing
of assembler code.  Here's the relevant part of the build log
http://buildd.debian.org/fetch.php?&pkg=dietlibc&ver=0.23-1&arch=arm&stamp=1063449359&file=log&as=raw

gcc -I. -Iinclude -pipe -nostdinc -Os -fomit-frame-pointer -fstrict-aliasing -mhard-float -Wall -W -Wchar-subscripts -Wmissing-prototypes -Wmissing-declarations -Wno-switch -Wredundant-decls -Wno-unused -c arm/clone.S -o bin-arm/clone.o
arm/clone.S: Assembler messages:
arm/clone.S:20: Error: bad instruction `syscall'
arm/clone.S:25: Error: bad instruction `syscall'
make[1]: *** [bin-arm/clone.o] Error 1
make[1]: Leaving directory `/build/buildd/dietlibc-0.23'
make: *** [build-stamp] Error 2

I attach the clone.S source file, and also the output 'gcc -E clone.S'.

The preprocessor adds linebreaks at the word 'syscall', even though it's
just a comment, see line 18 and line 24 in clone.S.

If there's something wrong with the arm/clone.S source file, please tell
me; in my opinion the preprocessor is at fault here.

Thanks, Gerrit.
#include <errno.h>
#include "syscalls.h"

	.text
	.weak 	clone
	.global __clone
	
@
@ Some slightly tricky stuff here... edit with care :-)
@

clone:
__clone:
	movs	r12, r0			@ check function pointer
	cmpne	r1, #0			@ if function check for stack pointer
	moveq	r0, #-EINVAL		@ if one is not available set errno value
	beq	__unified_syscall	@ handle as if error was returned by the syscall

	stmdb	r1!, { r3, r12 } 	@ store function param (r3) and function ptr (r12)
					@ into what will become the childs stack.

	mov	r0, r2			@ move flags argument to r0
	swi	__NR_clone		@ call the syscall
	movs	r0, r0			@ set condition codes
	blt	__unified_syscall	@ (return code < 0): handle as an error
	movne	pc, lr			@ (return code > 0): return to parent

	mov	fp, #0			@ clear the frame pointer
	adr	lr, 1f			@ setup return address
	ldmia	sp!, { r0, pc } 	@ load function param and jump to thread function

1:	b	_exit			@ branch to _exit (PIC safe)

# 1 "clone.S"
# 1 "<built-in>"
# 1 "<command line>"
# 1 "clone.S"

# 1 "/usr/include/errno.h" 1 3 4
# 29 "/usr/include/errno.h" 3 4
# 1 "/usr/include/features.h" 1 3 4
# 318 "/usr/include/features.h" 3 4
# 1 "/usr/include/gnu/stubs.h" 1 3 4
# 319 "/usr/include/features.h" 2 3 4
# 30 "/usr/include/errno.h" 2 3 4


__BEGIN_DECLS



# 1 "/usr/include/bits/errno.h" 1 3 4
# 25 "/usr/include/bits/errno.h" 3 4
# 1 "/usr/include/linux/errno.h" 1 3 4



# 1 "/usr/include/asm/errno.h" 1 3 4
# 5 "/usr/include/linux/errno.h" 2 3 4
# 26 "/usr/include/bits/errno.h" 2 3 4
# 37 "/usr/include/errno.h" 2 3 4
# 47 "/usr/include/errno.h" 3 4
extern int errno;
# 59 "/usr/include/errno.h" 3 4
__END_DECLS
# 3 "clone.S" 2
# 1 "syscalls.h" 1
# 474 "syscalls.h"
.macro __syscall_weak name wsym sym typ
.text
.type \wsym,function
.weak \wsym
\wsym:
.type \sym,function
.global \sym
\sym:
.ifgt \typ
        mov ip, sp
        stmfd sp!,{r4, r5, r6}
        ldmia ip, {r4, r5, r6}
.endif
        swi \name
.ifgt \typ
        b __unified_syscall4
.else
        b __unified_syscall
.endif
.endm


.macro __syscall name sym typ
.text
.type \sym,function
.global \sym
\sym:
.ifgt \typ
        mov ip, sp
        stmfd sp!,{r4, r5, r6}
        ldmia ip, {r4, r5, r6}
.endif
        swi \name
.ifgt \typ
        b __unified_syscall4
.else
        b __unified_syscall
.endif
.endm
# 4 "clone.S" 2

        .text
        .weak clone
        .global __clone

@
@ Some slightly tricky stuff here... edit with care :-)
@

clone:
__clone:
        movs r12, r0 @ check function pointer
        cmpne r1, #0 @ if function check for stack pointer
        moveq r0, #-22 @ if one is not available set errno value
        beq __unified_syscall @ handle as if error was returned by the

        syscall
# 20 "clone.S"
        stmdb r1!, { r3, r12 } @ store function param (r3) and function ptr (r12)
                                        @ into what will become the childs stack.

        mov r0, r2 @ move flags argument to r0
        swi (0x900000 +120) @ call the
        syscall
# 25 "clone.S"
        movs r0, r0 @ set condition codes
        blt __unified_syscall @ (return code < 0): handle as an error
        movne pc, lr @ (return code > 0): return to parent

        mov fp, #0 @ clear the frame pointer
        adr lr, 1f @ setup return address
        ldmia sp!, { r0, pc } @ load function param and jump to thread function

1: b _exit @ branch to _exit (PIC safe)

Reply to: