[PATCH] gas: Fix some x86_64 testcases for Solaris not using R_X86_64_PLT32 [PR25732]

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

[PATCH] gas: Fix some x86_64 testcases for Solaris not using R_X86_64_PLT32 [PR25732]

Rainer Orth-2
As reported in PR gas/25732, some testcases currently FAIL on
Solaris/x86:

FAIL: x86-64 branch 2
FAIL: x86-64 branch 3
FAIL: x86-64 MPX branch
FAIL: x86-64 branch with BND prefix
FAIL: x86-64 jump

Since https://sourceware.org/ml/binutils/2019-03/msg00163.html, gas
doesn't emit R_X86_64_PLT32 as branch marker on Solaris.  Since the
testsuite lacks a way to preprocess dump files, adjusted copies of the
affected dumps are now used on Solaris.  Unfortunately, those dumps
weren't adapted when the original testcases were changed or other
testcases started to differ between non-Solaris and Solaris targets.

The following patch fixes that, re-syncing the affected dump files or
creating new Solaris-specific ones.

Tested on i386-pc-solaris2.11, x86_64-pc-solaris2.11,
x86_64-pc-linux-gnu, and i686-pc-linux-gnu.

Ok for master?

        Rainer

--
-----------------------------------------------------------------------------
Rainer Orth, Center for Biotechnology, Bielefeld University


2020-03-31  Rainer Orth  <[hidden email]>

        PR gas/25732
        * testsuite/gas/i386/solaris/x86-64-branch-2.d: New file.
        * testsuite/gas/i386/solaris/x86-64-branch-3.d: New file.
        * testsuite/gas/i386/solaris/x86-64-jump.d: Incorporate changes to
        testsuite/gas/i386/x86-64-jump.d.
        * gas/testsuite/gas/i386/solaris/x86-64-mpx-branch-1.d:
        Incorporate changes to
        gas/testsuite/gas/i386/x86-64-mpx-branch-1.d.
        * testsuite/gas/i386/solaris/x86-64-mpx-branch-2.d : Incorporate
        changes to testsuite/gas/i386/x86-64-mpx-branch-2.d.
        * testsuite/gas/i386/x86-64-branch-2.d: Skip on *-*-solaris*.
        * testsuite/gas/i386/x86-64-branch-3.d: Likewise.


# HG changeset patch
# Parent  6fd0216a33b99f01c183bfc56b992fe0316681e4
gas: Fix some x86_64 testcases for Solaris not using R_X86_64_PLT32 (PR gas/25732)

