[Bug gas/26263] New: [Regression 2.35] binutils breaks 32-bit mesa

2020-07-19 Thread nsandschn at gmx dot de
https://sourceware.org/bugzilla/show_bug.cgi?id=26263

Bug ID: 26263
   Summary: [Regression 2.35] binutils breaks 32-bit mesa
   Product: binutils
   Version: 2.35
Status: UNCONFIRMED
  Severity: normal
  Priority: P2
 Component: gas
  Assignee: unassigned at sourceware dot org
  Reporter: nsandschn at gmx dot de
CC: hjl.tools at gmail dot com
  Target Milestone: ---

This commit broke 32-bit mesa:

commit 292676c15a615b5a95bede9ee91004d3f7ee7dfd
Author: H.J. Lu 
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

-- 
You are receiving this mail because:
You are on the CC list for the bug.


[Bug gas/26263] [Regression 2.35] binutils breaks 32-bit mesa

2020-07-19 Thread hjl.tools at gmail dot com
https://sourceware.org/bugzilla/show_bug.cgi?id=26263

H.J. Lu  changed:

   What|Removed |Added

 Ever confirmed|0   |1
 Status|UNCONFIRMED |WAITING
   Last reconfirmed||2020-07-19

--- Comment #1 from H.J. Lu  ---
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.

-- 
You are receiving this mail because:
You are on the CC list for the bug.


[Bug ld/26262] ld/plugin.c:plugin_notice may incorrectly replace an LTO bfd_link_hash_defined with bfd_link_hash_undefweak

2020-07-19 Thread hjl.tools at gmail dot com
https://sourceware.org/bugzilla/show_bug.cgi?id=26262

H.J. Lu  changed:

   What|Removed |Added

 CC||hjl.tools at gmail dot com

-- 
You are receiving this mail because:
You are on the CC list for the bug.


[Bug ld/26262] ld/plugin.c:plugin_notice may incorrectly replace an LTO bfd_link_hash_defined with bfd_link_hash_undefweak

2020-07-19 Thread hjl.tools at gmail dot com
https://sourceware.org/bugzilla/show_bug.cgi?id=26262

H.J. Lu  changed:

   What|Removed |Added

 Status|UNCONFIRMED |WAITING
 Ever confirmed|0   |1
   Last reconfirmed||2020-07-19

--- Comment #1 from H.J. Lu  ---
clang has different behavior depending on -fuse-ld=XXX:

