New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
FreeBSD/mips build linking fails with "unsupported non-zero ri_gp_value" #30497
Comments
assigned to @atanasyan |
LLD shows this error when an object file with non-zero ri_gp_value value in the .reginfo or .MIPS.options section is used to build a relocatable object (-r). Is it a regular object file or something "specific" like crt*.o? BTW you can check .reginfo or .MIPS.options content by the following command: llvm-readobj -mips-options -mips-reginfo *.o |
The build uses -r only in a few special cases, although I see many objects with non-zero GP. One example object that is used with -r, from the rescue tools (built as described in https://svnweb.freebsd.org/base/head/usr.sbin/crunch/crunchide/crunchide.c?revision=308734&view=markup#l28): File: ./rescue/librescue/sysctl.o The other case comes from statically-linked libpam: File: ./lib/libpam/static_libpam/openpam_static_modules.o |
reproducer for FreeBSD/mips linking error |
LLD does not perform any relocation calculation when generate a relocatable output. If all input files have the same ri_gp_value value, we can just copy this value to the output file and do not touch the relocations at all. But usually ri_gp_value differ from each other. So to fix the bug we have to teach LLD to calculate relocations in "-r" mode. At the first glance the task does not look easy. |
How do you build pam_echo.o or sysctl.o or any other object files with non-zero ri_gp_value? Are they in turn result of linking some other object files using -r option or just plain compiler output? |
It looks like pam_echo is built like so: --- pam_echo.o --- |
I'm surprised that compiler generates an object file with non-zero ri_gp_value, so a few more questions:
|
preprocessed pam_echo .i and .s, along with .o % make TARGET_ARCH=mips buildenv |
Coming back to this after some time, so I checked current FreeBSD with current LLD. Error still is:
String dump of section '.comment':
cc -isystem /usr/obj/mips.mips/usr/home/emaste/src/freebsd-mips-lld/tmp/usr/include -L/usr/obj/mips.mips/usr/home/emaste/src/freebsd-mips-lld/tmp/usr/lib -B/usr/obj/mips.mips/usr/home/emaste/src/freebsd-mips-lld/tmp/usr/lib --sysroot=/usr/obj/mips.mips/usr/home/emaste/src/freebsd-mips-lld/tmp -B/usr/obj/mips.mips/usr/home/emaste/src/freebsd-mips-lld/tmp/usr/bin -DOPENPAM_STATIC_MODULES -O -pipe -G0 -mxgot -EB -mabi=32 -msoft-float -I/usr/home/emaste/src/freebsd-mips-lld/contrib/openpam/include -I/usr/home/emaste/src/freebsd-mips-lld/lib/libpam -DOPENPAM_DEBUG -MD -MF.depend.pam_echo.o -MTpam_echo.o -std=gnu99 -Wsystem-headers -Werror -Wall -Wno-format-y2k -W -Wno-unused-parameter -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith -Wreturn-type -Wcast-qual -Wwrite-strings -Wswitch -Wshadow -Wunused-parameter -Wcast-align -Wchar-subscripts -Winline -Wnested-externs -Wredundant-decls -Wold-style-definition -Wno-pointer-sign -c /usr/home/emaste/src/freebsd-mips-lld/lib/libpam/modules/pam_echo/pam_echo.c -o pam_echo.o So pam_echo.o is as output by gcc 4.2.1, and it's just ar+ranlib for libpam_echo.a as lld input. nuc% readelf -A modules/pam_echo/pam_echo.o Section '.reginfo' contains 1 entries:
|
Ed, could you try the ri_gp_value.patch attached to this bug report? I hope it fixes the problem. |
I massaged the patch slightly to apply it to the lld in my FreeBSD working branch (6.0 + Multi-GOT) and will let it build tonight. |
With the patch I'm able to build rescue, one of the components that previously failed. (I have not yet been able to test the result.) |
Do you plan to test the result? If so, when do you plan to do that? I ask to just schedule me future tasks. |
I hope r331772 fixes the bug. |
Extended Description
Building 32-bit FreeBSD mips using LLD as the linker reports several failures across two components due to "unsupported non-zero ri_gp_value".
The text was updated successfully, but these errors were encountered: