[Toybox] Is binutils neccessary?

Isaac Dunham ibid.ag at gmail.com
Thu Dec 11 12:04:55 PST 2014


On Thu, Dec 11, 2014 at 01:58:01PM -0500, stephen Turner wrote:
> Rob and list,
> 
> I see there are plans to add "ar" to toybox. this would be compatible with
> binutils correct? I think musl-libc has a built in linker compatible with
That would be feasible, at least for someone who understands ELF better
than I do. (To build a linkable ar archive, you need to make an index
indicating all the symbols the library contains.)

> "ld" in binutils by creating a symlink to libc.so so then we would only
Wrong. I'm not sure about all the details myself, but this is my
understanding:
There are two types of "linker", which are rather diffferent in what
they do.  
ld.so (/lib/ld-linux.so.2 on glibc, /lib/ld-musl-$ARCH.so.1 = /lib/libc.so
on musl) is the "dynamic linker"; it will load a dynamically linked binary,
figure out what shared libraries it has been linked to, load all of them
into memory, and then relocate everything.

/usr/bin/ld converts ELF objects (*.o, contents of *.a, ...) into a
binary or shared library, including doing any relocations that can be
resolved using the symbols in the raw objects and marking what shared
libraries need to be used.

There are a couple of alternatives to binutils for /usr/bin/ld, but
they're experimental LLVM projects; mc-linker aim(s|ed) to provide
an LLVM-based linker for Android systems, and lld is part of LLVM but
is not yet ready for production on most Linux architectures (though 
Rich Pennington mentioned successful bootstrap of ELLCC with it on
x86_64).
tcc, which is not llvm based and cannot build musl, also has a 
built-in linker a la /usr/bin/ld.
neatld (from http://litcave.rudi.ir) apparently is finished but has
a *very* limited scope.

> need "as" to have a fully functioning compile suite correct? I am assuming
> the presence of a working compiler.
Assuming that you have an adequate ar, and that you can find a 
working ld, you might or might not need "as".
Clang (at least when configured without binutils) and tcc do not call 
external assemblers.
PCC calls an external assembler; it ostensibly supports YASM as an
alternative to binutils, but that's documented as being for the sake
of Windows.
> I see a number of programs in the binutils suite and am just curious of
> which are required now that i have started to find built in alternatives
> like the libc built in ld and the future toybox ar etc.
> 
> thanks,
> stephen

By the time we have a full-featured depmod, nm would be not much more
work.
A full POSIX ar (adequate for libraries) would also cover ranlib.
strings is already done.
size and strip are the main binutils tools in addition to those...

HTH,
Isaac Dunham


 1418328295.0


More information about the Toybox mailing list