OSDev.org

The Place to Start for Operating System Developers
It is currently Thu Mar 28, 2024 7:58 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: [RESOLVED] Binutils .a issue
PostPosted: Sun Dec 10, 2017 4:39 am 
Offline
Member
Member

Joined: Wed Aug 10, 2016 3:07 am
Posts: 31
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...


Last edited by Haoud on Fri Dec 29, 2017 5:21 am, edited 2 times in total.

Top
 Profile  
 
 Post subject: Re: HOSTED BINUTILS link with libc.a problem
PostPosted: Sun Dec 10, 2017 3:28 pm 
Offline
Member
Member
User avatar

Joined: Mon Mar 05, 2012 11:23 am
Posts: 616
Location: Germany
Hey,

with what modifications / configure options did you compile your host binutils?

Greets

_________________
Ghost OS - GitHub


Top
 Profile  
 
 Post subject: Re: HOSTED BINUTILS link with libc.a problem
PostPosted: Mon Dec 11, 2017 12:07 am 
Offline
Member
Member

Joined: Wed Aug 10, 2016 3:07 am
Posts: 31
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


Top
 Profile  
 
 Post subject: Re: HOSTED BINUTILS link with libc.a problem
PostPosted: Mon Dec 11, 2017 9:27 am 
Offline
Member
Member
User avatar

Joined: Sat Mar 31, 2012 3:07 am
Posts: 4591
Location: Chichester, UK
Such compiler did you use to produce your .a files? Are you sure it is a 32-bit one?


Top
 Profile  
 
 Post subject: Re: HOSTED BINUTILS link with libc.a problem
PostPosted: Mon Dec 11, 2017 9:43 am 
Offline
Member
Member

Joined: Wed Aug 10, 2016 3:07 am
Posts: 31
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")


Top
 Profile  
 
 Post subject: Re: HOSTED BINUTILS link with libc.a problem
PostPosted: Thu Dec 14, 2017 1:16 pm 
Offline
Member
Member

Joined: Wed Aug 10, 2016 3:07 am
Posts: 31
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.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: Bing [Bot], SemrushBot [Bot] and 55 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group