This is the mail archive of the newlib@sourceware.org mailing list for the newlib project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Generating assembly listing from newlib sourcecode


Your best bet is probably to disassemble the complete program using
your-target-objdump -d.  This assembly output will contain all the
functions (from your source code and from newlib) that you will need for
execution.

Regardless of the route you choose you are likely to have to
post-process the (dis)assembly to get it into the right format for your
simulator.

How does your simulator handle data?  There are likely to be at least
two data sections within the resultant executable that you will somehow
need to load into the simulator: .data and .rodata.  Again you could use
your-target-objdump (this time with the -j and -s options) to get at the
data.

All that said, if you have the source code for the simulator I'd rip out
the scanning/parsing and replace it with an instruction decode block.
:-)  It might be a fair amount of work, but at least then you'll be able
to run object code.

Regards,
Matt


On Fri, Aug 04, 2006 at 12:15:43AM -0300, Manuel Barros Reyes wrote:
> Hi, is it possible to generate in some way maybe using -S of gcc
> assembly listings of newlib for the MIPS architecture?
> 
> The problem is as follows: we need to make, for illustration purposes,
> some step by step execution inside the SPIM simulator (a MIPS
> processor simulator). This simulator unfortunately works directly with
> text files, usually handwritten. We need to do the same but from
> assembly language listings generated by gcc from simple C programs,
> maybe just a printf("Hello") message. As far as I got I managed to get
> my C program in assembly (with -S) but with jumps to newlib functions
> like printf().  The SPIM simulator can't resolve this jumps unless we
> feed it with some assembly listing that includes (if possible) the
> entry point and code for printf() with the syscalls that it possibly
> generates.
> 
> I don't know if all this is possible its just for teaching so it
> doesn't need to be a very elegant solution if it exists. Maybe I can
> copy & paste the printf code in a new file and compile it separately I
> don't know. Any comments will be very helpful for sure. Thanks in
> advance. Manuel.
> 

-- 
Matt Kern
http://www.undue.org/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]