OSDev.org https://forum.osdev.org/ |
|
[RESOLVED] Binutils .a issue https://forum.osdev.org/viewtopic.php?f=1&t=32630 |
Page 1 of 1 |
Author: | Haoud [ Sun Dec 10, 2017 4:39 am ] |
Post subject: | [RESOLVED] Binutils .a issue |
Hello, I am currently trying to port gcc and binutils to my operating system. I am currently using Newlib 2.5.0, GCC 5.2.0 and binutils 2.25. I have cross compiled binutils and gcc for my OS and their work and it seems to be functioning correctly. I'm trying to compile a very simple program under my OS: Code: int main(int argc, char *argv[]) { return 0; } I use this command to compile: Code: gcc -fno-use-linker-plugin /test.c GCC correctly generates the. o file but binutils can't link it to the. a libraries (libgcc. a, libc. a, libnosys.a ...) I get this error for all .a file: Code: libgcc.a: file not recognized: file format not recognized But my libraries work perfectly because if I compile with Code: gcc -c /test.c and that I link with the same libraries with my cross ld but under linux, it works and i get a valid executable that I can launch under my OS (and that doesn't do anything but is running well) Anybody have any ideas on how to solve this problem? Thank you EDIT: Under my OS, ar does'nt recognized .a files too but under linux, i386-haoudos-ar recognized it. It's strange... |
Author: | max [ Sun Dec 10, 2017 3:28 pm ] |
Post subject: | Re: HOSTED BINUTILS link with libc.a problem |
Hey, with what modifications / configure options did you compile your host binutils? Greets |
Author: | Haoud [ Mon Dec 11, 2017 12:07 am ] |
Post subject: | Re: HOSTED BINUTILS link with libc.a problem |
Hello, thank you for your response I made the same changes as in the tutorial by replacing "myos" with "haoudos" and "i686" with "i386". I use this shell script to compile binutils: Code: export PATH=$HOME/cross/bin:$PATH export SYSROOT=$HOME/sysroot export PREFIX=/bin cd $HOME/src/binutils-2.25/build ../binutils/configure --target=i386-haoudos --host=i386-haoudos --disable-multilib -with-arch=i386 --prefix="$PREFIX" --with-sysroot-build="$SYSROOT" -with-sysroot=/ --disable-werror --enable-nls --with-pkgversion="Binutils 2.25 for HaoudOS" make all -j8 make DESTDIR=$SYSROOT install ans to compile gcc: Code: export PATH=$HOME/cross/bin:$PATH
export SYSROOT=$HOME/sysroot export PREFIX=/bin cd $HOME/src/gcc-5.2.0/build make distclean ../gcc-5.2.0/configure --prefix="$PREFIX" --target=i386-haoudos --host=i386-haoudos --with-arch=i386 --disable-shared --disable-multilib --with-newlib --with-sysroot-build="$SYSROOT" --with-sysroot=/ --enable-languages=c,c++ --with-pkgversion="GCC 5.2.0 for HaoudOS" make all-gcc -j8 make all-target-libgcc -j8 make DESTDIR=$SYSROOT install-gcc make DESTDIR=$SYSROOT install-target-libgcc |
Author: | iansjack [ Mon Dec 11, 2017 9:27 am ] |
Post subject: | Re: HOSTED BINUTILS link with libc.a problem |
Such compiler did you use to produce your .a files? Are you sure it is a 32-bit one? |
Author: | Haoud [ Mon Dec 11, 2017 9:43 am ] |
Post subject: | Re: HOSTED BINUTILS link with libc.a problem |
I think my .a file are 32-bit but I'm not sure. I don't get precision with command "file" (libgcc.a: current ar file). Ho I get more information about libraries? I noticed several strange things: - These libraries work very well with the cross compiler for my OS: for example, if I ask GCC (under my OS) to produce .o file, I can correctly link it with the cross compiler for my OS (under linux) and run the executable produced under my OS. - If i run "strip" on .a file, the error disappears but I get another link error (I'm not home yet, I'll describe the mistake more precisely as soon as I can) on string index and a error like "crt0.o: no .eh_frame_hdr table will be created") |
Author: | Haoud [ Thu Dec 14, 2017 1:16 pm ] |
Post subject: | Re: HOSTED BINUTILS link with libc.a problem |
OK, when I run: Code: readelf libgcc.a -h I get this error: Code: readelf: Error: Archive member uses long names, but no longname table found readelf: Error: libgcc.a: bad archive file name EDIT:After a few weeks of debugging, I realized that my lseek system call did not return the position in the file after moving into the file. I've corrected that and everything went back in order. |
Page 1 of 1 | All times are UTC - 6 hours |
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group http://www.phpbb.com/ |