Can gcc linker options modify assembler instructions in a compiled binary?

I am wondering if the options of the gcc linker (for example: -Wl, options) can change the assembler commands in the compiled executable, since this happens if you use certain options for optimizing gcc? Could there be a difference between using the linker parameter and using it if you are compiling compiled binaries (for example, comparing signatures)?

UPDATE

To be more precise, I want to find out if the FLIRT signatures change when I use certain layout options during the compilation process. These signatures use only library functions to create signatures.

+5
source share
2 answers

For some linker options, changes can be seen in the resulting binary, for example:

  • Options for eliminating / saving debugging symbols ( --strip-all , --strip-debug , --discard-all )
  • Parameters for deleting / saving unused partitions, for example. a section containing a function that is never mentioned in other sections. These sections can be easily removed. Or save sections / content moving. ( --as-needed , --emit-relocs )
  • Parameters for including one static library or another compatible one (for example, library version x.0 vs version x.1)
  • The order in which objects and static libraries are placed on the command line. For example, ld -o foo a.obj b.obj c.obj and ld -o foo a.obj c.obj b.obj will probably create another binary if the call from a to the function from c is allowed (offset for the code from c.obj and therefore the function address in c will probably be different)

But even after linking, the signature of the binary may change. For example, on Linux, when you optimize your binary startup time by running prelink

+4
source

Yes, you will see a different checksum for the two binaries associated with the different linker options - if the option had no effect, for example, when you specify the default option or the option that does not change the binary (-print map).

What are you trying to figure out for sure? It looks like you have problems when you specify certain linker options, and you are trying to understand why. Tell us more and maybe we can provide better help.

+1
source

All Articles