385 lines · plain
1# REQUIRES: system-aix2## Test the "-X" option.3## The option specifies the type of object file llvm-ar will operate on.4 5# RUN: rm -rf %t && mkdir %t && cd %t6# RUN: yaml2obj --docnum=1 -DCLASS=ELFCLASS32 %s -o elf32.o7# RUN: yaml2obj --docnum=1 -DCLASS=ELFCLASS64 %s -o elf64.o8 9# RUN: yaml2obj --docnum=2 -DFLAG=0x1DF %s -o xcoff32.o10# RUN: yaml2obj --docnum=2 -DFLAG=0x1F7 %s -o xcoff64.o11 12## Test default -X option when creating a new archive.13# RUN: env -u OBJECT_MODE llvm-ar -q -c archive-default.a xcoff32.o elf32.o xcoff64.o elf64.o 2>&1 | \14# RUN: FileCheck %s --check-prefixes=WARN-XCOFF64,WARN-ELF6415# RUN: llvm-ar -t -Xany archive-default.a | \16# RUN: FileCheck %s --check-prefixes=OBJ3217 18## Test -X32 option when creating a new archive. 19# RUN: llvm-ar -q -c -X 32 archive-32.a xcoff32.o elf32.o xcoff64.o elf64.o 2>&1 | \20# RUN: FileCheck %s --check-prefixes=WARN-XCOFF64,WARN-ELF6421# RUN: llvm-ar -t -Xany archive-32.a | \22# RUN: FileCheck %s --check-prefixes=OBJ3223 24## Test -X option will override the "OBJECT_MODE" environment variable.25# RUN: env OBJECT_MODE=64 llvm-ar -q -c -X32 archive-32-env1.a xcoff32.o elf32.o xcoff64.o elf64.o 2>&1 | \26# RUN: FileCheck %s --check-prefixes=WARN-XCOFF64,WARN-ELF6427# RUN: llvm-ar -t -Xany archive-32-env1.a | \28# RUN: FileCheck %s --check-prefixes=OBJ3229 30# RUN: env OBJECT_MODE=32_64 llvm-ar -q -c -X32 archive-32-env2.a xcoff32.o elf32.o xcoff64.o elf64.o 2>&1 | \31# RUN: FileCheck %s --check-prefixes=WARN-XCOFF64,WARN-ELF6432# RUN: llvm-ar -t -Xany archive-32-env2.a | \33# RUN: FileCheck %s --check-prefixes=OBJ3234 35# RUN: env OBJECT_MODE=any llvm-ar -q -c -X32 archive-32-env3.a xcoff32.o elf32.o xcoff64.o elf64.o 2>&1 | \36# RUN: FileCheck %s --check-prefixes=WARN-XCOFF64,WARN-ELF6437# RUN: llvm-ar -t -Xany archive-32-env3.a | \38# RUN: FileCheck %s --check-prefixes=OBJ3239 40## Test -X64 option when creating a new archive.41# RUN: llvm-ar -q -c -X 64 archive-64.a xcoff32.o elf32.o xcoff64.o elf64.o 2>&1 | \42# RUN: FileCheck %s --check-prefixes=WARN-XCOFF32,WARN-ELF3243# RUN: llvm-ar -t -Xany archive-64.a | \44# RUN: FileCheck %s --check-prefixes=OBJ6445 46## Test -X32_64 option when creating a new archive.47## RUN: llvm-ar -q -c -X32_64 archive-32_64.a xcoff32.o elf32.o xcoff64.o elf64.o48## RUN: llvm-ar -t -Xany archive-32_64.a | \49## RUN: FileCheck %s --check-prefixes=OBJ32_6450 51## Test -Xany option when creating a new archive.52# RUN: llvm-ar -q -c -Xany archive-any.a xcoff32.o elf32.o xcoff64.o elf64.o53# RUN: llvm-ar -t -Xany archive-any.a | \54# RUN: FileCheck %s --check-prefixes=OBJ32_6455 56## Test envionment "OBJECT_MODE" when creating a new archive.57# RUN: env OBJECT_MODE=32 llvm-ar -q -c archive-env32.a xcoff32.o elf32.o xcoff64.o elf64.o 2>&1 | \58# RUN: FileCheck %s --check-prefixes=WARN-XCOFF64,WARN-ELF6459# RUN: llvm-ar -t -Xany archive-env32.a | \60# RUN: FileCheck %s --check-prefixes=OBJ3261 62# RUN: env OBJECT_MODE=64 llvm-ar -q -c archive-env64.a xcoff32.o elf32.o xcoff64.o elf64.o 2>&1 | \63# RUN: FileCheck %s --check-prefixes=WARN-XCOFF32,WARN-ELF3264# RUN: llvm-ar -t -Xany archive-env64.a | \65# RUN: FileCheck %s --check-prefixes=OBJ6466 67# RUN: env OBJECT_MODE=32_64 llvm-ar -q -c archive-env32_64.a xcoff32.o elf32.o xcoff64.o elf64.o68# RUN: llvm-ar -t -Xany archive-env32_64.a | \69# RUN: FileCheck %s --check-prefixes=OBJ32_6470 71# RUN: env OBJECT_MODE=any llvm-ar -q -c archive-envany.a xcoff32.o elf32.o xcoff64.o elf64.o72# RUN: llvm-ar -t -Xany archive-envany.a | \73# RUN: FileCheck %s --check-prefixes=OBJ32_6474 75## Test -X option for print operation.76# RUN: env -u OBJECT_MODE llvm-ar -t archive-any.a | \77# RUN: FileCheck %s --check-prefixes=OBJ3278 79# RUN: llvm-ar -t -X32 archive-any.a | \80# RUN: FileCheck %s --check-prefixes=OBJ3281 82# RUN: llvm-ar -t -X64 archive-any.a | \83# RUN: FileCheck %s --check-prefixes=OBJ6484 85# RUN: llvm-ar -t -X32_64 archive-any.a | \86# RUN: FileCheck %s --check-prefixes=OBJ32_6487 88# RUN: llvm-ar -t -Xany archive-any.a | \89# RUN: FileCheck %s --check-prefixes=OBJ32_6490 91## Test -X option for extract operation.92# RUN: llvm-ar --output=32 -x -X32 archive-any.a93# RUN: cmp xcoff32.o 32/xcoff32.o94# RUN: cmp elf32.o 32/elf32.o95# RUN: not ls 32/coff64.o96# RUN: not ls 32/elf64.o97 98# RUN: llvm-ar --output=64 -x -X64 archive-any.a99# RUN: cmp xcoff64.o 64/xcoff64.o100# RUN: cmp elf64.o 64/elf64.o101# RUN: not ls 64/xcoff32.o102# RUN: not ls 64/elf32.o103 104# RUN: llvm-ar --output=32_64 -x -X32_64 archive-any.a105# RUN: cmp xcoff32.o 32_64/xcoff32.o106# RUN: cmp elf32.o 32_64/elf32.o107# RUN: cmp xcoff64.o 32_64/xcoff64.o108# RUN: cmp elf64.o 32_64/elf64.o109 110# RUN: llvm-ar --output=any -x -Xany archive-any.a111# RUN: cmp xcoff32.o any/xcoff32.o112# RUN: cmp elf32.o any/elf32.o113# RUN: cmp xcoff64.o any/xcoff64.o114# RUN: cmp elf64.o any/elf64.o115 116## Extract a 64-bit object file with option -X32 (or default object mode).117# RUN: env -u OBJECT_MODE not llvm-ar --output=err64 -x archive-any.a xcoff64.o 2>&1 | \118# RUN: FileCheck %s -DFILE=xcoff64.o --check-prefixes=ERR64119# RUN: not llvm-ar --output=err64 -x -X32 archive-any.a xcoff64.o 2>&1 | \120# RUN: FileCheck %s -DFILE=xcoff64.o --check-prefixes=ERR64121 122# ERR64: llvm-ar: error: '[[FILE]]' was not found123# RUN: not ls err64/xcoff64.o124 125## Extract a 32-bit object file with option -X64.126# RUN: not llvm-ar --output=err32 -x -X64 archive-any.a xcoff32.o 2>&1 | \127# RUN: FileCheck %s -DFILE=xcoff32.o --check-prefixes=ERR32128 129# ERR32: llvm-ar: error: '[[FILE]]' was not found130# RUN: not ls err32/xcoff32.o131 132## Test deleting an object file from a big archive file.133# RUN: cp archive-any.a archive.a134# RUN: llvm-ar -d -X32 archive.a xcoff64.o elf64.o135# RUN: llvm-ar -t -Xany archive.a | \136# RUN: FileCheck %s --check-prefixes=OBJ32_64137 138# RUN: cp archive-any.a archive.a139# RUN: llvm-ar -d -X64 archive.a xcoff64.o elf64.o140# RUN: llvm-ar -t -Xany archive.a | \141# RUN: FileCheck %s --check-prefixes=OBJ32142 143# RUN: cp archive-any.a archive.a144# RUN: llvm-ar -d -Xany archive.a xcoff64.o elf64.o145# RUN: llvm-ar -t -Xany archive.a | \146# RUN: FileCheck %s --check-prefixes=OBJ32147 148# Test replace/insert an object file in a big archive file.149# RUN: cp xcoff32.o xcoff.o150# RUN: llvm-ar -q -c archive-rep.a xcoff.o151 152## xcoff.o is a 64-bit object file here.153# RUN: yaml2obj --docnum=2 -DFLAG=0x1F7 %s -o xcoff.o154 155## Without -X64, -X32_64 or -Xany, nothing changed here,156## since xcoff.o is a 64-bit object file in command line, but157## the xcoff.o member in archive-rep.a is a 32-bit object file.158# RUN: env -u OBJECT_MODE llvm-ar -r archive-rep.a xcoff.o159# RUN: llvm-ar -t -Xany archive-rep.a | \160# RUN: FileCheck %s --check-prefixes=REP161# RUN: llvm-nm -Xany --print-armap archive-rep.a | \162# RUN: FileCheck %s --check-prefixes=SYM32163 164## With options -X64, -X32_64 or -Xany, the old 32-bit xcoff.o165## member is still in the archive166## and a new 64-bit object file xcoff.o is added to the archive.167# RUN: llvm-ar -r -X64 archive-rep.a xcoff.o168# RUN: llvm-ar -t -Xany archive-rep.a | \169# RUN: FileCheck %s --check-prefixes=REP,REP-DUP170# RUN: llvm-nm -Xany --print-armap archive-rep.a | \171# RUN: FileCheck %s --check-prefixes=SYM32_64172 173# REP: xcoff.o174# REP-DUP-NEXT: xcoff.o175# REP-EMPTY: 176 177## Test move member.178# RUN: cp archive-any.a archive.a179## Do not move 64-bit object without options -X64, -X32_64, Xany.180# RUN: env -u OBJECT_MODE llvm-ar -ma elf32.o archive.a xcoff64.o 2>&1 | \181# RUN: FileCheck %s --check-prefix=WARN-XCOFF64182 183# RUN: llvm-ar -t -Xany archive.a | \184# RUN: FileCheck %s --check-prefixes=OBJ32_64185 186## Do not move 32-bit object with -X64.187# RUN: llvm-ar -ma -X64 elf64.o archive.a xcoff32.o 2>&1 | \188# RUN: FileCheck %s --check-prefix=WARN-XCOFF32189 190# WARN-XCOFF32: warning: 'xcoff32.o' is not valid with the current object file mode191# WARN-XCOFF64: warning: 'xcoff64.o' is not valid with the current object file mode192# WARN-ELF32: warning: 'elf32.o' is not valid with the current object file mode193# WARN-ELF64: warning: 'elf64.o' is not valid with the current object file mode194 195# RUN: llvm-ar -ma -X64 elf64.o archive.a xcoff64.o196# RUN: llvm-ar -t -Xany archive.a | \197# RUN: FileCheck %s --check-prefixes=MOVE64198 199# RUN: cp archive-any.a archive.a200# RUN: llvm-ar -ma -X32_64 elf64.o archive.a xcoff64.o201# RUN: llvm-ar -t -Xany archive.a | \202# RUN: FileCheck %s --check-prefixes=MOVE64203 204# RUN: cp archive-any.a archive.a205# RUN: llvm-ar -ma -Xany elf64.o archive.a xcoff64.o206# RUN: llvm-ar -t -Xany archive.a | \207# RUN: FileCheck %s --check-prefixes=MOVE64208 209# MOVE64: xcoff32.o210# MOVE64-NEXT: elf32.o211# MOVE64-NEXT: elf64.o212# MOVE64-NEXT: xcoff64.o213# MOVE64-EMPTY:214 215# RUN: cp archive-any.a archive.a216# RUN: llvm-ar -ma elf32.o archive.a xcoff32.o217# RUN: llvm-ar -t -Xany archive.a | \218# RUN: FileCheck %s --check-prefixes=MOVE32219 220# RUN: cp archive-any.a archive.a221# RUN: llvm-ar -ma -X32 elf32.o archive.a xcoff32.o222# RUN: llvm-ar -t -Xany archive.a | \223# RUN: FileCheck %s --check-prefixes=MOVE32224 225# RUN: cp archive-any.a archive.a226# RUN: llvm-ar -ma -X32_64 elf32.o archive.a xcoff32.o227# RUN: llvm-ar -t -Xany archive.a | \228# RUN: FileCheck %s --check-prefixes=MOVE32229 230# RUN: cp archive-any.a archive.a231# RUN: llvm-ar -ma -Xany elf32.o archive.a xcoff32.o232# RUN: llvm-ar -t -Xany archive.a | \233# RUN: FileCheck %s --check-prefixes=MOVE32234 235# MOVE32: elf32.o236# MOVE32-NEXT: xcoff32.o237# MOVE32-NEXT: xcoff64.o238# MOVE32-NEXT: elf64.o239# MOVE32-EMPTY:240 241## Move after a file with a bitness that doesn't match the object mode.242# RUN: env -u OBJECT_MODE not llvm-ar -ma xcoff64.o archive-any.a xcoff32.o 2>&1 | \243# RUN: FileCheck %s --check-prefixes=ERR-INSERT-POINT244 245# RUN: not llvm-ar -X32 -ma xcoff64.o archive-any.a xcoff32.o 2>&1 | \246# RUN: FileCheck %s --check-prefixes=ERR-INSERT-POINT247 248# RUN: not llvm-ar -X64 -ma xcoff32.o archive-any.a xcoff64.o 2>&1 | \249# RUN: FileCheck %s --check-prefixes=ERR-INSERT-POINT250 251# ERR-INSERT-POINT: error: insertion point not found252 253## Test move operation for archive when there are two object files with 254## the same name, but different bitness in archive.255## There are two files named xcoff.o in archive-rep.a (the first one in256## the archive is 32-bit, the second one is 64-bit).257# RUN: cp archive-rep.a archive-rep-mov32.a258# RUN: llvm-ar -Xany -q archive-rep-mov32.a elf32.o elf64.o259## Move elf32.o to after the 32-bit xcoff.o.260# RUN: llvm-ar -X32 -ma xcoff.o archive-rep-mov32.a elf32.o261# RUN: llvm-ar -t -Xany archive-rep-mov32.a | \262# RUN: FileCheck %s --check-prefixes=MOVE32-DUP263 264# MOVE32-DUP: xcoff.o265# MOVE32-DUP-NEXT: elf32.o266# MOVE32-DUP-NEXT: xcoff.o267# MOVE32-DUP-NEXT: elf64.o268 269# RUN: cp archive-rep.a archive-rep-mov64.a270# RUN: llvm-ar -Xany -q archive-rep-mov64.a elf32.o elf64.o271## Move elf64.o to after the 64-bit xcoff.o.272# RUN: llvm-ar -X64 -ma xcoff.o archive-rep-mov64.a elf64.o273# RUN: llvm-ar -t -Xany archive-rep-mov64.a | \274# RUN: FileCheck %s --check-prefixes=MOVE64-DUP275 276# MOVE64-DUP: xcoff.o277# MOVE64-DUP-NEXT: xcoff.o278# MOVE64-DUP-NEXT: elf64.o279# MOVE64-DUP-NEXT: elf32.o280 281# OBJ32: xcoff32.o282# OBJ32-NEXT: elf32.o283# OBJ32-EMPTY:284 285# OBJ64: xcoff64.o286# OBJ64-NEXT: elf64.o287# OBJ64-EMPTY:288 289# OBJ32_64: xcoff32.o290# OBJ32_64-NEXT: elf32.o291# OBJ32_64-NEXT: xcoff64.o292# OBJ32_64-NEXT: elf64.o293# OBJ32_64-EMPTY:294 295# SYM32: var_0x1DF296# SYM32-NOT: var_0x1F7297 298# SYM32_64: var_0x1DF299# SYM32_64: var_0x1F7300 301## Test -X option with other output formats. 302 303# RUN: llvm-as -o 32.bc %p/Inputs/bitcode-sym32.ll304# RUN: llvm-as -o 64.bc %p/Inputs/bitcode-sym64.ll305# RUN: yaml2obj --docnum=3 %s -o macho32.o306# RUN: yaml2obj --docnum=4 %s -o macho64.o307# RUN: yaml2obj --docnum=5 %s -o wasm.o308# RUN: yaml2obj --docnum=6 %s -o coff.o309 310# RUN: env -u OBJECT_MODE llvm-ar -q -c archive-other32.a coff.o 32.bc 64.bc wasm.o macho32.o macho64.o 2>&1 | \311# RUN: FileCheck %s --check-prefixes=WARN-64312# RUN: llvm-ar -t -Xany archive-other32.a | \313# RUN: FileCheck %s --check-prefixes=OTHER32314 315# WARN-64: warning: '64.bc' is not valid with the current object file mode316# WARN-64-NEXT: warning: 'macho64.o' is not valid with the current object file mode317 318# OTHER32: coff.o319# OTHER32-NEXT: 32.bc320# OTHER32-NEXT: wasm.o321# OTHER32-NEXT: macho32.o322# OTHER32-EMPTY:323 324# RUN: llvm-ar -q -c -X64 archive-other64.a coff.o 32.bc 64.bc wasm.o macho32.o macho64.o 2>&1 | \325# RUN: FileCheck %s --check-prefixes=WARN-32326# RUN: llvm-ar -t -Xany archive-other64.a | \327# RUN: FileCheck %s --check-prefixes=OTHER64328 329# WARN-32: warning: 'coff.o' is not valid with the current object file mode330# WARN-32-NEXT: warning: '32.bc' is not valid with the current object file mode331# WARN-32-NEXT: warning: 'wasm.o' is not valid with the current object file mode332# WARN-32-NEXT: warning: 'macho32.o' is not valid with the current object file mode333 334# OTHER64: 64.bc335# OTHER64-NEXT: macho64.o336# OTHER64-EMPTY:337 338 339--- !ELF340FileHeader:341 Class: [[CLASS]]342 Data: ELFDATA2LSB343 Type: ET_REL344Symbols:345 - Name: [[CLASS]]_var346 347--- !XCOFF348FileHeader:349 MagicNumber: [[FLAG]]350Symbols:351 - Name: var_[[FLAG]]352 353--- !mach-o354FileHeader:355 magic: 0xFEEDFACE356 cputype: 0x00000007357 cpusubtype: 0x00000003358 filetype: 0x00000001359 ncmds: 0360 sizeofcmds: 0361 flags: 0x00002000362 363## mach-o 64 bit364--- !mach-o365FileHeader:366 magic: 0xFEEDFACF367 cputype: 0x0100000C368 cpusubtype: 0x00000000369 filetype: 0x00000001370 ncmds: 0371 sizeofcmds: 0372 flags: 0x00000000373 reserved: 0x00000000374 375--- !WASM376FileHeader:377 Version: 0x00000001378 379--- !COFF380header:381 Machine: IMAGE_FILE_MACHINE_ARMNT382 Characteristics: [ ]383sections:384symbols:385