News for hackers. Stuff that matters.
Re:Embedding files in C programs with koio by emmelaich on Wednesday May 30, 2018 @05:26PM (#17191981)
What is the clang or macos equivalent to objcopy?
Re:Embedding files in C programs with koio by comex on Wednesday May 30, 2018 @07:44PM (#17192858)
Pass -sectcreate to the linker, e.g. -sectcreate __DATA __foo foo.txt. Then you can reference the data like this:

    extern char foo_start[] asm("section$start$__DATA$__foo");
    extern char foo_end[] asm("section$end$__DATA$__foo");
Re:Embedding files in C programs with koio by planteen on Wednesday May 30, 2018 @05:46PM (#17192149)
You are just dealing with ELF files, so objcopy works fine in those scenarios as long as the architecture matches for the linker. This trick works many other compilers that use ELF such as clang, MSVC, Green Hills, etc.
Re:Embedding files in C programs with koio by tetromino_ on Wednesday May 30, 2018 @06:12PM (#17192357)
Except that MacOS does not use ELF, it uses Mach-O.
Re:Embedding files in C programs with koio by planteen on Wednesday May 30, 2018 @07:19PM (#17192735)
Clang handles intermediate ELF object files fine and can link into a Mach-O final executable.

Windows under MSVC doesn't use ELF either (it uses PE for the .EXE) and it links in intermediate ELF object files fine. I've made an EXE that was a mix of files compiled by MSVC and GCC.