Issue
In building coreboot I got error regarding during linking:
coreboot/src/console/vtxprintf.c:102: undefined reference to '__udivmoddi4'
.
Where can I find the library containing this function?
I'm building coreboot for x86_64 (Lenovo x230) using gcc (8.1.1 20180531).
Coreboot - git hash: f59a052ee8dae6f1378514cb622d229e652ad2f6
Solution
__udivmoddi4
is a function in libgcc which is used to implement a combined unsigned division/modulo operation for what GCC calls DI mode (doubled-up integers, 64-bit on i686). It is used for operations like this one:
unsigned long long
div (unsigned long long a, unsigned long long b, unsigned long long *p)
{
*p = a % b;
return a / b;
}
The use of __udivmoddi4
on i386 is a new optimization in GCC 7, related to this patch. Previous versions emitted separate calls to __umoddi3
and __udivdi3
, basically doing the same work twice.
Normally, all these functions are provided by libgcc
, but Coreboot does not link against the standard libraries. It supplies its own implementations of these functions in payloads/libpayload/libc/64bit_div.c
, but __udivmoddi4
has yet to be added there.
Either you implement the function yourself (easiest way would be to call __umoddi3
and __udivdi3
from it), or you use GCC 6 to compile Coreboot for the time being. Lowering the optimization level just for the printf
implementation might constitute a workaround.
Answered By - Florian Weimer