Override assert handler

Walter Bright newshound2 at digitalmars.com
Sun Aug 18 01:53:51 UTC 2024


Allow me to explain how a library works.

The linker resolves all the symbols in the object files given to it. When there 
are references to symbols, but no symbols, then (and only then) does the linker 
consult the library. The linker will pull in modules from the library that 
export those missing symbols.

Therefore, the easiest way to override a function that's in the library is to 
write your own and put it in the list of object files for the linker to incorporate.

Unfortunately, some early work done on druntime was not aware of this, and so 
the assert handler is set up as a pointer to a function, with another function 
to call to set that pointer to your own function.

By the time I noticed that, it was too late to fix it.

I have spent nearly the entire time I've been working on compilers trying and 
failing to explain how linkers work.


More information about the Digitalmars-d mailing list