bogus reference to unused symbols
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Linaro GCC |
Won't Fix
|
Low
|
Michael Collison | ||
gcc |
Confirmed
|
Medium
|
Bug Description
This code is derived from the kernel. The problem is a link error for a missing symbol, __aeabi_uldivmod, that isn't actually used. Clearly, this is not right!
static void
f (unsigned int a)
{
unsigned long long __res;
if (~0ULL % (a / (a & -a)) == 0)
{
asm ("": "+&r" (__res));
}
}
int
g (unsigned int a)
{
f (a);
}
This gives:
.global __aeabi_uidiv
.global __aeabi_uldivmod
.text
.align 2
.global g
.thumb
.thumb_func
.type g, %function
g:
.fnstart
.LFB1:
@ args = 0, pretend = 0, frame = 0
@ frame_needed = 0, uses_anonymous_args = 0
push {lr}
.save {lr}
ldr pc, [sp], #4
.fnend
So, both __aeabi_uidiv and __aeabi_uldivmod are declared global, but neither is
actually used as the code is optimized away.
Changed in gcc: | |
importance: | Unknown → Medium |
status: | Unknown → New |
Changed in gcc-linaro: | |
status: | New → Triaged |
importance: | Undecided → Low |
Changed in gcc: | |
status: | New → Confirmed |
Changed in gcc-linaro: | |
assignee: | nobody → Michael Collison (michael-collison) |
Created attachment 24107
Preprocessed source
When compiled, the attached code refers to the 64 bit unsigned divmod helper function '__aeabi_uldivmod' even though the function is never called. This causes a link error when cross-compiling an ARM Linux 2.6.38 kernel.
To reproduce: tune=cortex- a9 --with-float=softfp --with-fpu=neon gnueabi- gcc -O2 -S wm8974.i'
* Make a arm-linux-gnueabi cross compiler configured with --with-mode=thumb --with-arch=armv7-a --with-
* Compile the attached code with 'arm-linux-
* See a '.global __aeabi_uldivmod' in the header of wm8974_set_dai_pll
Marking pll_factors() as noinline or putting asm("" : "+r"(source)); before the call to do_div() works around the problem.