Skip to content

Instantly share code, notes, and snippets.

View mszoek's full-sized avatar

Zoë Knox mszoek

View GitHub Profile
@mszoek
mszoek / llvm.diff
Created April 3, 2022 21:10
LLVM patches for ELF Framework bundles on FreeBSD
diff --git a/contrib/llvm-project/clang/include/clang/Driver/Options.td b/contrib/llvm-project/clang/include/clang/Driver/Options.td
index a0cbcae0bdc3..a5ef948450c3 100644
--- a/contrib/llvm-project/clang/include/clang/Driver/Options.td
+++ b/contrib/llvm-project/clang/include/clang/Driver/Options.td
@@ -634,7 +634,7 @@ def D : JoinedOrSeparate<["-"], "D">, Group<Preprocessor_Group>,
HelpText<"Define <macro> to <value> (or 1 if <value> omitted)">;
def E : Flag<["-"], "E">, Flags<[NoXarchOption,CC1Option, FlangOption, FC1Option]>, Group<Action_Group>,
HelpText<"Only run the preprocessor">;
-def F : JoinedOrSeparate<["-"], "F">, Flags<[RenderJoined,CC1Option]>,
+def F : JoinedOrSeparate<["-"], "F">, Flags<[RenderJoined,CC1Option,LinkerInput]>,
@mszoek
mszoek / ravynOS_MachO_loading.md
Last active August 19, 2024 16:41
ravynOS: Executing MachO

Some notes on implementing MachO loading and dyld on ravynOS as an early PoC.

So far, I have modified rtld-elf (the FreeBSD runtime linker) to handle simple MachO objects. It can now successfully load and run a trivial MachO executable built on a Mac with an external library dependency (libSystem.B.dylib - the C library). The linker also still handles ELF objects, so I call this monstrosity the "Macho ELF".

Loading a MachO object into the dynamic linker

★ zoe@haru ~/airyx-freebsd/libexec/dyldᐳ llvm-objdump -d hello