Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Compiler define, redirect function to different name

When using the edk2 (UEFI), functions like memcpy and memset are not available, but they have functions CopyMem and SetMem. Normally that is not too much of a problem, but sometimes the compiler does optimizations that replace my code with memcpy/memset and I get linker errors saying that I have a unresolved reference to them. As far as I can tell, they are used essentially the same (same args and whatnot).

I was wondering what would be possible to fix this rather than individually dealing with the instances as they happen. I tried googling compiler macros, but I couldn't find a good example to see if it would be a good way to do it.

like image 592
DanielCardin Avatar asked Aug 22 '26 07:08

DanielCardin


1 Answers

If the compiler inserts memcpy() and memset() as a part of the optimization process, then there's nothing you can achieve using macros. Your chances are:

I. Reduce the optimization level gradually in each individual case until the linker error goes away.

II. Switch to a conforming standard library

III. Implement memcpy() and memset() manually.


Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!