Kernel compiled at -O2 has a unused reference to __aeabi_uldivmod

Bug #771551 reported by Michael Hope
This bug report is a duplicate of:  Bug #771832: bogus reference to unused symbols. Edit Remove
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Linaro GCC
Triaged
Medium
Unassigned
gcc
New
Medium

Bug Description

See the upstream bug. Logged here to track.

Revision history for this message
In , Michael Hope (michaelh1) wrote :

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:
 * Make a arm-linux-gnueabi cross compiler configured with --with-mode=thumb --with-arch=armv7-a --with-tune=cortex-a9 --with-float=softfp --with-fpu=neon
 * Compile the attached code with 'arm-linux-gnueabi-gcc -O2 -S wm8974.i'
 * 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.

Changed in gcc-linaro:
status: New → Triaged
importance: Undecided → Medium
Changed in gcc:
importance: Unknown → Medium
status: Unknown → New
Revision history for this message
In , Andrew Stubbs (ams-codesourcery) wrote :

I don't see any call to __aeabi_uldivmod???

I *do* see __aeabi_uidivmod, and that does seem to be called properly.

I get:

        .global __aeabi_uidiv
        .global __aeabi_uidivmod
        .align 2
        .thumb
        .thumb_func
        .type pll_factors, %function
pll_factors:
        .fnstart
[.....]
.L54:
        ldrb r3, [r6, #0] @ zero_extendqisi2
        mov r0, r7
        mov r1, r4
        bfi r3, r5, #1, #4
        strb r3, [r6, #0]
        bl __aeabi_uidivmod
        movw r5, #52429
        movt r5, 52428
        mov r0, #167772160
        umull r0, r1, r1, r0
[.....]

I can't find a bug here?

Revision history for this message
In , Michael Hope (michaelh1) wrote :

Sorry, the original attachment included the __attribute__((noinline)) workaround on pll_factors(). Attached is the original that shows the fault.

Revision history for this message
In , Michael Hope (michaelh1) wrote :

Created attachment 24111
Preprocessed source

Revision history for this message
In , Andrew Stubbs (ams-codesourcery) wrote :

Somewhat reduced testcase:

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.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.