[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Bug ld/27259] New: ld: Support SHF_LINK_ORDER self-link
From: |
i at maskray dot me |
Subject: |
[Bug ld/27259] New: ld: Support SHF_LINK_ORDER self-link |
Date: |
Wed, 27 Jan 2021 22:26:07 +0000 |
https://sourceware.org/bugzilla/show_bug.cgi?id=27259
Bug ID: 27259
Summary: ld: Support SHF_LINK_ORDER self-link
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: ---
The code below is a sketch of how Clang>=13 PGO intends to make metadata
sections subject to --gc-sections.
It uses a SHF_LINK_ORDER self-link trick. However, that currently causes an
infinite loop in GNU ld.
cat > a.s <<e
.hidden __start___llvm_prf_cnts
.hidden __stop___llvm_prf_cnts
.globl _start
_start:
leaq __start___llvm_prf_cnts(%rip), %rdi
leaq __stop___llvm_prf_cnts(%rip), %rsi
.section .text.foo,"ax",@progbits
.globl foo
foo:
incq .L__profc_foo(%rip)
.section __llvm_prf_cnts,"aw",@progbits
.section __llvm_prf_data,"aw",@progbits
.section __llvm_prf_cnts,"awo",@progbits,.L__profc_foo,unique,1
###
#.section __llvm_prf_cnts,"aw",@progbits
.L__profc_foo:
.zero 8
.section __llvm_prf_data,"awo",@progbits,.L__profc_foo,unique,2
.L__profd_foo:
.quad 6699318081062747564 # 0x5cf8c24cdb18bdac
.quad 0 # 0x0
.quad .L__profc_foo
.quad foo
.quad 0
.long 1 # 0x1
.zero 4
e
as a.s -o a.o
ld-new -shared a.o --print-gc-sections --gc-sections # infinite loop
If the alternative (indicated as ###) .section directive is used, there is no
infinite loop.
However, __llvm_prf_cnts & __llvm_prf_data cannot be garbage collected.
The reason is that the C identifier sections are considered as GC roots.
Adding SHF_LINK_ORDER is a trick to defeat the GC root semantics.
--
You are receiving this mail because:
You are on the CC list for the bug.
- [Bug ld/27259] New: ld: Support SHF_LINK_ORDER self-link,
i at maskray dot me <=
- [Bug ld/27259] ld: Support SHF_LINK_ORDER self-link, amodra at gmail dot com, 2021/01/27
- [Bug ld/27259] ld: Support SHF_LINK_ORDER self-link, cvs-commit at gcc dot gnu.org, 2021/01/28
- [Bug ld/27259] ld: Support SHF_LINK_ORDER self-link, cvs-commit at gcc dot gnu.org, 2021/01/28
- [Bug ld/27259] ld: Support SHF_LINK_ORDER self-link, i at maskray dot me, 2021/01/28
- [Bug ld/27259] ld: Support SHF_LINK_ORDER self-link, cvs-commit at gcc dot gnu.org, 2021/01/29
- [Bug ld/27259] ld: Support SHF_LINK_ORDER self-link, cvs-commit at gcc dot gnu.org, 2021/01/29