Created
July 11, 2021 15:45
-
-
Save Silva97/14ea59af384b55ac44b1f463b03f8c18 to your computer and use it in GitHub Desktop.
Revisions
-
Silva97 created this gist
Jul 11, 2021 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,22 @@ // See how it's works using: gcc -S get-function-size.c -o get-function-size.s // To manually check function size: objdump -d get-function-size #include <stdio.h> #define DECLARE_FUNCSIZE(funcname) \ extern unsigned int funcname##_funcsize; \ asm(#funcname "_funcsize: .long . - " #funcname "\n\t") #define FUNCSIZE(funcname) \ funcname##_funcsize int add(int x, int y) { return x + y; } DECLARE_FUNCSIZE(add); // Need to be declared immediately after the function declaration! int main(void) { printf("Size: %d\n", FUNCSIZE(add)); return 0; }