[hjl@gnu-cfl-2 pr26262]$ clang -fuse-ld=gold -Wl,-y,__llvm_profile_raw_version
-Wl,-plugin-opt=save-temps -fprofile-generate -flto -o a a.c -save-temps
a.o: definition of __llvm_profile_raw_version
/usr/lib64/clang/10.0.0/lib/linux/libclang_rt.profile-x86_64.a(InstrProfiling.c.o):
definition of __llvm_profile_raw_version
a.o: definition of __llvm_profile_raw_version
[hjl@gnu-cfl-2 pr26262]$ clang -fuse-ld=bfd -Wl,-y,__llvm_profile_raw_version
-Wl,-plugin-opt=save-temps -fprofile-generate -flto -o a a.o
/usr/bin/ld.bfd: a.o: definition of __llvm_profile_raw_version
[hjl@gnu-cfl-2 pr26262]$ clang -fuse-ld=bfd -Wl,-y,__llvm_profile_raw_version
-Wl,-plugin-opt=save-temps -fprofile-generate -flto -o a a.c -save-temps
/usr/bin/ld.bfd: a.o (symbol from plugin): definition of
__llvm_profile_raw_version
/usr/bin/ld.bfd:
/usr/lib64/clang/10.0.0/lib/linux/libclang_rt.profile-x86_64.a(InstrProfiling.c.o):
definition of __llvm_profile_raw_version
[hjl@gnu-cfl-2 pr26262]$ clang -fuse-ld=gold -Wl,-y,__llvm_profile_raw_version
-Wl,-plugin-opt=save-temps -fprofile-generate -flto -o a a.o
/usr/lib64/clang/10.0.0/lib/linux/libclang_rt.profile-x86_64.a(InstrProfiling.c.o):
definition of __llvm_profile_raw_version
[hjl@gnu-cfl-2 pr26262]$ rm a.o
[hjl@gnu-cfl-2 pr26262]$ clang -fprofile-generate -flto -c a.c
[hjl@gnu-cfl-2 pr26262]$ clang -fuse-ld=bfd -Wl,-y,__llvm_profile_raw_version
-Wl,-plugin-opt=save-temps -fprofile-generate -flto -o a a.o
/usr/bin/ld.bfd: a.o (symbol from plugin): definition of
__llvm_profile_raw_version
/usr/bin/ld.bfd:
/usr/lib64/clang/10.0.0/lib/linux/libclang_rt.profile-x86_64.a(InstrProfiling.c.o):
definition of __llvm_profile_raw_version
[hjl@gnu-cfl-2 pr26262]$ clang -fuse-ld=gold -Wl,-y,__llvm_profile_raw_version
-Wl,-plugin-opt=save-temps -fprofile-generate -flto -o a a.o
/usr/lib64/clang/10.0.0/lib/linux/libclang_rt.profile-x86_64.a(InstrProfiling.c.o):
definition of __llvm_profile_raw_version
[hjl@gnu-cfl-2 pr26262]$ 

It looks like a clang bug.

-- 
You are receiving this mail because:
You are on the CC list for the bug.


[Bug gas/26263] [Regression 2.35] binutils breaks 32-bit mesa

2020-07-19 Thread nsandschn at gmx dot de
https://sourceware.org/bugzilla/show_bug.cgi?id=26263

--- Comment #3 from Niko Sandschneider  ---
Created attachment 12709
  --> https://sourceware.org/bugzilla/attachment.cgi?id=12709&action=edit
Good version of libglapi.so

-- 
You are receiving this mail because:
You are on the CC list for the bug.


[Bug gas/26263] [Regression 2.35] binutils breaks 32-bit mesa

2020-07-19 Thread nsandschn at gmx dot de
https://sourceware.org/bugzilla/show_bug.cgi?id=26263

--- Comment #2 from Niko Sandschneider  ---
Created attachment 12708
  --> https://sourceware.org/bugzilla/attachment.cgi?id=12708&action=edit
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.

-- 
You are receiving this mail because:
You are on the CC list for the bug.


[Bug gas/26263] [Regression 2.35] binutils breaks 32-bit mesa

2020-07-19 Thread hjl.tools at gmail dot com
https://sourceware.org/bugzilla/show_bug.cgi?id=26263

H.J. Lu  changed:

   What|Removed |Added

 Status|WAITING |NEW

--- Comment #4 from H.J. Lu  ---
-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 a0movl   $0xa0ff,-0x1c(%esi)
 5238:  c7 46 e8 34 12 00 00movl   $0x1234,-0x18(%esi)
 523f:  c7 46 ec 90 90 90 90movl   $0x90909090,-0x14(%esi)
-5246:  e8 95 ff ff ff  call   51e0 
+5246:  e8 2e ff ff ff  call   5179 
 524b:  89 6e e8mov%ebp,-0x18(%esi)
 524e:  83 c5 04add$0x4,%ebp
 5251:  89 46 e2mov%eax,-0x1e(%esi)
@@ -264,7 +264,7 @@ Disassembly of section .text:
 52e2:  89 46 08mov%eax,0x8(%esi)
 52e5:  8b 44 24 0c mov0xc(%esp),%eax
 52e9:  89 46 0cmov%eax,0xc(%esi)
