| # 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 old-gnu -target x86_64 %t.linkonce1a.o %t.linkonce1b.o \ |
| #RUN: --noinhibit-exec --output-filetype=yaml -o %t2.out.yaml |
| #RUN: lld -flavor old-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 |
| - 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 |
| - 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 |
| ... |