# Tests that an executable with a weak undefine will put this symbol in the # dynamic symbol table if the executable has a dynamic relocation against this # symbol. #RUN: yaml2obj --format elf %s -o %t.o #RUN: lld -flavor gnu -target x86_64 -e main %t.o -o %t1 #RUN: llvm-readobj -dt %t1 | FileCheck -check-prefix CHECKSYMS %s #CHECKSYMS: Name: x@ #CHECKSYMS-NEXT: Value: 0x0 #CHECKSYMS-NEXT: Size: 0 #CHECKSYMS-NEXT: Binding: Weak (0x2) #CHECKSYMS-NEXT: Type: None (0x0) #CHECKSYMS-NEXT: Other: 0 #CHECKSYMS-NEXT: Section: Undefined (0x0) # The object file above corresponds to the following C program compiled with # -fPIC: # extern int *x __attribute__((weak)); # # int main() { # if (x) # return 1; # return 0; # } --- 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: 0x0000000000000010 Content: 554889E5488B0500000000C745FC00000000488138000000000F840C000000C745FC01000000E907000000C745FC000000008B45FC5DC3 - Name: .rela.text Type: SHT_RELA Link: .symtab AddressAlign: 0x0000000000000008 Info: .text Relocations: - Offset: 0x0000000000000007 Symbol: x Type: R_X86_64_GOTPCREL Addend: -4 - 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 Symbols: Local: - Name: .text Type: STT_SECTION Section: .text - Name: .data Type: STT_SECTION Section: .data - Name: .bss Type: STT_SECTION Section: .bss Global: - Name: main Type: STT_FUNC Section: .text Size: 0x0000000000000037 - Name: _GLOBAL_OFFSET_TABLE_ Weak: - Name: x