[PATCH] D58102: Support X86 Control-flow Enforcement Technology (CET) in LLD
Peter Smith via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Mar 21 02:43:18 PDT 2019
peter.smith added a comment.
In D58102#1437364 <https://reviews.llvm.org/D58102#1437364>, @xiangzhangllvm wrote:
> In D58102#1436187 <https://reviews.llvm.org/D58102#1436187>, @peter.smith wrote:
>
> > I've checked that it does work, although at the moment it does leave a redundant .splt section in the binary. I think that this can be removed by accounting for this in the SPltSection::empty(), .........
>
>
> It shouldn't have **redundant** .splt section, there should not have any .splt section if IBT is disable or non-dynamic link. Could you show me your test please?
My test is a simple modification of x86-64-feature-1-and.s and Inputs/x86-64-feature-1-and1.s
Step 1: add func3 and func4 to Inputs/x86-64-feature-1-and1.s so that we can resolve the symbols.
.text
.globl func3
.type func3, at function
func3:
retq
.text
.globl func4
.type func4, at function
func4:
retq
For x86-64-feature-1-and.s
change.text to
.text
.type foo STT_GNU_IFUNC
.globl foo
foo:
ret
.globl func1
.type func1, at function
func1:
callq func2
callq func3
callq foo
callq func4
retq
I've added an ifunc, a call to an ifunc and a call to a couple more functions. Notably the ifunc is after the calls to func1 and func2, so we turn off the feature after having added entries to the .splt.
Disassembly from gnu objdump
0000000000201000 <foo>:
201000: c3 retq
0000000000201001 <func1>:
201001: e8 2a 00 00 00 callq 201030 <func2 at plt>
201006: e8 35 00 00 00 callq 201040 <func3 at plt>
20100b: e8 50 00 00 00 callq 201060 <*ABS*+0x201000 at plt>
201010: e8 3b 00 00 00 callq 201050 <func4 at plt>
201015: c3 retq
Disassembly of section .plt:
0000000000201020 <func2 at plt-0x10>:
201020: ff 35 e2 1f 00 00 pushq 0x1fe2(%rip) # 203008 <_DYNAMIC+0x1008>
201026: ff 25 e4 1f 00 00 jmpq *0x1fe4(%rip) # 203010 <_DYNAMIC+0x1010>
20102c: 0f 1f 40 00 nopl 0x0(%rax)
0000000000201030 <func2 at plt>:
201030: ff 25 e2 1f 00 00 jmpq *0x1fe2(%rip) # 203018 <func2>
201036: 68 00 00 00 00 pushq $0x0
20103b: e9 e0 ff ff ff jmpq 201020 <func1+0x1f>
0000000000201040 <func3 at plt>:
201040: ff 25 da 1f 00 00 jmpq *0x1fda(%rip) # 203020 <func3>
201046: 68 01 00 00 00 pushq $0x1
20104b: e9 d0 ff ff ff jmpq 201020 <func1+0x1f>
0000000000201050 <func4 at plt>:
201050: ff 25 d2 1f 00 00 jmpq *0x1fd2(%rip) # 203028 <func4>
201056: 68 02 00 00 00 pushq $0x2
20105b: e9 c0 ff ff ff jmpq 201020 <func1+0x1f>
0000000000201060 <*ABS*+0x201000 at plt>:
201060: ff 25 ca 1f 00 00 jmpq *0x1fca(%rip) # 203030 <_DYNAMIC+0x1030>
201066: 68 00 00 00 00 pushq $0x0
20106b: e9 e0 ff ff ff jmpq 201050 <func4 at plt>
Disassembly of section .splt:
0000000000201070 <.splt>:
201070: f3 0f 1e fa endbr64
201074: ff 25 9e 1f 00 00 jmpq *0x1f9e(%rip) # 203018 <func2>
20107a: 66 0f 1f 44 00 00 nopw 0x0(%rax,%rax,1)
201080: f3 0f 1e fa endbr64
201084: ff 25 96 1f 00 00 jmpq *0x1f96(%rip) # 203020 <func3>
20108a: 66 0f 1f 44 00 00 nopw 0x0(%rax,%rax,1)
Note the redundant splt. I'm using the previous version of the patch as the current one didn't compile for me. I will double check the most recent patch with a more recent compiler.
Repository:
rLLD LLVM Linker
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D58102/new/
https://reviews.llvm.org/D58102
More information about the llvm-commits
mailing list