------- Comment #19 from w at 1wt dot eu 2007-08-05 15:39 -------
Reproduced with trivial code. The reason is very simple : The asm code is
emitted in the .data section, because due to the -fno-unit-at-a-time argument,
the "interrupts" array is declared first and sets the current section to .data.
Interestingly, adding __attribute__ ((section(".text"))) before the function
declaration does not change anything. But adding ".section .text\n" in the asm
statement fixes it.
In fact, -fno-unit-at-a-time does not work on this code under gcc-4.2.1, while
it works with gcc-4.1.1. However, using the recommended -fno-toplevel-reorder
argument fixes the problem. Also, if the "dummy" array below is declared before
the asm statement, then even gcc-4.1.1 emits the code in the .data section.
In all cases, removing -fno-unit-at-a-time produces good code. I still suspect
that because the behaviour is different between 4.1 and 4.2, it might be a
regression in 4.2, but since its replacement works, I'm not sure it's worth
investigating further. I'll work on a fix for linux-2.4.
Trivial example below :
/* the following code may go to .data if compiled with gcc >= 4.1 and
-fno-unit-at-a-time */
void common_interrupt(void);
__asm__( "\n"
".align 4,0x90""\n"
"common_interrupt:\n\t"
"cld\n\t"
);
/* If dummy is not initialized, the code above goes into .text.
* If dummy is initialized to zero, the code above goes into .bss
* If dummy is initialized to non-zero, the code goes into .data
* If dummy is declared before the code above, then it goes to .data
* whatever the compiler.
*/
int dummy[1] = { 1 };
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32264