This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Why can't I LD_PRELOAD __assert_fail ?


Chris Barry <cbarry@soundmetrics.com> writes:

> Unlike x86, on ARM if a core file is generated when a function annotated with "__attribute ((noreturn))" is on the call stack---a function such as abort or __assert_fail---then a backtrace with that core will be nearly useless: you get a message about the PC not being saved:

I thought that was fixed in gcc 4.5.  What version of gcc are you using?


> But the same LD_PRELOAD trick does not work with the __assert_fail function that the assert macro expands to: this means that when an assert is triggered and a core is dumped, the core is useless.

Most likely __assert_fail is being linked directly into your executable,
rather than being provided by a shared library.  You can check this by
using readelf -s.  If that is the case, then rather than using an
LD_PRELOAD trick, just define your own version of __assert_fail in your
executable.  That will work with abort too, you don't need to use
LD_PRELOAD here.  The only advantage you get from LD_PRELOAD is being
able to turn it on and off at runtime.  It sounds like you never want to
turn this off.

Ian


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]