facebookarchive / BOLT

Binary Optimization and Layout Tool - A linux command-line utility used for optimizing performance of binaries
2.51k stars 177 forks source link

Where should I add --emit-relocs to use BOLT? #286

Closed ZahraHeydari95 closed 2 years ago

ZahraHeydari95 commented 2 years ago

Please explain how to do step 0 of BOLT. Give me an example. I do not know where to add the --emit-relocs flag. " Step 0 In order to allow BOLT to re-arrange functions (in addition to re-arranging code within functions) in your program, it needs a little help from the linker. Add --emit-relocs to the final link step of your application. You can verify the presence of relocations by checking for .rela.text section in the binary. BOLT will also report if it detects relocations while processing the binary.

" Thanks

yavtuk commented 2 years ago

Hello,

you can do it through -Wl,option Pass option as an option to the linker. If option contains commas, it is split into multiple options at the commas. https://gcc.gnu.org/onlinedocs/gcc-4.0.4/gcc/Link-Options.html

for example, gcc -o main main.c -Wl,--emit-relocs