Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to tell gcc to not use inbuilt functions

Tags:

c

linux

gcc

I'm trying to override some standard library functions using LD_PRELOAD. However, I notice that my version is never called for some functions, for example, the gettimeofday one. I suspect gcc uses an inbuilt version for some of these functions.

Is there a way I can tell gcc to not use inbuilt standard library functions.

like image 974
pythonic Avatar asked Dec 11 '12 15:12

pythonic


People also ask

What does __ Builtin_clz do?

__builtin_clz(x): Counts the leading number of zeros of the integer(long/long long).

What is __ Builtin_ffs?

Built-in Function: int __builtin_ffs (int x) Returns one plus the index of the least significant 1-bit of x , or if x is zero, returns zero. Built-in Function: int __builtin_clz (unsigned int x) Returns the number of leading 0-bits in x , starting at the most significant bit position.

What is FNO builtin?

Tells the compiler not to use generic (non-Arm specific) handling and optimization of standard C and C++ library functions and operators, for example for the printf() , strlen() , and malloc() functions from the C standard library, or for the new and delete operators from the C++ standard library.

What is built Popcount?

__builtin_popcount(x) is a function in C++ returns the number of 1-bits set in an int x. In fact, "popcount" stands for "population count," so this is a function to determine how "populated" an integer is.


1 Answers

Use the gcc switch -fno-builtin. Quoting from the gcc manual:

-fno-builtin

Don't recognize built-in functions that do not begin with `_builtin' as prefix.

More details: http://gcc.gnu.org/onlinedocs/gcc-3.0/gcc_3.html#SEC7

like image 122
Masked Man Avatar answered Sep 29 '22 23:09

Masked Man