News for hackers. Stuff that matters.
Re:Single C file TLS 1.2/1.3 implementation using tomcrypt by peterwwillis on Sunday January 06, 2019 @01:52PM (#18839853)
gcc -shared -o mycrypto.1.1.so file1.c file2.c file3.c file4.c

#include "mycrypto.1.1.h"

Doesn't that have the same effect of being easy to include? The amalgamation may be better for the compiler but I'm not sure why.

Re:Single C file TLS 1.2/1.3 implementation using tomcrypt by CJefferson on Sunday January 06, 2019 @06:42PM (#18841522)
Now do it on Mac, and windows, and dynamic and static, and install the libraries in the right place. It gets maddening.
Re:Single C file TLS 1.2/1.3 implementation using tomcrypt by tialaramex on Sunday January 06, 2019 @02:49PM (#18840172)
A platform has a fixed ABI that says e.g. the first integer parameter to a function goes in register R14, the sixth one goes on the stack. If you have sixty C files the compiler is obliged to produce sixty object files which each obey that ABI for all their functions because you might stitch in some other code, not using that compiler at all, which obeys the ABI and if you ignore the rules this will unexpectedly not work.

But within a single object the compiler doesn't need to obey the ABI rule at all if that's faster.

Now, you obviously could imagine an object and more powerful linkers that had enough optimisation magic to produce the same output executable from the sixty object files, but just spitting out a single source code file is a LOT easier than making that optimisation work on every platform now and in the future.

Re:Single C file TLS 1.2/1.3 implementation using tomcrypt by tedunangst on Sunday January 06, 2019 @03:15PM (#18840355)
The compiler invocation above only creates a single object file.
Re:Single C file TLS 1.2/1.3 implementation using tomcrypt by tialaramex on Sunday January 06, 2019 @07:42PM (#18841820)
No, but I can see why you thought so.

The invocation above creates one object file for each C source file, as temporary files, (in a Unix system you can watch it do this with a suitably powerful syscall tracer, presumably something similar is possible on non-Unix systems but I don't know exactly how)

Then it links them and produces the output you've mistaken for an "object file", then it deletes the temporary files.

Re:Single C file TLS 1.2/1.3 implementation using tomcrypt by tedunangst on Monday January 07, 2019 @01:12PM (#18848063)
Ah, probably the easiest way to deal with some translation unit edge cases. :(