diff --git a/gas/testsuite/gas/i386/solaris/x86-64-branch-2.d b/gas/testsuite/gas/i386/solaris/x86-64-branch-2.d
new file mode 100644
--- /dev/null
+++ b/gas/testsuite/gas/i386/solaris/x86-64-branch-2.d
@@ -0,0 +1,20 @@
+#as: -J
+#objdump: -dwr
+#source: ../x86-64-branch-2.s
+#name: x86-64 branch 2
+
+.*: +file format .*
+
+Disassembly of section .text:
+
+0+ <bar-0xb>:
+[ ]*[a-f0-9]+: 66 e9 00 00           jmpw   4 <bar-0x7> 2: R_X86_64_PC16 foo-0x2
+[ ]*[a-f0-9]+: 66 48 e9 00 00 00 00 data16 jmpq b <bar> 7: R_X86_64_PC32 foo-0x4
+
+0+b <bar>:
+[ ]*[a-f0-9]+: 89 c3                 mov    %eax,%ebx
+[ ]*[a-f0-9]+: 66 e8 00 00           callw  11 <bar\+0x6> f: R_X86_64_PC16 foo-0x2
+[ ]*[a-f0-9]+: 66 48 e8 00 00 00 00 data16 callq 18 <bar\+0xd> 14: R_X86_64_PC32 foo-0x4
+[ ]*[a-f0-9]+: 66 c3                 retw *
+[ ]*[a-f0-9]+: 66 c2 08 00           retw   \$0x8
+#pass
diff --git a/gas/testsuite/gas/i386/solaris/x86-64-branch-3.d b/gas/testsuite/gas/i386/solaris/x86-64-branch-3.d
new file mode 100644
--- /dev/null
+++ b/gas/testsuite/gas/i386/solaris/x86-64-branch-3.d
@@ -0,0 +1,22 @@
+#as: -J -mintel64
+#objdump: -dwr -Mintel64
+#source: ../x86-64-branch-3.s
+#name: x86-64 branch 3
+
+.*: +file format .*
+
+Disassembly of section .text:
+
+0+ <bar-0xd>:
+[ ]*[a-f0-9]+: 66 e9 00 00 00 00     data16 jmpq 6 <bar-0x7> 2: R_X86_64_PC32 foo-0x4
+[ ]*[a-f0-9]+: 66 48 e9 00 00 00 00 data16 rex\.W jmpq d <bar> 9: R_X86_64_PC32 foo-0x4
+
+0+d <bar>:
+[ ]*[a-f0-9]+: 89 c3                 mov    %eax,%ebx
+[ ]*[a-f0-9]+: 66 e8 00 00 00 00     data16 callq 15 <bar\+0x8> 11: R_X86_64_PC32 foo-0x4
+[ ]*[a-f0-9]+: 66 48 e8 00 00 00 00 data16 rex\.W callq 1c <bar\+0xf> 18: R_X86_64_PC32 foo-0x4
+[ ]*[a-f0-9]+: 66 c7 f8 00 00       xbeginw 21 <bar\+0x14> 1f: R_X86_64_PC16 foo-0x2
+[ ]*[a-f0-9]+: 66 48 c7 f8 00 00 00 00 data16 xbeginq 29 <bar\+0x1c> 25: R_X86_64_PC32 foo-0x4
+[ ]*[a-f0-9]+: 48 ff 18             lcallq \*\(%rax\)
+[ ]*[a-f0-9]+: 48 ff 29             ljmpq  \*\(%rcx\)
+#pass
diff --git a/gas/testsuite/gas/i386/solaris/x86-64-jump.d b/gas/testsuite/gas/i386/solaris/x86-64-jump.d
--- a/gas/testsuite/gas/i386/solaris/x86-64-jump.d
+++ b/gas/testsuite/gas/i386/solaris/x86-64-jump.d
@@ -31,14 +31,22 @@ 0+ <.text>:
 [ ]*[a-f0-9]+: e3 00                 jrcxz  0x69 68: R_X86_64_PC8 \$\+0x1
 [ ]*[a-f0-9]+: 90                   nop
 [ ]*[a-f0-9]+: 66 ff 13             callw  \*\(%rbx\)
+[ ]*[a-f0-9]+: 66 ff 1b             lcallw \*\(%rbx\)
+[ ]*[a-f0-9]+: ff 1b                 lcall  \*\(%rbx\)
+[ ]*[a-f0-9]+: ff 13                 callq  \*\(%rbx\)
+[ ]*[a-f0-9]+: ff 13                 callq  \*\(%rbx\)
 [ ]*[a-f0-9]+: ff 1b                 lcall  \*\(%rbx\)
 [ ]*[a-f0-9]+: 66 ff 23             jmpw   \*\(%rbx\)
+[ ]*[a-f0-9]+: 66 ff 2b             ljmpw  \*\(%rbx\)
 [ ]*[a-f0-9]+: ff 2b                 ljmp   \*\(%rbx\)
-[ ]*[a-f0-9]+: eb 00                 jmp    0x76
-[ ]*[a-f0-9]+: 90                   nop
-[ ]*[a-f0-9]+: 67 e3 00             jecxz  0x7a
+[ ]*[a-f0-9]+: ff 23                 jmpq   \*\(%rbx\)
+[ ]*[a-f0-9]+: ff 23                 jmpq   \*\(%rbx\)
+[ ]*[a-f0-9]+: ff 2b                 ljmp   \*\(%rbx\)
+[ ]*[a-f0-9]+: eb 00                 jmp    0x[0-9a-f]*
 [ ]*[a-f0-9]+: 90                   nop
-[ ]*[a-f0-9]+: e3 00                 jrcxz  0x7d
+[ ]*[a-f0-9]+: 67 e3 00             jecxz  0x[0-9a-f]*
 [ ]*[a-f0-9]+: 90                   nop
