110 lines · plain
1## Test the alignment of XCOFF object files in the big archive format.2 3# RUN: rm -rf %t && mkdir %t4# RUN: cd %t5 6# RUN: yaml2obj --docnum=1 -DFLAG=0x1DF -DSECNAME=.data %s -o t32_1.o7# RUN: yaml2obj --docnum=1 -DFLAG=0x1F7 -DSECNAME=.data %s -o t64_1.o8# RUN: yaml2obj --docnum=1 -DFLAG=0x1DF -DSECNAME=.text %s -o t32_2.o9# RUN: yaml2obj --docnum=1 -DFLAG=0x1F7 -DSECNAME=.text %s -o t64_2.o10# RUN: yaml2obj --docnum=2 -DFLAG=0x1DF %s -o t32_nomaxdata_text.o11# RUN: yaml2obj --docnum=2 -DFLAG=0x1F7 %s -o t64_nomaxdata_text.o12# RUN: yaml2obj --docnum=3 -DFLAG=0x1DF %s -o t32_maxdata_text.o13# RUN: yaml2obj --docnum=3 -DFLAG=0x1F7 %s -o t64_maxdata_text.o14# RUN: yaml2obj --docnum=4 -DFLAG=0x1DF %s -o t32_noloader.o15# RUN: yaml2obj --docnum=4 -DFLAG=0x1F7 %s -o t64_noloader.o16# RUN: yaml2obj --docnum=5 -DFLAG=0x1DF %s -o t32_excess.o17# RUN: yaml2obj --docnum=5 -DFLAG=0x1F7 %s -o t64_excess.o18 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.py20 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.o24## 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 %s26# RUN: %python print_magic.py t_aux.a 528 | FileCheck --check-prefix=MAGIC64 %s27## 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 %s29# RUN: %python print_magic.py t_aux.a 1536 | FileCheck --check-prefix=MAGIC64 %s30## 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 %s32# RUN: %python print_magic.py t_aux.a 2130 | FileCheck --check-prefix=MAGIC64 %s33## The content of t32_excess.o aligned at word.34# RUN: %python print_magic.py t_aux.a 2464 | FileCheck --check-prefix=MAGIC32 %s35## The content of t64_excess.o aligned at 2^12.36# RUN: %python print_magic.py t_aux.a 4096 | FileCheck --check-prefix=MAGIC64 %s37 38## Test that the content of an XCOFF object file, which does not have an auxiliary39## 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.o41# # RUN: %python print_magic.py t3.a 250 | FileCheck --check-prefix=MAGIC32 %s42# # RUN: %python print_magic.py t3.a 432 | FileCheck -check-prefix=MAGIC64 %s43# # RUN: %python print_magic.py t3.a 650 | FileCheck --check-prefix=MAGIC32 %s44# # RUN: %python print_magic.py t3.a 832 | FileCheck -check-prefix=MAGIC64 %s45 46# MAGIC64: b'\x01\xf7'47# MAGIC32: b'\x01\xdf'48 49--- !XCOFF50FileHeader:51 MagicNumber: [[FLAG]]52Sections:53 - Name: [[SECNAME]]54 Flags: [ STYP_DATA ]55 56## The auxiliary header has neither the MaxAlignOfData nor MaxAlignOfText field.57--- !XCOFF58FileHeader:59 MagicNumber: [[FLAG]]60 AuxiliaryHeaderSize: 1261AuxiliaryHeader:62 Magic: 0x10B63 SecNumOfLoader: 164Sections:65 - Name: .text66 Flags: [ STYP_DATA ]67 68## The auxiliary header has both MaxAlignOfData and MaxAlignOfText fields.69--- !XCOFF70FileHeader:71 MagicNumber: [[FLAG]]72 AuxiliaryHeaderSize: 4873AuxiliaryHeader:74 Magic: 0x10B75 SecNumOfLoader: 176 MaxAlignOfText: 677 MaxAlignOfData: 878Sections:79 - Name: .text80 Flags: [ STYP_DATA ]81 82## The auxiliary header does not have a loader section.83--- !XCOFF84FileHeader:85 MagicNumber: [[FLAG]]86 AuxiliaryHeaderSize: 3487AuxiliaryHeader:88 Magic: 0x10B89 SecNumOfLoader: 090 MaxAlignOfText: 1491 MaxAlignOfData: 892Sections:93 - Name: .text94 Flags: [ STYP_DATA ]95 96## The auxiliary header has both MaxAlignOfData and MaxAlignOfText fields97## but max(MaxAlignOfData, MaxAlignOfText) exceeds the page size(2^12).98--- !XCOFF99FileHeader:100 MagicNumber: [[FLAG]]101 AuxiliaryHeaderSize: 48102AuxiliaryHeader:103 Magic: 0x10B104 SecNumOfLoader: 1105 MaxAlignOfText: 14106 MaxAlignOfData: 8107Sections:108 - Name: .text109 Flags: [ STYP_DATA ]110