Hi, all

I've compiled elf2flt (a tool to convert elf format file to flat used by uClinux), but 
it crashs while I'm compiling uClinux.

This tool will use libiberty compiled for the specified target (for example, arm-elf) 
and I found if I don't use this library and it will works. (There are two applications 
elf2flt and flthdr, the second one will not use libiberty and I can compile it)

Then I wrote a simple program to test:

#include <stdio.h>
#include <getopt.h>

int main(int argc, char **argv)
{
    int opt;
    while ((opt = getopt(argc, argv, "avzdrkp:s:o:R:")) != -1) {
        printf("opt = %d,%c\n", opt, (char)opt);
        printf("optarg = %s\n", optarg);
    }
}


when it is compiled with     gcc -O2 opt.c -o opt
it is ok and it I type opt -s 1
it will output:
opt = 115,s
optarg = 1

but if it is compiled with     gcc -O2 opt.c -o opt -liberty
opt -s 1 will output:
opt = 115,s
optarg = (null)


gcc-3.3.1 and 3.2.3 is the same problem

I use     nm /lib/libiberty.a > iberty.txt and find there's already a getopt function 
in libiberty, and perhaps it conflicts with libc.a
It can be ok if I remove the getopt implementations in libiberty.a with
ar d libiberty.a getopt.o getopt1.o
then it will produce the correct output.

So I don't know how to deal with it.

Reply via email to