-52ec:  e8 ef fe ff ff  call   51e0 
+52ec:  e8 e2 fd ff ff  call   50d3 <__cxa_finalize@plt+0x3>
 52f1:  8b 4c 24 20 mov0x20(%esp),%ecx
 52f5:  89 46 02mov%eax,0x2(%esi)
 52f8:  89 f0   mov%esi,%eax

-- 
You are receiving this mail because:
You are on the CC list for the bug.


[Bug gas/26263] [Regression 2.35] binutils breaks 32-bit mesa

2020-07-19 Thread hjl.tools at gmail dot com
https://sourceware.org/bugzilla/show_bug.cgi?id=26263

H.J. Lu  changed:

   What|Removed |Added

 Status|NEW |WAITING

--- Comment #5 from H.J. Lu  ---
Which version of mesa are you using?

-- 
You are receiving this mail because:
You are on the CC list for the bug.


[Bug gas/26263] [Regression 2.35] binutils breaks 32-bit mesa

2020-07-19 Thread nsandschn at gmx dot de
https://sourceware.org/bugzilla/show_bug.cgi?id=26263

--- Comment #6 from Niko Sandschneider  ---
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.

-- 
You are receiving this mail because:
You are on the CC list for the bug.


[Bug gas/26263] [Regression 2.35] binutils breaks 32-bit mesa

2020-07-19 Thread hjl.tools at gmail dot com
https://sourceware.org/bugzilla/show_bug.cgi?id=26263

H.J. Lu  changed:

   What|Removed |Added

   Target Milestone|--- |2.35
 Status|WAITING |NEW

--- Comment #7 from H.J. Lu  ---
[hjl@gnu-cfl-2 pr25551]$ cat x.s
.section .init.text,"ax",@progbits
.global foo
foo:
callprintk@PLT
callprintk
.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:

1000 :
1000:   c3  ret

Disassembly of section .init.text:

1001 :
1001:   e8 f9 ff ff ff  call   fff 
1006:   e8 f5 ff ff ff  call   1000 
[hjl@gnu-cfl-2 pr25551]$

-- 
You are receiving this mail because:
You are on the CC list for the bug.


[Bug binutils/26246] invalid access in bfd/elf32-xtensa.c

2020-07-19 Thread amodra at gmail dot com
https://sourceware.org/bugzilla/show_bug.cgi?id=26246

Alan Modra  changed:

   What|Removed |Added

 CC||jcmvbkbc at gcc dot gnu.org

-- 
You are receiving this mail because:
You are on the CC list for the bug.


[Bug gas/26263] [Regression 2.35] binutils breaks 32-bit mesa

2020-07-19 Thread hjl.tools at gmail dot com
https://sourceware.org/bugzilla/show_bug.cgi?id=26263

H.J. Lu  changed:

   What|Removed |Added

   Assignee|unassigned at sourceware dot org   |hjl.tools at gmail dot 
com

--- Comment #8 from H.J. Lu  ---
Created attachment 12710
  --> https://sourceware.org/bugzilla/attachment.cgi?id=12710&action=edit
A patch

Please try this.

-- 
You are receiving this mail because:
You are on the CC list for the bug.


[Bug gas/26263] [Regression 2.35] binutils breaks 32-bit mesa

2020-07-19 Thread cvs-commit at gcc dot gnu.org
https://sourceware.org/bugzilla/show_bug.cgi?id=26263

--- Comment #9 from cvs-commit at gcc dot gnu.org  ---
The master branch has been updated by H.J. Lu :

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=2585b7a5ce5830e60a089aa2316a329558902f0c

commit 2585b7a5ce5830e60a089aa2316a329558902f0c
Author: H.J. Lu 
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.

-- 
You are receiving this mail because:
You are on the CC list for the bug.


[Bug gas/26263] [Regression 2.35] binutils breaks 32-bit mesa

2020-07-19 Thread nsandschn at gmx dot de
https://sourceware.org/bugzilla/show_bug.cgi?id=26263

