Re: Incorrect optimization for function__libc_message on C-SKY
* Mao Han:
> I've got some probelm with the optimization of __libc_message on C-SKY.
> __libc_message show nothing when MALLOC_CHECK_=3 is set.
> enum __libc_message_action
> do_message = 0, /* Print message. */
> do_abort = 1 << 0, /* Abort. */
> do_backtrace = 1 << 1 /* Backtrace. */
> if ((action & do_abort))
> if ((action & do_backtrace))
> BEFORE_ABORT (do_abort, written, fd);
> /* Kill the application. */
> abort ();
> The type of action is enum __libc_message_action, the C-SKY compiler
> think the action can not be both do_abort and do_backtrace at the
> same time, this path is supposed to be inaccessible.
I expect that even with -fstrict-enums, 3 is valid value for enum
__libc_message_action because in order to represent 2, the
implemnetation must supplied two or three bits (unsigned and signed
case), and then the value 3 is representable as well.
Without -fstrict-enums, I think the C standard requires that every enum
can represent at least the non-negative values of type char.
> static void
> backtrace_and_maps (int do_abort, bool written, int fd)
> if (do_abort > 1 && written)
> void *addrs;
> #define naddrs (sizeof (addrs) / sizeof (addrs))
> int n = __backtrace (addrs, naddrs);
> backtrace_and_maps is called with BEFORE_ABORT (do_abort, written, fd);
> do_abort equals to 1, and the function also check do_abort > 1, so the
> entire backtrace_and_maps is optimized.
> Some one can explain the excepted logic here?
I think nowadays, we practically never print a backtrace, so the code
can be simplified a lot. It's only used for fortification failures, but
even there, its use is questionable. We really do not want to elaborate
things (such as calling dlopen) when we know that the process is in a