2020-08-06 07:28:44 +08:00
|
|
|
# REQUIRES: x86
|
[ELF] Allow SHF_LINK_ORDER sections to have sh_link=0
Part of https://bugs.llvm.org/show_bug.cgi?id=41734
The semantics of SHF_LINK_ORDER have been extended to represent metadata
sections associated with some other sections (usually text).
The associated text section may be discarded (e.g. LTO) and we want the
metadata section to have sh_link=0 (D72899, D76802).
Normally the metadata section is only referenced by the associated text
section. sh_link=0 means the associated text section is discarded, and
the metadata section will be garbage collected. If there is another
section (.gc_root) referencing the metadata section, the metadata
section will be retained. It's the .gc_root consumer's job to validate
the metadata sections.
# This creates a SHF_LINK_ORDER .meta with sh_link=0
.section .meta,"awo",@progbits,0
1:
.section .meta,"awo",@progbits,foo
2:
.section .gc_root,"a",@progbits
.quad 1b
.quad 2b
Reviewed By: pcc, jhenderson
Differential Revision: https://reviews.llvm.org/D72904
2020-08-06 07:09:41 +08:00
|
|
|
## Test that we allow SHF_LINK_ORDER sections with sh_link=0.
|
|
|
|
## SHF_LINK_ORDER sections with sh_link!=0 are ordered before others.
|
2020-08-06 07:28:44 +08:00
|
|
|
# RUN: llvm-mc -filetype=obj -triple=x86_64 %s -o %t.o
|
[ELF] Allow SHF_LINK_ORDER sections to have sh_link=0
Part of https://bugs.llvm.org/show_bug.cgi?id=41734
The semantics of SHF_LINK_ORDER have been extended to represent metadata
sections associated with some other sections (usually text).
The associated text section may be discarded (e.g. LTO) and we want the
metadata section to have sh_link=0 (D72899, D76802).
Normally the metadata section is only referenced by the associated text
section. sh_link=0 means the associated text section is discarded, and
the metadata section will be garbage collected. If there is another
section (.gc_root) referencing the metadata section, the metadata
section will be retained. It's the .gc_root consumer's job to validate
the metadata sections.
# This creates a SHF_LINK_ORDER .meta with sh_link=0
.section .meta,"awo",@progbits,0
1:
.section .meta,"awo",@progbits,foo
2:
.section .gc_root,"a",@progbits
.quad 1b
.quad 2b
Reviewed By: pcc, jhenderson
Differential Revision: https://reviews.llvm.org/D72904
2020-08-06 07:09:41 +08:00
|
|
|
# RUN: ld.lld %t.o -o %t
|
|
|
|
# RUN: llvm-readelf -S -x .linkorder %t | FileCheck %s
|
|
|
|
|
|
|
|
# CHECK: [Nr] Name {{.*}} Size ES Flg Lk Inf
|
|
|
|
# CHECK-NEXT: [ 0] {{.*}}
|
|
|
|
# CHECK-NEXT: [ 1] .linkorder {{.*}} 000004 00 AL 3 0
|
|
|
|
# CHECK-NEXT: [ 2] .ignore {{.*}}
|
|
|
|
# CHECK-NEXT: [ 3] .text {{.*}}
|
|
|
|
|
|
|
|
# CHECK: Hex dump of section '.linkorder':
|
|
|
|
# CHECK-NEXT: [[#%x,ADDR:]] 01020003
|
|
|
|
|
2020-08-06 08:00:16 +08:00
|
|
|
# RUN: llvm-mc --filetype=obj -triple=x86_64 --defsym EXTRA=1 %s -o %t.o
|
2020-08-15 01:23:45 +08:00
|
|
|
# RUN: ld.lld %t.o -o %t1
|
|
|
|
# RUN: llvm-readelf -S -x .linkorder %t1 | FileCheck %s --check-prefix=CHECK1
|
|
|
|
|
|
|
|
# CHECK1: [Nr] Name {{.*}} Size ES Flg Lk Inf
|
|
|
|
# CHECK1-NEXT: [ 0] {{.*}}
|
|
|
|
# CHECK1-NEXT: [ 1] .linkorder {{.*}} 000005 00 AL 2 0
|
|
|
|
# CHECK1-NEXT: [ 2] .text {{.*}}
|
|
|
|
|
|
|
|
# CHECK1: Hex dump of section '.linkorder':
|
|
|
|
# CHECK1-NEXT: [[#%x,ADDR:]] 01020004 03
|
[ELF] Allow SHF_LINK_ORDER sections to have sh_link=0
Part of https://bugs.llvm.org/show_bug.cgi?id=41734
The semantics of SHF_LINK_ORDER have been extended to represent metadata
sections associated with some other sections (usually text).
The associated text section may be discarded (e.g. LTO) and we want the
metadata section to have sh_link=0 (D72899, D76802).
Normally the metadata section is only referenced by the associated text
section. sh_link=0 means the associated text section is discarded, and
the metadata section will be garbage collected. If there is another
section (.gc_root) referencing the metadata section, the metadata
section will be retained. It's the .gc_root consumer's job to validate
the metadata sections.
# This creates a SHF_LINK_ORDER .meta with sh_link=0
.section .meta,"awo",@progbits,0
1:
.section .meta,"awo",@progbits,foo
2:
.section .gc_root,"a",@progbits
.quad 1b
.quad 2b
Reviewed By: pcc, jhenderson
Differential Revision: https://reviews.llvm.org/D72904
2020-08-06 07:09:41 +08:00
|
|
|
|
|
|
|
.section .text,"ax",@progbits,unique,0
|
|
|
|
.Ltext0:
|
|
|
|
.section .text,"ax",@progbits,unique,1
|
|
|
|
.Ltext1:
|
|
|
|
.section .linkorder,"ao",@progbits,0,unique,0
|
|
|
|
.byte 0
|
|
|
|
.section .linkorder,"ao",@progbits,.Ltext0
|
|
|
|
.byte 1
|
|
|
|
.section .linkorder,"ao",@progbits,.Ltext1
|
|
|
|
.byte 2
|
|
|
|
|
|
|
|
.ifdef EXTRA
|
|
|
|
.section .linkorder,"a",@progbits
|
|
|
|
.byte 4
|
|
|
|
.else
|
|
|
|
.section .ignore,"ao",@progbits,.Ltext1
|
|
|
|
.endif
|
|
|
|
|
|
|
|
.section .linkorder,"ao",@progbits,0,unique,3
|
|
|
|
.byte 3
|