cc: assembler failed for tmp-divrem_2.s

Dennis Clarke dclarke at blastwave.org
Mon Mar 29 14:30:57 CEST 2010


> Dennis Clarke <dclarke at blastwave.org> writes:
> <snip>

> 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]; }

Only because I like to look at such things ... here :

[dclarke at icarus test]$ uname -a
Linux icarus 2.6.18-186.el5 #1 SMP Wed Jan 27 18:11:22 EST 2010 x86_64
x86_64 x86_64 GNU/Linux

[dclarke at icarus test]$ 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  }


[dclarke at icarus test]$ gcc -v -m32 -march=i486 -mno-mmx -mno-sse -S -c -o
foo.s foo.c
Using built-in specs.
Target: x86_64-redhat-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man
--infodir=/usr/share/info --enable-shared --enable-threads=posix
--enable-checking=release --with-system-zlib --enable-__cxa_atexit
--disable-libunwind-exceptions --enable-libgcj-multifile
--enable-languages=c,c++,objc,obj-c++,java,fortran,ada
--enable-java-awt=gtk --disable-dssi --enable-plugin
--with-java-home=/usr/lib/jvm/java-1.4.2-gcj-1.4.2.0/jre
--with-cpu=generic --host=x86_64-redhat-linux
Thread model: posix
gcc version 4.1.2 20080704 (Red Hat 4.1.2-48)
 /usr/libexec/gcc/x86_64-redhat-linux/4.1.2/cc1 -quiet -v foo.c -quiet
-dumpbase foo.c -m32 -march=i486 -mno-mmx -mno-sse -auxbase-strip foo.s
-version -o foo.s
ignoring nonexistent directory
"/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../x86_64-redhat-linux/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/include
 /usr/lib/gcc/x86_64-redhat-linux/4.1.2/include
 /usr/include
End of search list.
GNU C version 4.1.2 20080704 (Red Hat 4.1.2-48) (x86_64-redhat-linux)
        compiled by GNU C version 4.1.2 20080704 (Red Hat 4.1.2-48).
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: a3051c09b619a445813ce8bda3637643

[dclarke at icarus test]$ ls -lap
total 16
drwxrwxr-x 2 dclarke dclarke 4096 Mar 29 08:26 ./
drwxrwxr-x 3 dclarke dclarke 4096 Mar 29 08:21 ../
-rw-rw-r-- 1 dclarke dclarke  317 Mar 29 08:21 foo.c
-rw-rw-r-- 1 dclarke dclarke  905 Mar 29 08:26 foo.s

[dclarke at icarus test]$ cat -n foo.s
     1          .file   "foo.c"
     2          .section        .rodata
     3  .LC0:
     4          .string "\n b[0] = 0x%02xh\n"
     5          .text
     6  .globl main
     7          .type   main, @function
     8  main:
     9          leal    4(%esp), %ecx
    10          andl    $-16, %esp
    11          pushl   -4(%ecx)
    12          pushl   %ebp
    13          movl    %esp, %ebp
    14          pushl   %ecx
    15          subl    $20, %esp
    16          movb    $97, -6(%ebp)
    17          movb    $98, -5(%ebp)
    18          subl    $12, %esp
    19          leal    -6(%ebp), %eax
    20          pushl   %eax
    21          call    foo
    22          addl    $16, %esp
    23          movb    %al, -7(%ebp)
    24          movb    -7(%ebp), %al
    25          movsbl  %al,%eax
    26          movl    stderr, %edx
    27          subl    $4, %esp
    28          pushl   %eax
    29          pushl   $.LC0
    30          pushl   %edx
    31          call    fprintf
    32          addl    $16, %esp
    33          movl    $0, %eax
    34          movl    -4(%ebp), %ecx
    35          leave
    36          leal    -4(%ecx), %esp
    37          ret
    38          .size   main, .-main
    39  .globl foo
    40          .type   foo, @function
    41  foo:
    42          pushl   %ebp
    43          movl    %esp, %ebp
    44          movl    8(%ebp), %eax
    45          movb    (%eax), %dl
    46          movl    8(%ebp), %eax
    47          incl    %eax
    48          movb    (%eax), %al
    49          orl     %edx, %eax
    50          movsbl  %al,%eax
    51          popl    %ebp
    52          ret
    53          .size   foo, .-foo
    54          .ident  "GCC: (GNU) 4.1.2 20080704 (Red Hat 4.1.2-48)"
    55          .section        .note.GNU-stack,"", at progbits


[dclarke at icarus test]$ gcc -v -m32 -march=i486 -mno-mmx -mno-sse -o foo foo.s
Using built-in specs.
Target: x86_64-redhat-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man
--infodir=/usr/share/info --enable-shared --enable-threads=posix
--enable-checking=release --with-system-zlib --enable-__cxa_atexit
--disable-libunwind-exceptions --enable-libgcj-multifile
--enable-languages=c,c++,objc,obj-c++,java,fortran,ada
--enable-java-awt=gtk --disable-dssi --enable-plugin
--with-java-home=/usr/lib/jvm/java-1.4.2-gcj-1.4.2.0/jre
--with-cpu=generic --host=x86_64-redhat-linux
Thread model: posix
gcc version 4.1.2 20080704 (Red Hat 4.1.2-48)
 as -V -Qy --32 -o /tmp/ccuYuYOk.o foo.s
GNU assembler version 2.17.50.0.6-14.el5 (x86_64-redhat-linux) using BFD
version 2.17.50.0.6-14.el5 20061020
 /usr/libexec/gcc/x86_64-redhat-linux/4.1.2/collect2 --eh-frame-hdr -m
elf_i386 --hash-style=gnu -dynamic-linker /lib/ld-linux.so.2 -o foo
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../lib/crt1.o
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../lib/crti.o
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/32/crtbegin.o
-L/usr/lib/gcc/x86_64-redhat-linux/4.1.2/32
-L/usr/lib/gcc/x86_64-redhat-linux/4.1.2/32
-L/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../lib -L/lib/../lib
-L/usr/lib/../lib /tmp/ccuYuYOk.o -lgcc --as-needed -lgcc_s
--no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/32/crtend.o
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../lib/crtn.o
[dclarke at icarus test]$
[dclarke at icarus test]$ file foo
foo: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), for
GNU/Linux 2.6.9, dynamically linked (uses shared libs), for GNU/Linux
2.6.9, not stripped
[dclarke at icarus test]$ ./foo

 b[0] = 0x63h

I guess this shows that 'a'|'b' == 'c' == 0x63h and that is correct.

Dennis




More information about the gmp-bugs mailing list