Index: llvm/test/tools/yaml2obj/ELF/dynsym-section.yaml =================================================================== --- llvm/test/tools/yaml2obj/ELF/dynsym-section.yaml +++ llvm/test/tools/yaml2obj/ELF/dynsym-section.yaml @@ -31,3 +31,50 @@ # OFFSET-NEXT: [Nr] Name Type Address Off Size ES Flg Lk Inf Al # OFFSET-NEXT: [ 0] NULL 0000000000000000 000000 000000 00 0 0 0 # OFFSET-NEXT: [ 1] .dynsym DYNSYM 0000000000000000 000100 000018 18 A 0 1 0 + +## Check we are able to set Link = 0 for the .dynsym section explicitly. + +# RUN: yaml2obj %s --docnum=2 -DLINK="Link: 0" -o %t2 +# RUN: llvm-readelf --section-headers %t2 | FileCheck %s --check-prefix=LINK-NULL + +# LINK-NULL: [Nr] Name {{.*}} Flg Lk Inf +# LINK-NULL: [ 1] .dynsym {{.*}} A 0 1 + +--- !ELF +FileHeader: + Class: ELFCLASS64 + Data: ELFDATA2LSB + Type: ET_DYN +Sections: + - Name: .dynsym + Type: SHT_DYNSYM + [[LINK]] + - Name: .dynstr + Type: SHT_STRTAB + - Name: .foo + Type: SHT_PROGBITS + +## Check that by default the .dynsym section will be linked to the .dynstr section, +## when the latter one exists. + +# RUN: yaml2obj %s --docnum=2 -DLINK="" -o %t3 +# RUN: llvm-readelf --section-headers %t3 | FileCheck %s --check-prefix=LINK-DEFAULT + +# LINK-DEFAULT: [Nr] Name {{.*}} Flg Lk Inf +# LINK-DEFAULT: [ 1] .dynsym {{.*}} A 2 1 +# LINK-DEFAULT: [ 2] .dynstr {{.*}} A 0 0 + +## Even when the .dynstr section exists, we can explicitly link the .dynsym section +## to another section. + +# RUN: yaml2obj %s --docnum=2 -DLINK="Link: 3" -o %t4 +# RUN: llvm-readelf --section-headers %t4 | FileCheck %s --check-prefix=LINK-FOO + +# LINK-FOO: [Nr] Name {{.*}} Flg Lk Inf +# LINK-FOO: [ 1] .dynsym {{.*}} A 3 1 +# LINK-FOO: [ 3] .foo + +## Check we can use a section name as a Link value for .dynsym. + +# RUN: yaml2obj %s --docnum=2 -DLINK="Link: .foo" -o %t5 +# RUN: llvm-readelf --section-headers %t5 | FileCheck %s --check-prefix=LINK-FOO Index: llvm/test/tools/yaml2obj/ELF/dynsymtab-shlink.yaml =================================================================== --- llvm/test/tools/yaml2obj/ELF/dynsymtab-shlink.yaml +++ /dev/null @@ -1,93 +0,0 @@ -## For implicit dynamic symbol table sections, `Link` field can also -## be specified in YAML. Here we test the behavior in different cases. - -## Check we are able to set Link = 0 for .dynsym explicitly. - -# RUN: yaml2obj --docnum=1 %s -o %t1 -# RUN: llvm-readobj %t1 -S | FileCheck %s --check-prefix=CASE1 - -# CASE1: Name: .dynsym -# CASE1: Link: -# CASE1-SAME: 0 - ---- !ELF -FileHeader: - Class: ELFCLASS64 - Data: ELFDATA2LSB - Type: ET_DYN -Sections: - - Name: .dynsym - Type: SHT_DYNSYM - Link: 0 - -## Check that by default .dynsym will be linked to .dynstr -## if the latter exists. - -# RUN: yaml2obj --docnum=2 %s -o %t2 -# RUN: llvm-readobj %t2 -S | FileCheck %s --check-prefix=CASE2 - -# CASE2: .dynsym -# CASE2: Link: -# CASE2-SAME: 2 -# CASE2: Index: 2 -# CASE2-NEXT: Name: .dynstr - ---- !ELF -FileHeader: - Class: ELFCLASS64 - Data: ELFDATA2LSB - Type: ET_DYN -Sections: - - Name: .dynsym - Type: SHT_DYNSYM - - Name: .dynstr - Type: SHT_STRTAB - -## Even if .dynstr exists, we can explicitly link .dynsym -## to another section. - -# RUN: yaml2obj --docnum=3 %s -o %t3 -# RUN: llvm-readobj %t3 -S | FileCheck %s --check-prefix=CASE3 - -# CASE3: .dynsym -# CASE3: Link: -# CASE3-SAME: 3 -# CASE3: Index: 3 -# CASE3-NEXT: Name: .foo - ---- !ELF -FileHeader: - Class: ELFCLASS64 - Data: ELFDATA2LSB - Type: ET_DYN -Sections: - - Name: .dynsym - Type: SHT_DYNSYM - Link: 3 - - Name: .dynstr - Type: SHT_STRTAB - - Name: .foo - Type: SHT_PROGBITS - -## Check we can use a section name as a Link value for .dynsym. - -# RUN: yaml2obj --docnum=4 %s -o %t4 -# RUN: llvm-readobj %t4 -S | FileCheck %s --check-prefix=CASE4 - -# CASE4: .dynsym -# CASE4: Link: -# CASE4-SAME: 2 -# CASE4: Index: 2 -# CASE4-NEXT: Name: .foo - ---- !ELF -FileHeader: - Class: ELFCLASS64 - Data: ELFDATA2LSB - Type: ET_DYN -Sections: - - Name: .dynsym - Type: SHT_DYNSYM - Link: .foo - - Name: .foo - Type: SHT_PROGBITS