| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,147 @@ | ||
| # Tests that the linker is able to read .gnu.linkonce sections and link them | ||
| # appropriately. The testcase has been created by using the following source | ||
| # code. | ||
| # TODO: This test should produce a discarded reference error message which it | ||
| # doesnot currently. | ||
| # linkoncea.s | ||
| # .section .gnu.linkonce.d.dummy,"aw" | ||
| #bar: | ||
| # .long 0 | ||
| # linkonceb.s | ||
| # .section .gnu.linkonce.d.dummy,"aw" | ||
| #foo: | ||
| # .long 0 | ||
| # .section .blah, "aw" | ||
| # .long foo | ||
| #RUN: yaml2obj -format=elf -docnum 1 %s -o %t.linkonce1a.o | ||
| #RUN: yaml2obj -format=elf -docnum 2 %s -o %t.linkonce1b.o | ||
| #RUN: lld -flavor gnu -target x86_64 %t.linkonce1a.o %t.linkonce1b.o \ | ||
| #RUN: --noinhibit-exec --output-filetype=yaml -o %t2.out.yaml | ||
| #RUN: lld -flavor gnu -target x86_64 %t.linkonce1a.o %t.linkonce1b.o \ | ||
| #RUN: --noinhibit-exec -o %t2.out | ||
| #RUN: FileCheck %s -check-prefix=CHECKGNULINKONCE < %t2.out.yaml | ||
| #RUN: llvm-readobj -sections %t2.out | FileCheck %s -check-prefix=CHECKGNULINKONCESECTIONS | ||
| #CHECKGNULINKONCE: - name: .gnu.linkonce.d.dummy | ||
| #CHECKGNULINKONCE: scope: global | ||
| #CHECKGNULINKONCE: type: gnu-linkonce | ||
| #CHECKGNULINKONCE: section-choice: custom-required | ||
| #CHECKGNULINKONCE: section-name: .gnu.linkonce.d.dummy | ||
| #CHECKGNULINKONCE: permissions: rw- | ||
| #CHECKGNULINKONCE: references: | ||
| #CHECKGNULINKONCE: - kind: group-child | ||
| #CHECKGNULINKONCE: offset: 0 | ||
| #CHECKGNULINKONCE: target: bar | ||
| #CHECKGNULINKONCESECTIONS: Section { | ||
| #CHECKGNULINKONCESECTIONS: Name: .gnu.linkonce.d.dummy | ||
| #CHECKGNULINKONCESECTIONS: Type: SHT_PROGBITS | ||
| #CHECKGNULINKONCESECTIONS: Flags [ (0x3) | ||
| #CHECKGNULINKONCESECTIONS: SHF_ALLOC (0x2) | ||
| #CHECKGNULINKONCESECTIONS: SHF_WRITE (0x1) | ||
| #CHECKGNULINKONCESECTIONS: ] | ||
| #CHECKGNULINKONCESECTIONS: Size: 4 | ||
| #CHECKGNULINKONCESECTIONS: } | ||
| --- | ||
| FileHeader: | ||
| Class: ELFCLASS64 | ||
| Data: ELFDATA2LSB | ||
| 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: '' | ||
| - Name: .bss | ||
| Type: SHT_NOBITS | ||
| Flags: [ SHF_WRITE, SHF_ALLOC ] | ||
| AddressAlign: 0x0000000000000004 | ||
| Content: '' | ||
| - Name: .gnu.linkonce.d.dummy | ||
| Type: SHT_PROGBITS | ||
| Flags: [ SHF_WRITE, SHF_ALLOC ] | ||
| AddressAlign: 0x0000000000000001 | ||
| Content: '00000000' | ||
| Symbols: | ||
| Local: | ||
| - Name: .text | ||
| Type: STT_SECTION | ||
| Section: .text | ||
| - Name: .data | ||
| Type: STT_SECTION | ||
| Section: .data | ||
| - Name: .bss | ||
| Type: STT_SECTION | ||
| Section: .bss | ||
| - Name: .gnu.linkonce.d.dummy | ||
| Type: STT_SECTION | ||
| Section: .gnu.linkonce.d.dummy | ||
| - Name: bar | ||
| Section: .gnu.linkonce.d.dummy | ||
| ... | ||
| --- | ||
| FileHeader: | ||
| Class: ELFCLASS64 | ||
| Data: ELFDATA2LSB | ||
| 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: '' | ||
| - Name: .bss | ||
| Type: SHT_NOBITS | ||
| Flags: [ SHF_WRITE, SHF_ALLOC ] | ||
| AddressAlign: 0x0000000000000004 | ||
| Content: '' | ||
| - Name: .gnu.linkonce.d.dummy | ||
| Type: SHT_PROGBITS | ||
| Flags: [ SHF_WRITE, SHF_ALLOC ] | ||
| AddressAlign: 0x0000000000000001 | ||
| Content: '00000000' | ||
| - Name: .blah | ||
| Type: SHT_PROGBITS | ||
| Flags: [ SHF_WRITE, SHF_ALLOC ] | ||
| AddressAlign: 0x0000000000000001 | ||
| Content: '00000000' | ||
| - Name: .rela.blah | ||
| Type: SHT_RELA | ||
| Link: .symtab | ||
| AddressAlign: 0x0000000000000008 | ||
| Info: .blah | ||
| Relocations: | ||
| - Offset: 0x0000000000000000 | ||
| Symbol: foo | ||
| Type: R_X86_64_32 | ||
| Symbols: | ||
| Local: | ||
| - Name: .text | ||
| Type: STT_SECTION | ||
| Section: .text | ||
| - Name: .data | ||
| Type: STT_SECTION | ||
| Section: .data | ||
| - Name: .bss | ||
| Type: STT_SECTION | ||
| Section: .bss | ||
| - Name: .gnu.linkonce.d.dummy | ||
| Type: STT_SECTION | ||
| Section: .gnu.linkonce.d.dummy | ||
| - Name: foo | ||
| Section: .gnu.linkonce.d.dummy | ||
| - Name: .blah | ||
| Type: STT_SECTION | ||
| Section: .blah | ||
| ... |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,129 @@ | ||
| # Tests that the linker is able to read .gnu.linkonce sections and link them | ||
| # appropriately. The testcase has been created by using the following source | ||
| # code. This test checks that the linker produces an undefined error. | ||
| # linkoncea.s | ||
| # .section .gnu.linkonce.d.dummy,"aw" | ||
| #bar: | ||
| # .long 0 | ||
| # linkonceb.s | ||
| # .section .gnu.linkonce.d.dummy,"aw" | ||
| # .global foo | ||
| #foo: | ||
| # .long 0 | ||
| # .section .blah, "aw" | ||
| # .long foo | ||
| #RUN: yaml2obj -format=elf -docnum 1 %s -o %t.linkonce1a.o | ||
| #RUN: yaml2obj -format=elf -docnum 2 %s -o %t.linkonce1b.o | ||
| #RUN: not lld -flavor gnu -target x86_64 %t.linkonce1a.o %t.linkonce1b.o \ | ||
| #RUN: --output-filetype=yaml -o %t2.out.yaml 2>&1 | FileCheck \ | ||
| #RUN: -check-prefix=UNDEFS %s | ||
| #RUN: not lld -flavor gnu -target x86_64 %t.linkonce1a.o %t.linkonce1b.o \ | ||
| #RUN: -o %t2.out 2>&1 | FileCheck -check-prefix=UNDEFS %s | ||
| #UNDEFS: Undefined symbol: {{.*}} foo | ||
| --- | ||
| FileHeader: | ||
| Class: ELFCLASS64 | ||
| Data: ELFDATA2LSB | ||
| 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: '' | ||
| - Name: .bss | ||
| Type: SHT_NOBITS | ||
| Flags: [ SHF_WRITE, SHF_ALLOC ] | ||
| AddressAlign: 0x0000000000000004 | ||
| Content: '' | ||
| - Name: .gnu.linkonce.d.dummy | ||
| Type: SHT_PROGBITS | ||
| Flags: [ SHF_WRITE, SHF_ALLOC ] | ||
| AddressAlign: 0x0000000000000001 | ||
| Content: '00000000' | ||
| Symbols: | ||
| Local: | ||
| - Name: .text | ||
| Type: STT_SECTION | ||
| Section: .text | ||
| - Name: .data | ||
| Type: STT_SECTION | ||
| Section: .data | ||
| - Name: .bss | ||
| Type: STT_SECTION | ||
| Section: .bss | ||
| - Name: .gnu.linkonce.d.dummy | ||
| Type: STT_SECTION | ||
| Section: .gnu.linkonce.d.dummy | ||
| - Name: bar | ||
| Section: .gnu.linkonce.d.dummy | ||
| ... | ||
| --- | ||
| 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: '' | ||
| - Name: .bss | ||
| Type: SHT_NOBITS | ||
| Flags: [ SHF_WRITE, SHF_ALLOC ] | ||
| AddressAlign: 0x0000000000000004 | ||
| Content: '' | ||
| - Name: .gnu.linkonce.d.dummy | ||
| Type: SHT_PROGBITS | ||
| Flags: [ SHF_WRITE, SHF_ALLOC ] | ||
| AddressAlign: 0x0000000000000001 | ||
| Content: '00000000' | ||
| - Name: .blah | ||
| Type: SHT_PROGBITS | ||
| Flags: [ SHF_WRITE, SHF_ALLOC ] | ||
| AddressAlign: 0x0000000000000001 | ||
| Content: '00000000' | ||
| - Name: .rela.blah | ||
| Type: SHT_RELA | ||
| Link: .symtab | ||
| AddressAlign: 0x0000000000000008 | ||
| Info: .blah | ||
| Relocations: | ||
| - Offset: 0x0000000000000000 | ||
| Symbol: foo | ||
| Type: R_X86_64_32 | ||
| Symbols: | ||
| Local: | ||
| - Name: .text | ||
| Type: STT_SECTION | ||
| Section: .text | ||
| - Name: .data | ||
| Type: STT_SECTION | ||
| Section: .data | ||
| - Name: .bss | ||
| Type: STT_SECTION | ||
| Section: .bss | ||
| - Name: .gnu.linkonce.d.dummy | ||
| Type: STT_SECTION | ||
| Section: .gnu.linkonce.d.dummy | ||
| - Name: .blah | ||
| Type: STT_SECTION | ||
| Section: .blah | ||
| Global: | ||
| - Name: foo | ||
| Section: .gnu.linkonce.d.dummy | ||
| ... |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,151 @@ | ||
| # Tests that the linker is able to read .gnu.linkonce sections and link them | ||
| # appropriately. The testcase has been created by using the following source | ||
| # code | ||
| # linkonce1a.s | ||
| # ------------ | ||
| # .section .gnu.linkonce.d.dummy,"aw" | ||
| #bar: | ||
| # .long 0 | ||
| # linkonce1b.s | ||
| # ------------ | ||
| # .globl main | ||
| # .globl start | ||
| # .globl _start | ||
| # .globl __start | ||
| # .text | ||
| #main: | ||
| #start: | ||
| #_start: | ||
| #__start: | ||
| # .long 0 | ||
| # | ||
| # .section .gnu.linkonce.d.dummy,"aw" | ||
| #foo: | ||
| # .long 0 | ||
| #RUN: yaml2obj -format=elf -docnum 1 %s -o %t.linkonce1a.o | ||
| #RUN: yaml2obj -format=elf -docnum 2 %s -o %t.linkonce1b.o | ||
| #RUN: lld -flavor gnu -target x86_64 %t.linkonce1a.o %t.linkonce1b.o \ | ||
| #RUN: --noinhibit-exec --output-filetype=yaml -o %t2.out.yaml | ||
| #RUN: lld -flavor gnu -target x86_64 %t.linkonce1a.o %t.linkonce1b.o \ | ||
| #RUN: --noinhibit-exec -o %t2.out | ||
| #RUN: FileCheck %s -check-prefix=CHECKGNULINKONCE < %t2.out.yaml | ||
| #RUN: llvm-readobj -sections %t2.out | FileCheck %s -check-prefix=CHECKGNULINKONCESECTIONS | ||
| #CHECKGNULINKONCE: - name: .gnu.linkonce.d.dummy | ||
| #CHECKGNULINKONCE: scope: global | ||
| #CHECKGNULINKONCE: type: gnu-linkonce | ||
| #CHECKGNULINKONCE: section-choice: custom-required | ||
| #CHECKGNULINKONCE: section-name: .gnu.linkonce.d.dummy | ||
| #CHECKGNULINKONCE: permissions: rw- | ||
| #CHECKGNULINKONCE: references: | ||
| #CHECKGNULINKONCE: - kind: group-child | ||
| #CHECKGNULINKONCE: offset: 0 | ||
| #CHECKGNULINKONCE: target: bar | ||
| #CHECKGNULINKONCE: - kind: group-child | ||
| #CHECKGNULINKONCE: offset: 0 | ||
| #CHECKGNULINKONCESECTIONS: Section { | ||
| #CHECKGNULINKONCESECTIONS: Name: .gnu.linkonce.d.dummy | ||
| #CHECKGNULINKONCESECTIONS: Type: SHT_PROGBITS | ||
| #CHECKGNULINKONCESECTIONS: Flags [ (0x3) | ||
| #CHECKGNULINKONCESECTIONS: SHF_ALLOC (0x2) | ||
| #CHECKGNULINKONCESECTIONS: SHF_WRITE (0x1) | ||
| #CHECKGNULINKONCESECTIONS: ] | ||
| #CHECKGNULINKONCESECTIONS: Size: 4 | ||
| #CHECKGNULINKONCESECTIONS: } | ||
| --- | ||
| 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: '' | ||
| - Name: .bss | ||
| Type: SHT_NOBITS | ||
| Flags: [ SHF_WRITE, SHF_ALLOC ] | ||
| AddressAlign: 0x0000000000000004 | ||
| Content: '' | ||
| - Name: .gnu.linkonce.d.dummy | ||
| Type: SHT_PROGBITS | ||
| Flags: [ SHF_WRITE, SHF_ALLOC ] | ||
| AddressAlign: 0x0000000000000001 | ||
| Content: '00000000' | ||
| Symbols: | ||
| Local: | ||
| - Name: bar | ||
| Section: .gnu.linkonce.d.dummy | ||
| - Name: .text | ||
| Type: STT_SECTION | ||
| Section: .text | ||
| - Name: .data | ||
| Type: STT_SECTION | ||
| Section: .data | ||
| - Name: .bss | ||
| Type: STT_SECTION | ||
| Section: .bss | ||
| - Name: .gnu.linkonce.d.dummy | ||
| Type: STT_SECTION | ||
| Section: .gnu.linkonce.d.dummy | ||
| ... | ||
| --- | ||
| FileHeader: | ||
| Class: ELFCLASS64 | ||
| Data: ELFDATA2LSB | ||
| Type: ET_REL | ||
| Machine: EM_X86_64 | ||
| Sections: | ||
| - Name: .text | ||
| Type: SHT_PROGBITS | ||
| Flags: [ SHF_ALLOC, SHF_EXECINSTR ] | ||
| AddressAlign: 0x0000000000000004 | ||
| Content: '00000000' | ||
| - 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 | ||
| Content: '' | ||
| - Name: .gnu.linkonce.d.dummy | ||
| Type: SHT_PROGBITS | ||
| Flags: [ SHF_WRITE, SHF_ALLOC ] | ||
| AddressAlign: 0x0000000000000001 | ||
| Content: '00000000' | ||
| Symbols: | ||
| Local: | ||
| - Name: .text | ||
| Type: STT_SECTION | ||
| Section: .text | ||
| - Name: .data | ||
| Type: STT_SECTION | ||
| Section: .data | ||
| - Name: .bss | ||
| Type: STT_SECTION | ||
| Section: .bss | ||
| - Name: .gnu.linkonce.d.dummy | ||
| Type: STT_SECTION | ||
| Section: .gnu.linkonce.d.dummy | ||
| - Name: foo | ||
| Section: .gnu.linkonce.d.dummy | ||
| Global: | ||
| - Name: main | ||
| Section: .text | ||
| - Name: start | ||
| Section: .text | ||
| - Name: _start | ||
| Section: .text | ||
| - Name: __start | ||
| Section: .text | ||
| ... |