# This tests that comdat undef symbol is overridden by a global symbol. # comdat1.s #------------------------ # .section .foo,"axG",@progbits,g1,comdat # word g1 # #comdat2.s << \! #----------------- # .global g1 # .section .foo,"axG",@progbits,g1,comdat #g1: # nop # #global-g1.c #----------- #int g1=10; # #RUN: yaml2obj -format=elf -docnum 1 %s -o %t.comdat1.o #RUN: yaml2obj -format=elf -docnum 2 %s -o %t.comdat2.o #RUN: yaml2obj -format=elf -docnum 3 %s -o %t.g1.o #RUN: lld -flavor gnu -target x86_64 %t.comdat1.o %t.comdat2.o \ #RUN: %t.g1.o --noinhibit-exec --output-filetype=yaml -o %t2.out.yaml #RUN: lld -flavor gnu -target x86_64 %t.comdat1.o %t.comdat2.o \ #RUN: %t.g1.o --noinhibit-exec -o %t2.out #RUN: FileCheck %s -check-prefix=CHECKGROUP < %t2.out.yaml #RUN: llvm-readobj -sections %t2.out | FileCheck %s -check-prefix=CHECKGROUPSECTIONS #RUN: llvm-readobj -symbols %t2.out | FileCheck %s -check-prefix=CHECKSYMBOLS #CHECKGROUP: - name: g1 #CHECKGROUP: scope: global #CHECKGROUP: content: [ 0A, 00, 00, 00 ] #CHECKGROUP: section-name: .data #CHECKGROUPSECTIONS: Name: .foo #CHECKGROUPSECTIONS: Type: SHT_PROGBITS #CHECKGROUPSECTIONS: Flags [ #CHECKGROUPSECTIONS: SHF_ALLOC #CHECKGROUPSECTIONS: SHF_EXECINSTR #CHECKGROUPSECTIONS: ] #CHECKGROUPSECTIONS: Size: 2 #CHECKGROUPSECTIONS: Name: .data #CHECKGROUPSECTIONS: Type: SHT_PROGBITS #CHECKGROUPSECTIONS: Flags [ #CHECKGROUPSECTIONS: SHF_ALLOC #CHECKGROUPSECTIONS: SHF_WRITE #CHECKGROUPSECTIONS: ] #CHECKGROUPSECTIONS: Size: 4 #CHECKSYMBOLS: Name: g1 #CHECKSYMBOLS: Section: .data --- FileHeader: Class: ELFCLASS64 Data: ELFDATA2LSB OSABI: ELFOSABI_GNU Type: ET_REL Machine: EM_X86_64 Sections: - Name: .group Type: SHT_GROUP Link: .symtab AddressAlign: 0x0000000000000004 Info: g1 Members: - SectionOrType: GRP_COMDAT - SectionOrType: .foo - SectionOrType: .rela.foo - Name: .text Type: SHT_PROGBITS Flags: [ SHF_ALLOC, SHF_EXECINSTR ] AddressAlign: 0x0000000000000004 Content: '' - Name: .data Type: SHT_PROGBITS Flags: [ SHF_WRITE, SHF_ALLOC ] AddressAlign: 0x0000000000000004 Content: '' - Name: .bss Type: SHT_NOBITS Flags: [ SHF_WRITE, SHF_ALLOC ] AddressAlign: 0x0000000000000004 - Name: .foo Type: SHT_PROGBITS Flags: [ SHF_ALLOC, SHF_EXECINSTR, SHF_GROUP ] AddressAlign: 0x0000000000000001 Content: '0000' - Name: .rela.foo Type: SHT_RELA Flags: [ SHF_GROUP ] Link: .symtab AddressAlign: 0x0000000000000008 Info: .foo Relocations: - Offset: 0x0000000000000000 Symbol: g1 Type: R_X86_64_16 Symbols: Local: - Name: .text Type: STT_SECTION Section: .text - Name: .data Type: STT_SECTION Section: .data - Name: .bss Type: STT_SECTION Section: .bss - Name: .foo Type: STT_SECTION Section: .foo Global: - Name: g1 ... --- FileHeader: Class: ELFCLASS64 Data: ELFDATA2LSB OSABI: ELFOSABI_GNU Type: ET_REL Machine: EM_X86_64 Sections: - Name: .group Type: SHT_GROUP Link: .symtab AddressAlign: 0x0000000000000004 Info: g1 Members: - SectionOrType: GRP_COMDAT - SectionOrType: .foo - Name: .text Type: SHT_PROGBITS Flags: [ SHF_ALLOC, SHF_EXECINSTR ] AddressAlign: 0x0000000000000004 Content: '' - Name: .data Type: SHT_PROGBITS Flags: [ SHF_WRITE, SHF_ALLOC ] AddressAlign: 0x0000000000000004 Content: '' - Name: .bss Type: SHT_NOBITS Flags: [ SHF_WRITE, SHF_ALLOC ] AddressAlign: 0x0000000000000004 - Name: .foo Type: SHT_PROGBITS Flags: [ SHF_ALLOC, SHF_EXECINSTR, SHF_GROUP ] AddressAlign: 0x0000000000000001 Content: '90' Symbols: Local: - Name: .text Type: STT_SECTION Section: .text - Name: .data Type: STT_SECTION Section: .data - Name: .bss Type: STT_SECTION Section: .bss - Name: .foo Type: STT_SECTION Section: .foo Global: - Name: g1 Section: .foo ... --- FileHeader: Class: ELFCLASS64 Data: ELFDATA2LSB OSABI: ELFOSABI_GNU Type: ET_REL Machine: EM_X86_64 Sections: - Name: .text Type: SHT_PROGBITS Flags: [ SHF_ALLOC, SHF_EXECINSTR ] AddressAlign: 0x0000000000000004 Content: '' - Name: .data Type: SHT_PROGBITS Flags: [ SHF_WRITE, SHF_ALLOC ] AddressAlign: 0x0000000000000004 Content: 0A000000 - Name: .bss Type: SHT_NOBITS Flags: [ SHF_WRITE, SHF_ALLOC ] AddressAlign: 0x0000000000000004 - Name: .comment Type: SHT_PROGBITS Flags: [ SHF_MERGE, SHF_STRINGS ] AddressAlign: 0x0000000000000001 Content: 00636C616E672076657273696F6E20332E372E3020287472756E6B203232393535372920286C6C766D2F7472756E6B203232393536332900 - Name: .note.GNU-stack Type: SHT_PROGBITS AddressAlign: 0x0000000000000001 Content: '' Symbols: Local: - Name: global-g1.c Type: STT_FILE - Name: .text Type: STT_SECTION Section: .text - Name: .data Type: STT_SECTION Section: .data - Name: .bss Type: STT_SECTION Section: .bss - Name: .comment Type: STT_SECTION Section: .comment - Name: .note.GNU-stack Type: STT_SECTION Section: .note.GNU-stack Global: - Name: g1 Type: STT_OBJECT Section: .data Size: 0x0000000000000004 ...