-[ ]*[a-f0-9]+: eb 00                 jmp    0x80
+[ ]*[a-f0-9]+: e3 00                 jrcxz  0x[0-9a-f]*
+[ ]*[a-f0-9]+: 90                   nop
+[ ]*[a-f0-9]+: eb 00                 jmp    0x[0-9a-f]*
 #pass
diff --git a/gas/testsuite/gas/i386/solaris/x86-64-mpx-branch-1.d b/gas/testsuite/gas/i386/solaris/x86-64-mpx-branch-1.d
--- a/gas/testsuite/gas/i386/solaris/x86-64-mpx-branch-1.d
+++ b/gas/testsuite/gas/i386/solaris/x86-64-mpx-branch-1.d
@@ -8,22 +8,24 @@
 
 Disassembly of section .text:
 
-0+ <foo1-0xc>:
-[ ]*[a-f0-9]+: f2 e8 00 00 00 00     bnd callq 6 <foo1-0x6> 2: R_X86_64_PC32 \*ABS\*\+0x10003c
-[ ]*[a-f0-9]+: f2 e9 00 00 00 00     bnd jmpq c <foo1> 8: R_X86_64_PC32 \*ABS\*\+0x10003c
+0+ <foo1-0x1c>:
+[ ]*[a-f0-9]+: f2 e8 00 00 00 00     bnd callq 6 <foo1-0x16> 2: R_X86_64_PC32 \*ABS\*\+0x10003c
+[ ]*[a-f0-9]+: f2 e9 00 00 00 00     bnd jmpq c <foo1-0x10> 8: R_X86_64_PC32 \*ABS\*\+0x10003c
+[ ]*[a-f0-9]+: 66 f2 48 e8 00 00 00 00 data16 bnd callq 14 <foo1-0x8> 10: R_X86_64_PC32 \*ABS\*\+0x10003c
+[ ]*[a-f0-9]+: 66 f2 48 e9 00 00 00 00 data16 bnd jmpq 1c <foo1> 18: R_X86_64_PC32 \*ABS\*\+0x10003c
 
-0+c <foo1>:
-[ ]*[a-f0-9]+: f2 eb fd             bnd jmp c <foo1>
-[ ]*[a-f0-9]+: f2 72 fa             bnd jb c <foo1>
-[ ]*[a-f0-9]+: f2 e8 f4 ff ff ff     bnd callq c <foo1>
-[ ]*[a-f0-9]+: f2 eb 09             bnd jmp 24 <foo2>
-[ ]*[a-f0-9]+: f2 72 06             bnd jb 24 <foo2>
-[ ]*[a-f0-9]+: f2 e8 00 00 00 00     bnd callq 24 <foo2>
+0+1c <foo1>:
+[ ]*[a-f0-9]+: f2 eb fd             bnd jmp 1c <foo1>
+[ ]*[a-f0-9]+: f2 72 fa             bnd jb 1c <foo1>
+[ ]*[a-f0-9]+: f2 e8 f4 ff ff ff     bnd callq 1c <foo1>
+[ ]*[a-f0-9]+: f2 eb 09             bnd jmp 34 <foo2>
+[ ]*[a-f0-9]+: f2 72 06             bnd jb 34 <foo2>
+[ ]*[a-f0-9]+: f2 e8 00 00 00 00     bnd callq 34 <foo2>
 
