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]

Re: printf(), outbyte(), ...


Hi,

thanks for that hint.  Ok, i also tried that before.  I copied
write from write.c:

int _DEFUN (write, (fd, buf, nbytes), int fd _AND char *buf _AND int nbytes) {
  int i;

  outbyte('j');

  for (i = 0; i < nbytes; i++) {
    if (*(buf + i) == '\n') outbyte ('\r');

    outbyte (*(buf + i));
  }

  return nbytes;
}

If i call it directly from main() i can see an output:
write(1, "Hi world\n", 9);  // works fine

But printf("Hello world\n") does not work at all.

I've also generated a complete listing of my ELF file:
v850e-unknown-elf-objdump -D file.elf >file.list

In there i can see that there is a second __write.  Also when
i overwrite this one i don't get no output.

I've also overwritten some other functions and output a character
to see if they get called.  None of them does.  Here's a list:
close, fstat, getpid, isatty, kill, lseek, open, read, stat, unlink
and write.

I wonder if i need to initialise them somehow?


Best regards,
Torsten.


> Torsten Mohr wrote:
> > Hi,
> >
> > to use printf() in own programs i added the function
> > void outbyte(char c).
> >
> > But i don't get no output when i use printf().
> >
> > I run newlib-1.14 on an NEC V850.
> >
> > I wonder how i could track this problem down a bit closer.
> >
> > To my understanding i need to just implement void outbyte(char c);
> > Do i need more?
> >
> >
> > Best regards,
> > Torsten.
>
> I don't know where you got the idea from, but there is no call from
> printf to a function called outbyte.  Printf sits atop the write syscall
> which for your platform is found in newlib/libc/sys/sysnecv850/write.c.
>   In this particular case it is causing a trap to occur.  I am not at
> all familiar with the platform, but it is possible that this code was
> set up to run exclusively with a simulator.  A simulator sometimes
> translates a magic trap value to appropriate syscalls on the platform
> running the simulator.
>
> -- Jeff J.


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