This is the mail archive of the newlib@sourceware.org mailing list for the newlib 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]

brk syscall in libgloss/rs6000/simulator.S and libgloss/m68k/simulator.S


Hi,

After successfully building a PowerPC cross-compiling binutils and
gcc+newlib, I had the following problem when running PowerPC binaries
under qemu:

  rory@segserver:~/hack/c/hello$ cat simplesum.c
  #include <stdio.h>

  int
  main()
  {
    double y=1+2;
    printf("1+2 = %g\n",y);
    return 0;
  }
  rory@segserver:~/hack/c/hello$ powerpc-linux-elf-gcc -msim simplesum.c
-o simplesum
  rory@segserver:~/hack/c/hello$ qemu-ppc simplesum
  qemu: Unsupported syscall: 17
  qemu: Unsupported syscall: 17
  Invalid data memory access: 0x00000014
  Invalid segfault errno (2000000)
  qemu: uncaught target signal 11 (Segmentation fault) - exiting

According to the /usr/include/asm-i386/unistd.h on my machine, system
call 17 is 'break'; according to 'man 2 break', this system call is
unimplemented.  I guessed that what was really wanted was brk, which
is system call 45.  A corresponding change to the function brk in
libgloss/rs6000/simulator.S gave me a working result, i.e.,

  rory@segserver:~/hack/c/hello$ powerpc-linux-elf-gcc -msim simplesum.c
-o simplesum
  rory@segserver:~/hack/c/hello$ qemu-ppc simplesum
1+2 = 3

I don't really understand what is going on here: I don't know what the
break system call is (Google didn't help much), or why it's
unimplemented, or why it's called in libgloss and not brk.  Perhaps
there is some other target for which this is the correct behaviour.
Regardless, this fix Works On My Machine, and I thought it might be
handy for others to know.

The patch attached is against newlib 1.12.0; I checked the CVS trunk,
and
libgloss/rs6000/simulator.S still calls syscall 17.  The patch alters
libgloss/m68k/simulator.S in a similar manner; I haven't tested with
an m68k target.  I grepped for brk in the entire libgloss tree, but I
didn't understand the other hits.

Finally, some details on my cross-compile setup; the cross-compile
tools are:

  binutils 2.17.50.0.15.20070418
  gcc 2.95.3
  newlib 1.12.0

Host is an Ubuntu 6.06 system, with Ubuntu-provided gcc 4.0.3 and
binutils 2.16.91 20060118.

binutils config:

  ../../binutils-2.17.50.0.15/configure --target=powerpc-linux-elf
--prefix=/home/rory/powerpc-cross

gcc/newlib config:

  ../../gcc-2.95.3/configure
--with-gcc-version-trigger=/home/rory/work/adarter/cross-compile2/gcc-2.
95.3/gcc/version.c --host=i686-pc-linux-gnu --target=powerpc-linux-elf
--prefix=/home/rory/powerpc-cross --with-newlib
--program-prefix=powerpc-linux-elf- --norecursion

(that last is from config.status; my invocation was simpler).

gcc was built with newlib and libgloss symlinks in the gcc top-level
source directory.

I hope this is of some use.

Regards,

Rory

PS: this mail will go through MS Exchange, which may mess up line
endings; for that reason I've attached the patch rather than including
it in the mail.

*******************************************************************************************************
Disclaimer:  The information contained in this communication is confidential and may be legally privileged.  
It is intended solely for the use of the individual or entity to whom it is addressed and others authorised to receive it.  
Any review, retransmission, dissemination, copying, disclosure or other use of, or taking of any action in reliance upon, this information by person or entities other then the intended recipient is prohibited.  
If you have received this message in error, please notify the sender immediately by e-mail, facsimile or telephone and return and/or destroy the original message and all copies from any computer.  

Denel (Pty) Ltd exercises no editorial control over e-mail messages originating in the organisation and does not accept any responsibility for either the contents of the message or any copyright laws that may have been violated by the person sending this message.  
Denel (Pty) Ltd is neither liable for the proper and complete transmission of the information contained in this communication nor any delay in its receipt.  
This message should not be copied or used for any purpose other than intended, nor should it be disclosed to any other person.
*******************************************************************************************************

Attachment: newlib-1.12.0-brksyscall-45.patch
Description: newlib-1.12.0-brksyscall-45.patch


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