6 ms·
Here's the problem statement in a nutshell. Consider the following trivial C program: #include <stdio.h> #include <sys/random.h> int main(void) {
by defen 5y ago
Here's the problem statement in a nutshell. Consider the following trivial C program:
#include <stdio.h>
#include <sys/random.h>
int main(void) {
unsigned char buf[10];
ssize_t ret;
ret = getrandom(buf, sizeof(buf), 0);
if (ret != sizeof(buf))
fprintf(stderr, "getrandom() failed\n");
else
fprintf(stderr, "getrandom() success\n");
return ret != sizeof(buf);
}
You have an x86_64 Linux machine running glibc 2.17. Your task is to compile the above program into a dynamically linked executable targeting glibc 2.28 on x86_64 Linux.
With Zig, it looks like this:
1) Download zig
2) `zig cc -target x86_64-linux-gnu.2.28 random.c`
What would those steps look like using llvm/clang?
Next, try doing it from Windows 8
- charcircuit 5y agoIt's simpler with clang. clang random.c glibc 2.28 will work with binaries compiled against 2.17.
- mappu 5y agoUnfortunately that won't compile against glibc 2.17 since getrandom(2) was only added to glibc in 2.25. See https://lwn.net/Articles/711013/ https://lwn.net/Articles/711013/ for background info,
- charcircuit 5y agonvm then