This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/54529] New: dead code elimination deletes code adressed by referenced labels
- From: "Wasserthal at nefkom dot net" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Sat, 08 Sep 2012 16:06:57 +0000
- Subject: [Bug c/54529] New: dead code elimination deletes code adressed by referenced labels
- Auto-submitted: auto-generated
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54529
Bug #: 54529
Summary: dead code elimination deletes code adressed by
referenced labels
Classification: Unclassified
Product: gcc
Version: 4.6.3
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: Wasserthal@nefkom.net
given the code:
extern void __attribute__((sysv_abi)) breakfree(long long input);
void submaker(long long input)
{
breakfree(input);
}
void mainloop()
{
goto skipper;
;
hidden:
printf("Hello");
asm("nop; nop; int3; int3; int3; int3; int3; nop; nop; nop; nop");
asm("ret");
exit(1);
skipper:
submaker(&&hidden);
}
(breakfree is an assembler snippet that sets the basepointer to the one of the
over-overliying function and calls the parameter.)
the problem is that any stuff between ,,hidden'' and ,,skipper'' is removed.
there is no 90 90 CC CC CC CC CC 90 90 90 90 in the resulting elf binary.
Problem: there is no safe work-around because you cannot switch off dead code
elimination even on -O0!
you cannot declare the labels as extern, either.
The problem disappears when you add one calculated goto jump to the function,
but if that should not be taken, it is eliminated, too!