-0+24 <foo2>:
-[ ]*[a-f0-9]+: f2 e9 00 00 00 00     bnd jmpq 2a <foo2\+0x6> 26: R_X86_64_PC32 foo-0x4
-[ ]*[a-f0-9]+: f2 0f 82 00 00 00 00 bnd jb 31 <foo2\+0xd> 2d: R_X86_64_PC32 foo-0x4
-[ ]*[a-f0-9]+: f2 e8 00 00 00 00     bnd callq 37 <foo2\+0x13> 33: R_X86_64_PC32 foo-0x4
-[ ]*[a-f0-9]+: f2 e9 00 00 00 00     bnd jmpq 3d <foo2\+0x19> 39: R_X86_64_PLT32 foo-0x4
-[ ]*[a-f0-9]+: f2 0f 82 00 00 00 00 bnd jb 44 <foo2\+0x20> 40: R_X86_64_PLT32 foo-0x4
-[ ]*[a-f0-9]+: f2 e8 00 00 00 00     bnd callq 4a <foo2\+0x26> 46: R_X86_64_PLT32 foo-0x4
+0+34 <foo2>:
+[ ]*[a-f0-9]+: f2 e9 00 00 00 00     bnd jmpq 3a <foo2\+0x6> 36: R_X86_64_PC32 foo-0x4
+[ ]*[a-f0-9]+: f2 0f 82 00 00 00 00 bnd jb 41 <foo2\+0xd> 3d: R_X86_64_PC32 foo-0x4
+[ ]*[a-f0-9]+: f2 e8 00 00 00 00     bnd callq 47 <foo2\+0x13> 43: R_X86_64_PC32 foo-0x4
+[ ]*[a-f0-9]+: f2 e9 00 00 00 00     bnd jmpq 4d <foo2\+0x19> 49: R_X86_64_PLT32 foo-0x4
+[ ]*[a-f0-9]+: f2 0f 82 00 00 00 00 bnd jb 54 <foo2\+0x20> 50: R_X86_64_PLT32 foo-0x4
+[ ]*[a-f0-9]+: f2 e8 00 00 00 00     bnd callq 5a <foo2\+0x26> 56: R_X86_64_PLT32 foo-0x4
diff --git a/gas/testsuite/gas/i386/solaris/x86-64-mpx-branch-2.d b/gas/testsuite/gas/i386/solaris/x86-64-mpx-branch-2.d
--- a/gas/testsuite/gas/i386/solaris/x86-64-mpx-branch-2.d
+++ b/gas/testsuite/gas/i386/solaris/x86-64-mpx-branch-2.d
@@ -1,29 +1,5 @@
 #as: -J -madd-bnd-prefix
-#source: ../x86-64-mpx-branch-2.s
+#source: ../x86-64-mpx-branch-1.s
 #objdump: -dwr
 #name: x86-64 branch with BND prefix
-
-.*: +file format .*
-
-
-Disassembly of section .text:
-
-0+ <foo1-0xc>:
-[ ]*[a-f0-9]+: f2 e8 00 00 00 00     bnd callq 6 <foo1-0x6> 2: R_X86_64_PC32 \*ABS\*\+0x10003c
-[ ]*[a-f0-9]+: f2 e9 00 00 00 00     bnd jmpq c <foo1> 8: R_X86_64_PC32 \*ABS\*\+0x10003c
-
-0+c <foo1>:
-[ ]*[a-f0-9]+: f2 eb fd             bnd jmp c <foo1>
-[ ]*[a-f0-9]+: f2 72 fa             bnd jb c <foo1>
-[ ]*[a-f0-9]+: f2 e8 f4 ff ff ff     bnd callq c <foo1>
-[ ]*[a-f0-9]+: f2 eb 09             bnd jmp 24 <foo2>
-[ ]*[a-f0-9]+: f2 72 06             bnd jb 24 <foo2>
-[ ]*[a-f0-9]+: f2 e8 00 00 00 00     bnd callq 24 <foo2>
-
-0+24 <foo2>:
-[ ]*[a-f0-9]+: f2 e9 00 00 00 00     bnd jmpq 2a <foo2\+0x6> 26: R_X86_64_PC32 foo-0x4
-[ ]*[a-f0-9]+: f2 0f 82 00 00 00 00 bnd jb 31 <foo2\+0xd> 2d: R_X86_64_PC32 foo-0x4
-[ ]*[a-f0-9]+: f2 e8 00 00 00 00     bnd callq 37 <foo2\+0x13> 33: R_X86_64_PC32 foo-0x4
-[ ]*[a-f0-9]+: f2 e9 00 00 00 00     bnd jmpq 3d <foo2\+0x19> 39: R_X86_64_PLT32 foo-0x4
-[ ]*[a-f0-9]+: f2 0f 82 00 00 00 00 bnd jb 44 <foo2\+0x20> 40: R_X86_64_PLT32 foo-0x4
-[ ]*[a-f0-9]+: f2 e8 00 00 00 00     bnd callq 4a <foo2\+0x26> 46: R_X86_64_PLT32 foo-0x4
+#dump: x86-64-mpx-branch-1.d
diff --git a/gas/testsuite/gas/i386/x86-64-branch-2.d b/gas/testsuite/gas/i386/x86-64-branch-2.d
--- a/gas/testsuite/gas/i386/x86-64-branch-2.d
+++ b/gas/testsuite/gas/i386/x86-64-branch-2.d
@@ -1,6 +1,7 @@
 #as: -J
 #objdump: -dwr
 #name: x86-64 branch 2
