printf failed when created by a cross compiler

yu_chen@ict.ac.cn yu_chen@ict.ac.cn
Tue Oct 19 14:06:00 GMT 2004


Hi,
   I'm coming with a problem, and the case is like this:
   When I compiled and linked my code like this:
   1.gcc -Wl,-r -Wl,-d -static a.c -o a.o
   2.ld -q a.o -o a.out
   I got the file a.out which is an excutable file with relocation
information, however, all the printf functions worked improperly if I
redirected output of a.out to a specific file
   ./a.out > a.log
   There was nothing in a.log, but if I just run a.out without
redirection, I could get the result from the standard output.

   I compiled and linked my program like this because I want to create a
static  program with relocation infomation, which would be used as the
input of ALTO(A Link Time Optimizer).

    The program a.c goes as follows
==============================================================
#include <stdio.h>
int main()
{
    printf("this is a try\n");
    return 0;
}
==============================================================

    The a.c was compiled by a cross-compiler generated by gcc 3.4.1.  And
the cross compiler was made to generate codes running on a mips
platform. The a.o  was linked by a cross-compiled ld with GNU ld
version 2.15.







More information about the Gcc-help mailing list