Gcc option: get start and end addresses of built-in functions

My question is clear:

How to get compiled instructions for built-in functions when using -O2? I tried readelf to get a mapping between lines of source code and addresses of binary codes. But there is no match for the line in which the inline function is called.

So, which version of the compiler or any approach can be used?

In fact, I believe that there MUST be a way to tell gcc to reset all start and end addresses of functions. Does anyone have a key? Thank!

---

Let me rephrase my intention: I want to configure gcc so that it can tell me which function it is from a certain set of instructions compiled from. Yes, just that.

+3
source share
4 answers

If a file is attached, it does not have a start and end function. Each time it is called, all code will be duplicated where it was called. This is the goal of embedding.

Each time it is called, it will have a different start and end address. Therefore there is no display.

If all you are trying to do is retrieve the assembly for this function, then do not make it inline, and then you can see it for sure. However, depending on how the compiler optimizes the code, it may not be the same assembly that was generated when the function was built in.

0
source

Since the function is built-in, it is not a normal function with one start and end. His body was inserted wherever you called him.

0
source

GCC ( ). , , , .

++. ++, , , ! GCC, . , .

, , , ehm... !. . . . GCC:

... [ ] ( , , , , ). , , . , , , .

, :

inline int uiopuiop()
{
  return 4;
}
typedef int (*fptr)();
int main()
{
  fptr f = uiopuiop;
  return uiopuiop();
}

C, -fkeep-inline-functions static-inline.

0

The built-in function is not only (often) built-in, but also after optimization. For example, if it sumis an obvious built-in function that adds two integers, it sum(3,4)is replaced by 7, and the program does not display a sum call, and you can’t even give it a position.

Therefore, you really do not want to know about built-in calls to built-in functions.

0
source

Source: https://habr.com/ru/post/1770134/


All Articles