brintos

brintos / llvm-project-archived public Read only

0
0
Text · 11.1 KiB · b17b149 Raw
200 lines · plain
1## This test tests the behavior of --change-section-address option.2 3# RUN: yaml2obj -DTYPE=REL %s -o %ti14 5## Basic check that the option processes wildcards and changes the address as expected.6# RUN: llvm-objcopy --change-section-address *+0x20 %ti1 %to17# RUN: llvm-readelf --section-headers %to1 | FileCheck %s --check-prefix=CHECK-ADD-ALL8 9## Check that --change-section-address alias --adjust-section-vma produces the same output as the test above.10# RUN: llvm-objcopy --adjust-section-vma *+0x20 %ti1 %to211# RUN: cmp %to1 %to212 13## Check that negative adjustment reduces the address by the specified value.14# RUN: llvm-objcopy --change-section-address .anotherone-0x30 %ti1 %to315# RUN: llvm-readelf --section-headers %to3 | FileCheck %s --check-prefix=CHECK-SUB-SECTION16 17## Check that a wildcard pattern works and only the specified sections are updated.18# RUN: llvm-objcopy --change-section-address .text*+0x20 %ti1 %to419# RUN: llvm-readelf --section-headers %to4 | FileCheck %s --check-prefix=CHECK-ADD-PATTERN20 21## Check that regex pattern can be used with --change-section-address.22# RUN: llvm-objcopy --regex --change-section-address .text.+0x20 %ti1 %to523# RUN: llvm-readelf --section-headers %to5 | FileCheck %s --check-prefix=CHECK-ADD-PATTERN24 25## Check that a section address can be set to a specific value.26# RUN: llvm-objcopy --change-section-address .text*=0x10 %ti1 %to627# RUN: llvm-readelf --section-headers %to6 | FileCheck %s --check-prefix=CHECK-SET-PATTERN28 29## Check setting that a section address can be set to the maximum possible value (UINT64_MAX).30# RUN: llvm-objcopy --change-section-address .text2=0xffffffffffffffff %ti1 %to731# RUN: llvm-readelf --section-headers %to7 | FileCheck %s --check-prefix=CHECK-MAX32 33## Check that a section address can be adjusted to the maximum possible value (UINT64_MAX).34# RUN: llvm-objcopy --change-section-address .text2+0xfffffffffffffdff %ti1 %to835# RUN: llvm-readelf --section-headers %to8 | FileCheck %s --check-prefix=CHECK-MAX36 37## Check that the section address can be adjusted to the minimum possible value (0).38# RUN: llvm-objcopy --change-section-address .text2-0x200 %ti1 %to939# RUN: llvm-readelf --section-headers %to9 | FileCheck %s --check-prefix=CHECK-ZERO40 41## Check that a section address can be adjusted by a maximum possible positive offset (UINT64_MAX).42# RUN: llvm-objcopy --change-section-address .text2=0 %ti1 %to1043# RUN: llvm-objcopy --change-section-address .text2+0xffffffffffffffff %to10 %to1144# RUN: llvm-readelf --section-headers %to11 | FileCheck %s --check-prefix=CHECK-MAX45 46## Check that a section address can be adjusted by a maximum possible negative offset (UINT64_MIN).47# RUN: llvm-objcopy --change-section-address .text2=0xffffffffffffffff %ti1 %to1248# RUN: llvm-objcopy --change-section-address .text2-0xffffffffffffffff %to12 %to1349# RUN: llvm-readelf --section-headers %to13 | FileCheck %s --check-prefix=CHECK-ZERO50 51## Check two independent changes.52# RUN: llvm-objcopy --change-section-address .text1=0x110 --change-section-address .text2=0x210 %ti1 %to1453# RUN: llvm-readelf --section-headers %to14 | FileCheck %s --check-prefix=CHECK-INDEPENDENT54 55## Check two overlapping changes.56# RUN: llvm-objcopy --change-section-address .anotherone-0x30 --change-section-address .anotherone+0x20 %ti1 %to1557# RUN: llvm-readelf --section-headers %to15 | FileCheck %s --check-prefix=CHECK-USE-LAST58 59## Check unused option.60# RUN: llvm-objcopy --change-section-address .anotherone=0x455 --change-section-address *+0x20 %ti1 %to1661# RUN: llvm-readelf --section-headers %to16 | FileCheck %s --check-prefix=CHECK-NOTSUPERSET-SET62 63## Check partial overlap (.anotherone overlaps).64# RUN: llvm-objcopy --change-section-address *+0x20 --change-section-address .anotherone=0x455 %ti1 %to1765# RUN: llvm-readelf --section-headers %to17 | FileCheck %s --check-prefix=CHECK-SUPERSET-SET66 67## Check more complex partial overlap (P1: .anotherone, .text2, P2: .text1, text2) (.text2 overlaps).68# RUN: llvm-objcopy --regex  --change-section-address  ".(text2|anotherone)+0x20" --change-section-address .text.*+0x30  %ti1 %to1869# RUN: llvm-readelf --section-headers %to18 | FileCheck %s --check-prefix=CHECK-PARTIAL-OVERLAP70 71# CHECK-ADD-ALL:          [Nr] Name              Type            Address72# CHECK-ADD-ALL:               .text173# CHECK-ADD-ALL-SAME:                                            000000000000012074# CHECK-ADD-ALL:               .text275# CHECK-ADD-ALL-SAME:                                            000000000000022076# CHECK-ADD-ALL:               .anotherone77# CHECK-ADD-ALL-SAME:                                            000000000000032078# CHECK-ADD-ALL:               =a-b+c++d79# CHECK-ADD-ALL-SAME:                                            000000000000042080# CHECK-ADD-ALL:               .strtab81# CHECK-ADD_ALL-SAME:                                            000000000000002082# CHECK-ADD-ALL:               .shstrtab83# CHECK-ADD-ALL-SAME:                                            000000000000002084 85# CHECK-SUB-SECTION:           .text186# CHECK-SUB-SECTION-SAME:                                        000000000000010087# CHECK-SUB-SECTION:           .text288# CHECK-SUB-SECTION-SAME:                                        000000000000020089# CHECK-SUB-SECTION:           .anotherone90# CHECK-SUB-SECTION-SAME:                                        00000000000002d091 92# CHECK-ADD-PATTERN:           .text193# CHECK-ADD-PATTERN-SAME:                                        000000000000012094# CHECK-ADD-PATTERN:           .text295# CHECK-ADD-PATTERN-SAME:                                        000000000000022096# CHECK-ADD-PATTERN:           .anotherone97# CHECK-ADD-PATTERN-SAME:                                        000000000000030098 99# CHECK-SET-PATTERN:           .text1100# CHECK-SET-PATTERN-SAME:                                        0000000000000010101# CHECK-SET-PATTERN:           .text2102# CHECK-SET-PATTERN-SAME:                                        0000000000000010103# CHECK-SET-PATTERN:           .anotherone104# CHECK-SET-PATTERN-SAME:                                        0000000000000300105 106# CHECK-MAX:                   .text2107# CHECK-MAX-SAME:                                                ffffffffffffffff108# CHECK-ZERO:                  .text2109# CHECK-ZERO-SAME:                                               0000000000000000110 111# CHECK-INDEPENDENT:           .text1112# CHECK-INDEPENDENT-SAME:                                        0000000000000110113# CHECK-INDEPENDENT:           .text2114# CHECK-INDEPENDENT-SAME:                                        0000000000000210115 116# CHECK-USE-LAST:              .anotherone117# CHECK-USE-LAST-SAME:                                           0000000000000320118 119# CHECK-NOTSUPERSET-SET:       .text1120# CHECK-NOTSUPERSET-SET-SAME:                                    0000000000000120121# CHECK-NOTSUPERSET-SET:       .text2122# CHECK-NOTSUPERSET-SET-SAME:                                    0000000000000220123# CHECK-NOTSUPERSET-SET:       .anotherone124# CHECK-NOTSUPERSET-SET-SAME:                                    0000000000000320125 126# CHECK-SUPERSET-SET:          .text1127# CHECK-SUPERSET-SET-SAME:                                       0000000000000120128# CHECK-SUPERSET-SET:          .text2129# CHECK-SUPERSET-SET-SAME:                                       0000000000000220130# CHECK-SUPERSET-SET:          .anotherone131# CHECK-SUPERSET-SET-SAME:                                       0000000000000455132 133# CHECK-PARTIAL-OVERLAP:        .text1134# CHECK-PARTIAL-OVERLAP-SAME:                                    0000000000000130135# CHECK-PARTIAL-OVERLAP:        .text2136# CHECK-PARTIAL-OVERLAP-SAME:                                    0000000000000230137# CHECK-PARTIAL-OVERLAP:        .anotherone138# CHECK-PARTIAL-OVERLAP-SAME:                                    0000000000000320139 140## Check overflow by 1.141# RUN: not llvm-objcopy --change-section-address .anotherone+0xfffffffffffffd00 %ti1 2>&1 | FileCheck %s --check-prefix=ERR-OVERFLOW142## Check underflow by 1.143# RUN: not llvm-objcopy --change-section-address .text2-0x201 %ti1 2>&1 | FileCheck %s --check-prefix=ERR-UNDERFLOW144## Check error when argument value is invalid as a whole.145# RUN: not llvm-objcopy --change-section-address 0 %ti1 2>&1 | FileCheck %s --check-prefix=ERR-IVALID-VAL146## Check error when the value is invalid in the argument value.147# RUN: not llvm-objcopy --change-section-address .anotherone+0c50 %ti1 2>&1 | FileCheck %s --check-prefix=ERR-NOT-INTEGER148## Check error when the value does not fit in uint64_t.149# RUN  not llvm-objcopy --change-section-address .text1=0x10000000000000000 %ti1 %to 2>&1 | FileCheck %s --chack-prefix=ERR-NOT-INTEGER150## Check error when the section pattern is missing.151# RUN: not llvm-objcopy --change-section-address =0x10 %ti1 2>&1 | FileCheck %s --check-prefix=ERR-MISSING-SECTION152## Check error when the negative adjustment value is missing.153# RUN: not llvm-objcopy --change-section-address .text1- %ti1 2>&1 | FileCheck %s --check-prefix=ERR-MISSING-VALUE-MINUS154## Check error when the positive adjustment value is missing.155# RUN: not llvm-objcopy --change-section-address .text1+ %ti1 2>&1 | FileCheck %s --check-prefix=ERR-MISSING-VALUE-PLUS156## Check error when the value to set the address to is missing.157# RUN: not llvm-objcopy --change-section-address .text1= %ti1 2>&1 | FileCheck %s --check-prefix=ERR-MISSING-VALUE-EQUAL158## Check error when the provided regex is invalid.159# RUN: not llvm-objcopy --regex --change-section-address "ab**-0x20" %ti1 2>&1 | FileCheck %s --check-prefix=ERR-MATCHER-FAILURE160 161# ERR-OVERFLOW: address 0x300 cannot be increased by 0xfffffffffffffd00. The result would overflow162# ERR-UNDERFLOW: address 0x200 cannot be decreased by 0x201. The result would underflow163# ERR-IVALID-VAL: error: bad format for --change-section-address: argument value 0 is invalid. See --help164# ERR-NOT-INTEGER: error: bad format for --change-section-address: value after + is 0c50 when it should be a 64-bit integer165# ERR-MISSING-SECTION: error: bad format for --change-section-address: missing section pattern to apply address change to166# ERR-MISSING-VALUE-MINUS: error: bad format for --change-section-address: missing value of offset after '-'167# ERR-MISSING-VALUE-PLUS: error: bad format for --change-section-address: missing value of offset after '+'168# ERR-MISSING-VALUE-EQUAL: error: bad format for --change-section-address: missing address value after '='169# ERR-MATCHER-FAILURE: error: cannot compile regular expression 'ab**': repetition-operator operand invalid170 171--- !ELF172FileHeader:173  Class:           ELFCLASS64174  Data:            ELFDATA2LSB175  Type:            ET_[[TYPE]]176Sections:177  - Name:          .text1178    Type:          SHT_PROGBITS179    Size:          0x100180    Address:       0x100181  - Name:          .text2182    Type:          SHT_PROGBITS183    Size:          0x100184    Address:       0x200185  - Name:          .anotherone186    Type:          SHT_PROGBITS187    Size:          0x100188    Address:       0x300189  - Name:          =a-b+c++d190    Type:          SHT_PROGBITS191    Size:          0x100192    Address:       0x400193 194# RUN: yaml2obj -DTYPE=EXEC %s -o %ti2195 196## Input file is not ET_REL197# RUN: not llvm-objcopy --change-section-address *+0x20 %ti2 2>&1 | FileCheck %s --check-prefix=ERR-FILE-TYPE198 199# ERR-FILE-TYPE: cannot change section address in a non-relocatable file200