Jump to content

macosxbootloader (Hackintosh version).


Andy Vandijck
 Share

37 posts in this topic

Recommended Posts

Tried all of those...

Found nothing with stock clang for 32 bit win target...

So I implemented it the way it is now

Yeah but now you end up with darwin files instead of win32 files.

 

Edit: the clang default without -target results in: -triple i386-apple-macosx10.10.0

 

Seems like clang can't handle it. Any other toolsets that work?

 

See also: http://clang.llvm.org/docs/CrossCompilation.html (target triple ).

 

P.s. The offset is also different. It is 0x400 in the MS Windows boot.efi and 0x1000 in the Apple one.

Link to comment
Share on other sites

Yeah but now you end up with darwin files instead of win32 files.

 

Edit: the clang default without -target results in: -triple i386-apple-macosx10.10.0

 

Seems like clang can't handle it. Any other toolsets that work?

 

See also: http://clang.llvm.org/docs/CrossCompilation.html (target triple ).

 

P.s. The offset is also different. It is 0x400 in the MS Windows boot.efi and 0x1000 in the Apple one.

Should be possible to use i386 / x86_64 MinGW32 cross toolchain then.

That should work.

Not tested yet (but will do so).

Other option is to mod Apple clang sources.

Then we could use clang for x86 build...

Link to comment
Share on other sites

Should be possible to use i386 / x86_64 MinGW32 cross toolchain then.

That should work.

Not tested yet (but will do so).

Other option is to mod Apple clang sources.

Then we could use clang for x86 build...

Andy, thanks. Let me know how thing go.

 

Guys,

what about you? There is Clover that can be compiled to EFI32 application by well known toolsets.

 

Slice,

 

Thanks. We know that. What I want is Clang to work. It worked before, as you may remember (I said this some time ago) but with all the  changes that went in... someone did something that it no longer works.

Link to comment
Share on other sites

I can compile ShellPkg with Clang. Also CloverX64.efi compiled by Clang is working.

Not tested 32bit compilation but it was working previously.

 

The big problem is BOOT file. Clang can't compile it because of absolute addressing not supported by the clang.

Link to comment
Share on other sites

I can compile ShellPkg with Clang. Also CloverX64.efi compiled by Clang is working.

Not tested 32bit compilation but it was working previously.

 

The big problem is BOOT file. Clang can't compile it because of absolute addressing not supported by the clang.

No problem with 64 bit. And what do you mean with absolute addressing? Pic mode versus non-pic mode?

Link to comment
Share on other sites

No problem with 64 bit. And what do you mean with absolute addressing? Pic mode versus non-pic mode?

No, I mean binaries must be movable. Absolute addressing is prohibited.

For example

+;lea     rax, [GDT_BASE]             ; RAX=PHYSICAL address of gdt
+;mov     qword  [gdtr + 2], rax   ; Put address of gdt into the gdtr
+;lgdt     [gdtr]

+        lea     rax, [REL gdtr]  ; use relative addressing
+        lgdt       [rax]

All such mistakes were corrected in EDK2 and in Clover sources (for example commit 2865).

But BOOT file is still can't be compiled with message about relocation is impossible. I still don't know exact reason of this.

 

Anyway 32-bit compilation doesn't depend on this. Clover is compilable by Clang... but not fully working. 

Build environment: Darwin-11.4.2-i386-64bit
Build start time: 14:02:36, Feb.13 2015

WORKSPACE        = /Users/slice/src/edk2
ECP_SOURCE       = /Users/slice/src/edk2/EdkCompatibilityPkg
EDK_SOURCE       = /Users/slice/src/edk2/EdkCompatibilityPkg
EFI_SOURCE       = /Users/slice/src/edk2/EdkCompatibilityPkg
EDK_TOOLS_PATH   = /Users/slice/src/edk2/BaseTools


Architecture(s)  = IA32
Build target     = RELEASE
Toolchain        = XCLANG
.....

- Done -
Build end time: 14:05:17, Feb.13 2015
Build total time: 00:00:37

HelloWorld.efi-32bit.zip

Link to comment
Share on other sites

I built a version of the bootloader with the new tools.

I had to modify cctools to fix conversion using mtoc and I had to change clang with the patch above…
My github repo contains the necessary patches for building the bootloader properly now…
You can check the result if you like, it’s pushed to my github repo including build results…
Some other source mods were required to make this possible but now it works…
I was also able to now use the assembly version of the Rijndael algorithms… should be a lot faster and smaller…
So finally a nice update :D

Link to comment
Share on other sites

 

Tested version from topic boot.clover..bla-bla....

20:913  0:002  Loading boot.efi  status=Unsupported

Hmm. It still doesn't work for you?

 

@Andy,

 

What could be causing this?

 

Edit:

 

I see that you extended NASMFLAGS but what is the purpose of ARCH64/ARCH32? I mean looking at the Makefiles I would say that the x86 directory is only used for macho32/i386 so why would you add this without a need for it? Or am I reading it wrong?

 

Edit-2:

 

Clang does not support  __cdecl – the parser just ignores it – but it is used by MSVC for EFIAPI and BOOTAPI so what about using extern "C" for calls where it is used?

 

I made the changes in my local tree for EFIAPI and now I can use -u _EfiMain -e _EfiMain (no more name mangling) in the Makefile. What do you think?

 

See also: https://github.com/Piker-Alpha/macosxbootloader/blob/master/sdk/include/x86/EfiBind.h#L233

Link to comment
Share on other sites

  • 2 months later...

Hmm. It still doesn't work for you?

 

@Andy,

 

What could be causing this?

 

Edit:

 

I see that you extended NASMFLAGS but what is the purpose of ARCH64/ARCH32? I mean looking at the Makefiles I would say that the x86 directory is only used for macho32/i386 so why would you add this without a need for it? Or am I reading it wrong?

 

Edit-2:

 

Clang does not support  __cdecl – the parser just ignores it – but it is used by MSVC for EFIAPI and BOOTAPI so what about using extern "C" for calls where it is used?

 

I made the changes in my local tree for EFIAPI and now I can use -u _EfiMain -e _EfiMain (no more name mangling) in the Makefile. What do you think?

 

See also: https://github.com/Piker-Alpha/macosxbootloader/blob/master/sdk/include/x86/EfiBind.h#L233

Great plan.

I hate those C++ mangled pieces of code.

Also we could port the code to EDK2 now...

Should be better that way and minimize code :D

No problem with 64 bit. And what do you mean with absolute addressing? Pic mode versus non-pic mode?

PIC = Position Independepent Code...

 

Info:

http://en.wikipedia.org/wiki/Position-independent_code

Link to comment
Share on other sites

 Share

×
×
  • Create New...