[Solved] Compilation error while building ported binutils

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
User avatar
Agola
Member
Member
Posts: 155
Joined: Sun Nov 20, 2016 7:26 am
Location: Somewhere

[Solved] Compilation error while building ported binutils

Post by Agola »

Hi again.

After finishing Newlib syscalls and elf support, I ported some small programs easily. Then I wanted to port a bit harder one, Binutils.

I added i686-agola host to Binutils, then configured Binutils with
../agola-binutils/configure --target=i686-agola --host=i686-agola --prefix=$HOME/agola/sysroot/binutils --disable-werror
Then started compiling with make all... But compilation failed with an error:
libc.a (syscalls.o): In function `syscall_getcwd':
newlib/libc/sys/agola/../../../newlib/libc/sys/agola/syscalls.c:86: multiple definition of `getcwd' ../libiberty/libiberty.a (getcwd.o): /binutils/libiberty/../binutils/libiberty/getcwd.c:42: first defined here
getcwd is a syscall, but compilation fails. It is defined in syscalls.c:

Code: Select all

DEFINE_SYSCALL_2ARGS(getcwd, 27, char*, size_t)

char *getcwd(char *buf, size_t size)
{
   return (char*) syscall_getcwd(buf, size);
}
Why it is defined in libiberty, too?
How can I solve that, I'm stucked :|
Last edited by Agola on Sat Jan 21, 2017 5:51 am, edited 1 time in total.
Keyboard not found!

Press F1 to run setup.
Press F2 to continue.
User avatar
dchapiesky
Member
Member
Posts: 204
Joined: Sun Dec 25, 2016 1:54 am
Libera.chat IRC: dchapiesky

Re: Compilation error while building ported binutils

Post by dchapiesky »

Code: Select all

getcwd.c
Don't put your syscalls all in one big file - break em out into separate files...

As I understand it and I certainly don't and would love someone to expand upon this I can only say that having two getcwd.o (object files) means only the first one encountered is read in by the linker (thus no multiple definition)

or more likely the archive manager for .a static libraries. not sure

The upshot is that it isn't the symbol name you have to worry about but the file.o containing it....

weird no?
Plagiarize. Plagiarize. Let not one line escape thine eyes...
User avatar
Agola
Member
Member
Posts: 155
Joined: Sun Nov 20, 2016 7:26 am
Location: Somewhere

Re: Compilation error while building ported binutils

Post by Agola »

It is compiled now, but it page faults like in old crt0 problem.

I called as with ./as --version, it printed everything then it crashed.
Is it an exit() problem?

It is a screenshot before crash:

Image

It immediately page faults after that. That made me thought problem is again about exit(), reentrancy :(
Keyboard not found!

Press F1 to run setup.
Press F2 to continue.
User avatar
Agola
Member
Member
Posts: 155
Joined: Sun Nov 20, 2016 7:26 am
Location: Somewhere

Re: Compilation error while building ported binutils

Post by Agola »

Sorry, my bad, found a bug in syscall_exit() causing all of these problems.

Everything is great now! A big thanks to you [-o<
Keyboard not found!

Press F1 to run setup.
Press F2 to continue.
User avatar
dchapiesky
Member
Member
Posts: 204
Joined: Sun Dec 25, 2016 1:54 am
Libera.chat IRC: dchapiesky

Re: Compilation error while building ported binutils

Post by dchapiesky »

Agola wrote:Sorry, my bad, found a bug in syscall_exit() causing all of these problems.

Everything is great now! A big thanks to you [-o<
=D> =D> =D>

Glad to help - although I will give you an update on my work with newlib - I am using it in the kernel as opposed to user space - so my answers in the future may need to be taken with a grain of salt...

cheers
Plagiarize. Plagiarize. Let not one line escape thine eyes...
User avatar
Agola
Member
Member
Posts: 155
Joined: Sun Nov 20, 2016 7:26 am
Location: Somewhere

Re: Compilation error while building ported binutils

Post by Agola »

dchapiesky wrote:
Agola wrote:Sorry, my bad, found a bug in syscall_exit() causing all of these problems.

Everything is great now! A big thanks to you [-o<
=D> =D> =D>

Glad to help - although I will give you an update on my work with newlib - I am using it in the kernel as opposed to user space - so my answers in the future may need to be taken with a grain of salt...

cheers
An update? I'm looking forward to see it :D
Thanks
Keyboard not found!

Press F1 to run setup.
Press F2 to continue.
Post Reply