LibAFL icon indicating copy to clipboard operation
LibAFL copied to clipboard

Print warnings on any weakly override function

Open maxammann opened this issue 2 years ago • 4 comments

LibAFL uses several weak function definitions, which are supposed to take over if a library is not linked/available.

When running a debug build it would be great if LibAFL would warn about any overriden functions. This increases debugability if the linker misbehaves. I propose to add a println for every call of weak function. Because this would be noisy, we can limit it to print only once.

This issue is inspired by https://github.com/AFLplusplus/LibAFL/issues/1231 which was extremely hard to debug. Generally I think a weak function being called, indicates a somewhat special build.

This is open for discussion. Generally, I think LibAFL should support users in getting a correctly linked binary. Linkers are weird and we somehow have to deal with it...

maxammann avatar May 19 '23 10:05 maxammann

Is there a automated way to display the name of weakly defined function?

tokatoka avatar May 24 '23 16:05 tokatoka

Adding another example to this issue: The weakly defined LLVMFuzzerTestOneInput in libafl_targets was executing instead of the one in my harness. This was fixed by forcing linking of my target static lib using whole-archive (thanks for the tip tokatoka).

Finding it to be a linking error wasn't intuitive though; at first it just looked like I was getting no coverage.

For better debugability, perhaps select weakly defined functions could throw out a warning if they are ever executed, instead of being defined as no-ops in libafl_targets.

jordan9001 avatar Jun 01 '23 14:06 jordan9001

The more I'm exposed to weak functions the more I want to never touch linkers again :D

Is there a automated way to display the name of weakly defined function?

What do you mean with that?

maxammann avatar Jun 01 '23 16:06 maxammann

What do you mean with that?

Nevermind I thought you want the warnings to appear on compile time. Now I understand what you mean

tokatoka avatar Jun 01 '23 19:06 tokatoka