+#notarget: *-*-solaris*
 
 .*: +file format .*
 
diff --git a/gas/testsuite/gas/i386/x86-64-branch-3.d b/gas/testsuite/gas/i386/x86-64-branch-3.d
--- a/gas/testsuite/gas/i386/x86-64-branch-3.d
+++ b/gas/testsuite/gas/i386/x86-64-branch-3.d
@@ -1,6 +1,7 @@
 #as: -J -mintel64
 #objdump: -dwr -Mintel64
 #name: x86-64 branch 3
+#notarget: *-*-solaris*
 
 .*: +file format .*
 
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] gas: Fix some x86_64 testcases for Solaris not using R_X86_64_PLT32 [PR25732]

Sourceware - binutils list mailing list
On Wed, Apr 1, 2020 at 3:47 AM Rainer Orth <[hidden email]> wrote:

>
> As reported in PR gas/25732, some testcases currently FAIL on
> Solaris/x86:
>
> FAIL: x86-64 branch 2
> FAIL: x86-64 branch 3
> FAIL: x86-64 MPX branch
> FAIL: x86-64 branch with BND prefix
> FAIL: x86-64 jump
>
> Since https://sourceware.org/ml/binutils/2019-03/msg00163.html, gas
> doesn't emit R_X86_64_PLT32 as branch marker on Solaris.  Since the
> testsuite lacks a way to preprocess dump files, adjusted copies of the
> affected dumps are now used on Solaris.  Unfortunately, those dumps
> weren't adapted when the original testcases were changed or other
> testcases started to differ between non-Solaris and Solaris targets.
>
> The following patch fixes that, re-syncing the affected dump files or
> creating new Solaris-specific ones.
>
> Tested on i386-pc-solaris2.11, x86_64-pc-solaris2.11,
> x86_64-pc-linux-gnu, and i686-pc-linux-gnu.
>
> Ok for master?
>

OK.

BTW, please watch out for future adjustments similar to this.

Thanks.

--
H.J.
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] gas: Fix some x86_64 testcases for Solaris not using R_X86_64_PLT32 [PR25732]

Fangrui Song-2
On 2020-04-01, H.J. Lu via Binutils wrote:

>On Wed, Apr 1, 2020 at 3:47 AM Rainer Orth <[hidden email]> wrote:
>>
>> As reported in PR gas/25732, some testcases currently FAIL on
>> Solaris/x86:
>>
>> FAIL: x86-64 branch 2
>> FAIL: x86-64 branch 3
>> FAIL: x86-64 MPX branch
>> FAIL: x86-64 branch with BND prefix
>> FAIL: x86-64 jump
>>
>> Since https://sourceware.org/ml/binutils/2019-03/msg00163.html, gas
>> doesn't emit R_X86_64_PLT32 as branch marker on Solaris.  Since the
>> testsuite lacks a way to preprocess dump files, adjusted copies of the
>> affected dumps are now used on Solaris.  Unfortunately, those dumps
>> weren't adapted when the original testcases were changed or other
>> testcases started to differ between non-Solaris and Solaris targets.
>>
>> The following patch fixes that, re-syncing the affected dump files or
>> creating new Solaris-specific ones.
>>
>> Tested on i386-pc-solaris2.11, x86_64-pc-solaris2.11,
>> x86_64-pc-linux-gnu, and i686-pc-linux-gnu.
>>
>> Ok for master?
>>
>
>OK.
>
>BTW, please watch out for future adjustments similar to this.
>
>Thanks.

Why doesn't Solaris x86 use R_X86_64_PLT32?
Disclosure: I know close to zero about Solaris.

