# Check that a symbol declared as a week in a shared library gets a dynamic # symbol table record in an executable file if this executabe file declares the # symbol as strong. # RUN: yaml2obj -format=elf -docnum 1 %s > %t.foo.o # RUN: lld -flavor gnu -target x86_64 -shared -o %t.so %t.foo.o # RUN: yaml2obj -format=elf -docnum 2 %s > %t.main.o # # Link executable file with strong symbol. Weak symbol is in the shared lib. # RUN: lld -flavor gnu -target x86_64 -e main -o %t1.exe %t.main.o %t.so # RUN: llvm-readobj -dyn-symbols %t1.exe | FileCheck -check-prefix=EXE %s # # Link executable file. Strong and weak symbol come from different object files. # RUN: lld -flavor gnu -target x86_64 -e main -o %t2.exe %t.main.o %t.foo.o # RUN: llvm-readobj -dyn-symbols %t2.exe | FileCheck -check-prefix=OBJ %s # # Link shared library. Weak symbol is in the another shared lib. # RUN: lld -flavor gnu -target x86_64 -shared -o %t.res.so %t.main.o %t.so # RUN: llvm-readobj -dyn-symbols %t.res.so | FileCheck -check-prefix=SO %s # EXE: Symbol { # EXE: Name: flag@ ({{[0-9]+}}) # EXE-NEXT: Value: 0x{{[0-9A-F]+}} # EXE-NEXT: Size: 4 # EXE-NEXT: Binding: Global (0x1) # EXE-NEXT: Type: Object (0x1) # EXE-NEXT: Other: 0 # EXE-NEXT: Section: .data (0x{{[0-9A-F]+}}) # EXE-NEXT: } # OBJ-NOT: Name: flag@ ({{[0-9]+}}) # SO: Symbol { # SO: Name: flag@ ({{[0-9]+}}) # SO-NEXT: Value: 0x{{[0-9A-F]+}} # SO-NEXT: Size: 4 # SO-NEXT: Binding: Global (0x1) # SO-NEXT: Type: Object (0x1) # SO-NEXT: Other: 0 # SO-NEXT: Section: .data (0x{{[0-9A-F]+}}) # SO-NEXT: } # foo.o --- FileHeader: Class: ELFCLASS64 Data: ELFDATA2LSB Type: ET_REL Machine: EM_X86_64 Sections: - Name: .text Type: SHT_PROGBITS Flags: [ SHF_ALLOC, SHF_EXECINSTR ] AddressAlign: 0x04 Size: 0x08 - Name: .rela.text Type: SHT_RELA Link: .symtab AddressAlign: 0x08 Info: .text Relocations: - Offset: 0x00 Symbol: flag Type: R_X86_64_GOTPCREL Addend: -4 Symbols: Global: - Name: foo Type: STT_FUNC Section: .text Size: 0x08 Weak: - Name: flag # main.o --- FileHeader: Class: ELFCLASS64 Data: ELFDATA2LSB Type: ET_REL Machine: EM_X86_64 Sections: - Name: .text Type: SHT_PROGBITS Flags: [ SHF_ALLOC, SHF_EXECINSTR ] AddressAlign: 0x04 Size: 0x08 - Name: .rela.text Type: SHT_RELA Link: .symtab AddressAlign: 0x08 Info: .text Relocations: - Offset: 0x00 Symbol: foo Type: R_X86_64_PLT32 Addend: -4 - Name: .data Type: SHT_PROGBITS Flags: [ SHF_WRITE, SHF_ALLOC ] AddressAlign: 0x04 Size: 0x04 Symbols: Global: - Name: flag Type: STT_OBJECT Section: .data Size: 0x04 - Name: main Type: STT_FUNC Section: .text Size: 0x08 - Name: foo ...