How to replace characters in object files

I want to rewrite object files so that most function addresses are changed to no-op function. How can i do this?

More context: In C ++, I want all features to be automatically configured by default. To go from a()

call a() {}

and b()

call b() {}

to a()

actually call replacement() {}

and have b()

also call (same) replacement() {}

.

Things I have considered so far:

  • objcopy --redefine-syms=filename

    - this changes the name of the symbol, not its address.
  • Using the linker argument --wrap

    - this requires compiling a separate symbol __wrap_NameOfWrappedThing

    for each thing I want to wrap, and in general doesn't seem to scale well.
+3


source to share





All Articles