If a PC32 references a preemptible STT_FUNC, a canonical PLT entry (st_value>0, st_shndx=0) will be created.
This is a hack in ld.so and can slow down symbol resolution a bit.

My interpretation of PLT32 is that the address is not significant.
PC32 means the address is taken. Generally it is good for emitted code
sequences to have lower expectation.
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] gas: Fix some x86_64 testcases for Solaris not using R_X86_64_PLT32 [PR25732]

Rainer Orth-2
Hi Fangrui,

> On 2020-04-01, H.J. Lu via Binutils wrote:
>>On Wed, Apr 1, 2020 at 3:47 AM Rainer Orth <[hidden email]> wrote:
>>>
>>> As reported in PR gas/25732, some testcases currently FAIL on
>>> Solaris/x86:
>>>
>>> FAIL: x86-64 branch 2
>>> FAIL: x86-64 branch 3
>>> FAIL: x86-64 MPX branch
>>> FAIL: x86-64 branch with BND prefix
>>> FAIL: x86-64 jump
>>>
>>> Since https://sourceware.org/ml/binutils/2019-03/msg00163.html, gas
>>> doesn't emit R_X86_64_PLT32 as branch marker on Solaris.  Since the
>>> testsuite lacks a way to preprocess dump files, adjusted copies of the
>>> affected dumps are now used on Solaris.  Unfortunately, those dumps
>>> weren't adapted when the original testcases were changed or other
>>> testcases started to differ between non-Solaris and Solaris targets.
>>>
>>> The following patch fixes that, re-syncing the affected dump files or
>>> creating new Solaris-specific ones.
>>>
>>> Tested on i386-pc-solaris2.11, x86_64-pc-solaris2.11,
>>> x86_64-pc-linux-gnu, and i686-pc-linux-gnu.
>>>
>>> Ok for master?
>>>
>>
>>OK.
>>
>>BTW, please watch out for future adjustments similar to this.
>>
>>Thanks.
>
> Why doesn't Solaris x86 use R_X86_64_PLT32?

it does, it just doesn't want to implement support for HJ's branch
marker optimization referred to in the patch linked above.  Some of that
is explained in my patch submission, buf if you want to know all the
gory details, ask Ali ;-)

> Disclosure: I know close to zero about Solaris.

That can be changed :-)  For one, there's the Linkers and Libraries Guide

        https://docs.oracle.com/cd/E37838_01/html/E36783/index.html

written by the linker engineers themselves.  And for even more
background, you can check out their blog

        http://www.linker-aliens.org/

Both make for quite interesting reading for anyone interested in ELF in
general and Solaris innovations in particular.

        Rainer

--
-----------------------------------------------------------------------------
Rainer Orth, Center for Biotechnology, Bielefeld University
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] gas: Fix some x86_64 testcases for Solaris not using R_X86_64_PLT32 [PR25732]

Fangrui Song-2
On 2020-04-02, Rainer Orth wrote:

>Hi Fangrui,
>
>> On 2020-04-01, H.J. Lu via Binutils wrote:
>>>On Wed, Apr 1, 2020 at 3:47 AM Rainer Orth <[hidden email]> wrote:
>>>>
>>>> As reported in PR gas/25732, some testcases currently FAIL on
>>>> Solaris/x86:
>>>>
>>>> FAIL: x86-64 branch 2
>>>> FAIL: x86-64 branch 3
>>>> FAIL: x86-64 MPX branch
>>>> FAIL: x86-64 branch with BND prefix
>>>> FAIL: x86-64 jump
>>>>
>>>> Since https://sourceware.org/ml/binutils/2019-03/msg00163.html, gas
>>>> doesn't emit R_X86_64_PLT32 as branch marker on Solaris.  Since the
>>>> testsuite lacks a way to preprocess dump files, adjusted copies of the
>>>> affected dumps are now used on Solaris.  Unfortunately, those dumps
>>>> weren't adapted when the original testcases were changed or other
>>>> testcases started to differ between non-Solaris and Solaris targets.
>>>>
>>>> The following patch fixes that, re-syncing the affected dump files or
>>>> creating new Solaris-specific ones.
>>>>
>>>> Tested on i386-pc-solaris2.11, x86_64-pc-solaris2.11,
>>>> x86_64-pc-linux-gnu, and i686-pc-linux-gnu.
>>>>
>>>> Ok for master?
>>>>
>>>
>>>OK.
>>>
>>>BTW, please watch out for future adjustments similar to this.
>>>
>>>Thanks.
>>
>> Why doesn't Solaris x86 use R_X86_64_PLT32?
>
>it does, it just doesn't want to implement support for HJ's branch
>marker optimization referred to in the patch linked above.  Some of that
>is explained in my patch submission, buf if you want to know all the
>gory details, ask Ali ;-)

