[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Tinycc-devel] OSX
From: |
Peter \"Firefly\" Lund |
Subject: |
Re: [Tinycc-devel] OSX |
Date: |
Mon, 21 Apr 2003 12:12:19 +0200 (MEST) |
On Sun, 20 Apr 2003, Steve Dekorte wrote:
> > 2) Do you know the executable format for OS X? Does it use ELF? COFF?
>
> Mach-O, I think. I don't know anything about executable formats, btw.
> This sounds difficult...
After a little googling I can confirm that it uses Mach-O :(
It is apparently also possible to load and execute a few other file
formats, one of them being ELF -- but you may need to cast a few spells
first. (This is not all that different from FreeBSD being able to run
Linux binaries and Linux being able to run Java, MS-DOS exe files, and
Windows binaries seamlessly, provided the right wrappers are installed)
Mach-O seems to be a sensible format so it is not so bad as it might first
look.
Since you are only interested in compilation to memory, you can cheat a
little. Stub out the ELF calls to make tcc generate raw binaries which
you can then disassemble (with objdump if with nothing else). You can
also run tcc in a debugger and see "live" what code it generates but it is
hard to do regression tests with a human in the loop ;)
You will also need to insert either instructions or OS X calls to handle
the run-time code generation (cache flushing/invalidation, perhaps also
TLB flushing/invalidation) + you might need mprotect() or similar to tell
OS X that the piece of memory you are generating code into should be
marked executable.
Considering this, I definitely think it would be easier to just generate
raw binary files (without symbols or relocation tables) at first.
-Peter
"Of course, I'm not unbiased, but in my humble opinion, I've
gotten close to something that I can be really proud of."
-- Knuth on The Art of Computer Programming.
- Re: [Tinycc-devel] CVS tags for new releases?, (continued)
- Re: [Tinycc-devel] CVS tags for new releases?, Fabrice Bellard, 2003/04/15
- [Tinycc-devel] OSX, Steve Dekorte, 2003/04/16
- Re: [Tinycc-devel] OSX,
Peter \"Firefly\" Lund <=
- Re: [Tinycc-devel] OSX [run-time code generation], Peter \"Firefly\" Lund, 2003/04/21
- Re: [Tinycc-devel] OSX [run-time code generation], Steve Dekorte, 2003/04/22
- [Tinycc-devel] Re: PPC [run-time code generation], Steve Dekorte, 2003/04/22
- Re: [Tinycc-devel] Re: PPC [run-time code generation], Peter \"Firefly\" Lund, 2003/04/22
- Re: [Tinycc-devel] OSX, Jim Peters, 2003/04/20
- Re: [Tinycc-devel] OSX, Peter \"Firefly\" Lund, 2003/04/20
- Re: [Tinycc-devel] OSX, Steve Dekorte, 2003/04/20
- Re: [Tinycc-devel] OSX, Peter \"Firefly\" Lund, 2003/04/20
- Re: [Tinycc-devel] OSX, Steve Dekorte, 2003/04/20
- Re: [Tinycc-devel] OSX, Peter \"Firefly\" Lund, 2003/04/21