Niko Sandschneider  changed:

   What|Removed |Added

 Resolution|--- |FIXED
 Status|NEW |RESOLVED

--- Comment #10 from Niko Sandschneider  ---
The patch indeed fixes the segmentation fault. Thank you very much for the
quick fix!

-- 
You are receiving this mail because:
You are on the CC list for the bug.


[Bug gas/26263] [Regression 2.35] binutils breaks 32-bit mesa

2020-07-19 Thread cvs-commit at gcc dot gnu.org
https://sourceware.org/bugzilla/show_bug.cgi?id=26263

--- Comment #11 from cvs-commit at gcc dot gnu.org  ---
The binutils-2_35-branch branch has been updated by H.J. Lu
:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=52da8d36c60fc2ad7bef1256a9bbc3e3b1602787

commit 52da8d36c60fc2ad7bef1256a9bbc3e3b1602787
Author: H.J. Lu 
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)

-- 
You are receiving this mail because:
You are on the CC list for the bug.


[Bug gas/26263] [Regression 2.35] binutils breaks 32-bit mesa

2020-07-19 Thread hjl.tools at gmail dot com
https://sourceware.org/bugzilla/show_bug.cgi?id=26263

--- Comment #12 from H.J. Lu  ---
Fixed for master and 2.35.

-- 
You are receiving this mail because:
You are on the CC list for the bug.


[Bug ld/26265] New: Spurious 'gc-sections requires either an entry or an undefined symbol' when --init or --fini is specified

2020-07-19 Thread i at maskray dot me
https://sourceware.org/bugzilla/show_bug.cgi?id=26265

Bug ID: 26265
   Summary: Spurious 'gc-sections requires either an entry or an
undefined symbol' when --init or --fini is specified
   Product: binutils
   Version: unspecified
Status: UNCONFIRMED
  Severity: normal
  Priority: P2
 Component: ld
  Assignee: unassigned at sourceware dot org
  Reporter: i at maskray dot me
  Target Milestone: ---

link_info.init_function & link_info.fini_function are GC roots. When they are
explicitly specified, there is no need for the error:

% ld.bfd -r --gc-sections -init _init a.o
ld.bfd: gc-sections requires either an entry or an undefined symbol

-- 
You are receiving this mail because:
You are on the CC list for the bug.


[Bug ld/26262] ld/plugin.c:plugin_notice may incorrectly replace an LTO bfd_link_hash_defined with bfd_link_hash_undefweak

2020-07-19 Thread i at maskray dot me
https://sourceware.org/bugzilla/show_bug.cgi?id=26262

--- Comment #2 from Fangrui Song  ---
(In reply to H.J. Lu from comment #1)
> clang has different behavior depending on -fuse-ld=XXX:
> 
> ...
> 
> It looks like a clang bug.

Thanks for the report. It is an LLVMgold.so bug. LLVMgold.so is used by GNU ld
and gold for clang LTO (full LTO or ThinLTO). The problem is that

clang -fuse-ld=bfd -flto a.o -o a -Wl,-plugin-opt=save-temps  # override a.o

I will fix it in https://reviews.llvm.org/D84132 and cherry pick it into
llvm-project's release/11.x branch (newly created for the 11.0.0 release).

Let's move back to the original topic. Use a different output filename (than
the basename of the source file) to avoid the -plugin-opt=save-temps issue.

-

% clang -fuse-ld=bfd -fprofile-generate=out -flto a.c
-Wl,-y,__llvm_profile_raw_version -Wl,-plugin-opt=save-temps -o aa
/usr/bin/ld.bfd: /tmp/a-1cd442.o (symbol from plugin): definition of
__llvm_profile_raw_version
/usr/bin/ld.bfd:
/tmp/RelA/lib/clang/12.0.0/lib/linux/libclang_rt.profile-x86_64.a(InstrProfiling.c.o):
definition of __llvm_profile_raw_version
% ./aa
% llvm-profdata merge out -o a.profdata
% llvm-profdata show a.profdata  
Instrumentation level: Front-end### incorrect, it should be IR
Total functions: 1
Maximum function count: 1
Maximum internal block count: 0

