1## Test the alignment of XCOFF object files in the big archive format. 2 3# RUN: rm -rf %t && mkdir %t 4# RUN: cd %t 5 6# RUN: yaml2obj --docnum=1 -DFLAG=0x1DF -DSECNAME=.data %s -o t32_1.o 7# RUN: yaml2obj --docnum=1 -DFLAG=0x1F7 -DSECNAME=.data %s -o t64_1.o 8# RUN: yaml2obj --docnum=1 -DFLAG=0x1DF -DSECNAME=.text %s -o t32_2.o 9# RUN: yaml2obj --docnum=1 -DFLAG=0x1F7 -DSECNAME=.text %s -o t64_2.o 10# RUN: yaml2obj --docnum=2 -DFLAG=0x1DF %s -o t32_nomaxdata_text.o 11# RUN: yaml2obj --docnum=2 -DFLAG=0x1F7 %s -o t64_nomaxdata_text.o 12# RUN: yaml2obj --docnum=3 -DFLAG=0x1DF %s -o t32_maxdata_text.o 13# RUN: yaml2obj --docnum=3 -DFLAG=0x1F7 %s -o t64_maxdata_text.o 14# RUN: yaml2obj --docnum=4 -DFLAG=0x1DF %s -o t32_noloader.o 15# RUN: yaml2obj --docnum=4 -DFLAG=0x1F7 %s -o t64_noloader.o 16# RUN: yaml2obj --docnum=5 -DFLAG=0x1DF %s -o t32_excess.o 17# RUN: yaml2obj --docnum=5 -DFLAG=0x1F7 %s -o t64_excess.o 18 19# RUN: echo -e "import sys\nf=open(sys.argv[1],\"rb\");f.seek(int(sys.argv[2]));print(f.read(2));f.close()" > print_magic.py 20 21## Test that the content of an XCOFF object file, which has an auxiliary header, 22## is aligned in a big archive based on the content of auxiliary header. 23# RUN: env OBJECT_MODE=32_64 llvm-ar -q t_aux.a t32_nomaxdata_text.o t64_nomaxdata_text.o t32_maxdata_text.o t64_maxdata_text.o t32_noloader.o t64_noloader.o t32_excess.o t64_excess.o 24## The content of t32_nomaxdata_text, t64_nomaxdata_text.o aligned at 2. 25# RUN: %python print_magic.py t_aux.a 262 | FileCheck --check-prefix=MAGIC32 %s 26# RUN: %python print_magic.py t_aux.a 528 | FileCheck --check-prefix=MAGIC64 %s 27## The content of t32_maxdata_text.o, t64_maxdata_text.o aligned at 2^8. 28# RUN: %python print_magic.py t_aux.a 1024 | FileCheck --check-prefix=MAGIC32 %s 29# RUN: %python print_magic.py t_aux.a 1536 | FileCheck --check-prefix=MAGIC64 %s 30## The content of t32_noloader.o, t64_noloader.o aligned at 2. 31# RUN: %python print_magic.py t_aux.a 1870 | FileCheck --check-prefix=MAGIC32 %s 32# RUN: %python print_magic.py t_aux.a 2130 | FileCheck --check-prefix=MAGIC64 %s 33## The content of t32_excess.o aligned at word. 34# RUN: %python print_magic.py t_aux.a 2464 | FileCheck --check-prefix=MAGIC32 %s 35## The content of t64_excess.o aligned at 2^12. 36# RUN: %python print_magic.py t_aux.a 4096 | FileCheck --check-prefix=MAGIC64 %s 37 38## Test that the content of an XCOFF object file, which does not have an auxiliary 39## header, is aligned at 2 in a big archive. 40# RUN: env OBJECT_MODE=32_64 llvm-ar -q t3.a t32_1.o t64_1.o t32_2.o t64_2.o 41# # RUN: %python print_magic.py t3.a 250 | FileCheck --check-prefix=MAGIC32 %s 42# # RUN: %python print_magic.py t3.a 432 | FileCheck -check-prefix=MAGIC64 %s 43# # RUN: %python print_magic.py t3.a 650 | FileCheck --check-prefix=MAGIC32 %s 44# # RUN: %python print_magic.py t3.a 832 | FileCheck -check-prefix=MAGIC64 %s 45 46# MAGIC64: b'\x01\xf7' 47# MAGIC32: b'\x01\xdf' 48 49--- !XCOFF 50FileHeader: 51 MagicNumber: [[FLAG]] 52Sections: 53 - Name: [[SECNAME]] 54 Flags: [ STYP_DATA ] 55 56## The auxiliary header has neither the MaxAlignOfData nor MaxAlignOfText field. 57--- !XCOFF 58FileHeader: 59 MagicNumber: [[FLAG]] 60 AuxiliaryHeaderSize: 12 61AuxiliaryHeader: 62 Magic: 0x10B 63 SecNumOfLoader: 1 64Sections: 65 - Name: .text 66 Flags: [ STYP_DATA ] 67 68## The auxiliary header has both MaxAlignOfData and MaxAlignOfText fields. 69--- !XCOFF 70FileHeader: 71 MagicNumber: [[FLAG]] 72 AuxiliaryHeaderSize: 48 73AuxiliaryHeader: 74 Magic: 0x10B 75 SecNumOfLoader: 1 76 MaxAlignOfText: 6 77 MaxAlignOfData: 8 78Sections: 79 - Name: .text 80 Flags: [ STYP_DATA ] 81 82## The auxiliary header does not have a loader section. 83--- !XCOFF 84FileHeader: 85 MagicNumber: [[FLAG]] 86 AuxiliaryHeaderSize: 34 87AuxiliaryHeader: 88 Magic: 0x10B 89 SecNumOfLoader: 0 90 MaxAlignOfText: 14 91 MaxAlignOfData: 8 92Sections: 93 - Name: .text 94 Flags: [ STYP_DATA ] 95 96## The auxiliary header has both MaxAlignOfData and MaxAlignOfText fields 97## but max(MaxAlignOfData, MaxAlignOfText) exceeds the page size(2^12). 98--- !XCOFF 99FileHeader: 100 MagicNumber: [[FLAG]] 101 AuxiliaryHeaderSize: 48 102AuxiliaryHeader: 103 Magic: 0x10B 104 SecNumOfLoader: 1 105 MaxAlignOfText: 14 106 MaxAlignOfData: 8 107Sections: 108 - Name: .text 109 Flags: [ STYP_DATA ] 110