https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118384

            Bug ID: 118384
           Summary: unexpected call to __muldi3 generated for riscv target
           Product: gcc
           Version: 14.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: fanghuaqi at vip dot qq.com
  Target Milestone: ---

Hi there,

I am trying to compile source code using riscv gcc 14.2 like below:

cat test.c

#include "stdint.h"
uint64_t muldi3(uint64_t a, uint64_t b)
{

    uint64_t Product;

    Product = 0;
    while (a) {
        if (a & 1) {
            Product += b;
        }
        a >>= 1;
        b <<= 1;
    }

    return Product;
}

riscv64-unknown-elf-gcc  -march=rv32ec -mabi=ilp32e   -Os  test.c -c -o test.o

riscv64-unknown-elf-readelf -s test.o

Symbol table '.symtab' contains 13 entries:
   Num:    Value  Size Type    Bind   Vis      Ndx Name
     0: 00000000     0 NOTYPE  LOCAL  DEFAULT  UND
     1: 00000000     0 FILE    LOCAL  DEFAULT  ABS test.c
     2: 00000000     0 SECTION LOCAL  DEFAULT    1 .text
     3: 00000000     0 SECTION LOCAL  DEFAULT    3 .data
     4: 00000000     0 SECTION LOCAL  DEFAULT    4 .bss
     5: 00000000     0 NOTYPE  LOCAL  DEFAULT    1 $xrv32e2p0_c2p0_[...]
     6: 00000000     0 SECTION LOCAL  DEFAULT    6 .note.GNU-stack
     7: 00000026     0 NOTYPE  LOCAL  DEFAULT    1 .L3
     8: 00000012     0 NOTYPE  LOCAL  DEFAULT    1 .L2
     9: 00000000     0 SECTION LOCAL  DEFAULT    5 .comment
    10: 00000000     0 SECTION LOCAL  DEFAULT    7 .riscv.attributes
    11: 00000000   106 FUNC    GLOBAL DEFAULT    1 muldi3
    12: 00000000     0 NOTYPE  GLOBAL DEFAULT  UND __muldi3


You can see the generated object file required a external UND __muldi3 , but
actually I am implementing it now.

And if I switch it to gcc 13.2, this issue will dispear, there will no 12:
00000000     0 NOTYPE  GLOBAL DEFAULT  UND __muldi3 line.

Thanks

Reply via email to