[Bug tree-optimization/56139] New: unmodified static data could go in .rodata, not .data
amker.cheng at gmail dot com
gcc-bugzilla@gcc.gnu.org
Tue Jan 29 10:06:00 GMT 2013
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56139
Bug #: 56139
Summary: unmodified static data could go in .rodata, not .data
Classification: Unclassified
Product: gcc
Version: 4.8.0
Status: UNCONFIRMED
Severity: enhancement
Priority: P3
Component: tree-optimization
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: amker.cheng@gmail.com
For below program:
static int x[] = {1, 2, 3, 4};
void bar (int x);
int func(int i)
{
int * const p = (int * const)&x;
bar(p[i]);
return 0;
}
build with:
arm-none-eabi-gcc -mthumb -mcpu=cortex-m0 -Os ...
The generated assembly code is:
.text
.align 1
.global func
.code 16
.thumb_func
.type func, %function
func:
push {r3, lr}
ldr r3, .L2
lsl r0, r0, #2
ldr r0, [r0, r3]
bl bar
@ sp needed for prologue
mov r0, #0
pop {r3, pc}
.L3:
.align 2
.L2:
.word .LANCHOR0
.size func, .-func
.data
.align 2
.set .LANCHOR0,. + 0
.type x, %object
.size x, 16
x:
.word 1
.word 2
.word 3
.word 4
while GCC 4.6 puts x in .rodata.
More information about the Gcc-bugs
mailing list