Page 1 of 1

[Solved] Compilation error while building ported binutils

Posted: Sat Jan 21, 2017 3:54 am
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 :|

Re: Compilation error while building ported binutils

Posted: Sat Jan 21, 2017 4:06 am
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?

Re: Compilation error while building ported binutils

Posted: Sat Jan 21, 2017 5:19 am
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 :(

Re: Compilation error while building ported binutils

Posted: Sat Jan 21, 2017 5:51 am
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<

Re: Compilation error while building ported binutils

Posted: Sat Jan 21, 2017 3:13 pm
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

Re: Compilation error while building ported binutils

Posted: Sat Jan 21, 2017 4:01 pm
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