79337885

Date: 2025-01-08 03:18:34
Score: 0.5
Natty:
Report link

Sorry, I made a mistake about this problem.

The problem is, on MacOS, it will automatically add _ prefix to all function, except our own assembly code.

So when calling test_func() in the main(), it is actually calling to _test_func().

I will edit this to previous question.

Then we can keep all the function in c file unchanged, and define the assembly code like this:

#ifdef __APPLE__
#define DEFINE_FUNC(func) \
    .global _##func; \
    _##func
#define END_FUNC(...) /*_*/
#else
#define DEFINE_FUNC(func)\
    .global func;   \
    .type func,%function; \
    func
#define END_FUNC(func)\
    .size func,.-func;
#endif

DEFINE_FUNC(test_func):
    mov x0, x1
    ret
END_FUNC(test_func)

So now I think I solved this problem elegantly. If there is a better way, please post your idea without any hesitation.

Reasons:
  • Whitelisted phrase (-2): I solved
  • RegEx Blacklisted phrase (2.5): please post your
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (0.5):
Posted by: Tall