basic-archive-copy.test 2.44 KB
# RUN: yaml2obj %s > %t

# RUN: rm -f %t.a
# RUN: llvm-ar crs %t.a %t
# RUN: cp %t.a %t.copy.a
# RUN: llvm-objcopy %t.a %t2.a
# RUN: llvm-objcopy %t %t2
# RUN: llvm-ar p %t2.a > %t3
# RUN: cmp %t2 %t3

# RUN: llvm-readobj --sections %t2 | FileCheck %s
# RUN: llvm-nm --print-armap %t.a | FileCheck --check-prefix=INDEX-TABLE %s
# RUN: llvm-nm --print-armap %t2.a | FileCheck --check-prefix=INDEX-TABLE %s
# Verify that llvm-objcopy has not modifed the input.
# RUN: cmp %t.copy.a %t.a

# INDEX-TABLE: Archive map
# INDEX-TABLE-NEXT: foo in

# RUN: rm -f %t.no.index.a
# RUN: llvm-ar crS %t.no.index.a %t
# RUN: llvm-objcopy %t.no.index.a %t2.no.index.a
# RUN: llvm-ar p %t2.no.index.a > %t4

# RUN: llvm-nm --print-armap %t.no.index.a | FileCheck --check-prefix=NO-INDEX-TABLE %s
# RUN: llvm-nm --print-armap %t2.no.index.a | FileCheck --check-prefix=NO-INDEX-TABLE %s
# RUN: cmp %t2 %t4

# NO-INDEX-TABLE-NOT: Archive map
# NO-INDEX-TABLE-NOT: foo in

!ELF
FileHeader:
  Class:           ELFCLASS64
  Data:            ELFDATA2LSB
  Type:            ET_EXEC
  Machine:         EM_X86_64
Sections:
  - Name:            .bss
    Type:            SHT_NOBITS
    Flags:           [ SHF_ALLOC ]
    AddressAlign:    0x0000000000000010
    Size:            64
  - Name:            .text
    Type:            SHT_PROGBITS
    Flags:           [ SHF_ALLOC, SHF_EXECINSTR ]
    AddressAlign:    0x0000000000000010
    Content:         "00000000"
Symbols:
  - Name:     foo
    Type:     STT_FUNC
    Section:  .text
    Value:    0x1004
    Binding:  STB_GLOBAL

# CHECK: Type: SHT_NULL

# CHECK:      Name: .bss
# CHECK-NEXT: Type: SHT_NOBITS
# CHECK-NEXT: Flags [
# CHECK-NEXT:   SHF_ALLOC
# CHECK-NEXT: ]
# CHECK-NEXT: Address:
# CHECK-NEXT: Offset:
# CHECK-NEXT: Size: 64

# CHECK:      Name: .text
# CHECK-NEXT: Type: SHT_PROGBITS
# CHECK-NEXT: Flags [
# CHECK-NEXT:   SHF_ALLOC
# CHECK-NEXT:   SHF_EXECINSTR
# CHECK-NEXT: ]
# CHECK-NEXT: Address:
# CHECK-NEXT: Offset:
# CHECK-NEXT: Size: 4

# CHECK:      Name: .symtab
# CHECK-NEXT: Type: SHT_SYMTAB
# CHECK-NEXT: Flags [ (0x0)
# CHECK-NEXT: ]
# CHECK-NEXT: Address:
# CHECK-NEXT: Offset:
# CHECK-NEXT: Size: 48

# CHECK:      Name: .strtab
# CHECK-NEXT: Type: SHT_STRTAB
# CHECK-NEXT: Flags [ (0x0)
# CHECK-NEXT: ]
# CHECK-NEXT: Address:
# CHECK-NEXT: Offset:
# CHECK-NEXT: Size: 5

# CHECK:      Name: .shstrtab
# CHECK-NEXT: Type: SHT_STRTAB
# CHECK-NEXT: Flags [
# CHECK-NEXT: ]
# CHECK-NEXT: Address:
# CHECK-NEXT: Offset:
# CHECK-NEXT: Size: 38