Compiling busybox to .s assembly file

Harald Becker ralda at gmx.de
Thu Feb 24 19:14:07 UTC 2011


 Hallo Eric!
> I'm hoping to generate a compiled text asm file (gcc -S) of the busybox
> executable.  I've looked at scripts/showasm, but it uses objdump the
> output of which could not (easily) then be edited and linked to generate
> an executable.
>
> I've spend a good deal of time mucking around in the Makefile, but
> having never fully felt comfortable with Makefiles even in relatively
> simple cases, the busybox Makefile is largely opaque to me.
>
> If anyone can offer a suggestion, or point me in the right direction I
> will be very appreciative.  Once I get this working if there is any
> interest I would be happy to wrap it up in a script which could be
> included in scripts/ -- although I'm not sure that such functionality
> would be generally useful.

I'm not absolutly sure, if I understand, what you are going to do. First
of all, Busybox is not produced by compiling a single file, so it won't
be possible to create a single assembler file as output. In general you
are able to compile each C source file into it's assembler output. I
suggest you create a simple fake tool chain by just writing some shell
scripts for the following commands:

my-as
my-gcc
my-ar
my-nm
my-strip
my-objcopy
my-objdump
my-ld

In general all those can be implement as simple scripts:

/usr/local/bin/my-xxx:

#!/bin/sh
exec /usr/bin/xxx ${1+"$@"}

That wraps (as the first step) all commands back to there normal
behavior. Now you are able to enter the cross compiler prefix "my-" in
Busybox configuration:

make menuconfig
Busybox Settings -> Build-Options -> Cross Compiler prefix

If you did everything right, Busybox should build correct (with an
unmodified source tree). After verifying this you are nearly through.
Just extend your  my-gcc script to do two separate runs (grab command
args and replace "-o filename.o" by "-S -o filename.S"), than do the gcc
again with the unmodified command args. After that you should have the
source tree of Busybox populated with your assembler files ... without
fiddling on the Makefile. Simply compiling most of those assembler files
to there objects and linking them together should produce a functioning
Busybox binary (there are only a few exceptions to be excluded from link
= tools used during build).

Unverified idea, just out of my brain, but should work. May be I'm able
to help further on this.

--
Harald


More information about the busybox mailing list