% rm -r out
% clang -fuse-ld=gold -fprofile-generate=out -flto a.c
-Wl,-y,__llvm_profile_raw_version -Wl,-plugin-opt=save-temps -o aa
/tmp/a-3b2969.o: definition of __llvm_profile_raw_version
/tmp/RelA/lib/clang/12.0.0/lib/linux/libclang_rt.profile-x86_64.a(InstrProfiling.c.o):
definition of __llvm_profile_raw_version
aa.o: definition of __llvm_profile_raw_version
% ./aa
% llvm-profdata merge out -o a.profdata
% llvm-profdata show a.profdata  
Instrumentation level: IR
Total functions: 1
Maximum function count: 1
Maximum internal block count: 0



As my first comment says, you can inspect aa.resolution.txt to see that GNU ld
incorrectly thinks that __llvm_profile_raw_versio is non-prevailing.

-- 
You are receiving this mail because:
You are on the CC list for the bug.


[Bug ld/26265] Spurious 'gc-sections requires either an entry or an undefined symbol' when --init or --fini is specified

2020-07-19 Thread amodra at gmail dot com
https://sourceware.org/bugzilla/show_bug.cgi?id=26265

Alan Modra  changed:

   What|Removed |Added

   Last reconfirmed||2020-07-20
   Assignee|unassigned at sourceware dot org   |amodra at gmail dot com
 Status|UNCONFIRMED |ASSIGNED
 Ever confirmed|0   |1

-- 
You are receiving this mail because:
You are on the CC list for the bug.


[Bug gas/4572] division doesn't work on solaris/x86

2020-07-19 Thread cvs-commit at gcc dot gnu.org
https://sourceware.org/bugzilla/show_bug.cgi?id=4572

--- Comment #13 from cvs-commit at gcc dot gnu.org  ---
The master branch has been updated by Jan Beulich :

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=750e4bf70f2caab39dc5d0a1b2d26c9ca1fbd909

commit 750e4bf70f2caab39dc5d0a1b2d26c9ca1fbd909
Author: Jan Beulich 
Date:   Mon Jul 20 08:56:23 2020 +0200

gas: generalize comment character escaping recognition

PR gas/4572

Generalize what ab1fadc6b2f0 ("PR22714, Assembler preprocessor loses
track of \@") did to always honor escaped comment chars. Use this then
to support escaped /, %, and * operators on x86, when / is a comment
char (to match the Sun assembler's behavior).

-- 
You are receiving this mail because:
You are on the CC list for the bug.


[Bug gas/4572] division doesn't work on solaris/x86

2020-07-19 Thread cvs-commit at gcc dot gnu.org
https://sourceware.org/bugzilla/show_bug.cgi?id=4572

--- Comment #14 from cvs-commit at gcc dot gnu.org  ---
The master branch has been updated by Jan Beulich :

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=b3983e5f53caad175563f8c842f2ab2a1277c2bc

commit b3983e5f53caad175563f8c842f2ab2a1277c2bc
Author: Jan Beulich 
Date:   Mon Jul 20 08:57:18 2020 +0200

x86: handle SVR4 escaped binary operators

PR gas/4572

When / is a comment character, its use as binary "divide" operator needs
escaping by a backslash. Besides the scrubber needing to support this
(addressed in an earlier change), there are also a few provisions needed
in target specific operator handling.

As the spec calls for % and * to also be escaped because of being
"overloaded", also recognize these, despite the overloading there not
really preventing their use as operators in most (%) or all (*) cases,
given the way how the rest of the assembler works.

To bring source and testsuite in line, also drop the TE_I386AIX part of
the respective conditional, as i?86-*-aix* support had been removed a
while ago.

-- 
You are receiving this mail because:
You are on the CC list for the bug.