This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
printf failed when created by a cross compiler
- From: yu_chen at ict dot ac dot cn
- To: gcc-help at gcc dot gnu dot org
- Date: Tue, 19 Oct 2004 21:42:52 +0800 (CST)
- Subject: printf failed when created by a cross compiler
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.