I need to put some externally generated data into an array inside a C program at compile time & to guarantee the array is 64-bit aligned. Specifically I want to initialise the input pool in the Linux random(4) device with data from /dev/urandom on the machine that compiles the kernel.
I already have a program that does it by generating a C header file that declares an array of unit64_t and fills it. That works fine in my test environment, but the kernel has large complicated makefiles which I do not fully understand & I'd like to avoid messing with them any more than absolutely necessary.
The makefile changes would be smaller if I could just generate a .o file & let the linker do the rest. A method using ld(1) is given here: Embedding resources in executable using GCC
That method also works fine in my tests, but I have two questions:
I need 64-bit alignment and looking at the manual it is not obvious that ld(1) guarantees that, or how to force it to if it does not.
The file size seems extravagant. I have 640 bytes of data but ld(1) gives me an output file that's about 5k. So far, playing with ld(1) options has not helped.