Tools, Tutorials & Resources Various tools to help you develop your hacks can be found here.

Reply
 
Thread Tools
  #1    
Old February 12th, 2011 (6:49 AM). Edited February 13th, 2011 by knizz.
knizz's Avatar
knizz knizz is offline
     
    Join Date: Aug 2007
    Posts: 192

    There is a compiler framework called LLVM. It's faster than GCC and opimizes code more aggresively and the llvm-frontend 'clang' has much better error-messages. I chose it to get rid of the devkit-dependency. (Which I didn't manage but ... at least I have fast code now.)

    My clang version doesn't support arm (not because it can't but because the pre-compiled version doesn't include it.)
    Fortunately the LLVM-Output is platform/cpu/os-independent. So I compile for x86 first and the override the cpu-type (i think clang ignores -march=thumb) when using llc.

    http://llvm.org/docs/Passes.html lists all options for optimizations. They are supposed to be used with clang when it performs *all* actions. When you do linking, etc. yourself you probably have to give the optimization options to llvm-ld too.

    Code:
    clang -O4 -S -emit-llvm -march=thumb file1.c file2.cpp
    llvm-as-2.8 file1.s
    llvm-as-2.8 file2.s
    llvm-ld-2.8 -o rom file1.s.bc file2.s.bc
    llc-2.8 -O=3 -march=thumb -mcpu=arm7tdmi rom.bc
    arm-thumb-elf-as -mthumb-interwork -o crt0.o crt0.S
    arm-thumb-elf-as -mthumb-interwork -o rom.o rom.s
    arm-thumb-elf-ld -q -Ttext=0x8000000 -Tbss=0x3000000 -o rom.elf crt0.o rom.o
    arm-thumb-elf-strip -s rom.elf
    arm-thumb-elf-objcopy -O binary rom.elf rom.gba
    gbafix rom.gba

    I use the crt0.S from http://velvetfr.ath.cx/gba/tutorial/gba-tutorial1.html

    __________________

    Firered IDA 6.6 DB: https://www.dropbox.com/s/d856o3pyndyr5sr/firered.idb
    VBA-M with lua scripting support

    Reply With Quote

    Relevant Advertising!

      #2    
    Old February 12th, 2011 (2:13 PM).
    IIMarckus's Avatar
    IIMarckus IIMarckus is offline
    [email protected]
       
      Join Date: Oct 2007
      Gender:
      Posts: 402

      Quote:
      Originally Posted by knizz View Post
      Fortunately the LLVM-Output is platform/cpu/os-independent.
      This is not correct. But it may (or may not) be close enough for your purposes; I don’t know enough about LLVM to comment.

      I do like LLVM. It’s nice to finally see some competition to GCC, which is a bloated mess and a nightmare to build.

      __________________

      iimarck.us / hax.iimarck.us

      If you want me, please contact me by email. [email protected]

      If you want to hack Pokémon RBY or GSC, read, read, and read some more. This has tons of valuable information.

      Pokémon Red disassembly project

      Rules that should be rethought: 25charlimit, bumping.
      Bad posts are bad posts, regardless of how many words are in them or how old the thread is.
      Good posts are good posts, regardless of how old the thread is—and brevity is underrated.

      Reply With Quote
        #3    
      Old February 12th, 2011 (2:30 PM).
      knizz's Avatar
      knizz knizz is offline
         
        Join Date: Aug 2007
        Posts: 192

        Quote:
        Originally Posted by IIMarckus View Post
        This is not correct. But it may (or may not) be close enough for your purposes; I don’t know enough about LLVM to comment.

        I do like LLVM. It’s nice to finally see some competition to GCC, which is a bloated mess and a nightmare to build.

        It simply means that the only platform-limitation is in your own code and not the compiler or llvm-representation. In other words: Your code will only work on the GBA when you write for GBA.

        Platform-independent enough for my purposes.

        __________________

        Firered IDA 6.6 DB: https://www.dropbox.com/s/d856o3pyndyr5sr/firered.idb
        VBA-M with lua scripting support

        Reply With Quote
          #4    
        Old March 1st, 2011 (5:36 PM).
        Full Metal's Avatar
        Full Metal Full Metal is offline
        C(++) Developer.
        • Silver Tier
         
        Join Date: Jan 2008
        Location: In my mind.
        Age: 22
        Gender: Male
        Nature: Timid
        Posts: 806

        ohai how did I not see this thread?
        nifty nifty, but does it have things like malloc and new built in (for C/C++ respectively)?
        I mean, making my own malloc in asm would be as simple as using my FS code and making it into code that...works on a GBA, but you know, it's nice to avoid that. haha. I sound like I don't know what I'm talking about, but I do! ... yea! XD

        __________________


        ★ full metal.

        I like to push it,
        and push it,
        until my luck is over.

        Reply With Quote
          #5    
        Old March 4th, 2011 (6:32 PM).
        Silent Crest Silent Crest is offline
        Celestial Shine
           
          Join Date: Dec 2010
          Nature: Calm
          Posts: 40

          Okay. So LLVM is a compiler. So what?!?

          There's a lot of C/ C++ compilers. When I used to write c/ c++ I used Bloodshed Dev. My question is (since I don't know a lot about rom hacking) what does the LLVM have to do with Rom Hacking?

          Reply With Quote
            #6    
          Old June 12th, 2011 (5:09 PM).
          Full Metal's Avatar
          Full Metal Full Metal is offline
          C(++) Developer.
          • Silver Tier
           
          Join Date: Jan 2008
          Location: In my mind.
          Age: 22
          Gender: Male
          Nature: Timid
          Posts: 806

          It takes C or C++ code...and compiles it.
          You see, if you actually knew what you were talking about, you would know that devkitpro/advance generates HUGE and very terrible code ( as far as assembly and instructions go atleast ). Even optimizations don't do that much for it.
          What this thing does is makes actual optimized code. IDK if it does anything about file-size compared to devkitpro ( I haven't used this thing just yet -- still -- ), but it definitely increases over-all performance of the .elf files generated. That's my comprehension anyways.

          __________________


          ★ full metal.

          I like to push it,
          and push it,
          until my luck is over.

          Reply With Quote
          Reply
          Quick Reply

          Sponsored Links
          Thread Tools

          Posting Rules
          You may not post new threads
          You may not post replies
          You may not post attachments
          You may not edit your posts

          BB code is On
          Smilies are On
          [IMG] code is On
          HTML code is Off

          Forum Jump


          All times are GMT -8. The time now is 4:51 AM.