cc: assembler failed for tmp-divrem_2.s
Dennis Clarke
dclarke at blastwave.org
Mon Mar 29 14:10:47 CEST 2010
> Dennis Clarke <dclarke at blastwave.org> writes:
>
> wow .. that's really old and out of date.
>
> I have this :
>
> $ cc -V
> cc: Sun C 5.8 Patch 121016-08 2009/04/20
>
> Sorry, that was from an even older (sparc) machine. This is from the
> PC:
>
> cc: Sun C 5.10 SunOS_i386 2009/06/03
> usage: cc [ options] files. Use 'cc -flags' for details
>
> So, I suppose my compiler is newer than yours. Which means Sun has
> fixed the bug.
I'll see your 5.10 22009/06/03 and raise you these :
$ uname -a
SunOS mercury 5.10 Generic_142900-07 sun4u sparc SUNW,Sun-Blade-2500
$ ls /opt/studio/*/SUNWspro/bin/cc
/opt/studio/SOS12.1/SUNWspro/bin/cc /opt/studio/SOS12/SUNWspro/bin/cc
$ /opt/studio/SOS12/SUNWspro/bin/cc -V
cc: Sun C 5.9 SunOS_sparc Patch 124867-13 2010/03/09
usage: cc [ options] files. Use 'cc -flags' for details
$ /opt/studio/SOS12.1/SUNWspro/bin/cc -V
cc: Sun C 5.10 SunOS_sparc Patch 141861-03 2009/12/03
usage: cc [ options] files. Use 'cc -flags' for details
> The problem is probably with as, the assembler. But I'm guessing.
>
> Yes, in whatever assembler the compiler invokes.
>
> > Can their tools cope with "xor %dl,%al" and "and %dl,%al"?
> > How about "orb %dl,%al" "xorb %dl,%al" and "andb %dl,%al"?
>
> Could you please check this? It is enough to insert them in an
> (otherwise) empty file called e.g., foo.s and the feed that to the
> naughty compiler.
sure ... I'll have a look at that.
> I might be able to work around this.
>
> And BTW, what assembly code does this C code get (using cc -O -S):
>
> char foo (char *bar) { return bar[0] | bar[1]; }
How about this :
$ cat -n foo.c
1 #include <stdio.h>
2
3 char foo (char *foo);
4
5 int
6 main(int argc, char *argv[])
7 {
8 char a[2] = { 'a', 'b' };
9 char b[1];
10 b[0] = ( char ) foo ( a );
11
12 fprintf ( stderr, "\n b[0] = 0x%02xh\n", b[0] );
13
14 return (0);
15 }
16
17 char foo (char *bar)
18 {
19 return bar[0] | bar[1];
20 }
$ cc -\# -H -c -S -o foo.s foo.c
### Note: NLSPATH =
/opt/SUNWspro/prod/bin/../lib/locale/%L/LC_MESSAGES/%N.cat:/opt/SUNWspro/prod/bin/../../lib/locale/%L/LC_MESSAGES/%N.cat
### command line files and options (expanded):
### -H -S foo.c -o foo.s
/opt/SUNWspro/prod/bin/acomp -xldscope=global -i foo.c -y-fbe
-y/opt/SUNWspro/prod/bin/fbe -y-xarch=generic -y-S -yfoo.s -y-verbose
-y-xthreadvar=no%dynamic -y-comdat -xdbggen=no%stabs+dwarf2+usedonly -H
-fparam_ir -Qy -D__SunOS_5_8 -D__SUNPRO_C=0x580 -D__SVR4 -D__unix -D__sun
-D__i386 -D__BUILTIN_VA_ARG_INCR -D__C99FEATURES__ -Xa
-D__PRAGMA_REDEFINE_EXTNAME -Dunix -Dsun -Di386 -D__RESTRICT
-xc99=%all,no%lib -D__FLT_EVAL_METHOD__=-1 -I/opt/SUNWspro/prod/include/cc
"-g/opt/SUNWspro/prod/bin/cc -H -c -S " -fsimple=0 -destination_ir=yabe
/usr/include/stdio.h
/usr/include/iso/stdio_iso.h
/usr/include/sys/feature_tests.h
/usr/include/sys/isa_defs.h
/usr/include/sys/va_list.h
/usr/include/stdio_tag.h
/usr/include/stdio_impl.h
$
$ wc -l foo.s
161 foo.s
$
$ cc -o foo foo.s
$ ./foo
b[0] = 0x63h
$ cat -n foo.s
1
2 .section .text,"ax"
3 .align 4
4
5 .globl main
6 .type main, at function
7 .align 16
8 main:
9 pushl %ebp
10 movl %esp,%ebp
11 subl $8,%esp
12 .L13:
13
14 / File foo.c:
15 / Line 8
16 movsbl .L15,%eax
17 movb %al,-6(%ebp)
18 movsbl .L15+1,%eax
19 movb %al,-5(%ebp)
20 / Line 10
21 lea -6(%ebp), %eax
22 pushl %eax
23 call foo
24 addl $4,%esp
25 movb %al,-7(%ebp)
26 / Line 12
27 movsbl -7(%ebp), %eax
28 pushl %eax
29 pushl $.L16+0
30 pushl $__iob+32
31 call fprintf
32 addl $12,%esp
33 / Line 14
34 movl $0, -4(%ebp)
35 jmp .L12
36 .align 4
37 .L12:
38 movl -4(%ebp), %eax
39 leave
40 ret
41 .size main,.-main
42 .align 4
43
44 .globl foo
45 .type foo, at function
46 .align 16
47 foo:
48 pushl %ebp
49 movl %esp,%ebp
50 subl $4,%esp
51 .L19:
52
53 / File foo.c:
54 / Line 19
55 movl 8(%ebp), %eax
56 movsbl 0(%eax), %edx
57 movl 8(%ebp), %eax
58 movsbl 1(%eax), %eax
59 orl %eax, %edx
60 movb %dl,-1(%ebp)
61 jmp .L18
62 .align 4
63 .L18:
64 movsbl -1(%ebp), %eax
65 leave
66 ret
67 .size foo,.-foo
68
69 .section .bss,"aw"
70 Bbss.bss:
71 .type Bbss.bss, at object
72 .size Bbss.bss,0
73
74 .section .data,"aw"
75 Ddata.data:
76 .type Ddata.data, at object
77 .size Ddata.data,0
78
79 .section .rodata,"a"
80 Drodata.rodata:
81 .type Drodata.rodata, at object
82 .size Drodata.rodata,0
83 .L15:
84 .byte 0x61,0x62
85 .type .L15, at object
86 .size .L15,2
87
88 .section .rodata1,"a"
89 .align 4
90 .L16:
91 .byte 0xa,0x20,0x62,0x5b,0x30,0x5d,0x20,0x3d,0x20,0x30
92 .byte 0x78,0x25,0x30,0x32,0x78,0x68,0xa,0x0
93 .type .L16, at object
94 .size .L16,18
95 .type fprintf, at function
96
97 .file "foo.c"
98 .ident "@(#)stdio.h 1.78 99/12/08 SMI"
99 .ident "@(#)stdio_iso.h 1.2 99/10/25 SMI"
100 .ident "@(#)feature_tests.h 1.18 99/07/26 SMI"
101 .ident "@(#)isa_defs.h 1.20 99/05/04 SMI"
102 .ident "@(#)va_list.h 1.12 99/05/04 SMI"
103 .ident "@(#)stdio_tag.h 1.3 98/04/20 SMI"
104 .ident "@(#)stdio_impl.h 1.8 99/06/10 SMI"
105 .ident "acomp: Sun C 5.8 Patch 121016-08 2009/04/20"
106
107 .globl __fsr_init_value
108 __fsr_init_value = 0x0
109 / Begin sdCreateSection : .debug_info
110 / Section Info: link_name/strtab=, entsize=0x1, adralign=0x1,
flags=0x0
111 / Section Data Blocks:
112 / reloc[0]: knd=2, off=6, siz=4, lab1=.debug_abbrev, lab2=, loff=0
113 / reloc[1]: knd=2, off=164, siz=4, lab1=.debug_line, lab2=, loff=0
114 .section .debug_info
115 .byte 0xa8,0x00,0x00,0x00,0x02,0x00
116 .4byte .debug_abbrev
117 .byte 0x04,0x01,0x00,0x00,0x00,0x00,0x04,0x00
118 .byte 0x00,0x00,0x66,0x6f,0x6f,0x2e,0x63,0x00
119 .byte 0x0c,0x2f,0x6f,0x70,0x74,0x2f,0x63,0x73
120 .byte 0x77,0x2f,0x73,0x72,0x63,0x2f,0x47,0x4e
121 .byte 0x55,0x2f,0x74,0x65,0x73,0x74,0x00,0x20
122 .byte 0x2f,0x6f,0x70,0x74,0x2f,0x53,0x55,0x4e
123 .byte 0x57,0x73,0x70,0x72,0x6f,0x2f,0x70,0x72
124 .byte 0x6f,0x64,0x2f,0x62,0x69,0x6e,0x2f,0x63
125 .byte 0x63,0x20,0x2d,0x48,0x20,0x2d,0x63,0x20
126 .byte 0x2d,0x53,0x20,0x20,0x66,0x6f,0x6f,0x2e
127 .byte 0x63,0x00,0x58,0x61,0x3b,0x52,0x3d,0x53
128 .byte 0x75,0x6e,0x20,0x43,0x20,0x35,0x2e,0x38
129 .byte 0x20,0x50,0x61,0x74,0x63,0x68,0x20,0x31
130 .byte 0x32,0x31,0x30,0x31,0x36,0x2d,0x30,0x38
131 .byte 0x20,0x32,0x30,0x30,0x39,0x2f,0x30,0x34
132 .byte 0x2f,0x32,0x30,0x3b,0x62,0x61,0x63,0x6b
133 .byte 0x65,0x6e,0x64,0x3b,0x72,0x61,0x77,0x3b
134 .byte 0x63,0x64,0x3b,0x00,0x44,0x42,0x47,0x5f
135 .byte 0x47,0x45,0x4e,0x20,0x35,0x2e,0x30,0x2e
136 .byte 0x38,0x00
137 .4byte .debug_line
138 .byte 0x00,0x00,0x00,0x00
139 / End sdCreateSection
140 / Begin sdCreateSection : .debug_line
141 / Section Info: link_name/strtab=, entsize=0x1, adralign=0x1,
flags=0x0
142 / Section Data Blocks:
143 .section .debug_line
144 .byte 0x35,0x00,0x00,0x00,0x02,0x00,0x2f,0x00
145 .byte 0x00,0x00,0x01,0x00,0xff,0x04,0x0a,0x00
146 .byte 0x01,0x01,0x01,0x01,0x00,0x00,0x00,0x01
147 .byte 0x2f,0x6f,0x70,0x74,0x2f,0x63,0x73,0x77
148 .byte 0x2f,0x73,0x72,0x63,0x2f,0x47,0x4e,0x55
149 .byte 0x2f,0x74,0x65,0x73,0x74,0x00,0x00,0x66
150 .byte 0x6f,0x6f,0x2e,0x63,0x00,0x01,0x00,0x00
151 .byte 0x00
152 / End sdCreateSection
153 / Begin sdCreateSection : .debug_abbrev
154 / Section Info: link_name/strtab=, entsize=0x1, adralign=0x1,
flags=0x0
155 / Section Data Blocks:
156 .section .debug_abbrev
157 .byte 0x01,0x11,0x00,0x11,0x01,0x12,0x01,0x03
158 .byte 0x08,0x13,0x0b,0x1b,0x08,0x85,0x44,0x08
159 .byte 0x87,0x44,0x08,0x25,0x08,0x10,0x06,0x00
160 .byte 0x00,0x00
161 / End sdCreateSection
> > The file mpn/x86/divrem_2.asm will then be chosen, and it indeed
> > contains some "or" instructions with byte registers.
>
> Is there a way for force the usage of the more portable "generic" C
> sources?
>
> Sure, and this is documented, please read the fine manual. :-)
oookay. It's way to late or early for me to go digging. I'll do that later
today.
Let me know if the above asm output was of any value.
--
Dennis Clarke
dclarke at opensolaris.ca <- Email related to the open source Solaris
dclarke at blastwave.org <- Email related to open source for Solaris
More information about the gmp-bugs
mailing list