archive-symtab.test 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. RUN: rm -f %t.a
  2. RUN: llvm-ar rcsU %t.a %p/Inputs/trivial-object-test.elf-x86-64 %p/Inputs/trivial-object-test2.elf-x86-64
  3. RUN: llvm-nm -M %t.a | FileCheck %s
  4. CHECK: Archive map
  5. CHECK-NEXT: main in trivial-object-test.elf-x86-64
  6. CHECK-NEXT: foo in trivial-object-test2.elf-x86-64
  7. CHECK-NEXT: main in trivial-object-test2.elf-x86-64
  8. CHECK-NOT: bar
  9. CHECK: trivial-object-test.elf-x86-64:
  10. CHECK-NEXT: U SomeOtherFunction
  11. CHECK-NEXT: 0000000000000000 T main
  12. CHECK-NEXT: U puts
  13. CHECK: trivial-object-test2.elf-x86-64:
  14. CHECK-NEXT: 0000000000000000 t bar
  15. CHECK-NEXT: 0000000000000006 T foo
  16. CHECK-NEXT: 0000000000000016 T main
  17. RUN: rm -f %t.a
  18. RUN: llvm-ar rcSU %t.a %p/Inputs/trivial-object-test.elf-x86-64 %p/Inputs/trivial-object-test2.elf-x86-64
  19. RUN: llvm-nm -M %t.a | FileCheck %s --check-prefix=NOMAP
  20. NOMAP-NOT: Archive map
  21. RUN: llvm-ar s %t.a
  22. RUN: llvm-nm -M %t.a | FileCheck %s
  23. check that the archive does have a corrupt symbol table.
  24. RUN: rm -f %t.a
  25. RUN: cp %p/Inputs/archive-test.a-corrupt-symbol-table %t.a
  26. RUN: llvm-nm -M %t.a | FileCheck %s --check-prefix=CORRUPT
  27. CORRUPT: Archive map
  28. CORRUPT-NEXT: mbin in trivial-object-test.elf-x86-64
  29. CORRUPT-NEXT: foo in trivial-object-test2.elf-x86-64
  30. CORRUPT-NEXT: main in trivial-object-test2.elf-x86-64
  31. CORRUPT: trivial-object-test.elf-x86-64:
  32. CORRUPT-NEXT: U SomeOtherFunction
  33. CORRUPT-NEXT: 0000000000000000 T main
  34. CORRUPT-NEXT: U puts
  35. CORRUPT: trivial-object-test2.elf-x86-64:
  36. CORRUPT-NEXT: 0000000000000000 t bar
  37. CORRUPT-NEXT: 0000000000000006 T foo
  38. CORRUPT-NEXT: 0000000000000016 T main
  39. check that the we *don't* update the symbol table.
  40. RUN: llvm-ar s %t.a
  41. RUN: llvm-nm -M %t.a | FileCheck %s --check-prefix=CORRUPT
  42. repeate the test with llvm-ranlib
  43. RUN: rm -f %t.a
  44. RUN: llvm-ar rcSU %t.a %p/Inputs/trivial-object-test.elf-x86-64 %p/Inputs/trivial-object-test2.elf-x86-64
  45. RUN: llvm-nm -M %t.a | FileCheck %s --check-prefix=NOMAP
  46. RUN: llvm-ranlib %t.a
  47. RUN: llvm-nm -M %t.a | FileCheck %s
  48. RUN: llvm-nm -M %p/Inputs/macho-archive-x86_64.a | FileCheck %s --check-prefix=BSD-MachO
  49. RUN: llvm-nm -M %p/Inputs/macho-archive-unsorted-x86_64.a | FileCheck %s --check-prefix=BSD-MachO
  50. BSD-MachO: Archive map
  51. BSD-MachO: _bar in bar.o
  52. BSD-MachO: _foo in foo.o
  53. RUN: rm -f %t.a
  54. RUN: llvm-ar --format=bsd rcsU %t.a %p/Inputs/trivial-object-test.macho-x86-64 %p/Inputs/trivial-object-test2.macho-x86-64
  55. RUN: llvm-nm -M %t.a | FileCheck --check-prefix=MACHO %s
  56. MACHO: Archive map
  57. MACHO-NEXT: _main in trivial-object-test.macho-x86-64
  58. MACHO-NEXT: _foo in trivial-object-test2.macho-x86-64
  59. MACHO-NEXT: _main in trivial-object-test2.macho-x86-64
  60. MACHO-NOT: bar
  61. MACHO: trivial-object-test.macho-x86-64
  62. MACHO-NEXT: 0000000000000028 s L_.str
  63. MACHO-NEXT: U _SomeOtherFunction
  64. MACHO-NEXT: 0000000000000000 T _main
  65. MACHO-NEXT: U _puts
  66. MACHO: trivial-object-test2.macho-x86-64
  67. MACHO-NEXT: 0000000000000000 t _bar
  68. MACHO-NEXT: 0000000000000001 T _foo
  69. MACHO-NEXT: 0000000000000002 T _main
  70. Test that we pad the symbol table so that it ends in a multiple of 4 bytes:
  71. 8 + 60 + 36 == 104
  72. RUN: rm -f %t.a
  73. RUN: llvm-ar --format=bsd rcsU %t.a %p/Inputs/trivial-object-test.macho-x86-64
  74. RUN: FileCheck --check-prefix=MACHO-SYMTAB-ALIGN %s < %t.a
  75. MACHO-SYMTAB-ALIGN: !<arch>
  76. MACHO-SYMTAB-ALIGN-NEXT: #1/12 {{..........}} 0 0 0 36 `