Comment "FIXME" in X86MachObjectWriter::RecordX86Relocation


In X86MachObjectWriter::RecordX86Relocation I found the comment

   if (Target.isAbsolute()) { // constant
     // SymbolNum of 0 indicates the absolute section.
     // FIXME: Currently, these are never generated (see code below). I cannot
     // find a case where they are actually emitted.
     Type = macho::RIT_Vanilla;

Is the FIXME still true? I've got some code that hits this, and it seems any code doing a function call to an absolute address (as described in this bug for ELF: would hit this. (Although I haven't tried it)

I'm using Windows 32bit x86 Mach-O, with MCJIT.

Trying to find a bug within my program and wondered whether the code is just not supported by LLVM. Let me know if you need a testcase.


Hi Verena,

Windows + MachO is likely to run into lots of problems once you start passing in non-trivial code. The relocation model is very tied to Darwin.

I believe some folks doing JIT on Windows have had some success w/ ELF. Hopefully someone more familiar with the specifics of that will chime in.


Can I assume we're talking about MCJIT since a file format and relocations are involved?

Some changes are required in order to get MCJIT to generate ELF object files. Eli Bendersky submitted a patch some time ago to modify the target triple code to enable this, but after a bit of discussion there didn't seem to be a consensus for accepting this proposal.

If you want to try it out, the patch can be found here:

I believe you can also find the related discussions from that post. We've had success using this patch to generate ELF on Windows. I don't know if any progress has been made toward a more generally acceptable solution.


Hi Jim, Andrew,

Thanks, I read the discussions about using ELF + MCJIT + Windows and was hoping MachO would work just as well. Since you don't need to modify LLVM to be able to output MachO this was my first choice.
But are you saying MachO will not work as well as ELF?

Thanks for the patch Andrew, that will have to be my plan B in this case.


Hi Verena,

It all depends on the details of what you want to do, of course. No-one has tried, that I know of, to use MachO on Windows before, so there are going to be pitfalls. For example, the way Darwin handles PIC code, indirect symbol resolution, etc, are all assumed by the MachO code. You may well be able to deal with that with fancy handling in a Windows-specific RuntimeDyld or something similar. It's not that there will be insurmountable issues, but rather that there is likely to be some significant work required.

ELF, as I understand it, has more users on Windows already so a lot of those sorts of issues are better understood already.