Hacker News new | past | comments | ask | show | jobs | submit login

I can confirm that C (GCC and Clang) will generate this:

    7e2f0:       f3 0f 1e fa             endbr64
    7e2f4:       64 48 8b 04 25 f8 ff    mov    %fs:0xfffffffffffffff8,%rax
    7e2fb:       ff ff
    7e2fd:       c3                      ret
    7e2fe:       66 90                   xchg   %ax,%ax
But they did not inline the function that does that, even with `__attribute__((always_inline))` and link-time optimization. I need to investigate that.



Is this from a shared library (compiled with -fPIC and linked with -shared) though? That's where the big troubles start and I think C isn't better than C++ here


No, this is an executable without `-fPIC`.

I am grateful that I only use one multi-call executable (built from a monorepo made partially because of your post, btw) because I think shared libraries in C might have the same sort of problems, just without constructors.




Consider applying for YC's Summer 2025 batch! Applications are open till May 13

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: