1 Star 0 Fork 25

lixing.loongson.cn/binutils_anolis

forked from src-anolis-os/binutils 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
binutils-x86_64-ibt-enabled-tlsdesc.patch 3.36 KB
一键复制 编辑 原始数据 按行查看 历史
张彬琛 提交于 2021-01-20 13:04 . import binutils-2.30-73.el8.src.rpm
diff -rup binutils.orig/bfd/elf64-x86-64.c binutils-2.30/bfd/elf64-x86-64.c
--- binutils.orig/bfd/elf64-x86-64.c 2018-10-08 15:24:17.980797510 +0100
+++ binutils-2.30/bfd/elf64-x86-64.c 2018-10-08 15:25:02.643458607 +0100
@@ -4399,15 +4399,23 @@ elf_x86_64_finish_dynamic_sections (bfd
if (htab->tlsdesc_plt)
{
+ /* The TLSDESC entry in a lazy procedure linkage table. */
+ static const bfd_byte tlsdesc_plt_entry[LAZY_PLT_ENTRY_SIZE] =
+ {
+ 0xf3, 0x0f, 0x1e, 0xfa, /* endbr64 */
+ 0xff, 0x35, 8, 0, 0, 0, /* pushq GOT+8(%rip) */
+ 0xff, 0x25, 16, 0, 0, 0 /* jmpq *GOT+TDG(%rip) */
+ };
+
bfd_put_64 (output_bfd, (bfd_vma) 0,
htab->elf.sgot->contents + htab->tlsdesc_got);
memcpy (htab->elf.splt->contents + htab->tlsdesc_plt,
- htab->lazy_plt->plt0_entry,
- htab->lazy_plt->plt0_entry_size);
+ tlsdesc_plt_entry, LAZY_PLT_ENTRY_SIZE);
- /* Add offset for pushq GOT+8(%rip), since the
- instruction uses 6 bytes subtract this value. */
+ /* Add offset for pushq GOT+8(%rip), since ENDBR64 uses 4
+ bytes and the instruction uses 6 bytes, subtract these
+ values. */
bfd_put_32 (output_bfd,
(htab->elf.sgotplt->output_section->vma
+ htab->elf.sgotplt->output_offset
@@ -4415,14 +4423,13 @@ elf_x86_64_finish_dynamic_sections (bfd
- htab->elf.splt->output_section->vma
- htab->elf.splt->output_offset
- htab->tlsdesc_plt
- - 6),
+ - 4 - 6),
(htab->elf.splt->contents
+ htab->tlsdesc_plt
- + htab->lazy_plt->plt0_got1_offset));
- /* Add offset for the PC-relative instruction accessing
- GOT+TDG, where TDG stands for htab->tlsdesc_got,
- subtracting the offset to the end of that
- instruction. */
+ + 4 + 2));
+ /* Add offset for indirect branch via GOT+TDG, where TDG
+ stands for htab->tlsdesc_got, subtracting the offset
+ to the end of that instruction. */
bfd_put_32 (output_bfd,
(htab->elf.sgot->output_section->vma
+ htab->elf.sgot->output_offset
@@ -4430,10 +4437,9 @@ elf_x86_64_finish_dynamic_sections (bfd
- htab->elf.splt->output_section->vma
- htab->elf.splt->output_offset
- htab->tlsdesc_plt
- - htab->lazy_plt->plt0_got2_insn_end),
+ - 4 - 6 - 6),
(htab->elf.splt->contents
- + htab->tlsdesc_plt
- + htab->lazy_plt->plt0_got2_offset));
+ + htab->tlsdesc_plt + 4 + 6 + 2));
}
}
Only in binutils-2.30/bfd: elf64-x86-64.c.orig
diff -rup binutils.orig/ld/testsuite/ld-x86-64/tlsdesc.pd binutils-2.30/ld/testsuite/ld-x86-64/tlsdesc.pd
--- binutils.orig/ld/testsuite/ld-x86-64/tlsdesc.pd 2018-10-08 15:24:17.293802722 +0100
+++ binutils-2.30/ld/testsuite/ld-x86-64/tlsdesc.pd 2018-10-08 15:25:07.515421664 +0100
@@ -13,7 +13,7 @@ Disassembly of section .plt:
[0-9a-f]+: ff 35 .. .. 20 00 pushq .*\(%rip\) # 201358 <_GLOBAL_OFFSET_TABLE_\+0x8>
[0-9a-f]+: ff 25 .. .. 20 00 jmpq \*.*\(%rip\) # 201360 <_GLOBAL_OFFSET_TABLE_\+0x10>
[0-9a-f]+: 0f 1f 40 00 nopl 0x0\(%rax\)
+ [0-9a-f]+: f3 0f 1e fa endbr64
[0-9a-f]+: ff 35 .. .. 20 00 pushq .*\(%rip\) # 201358 <_GLOBAL_OFFSET_TABLE_\+0x8>
[0-9a-f]+: ff 25 .. .. 20 00 jmpq \*.*\(%rip\) # 201348 <.*>
- [0-9a-f]+: 0f 1f 40 00 nopl 0x0\(%rax\)
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/lixing-loongson-cn/binutils_anolis.git
git@gitee.com:lixing-loongson-cn/binutils_anolis.git
lixing-loongson-cn
binutils_anolis
binutils_anolis
a8

搜索帮助

23e8dbc6 1850385 7e0993f3 1850385