Looking at the tests, if I guess correctly, a @plt modifier is required
to emit R_X86_64_PLT32. I have put many thoughts in this area.  HJ's
branch marker optimization is a great thing to me.

R_X86_64_PLT32 is categorized as R_PLT_PC (a PC-relative relocation
which may create a PLT entry). It can be relaxed to R_PC (a PC-relative
relocation) if the symbol is non-preemptible (logical AND (non-ifunc or
FreeBSD extension -z ifunc-noplt); I know Solaris will never support ifunc).

A PLT32 has less requirement than a PC32. A PLT32 means the address is
not significant. The linker can use whatever approach appropriate to
arrange for a call to the symbol. It can be a direct jump, a jump
through a PLT entry, or other novel approach if it prefers.

A PC32, on the other hand, is indistinguishable with an address taken
operation.  This causes us copy relocations and canonical PLT entries (I
should note that I've seen a few people (at least Rafael Espindola and
Cary Coutant) using the term "canonical PLT entry" but it is not widely
used).

When emitting a jump/call instruction, it is unnecessary for the
compiler to emit extra info: R_X86_64_PLT32 vs R_X86_64_PC32;
R_PPC_LOCAL24PC vs R_PPC_PLTREL24 vs R_PPC_REL24. It is great that PPC64
dropped some relocation types in contrast to PPC32...

The non-preemptible property is a mergeable property of the symbol, not
an unmergeable property of the relocation.

I made a complaint about RISC-V's call relocation types while working on
the RISC-V port for lld
https://github.com/riscv/riscv-elf-psabi-doc/issues/98 R_RISCV_CALL vs R_RISCV_CALL_PLT

 From the viewpoint of implementation, with proper abstraction,
R_X86_64_PLT32 -> R_X86_64_PC32 can be implemented with very little
code:

https://github.com/llvm/llvm-project/blob/master/lld/ELF/Relocations.cpp#L1329
plus the definition of fromPlt

   if (!sym.isPreemptible && (!sym.isGnuIFunc() || config->zIfuncNoplt)) {
     if (expr == R_GOT_PC && !isAbsoluteValue(sym)) {
       /// For the curious, this is the recent https://sourceware.org/bugzilla/show_bug.cgi?id=25754
       expr = target->adjustRelaxExpr(type, relocatedAddr, expr);
     } else {
       // The 0x8000 bit of r_addend of R_PPC_PLTREL24 is used to choose call
       // stub type. It should be ignored if optimized to R_PC.
       if (config->emachine == EM_PPC && expr == R_PPC32_PLTREL)
         addend &= ~0x8000;
       expr = fromPlt(expr);
     }
   }


>> Disclosure: I know close to zero about Solaris.
>
>That can be changed :-)  For one, there's the Linkers and Libraries Guide
>
> https://docs.oracle.com/cd/E37838_01/html/E36783/index.html
>
>written by the linker engineers themselves.  And for even more
>background, you can check out their blog
>
> http://www.linker-aliens.org/
>
>Both make for quite interesting reading for anyone interested in ELF in
>general and Solaris innovations in particular.
>
> Rainer
>--
>-----------------------------------------------------------------------------
>Rainer Orth, Center for Biotechnology, Bielefeld University

I take this as a very friendly invitation to ask me to read:) Thanks.
I have read some when I started to work on lld. They are phrased very
well and have taught me a lot. As a linker and loader lover, I should
finish reading the Linkers and Libraries Guide...
It is refreshing to get some non-GNU perspective.