This is with gcc 3.3.6 for arm-linux with fixes for bugs 22528 & 16201 patched
in.
I've run into a c file where gcc produces a ldr with too large of an offset for
load:
{standard input}:26675: Error: bad immediate value for offset (4100)
At first this looked like bug 10730 or bug 16201 however 10730 is fixed in
3.3.6 and I've added the patch for arm_eliminable_register() provided in 16201.
I'm still seeing the issue.
asm line 26675 is on c line 3689 which pre-processes to the following:
{ sessdata->Identity.Session.v.uint32value = SN_BEGINNING_SESSION_FALSE; {
sn_aaa_session_data_open_t *open; ; (sessdata)->Identity.Session.valid = 1;
(sessdata)->Identity.Session.set = 1; open = (sn_aaa_session_data_open_t
*)((sessdata)->open); if (open) { sn_aaa_attr_record_t *attr; attr =
(sn_aaa_attr_record_t*)((sessdata)->Identity.Session.internal); ; { ; ; if
(!((open)->valid_cache[(attr)->id])) { (open)->valid_cache[(attr)->id] = 1;
(open)->valid[(open)->next_valid] = (attr); (open)->next_valid++; } };
open->set[open->next_set] = attr; open->next_set++; } }; };
parts of the compiled output are below:
.L3680:
.align 2
.L3679:
.word _GLOBAL_OFFSET_TABLE_-(.L3408+8)
<<<<< SNIP >>>>>
.word 15292
.word 12612
.word 10444 <---- offset 532
.loc 1 3167 0
.L3590:
<<<<< SNIP >>>>>
.loc 1 3689 0
.LBB1666:
ldr r3, .L3679+532 <---- line 26675
.LBE1666:
mov r1, #0
ldr r2, .L3681+208
.LBB1667:
ldr ip, [r6, r3]
ldr r3, .L3681+212
mov r4, #1
cmp ip, #0
.LBE1667:
str r1, [r6, r3]
ldr r3, .L3681+216
.LBB1668:
strb r4, [r6, r2]
strb r4, [r6, r3]
beq .L2385
ldr r3, .L3681+220
.LBB1669:
ldr r1, .L3681+324
ldr lr, [r6, r3]
ldr r2, [lr, #0]
add r2, r2, ip
ldrb r3, [r2, r1] @ zero_extendqisi2
cmp r3, #0
bne .L2386
ldr r0, .L3681+328
strb r4, [r2, r1]
ldr r2, .L3681+332
ldr r3, [ip, r0]
add r1, r3, r4
add r3, ip, r3, asl #2
str lr, [r3, r2]
str r1, [ip, r0]
.L2386:
ldr r1, .L3681+336
ldr r2, .L3681+340
ldr r3, [ip, r1]
add r0, r3, #1
add r3, ip, r3, asl #2
str lr, [r3, r2]
str r0, [ip, r1]
.L2385:
.loc 1 3693 0
It's probably just coincidence, but it only happens with these optimizations:
arm-linux-gcc -mbig-endian -march=armv5te -mtune=xscale -Wa,-mcpu=xscale -O2 -g
-pipe -Wimplicit -Wunused -Wcomment -Wchar-subscripts -Wuninitialized
-Wparentheses -Wformat -Wreturn-type -fPIC -Wmissing-prototypes <<lots of -D
and -I here>> -c thefile.c -o thefile.o
An not these:
arm-linux-gcc -mbig-endian -O2 -g -pipe -Wimplicit -Wunused -Wcomment
-Wchar-subscripts -Wuninitialized -Wparentheses -Wformat -Wreturn-type -fPIC
-Wmissing-prototypes <<lots of -D and -I here>> -c thefile.c -o thefile.o
arm-linux-gcc -mbig-endian -O -g -pipe -Wimplicit -Wunused -Wcomment
-Wchar-subscripts -Wuninitialized -Wparentheses -Wformat -Wreturn-type -fPIC
-Wmissing-prototypes <<lots of -D and -I here>> -c thefile.c -o thefile.o
arm-linux-gcc -mbig-endian -march=armv5te -mtune=xscale -Wa,-mcpu=xscale -O -g
-pipe -Wimplicit -Wunused -Wcomment -Wchar-subscripts -Wuninitialized
-Wparentheses -Wformat -Wreturn-type -fPIC -Wmissing-prototypes <<lots of -D
and -I here>> -c thefile.c -o thefile.o
--
Summary: Error: bad immediate value for offset (4100)
Product: gcc
Version: 3.3.6
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: target
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: djohnson+gcc at sw dot starentnetworks dot com
GCC build triplet: i686-pc-linux-gnu
GCC host triplet: i686-pc-linux-gnu
GCC target triplet: arm-linux
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25190