llvm-project/lld/test/elf/gnulinkonce/gnulinkonce-report-discarde...

146 lines
5.0 KiB
Plaintext

# 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
# does not 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
- 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
- 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
...