This commit broke 32-bit mesa: commit 292676c15a615b5a95bede9ee91004d3f7ee7dfd Author: H.J. Lu <hjl.tools@gmail.com> Date: Thu Feb 13 13:44:17 2020 -0800 x86: Resolve PLT32 reloc aganst local symbol to section To reproduce create a i386 chroot and build binutils inside that chroot. (sid-i386)niko@niko-desktop:~/build/binutils-gdb$ git checkout 292676c15a615b5a95bede9ee91004d3f7ee7dfd To fix the binutils build on i386 you need one additionial commit: (sid-i386)niko@niko-desktop:~/build/binutils-gdb$ git cherry-pick 74e10d1742f1b8312359c59a2af06c9e661252b3 This will produce a merge error in two Changelog files but they can be ignored. (sid-i386)niko@niko-desktop:~/build/binutils-gdb$ ./configure --enable-targets=x86_64-linux-gnu,x86_64-linux-gnux32 --disable-gdb --disable-gdbserver (sid-i386)niko@niko-desktop:~/build/binutils-gdb$ make && sudo make install (sid-i386)niko@niko-desktop:~/build/binutils-gdb$ ld -v GNU ld (GNU Binutils) 2.34.50.20200213 Now build mesa inside the chroot: (sid-i386)niko@niko-desktop:~/build/mesa-git$ meson build/ (sid-i386)niko@niko-desktop:~/build/mesa-git$ ninja -C build/ (sid-i386)niko@niko-desktop:~/build/mesa-git$ sudo ninja -C build/ install The build works fine without any apparent errors. However, if you try to run any program using mesa it raises a segmentation fault: (sid-i386)niko@niko-desktop:~/build/mesa-upstream/mesa$ LIBGL_DRIVERS_PATH=/usr/local/lib/i386-linux-gnu/dri glxinfo name of display: :0 Segmentation fault Reverting commit 292676c15a615b5a95bede9ee91004d3f7ee7dfd and rebuilding binutils and mesa fixes the segmentation fault: (sid-i386)niko@niko-desktop:~/build/mesa-upstream/mesa$ LIBGL_DRIVERS_PATH=/usr/local/lib/i386-linux-gnu/dri glxinfo | head -3 name of display: :0 display: :0 screen: 0 direct rendering: Yes
I don't have i386 system to try. Which .so file under /usr/local/lib/i386-linux-gnu/dri is bad? Please provide good and bad .so files.
Created attachment 12708 [details] Bad version of libglapi.so I tried to get a back trace of the segmentation fault and it points to libglapi.so. I attached the good and bad versions of that file.
Created attachment 12709 [details] Good version of libglapi.so
-libglapi_good.so: file format elf32-i386 +libglapi_bad.so: file format elf32-i386 Disassembly of section .init: @@ -209,7 +209,7 @@ Disassembly of section .text: 5231: c7 46 e4 00 00 ff a0 movl $0xa0ff0000,-0x1c(%esi) 5238: c7 46 e8 34 12 00 00 movl $0x1234,-0x18(%esi) 523f: c7 46 ec 90 90 90 90 movl $0x90909090,-0x14(%esi) - 5246: e8 95 ff ff ff call 51e0 <x86_current_tls> + 5246: e8 2e ff ff ff call 5179 <register_tm_clones+0x49> 524b: 89 6e e8 mov %ebp,-0x18(%esi) 524e: 83 c5 04 add $0x4,%ebp 5251: 89 46 e2 mov %eax,-0x1e(%esi) @@ -264,7 +264,7 @@ Disassembly of section .text: 52e2: 89 46 08 mov %eax,0x8(%esi) 52e5: 8b 44 24 0c mov 0xc(%esp),%eax 52e9: 89 46 0c mov %eax,0xc(%esi) - 52ec: e8 ef fe ff ff call 51e0 <x86_current_tls> + 52ec: e8 e2 fd ff ff call 50d3 <__cxa_finalize@plt+0x3> 52f1: 8b 4c 24 20 mov 0x20(%esp),%ecx 52f5: 89 46 02 mov %eax,0x2(%esi) 52f8: 89 f0 mov %esi,%eax
Which version of mesa are you using?
I used mesa-git from yesterday (b85ef043245e318422dbf99701267734a336ddf5), but the problem also appears when building mesa-20.1.2. I didn't try any older versions yet.
[hjl@gnu-cfl-2 pr25551]$ cat x.s .section .init.text,"ax",@progbits .global foo foo: call printk@PLT call printk .text printk: ret [hjl@gnu-cfl-2 pr25551]$ make as --32 -o x.o x.s ld -shared -melf_i386 -o x.so x.o objdump -dw x.so x.so: file format elf32-i386 Disassembly of section .text: 00001000 <printk>: 1000: c3 ret Disassembly of section .init.text: 00001001 <foo>: 1001: e8 f9 ff ff ff call fff <printk-0x1> 1006: e8 f5 ff ff ff call 1000 <printk> [hjl@gnu-cfl-2 pr25551]$
Created attachment 12710 [details] A patch Please try this.
The master branch has been updated by H.J. Lu <hjl@sourceware.org>: https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=2585b7a5ce5830e60a089aa2316a329558902f0c commit 2585b7a5ce5830e60a089aa2316a329558902f0c Author: H.J. Lu <hjl.tools@gmail.com> Date: Sun Jul 19 06:51:19 2020 -0700 x86: Change PLT32 reloc against section to PC32 Commit 292676c1 resolved PLT32 reloc aganst local symbol to section. Since PLT32 relocation must be against symbols, turn such PLT32 relocation into PC32 relocation. gas/ PR gas/26263 * config/tc-i386.c (i386_validate_fix): Change PLT32 reloc against section to PC32 reloc. * testsuite/gas/i386/relax-5.d: Updated. * testsuite/gas/i386/x86-64-relax-4.d: Likewise. ld/ PR gas/26263 * testsuite/ld-i386/i386.exp: Run PR gas/26263 test. * testsuite/ld-x86-64/x86-64.exp: Likewise. * testsuite/ld-i386/pr26263.d: New file. * testsuite/ld-x86-64/pr26263.d: Likewise. * testsuite/ld-x86-64/pr26263.s: Likewise.
The patch indeed fixes the segmentation fault. Thank you very much for the quick fix!
The binutils-2_35-branch branch has been updated by H.J. Lu <hjl@sourceware.org>: https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=52da8d36c60fc2ad7bef1256a9bbc3e3b1602787 commit 52da8d36c60fc2ad7bef1256a9bbc3e3b1602787 Author: H.J. Lu <hjl.tools@gmail.com> Date: Sun Jul 19 06:51:19 2020 -0700 x86: Change PLT32 reloc against section to PC32 Commit 292676c1 resolved PLT32 reloc aganst local symbol to section. Since PLT32 relocation must be against symbols, turn such PLT32 relocation into PC32 relocation. gas/ PR gas/26263 * config/tc-i386.c (i386_validate_fix): Change PLT32 reloc against section to PC32 reloc. * testsuite/gas/i386/relax-5.d: Updated. * testsuite/gas/i386/x86-64-relax-4.d: Likewise. ld/ PR gas/26263 * testsuite/ld-i386/i386.exp: Run PR gas/26263 test. * testsuite/ld-x86-64/x86-64.exp: Likewise. * testsuite/ld-i386/pr26263.d: New file. * testsuite/ld-x86-64/pr26263.d: Likewise. * testsuite/ld-x86-64/pr26263.s: Likewise. (cherry picked from commit 2585b7a5ce5830e60a089aa2316a329558902f0c)
Fixed for master and 2.35.
The master branch has been updated by H.J. Lu <hjl@sourceware.org>: https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=98b3697bcdedb92739d8feb9b881efdd70fd40d3 commit 98b3697bcdedb92739d8feb9b881efdd70fd40d3 Author: H.J. Lu <hjl.tools@gmail.com> Date: Mon Jul 20 04:53:58 2020 -0700 x86: Update PR gas/26263 linker tests Update and run PR gas/26263 linker tests for all x86 ELF targets to accept any program header layout. PR gas/26263 * testsuite/ld-i386/pr26263.d: Updated. * testsuite/ld-x86-64/pr26263.d: Likewise. * testsuite/ld-x86-64/x86-64.exp: Run gas/26263 test for all ELF targets.
The binutils-2_35-branch branch has been updated by H.J. Lu <hjl@sourceware.org>: https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=fd7f5a211aada713ec438d5f2b46338c3f32092e commit fd7f5a211aada713ec438d5f2b46338c3f32092e Author: H.J. Lu <hjl.tools@gmail.com> Date: Mon Jul 20 04:53:58 2020 -0700 x86: Update PR gas/26263 linker tests Update and run PR gas/26263 linker tests for all x86 ELF targets to accept any program header layout. PR gas/26263 * testsuite/ld-i386/pr26263.d: Updated. * testsuite/ld-x86-64/pr26263.d: Likewise. * testsuite/ld-x86-64/x86-64.exp: Run gas/26263 test for all ELF targets. (cherry picked from commit 98b3697bcdedb92739d8feb9b881efdd70fd40d3)