brintos

brintos / llvm-project-archived public Read only

0
0
Text · 5.6 KiB · 2caab80 Raw
154 lines · plain
1## Show that if --only-section is given, llvm-objcopy removes all sections2## except ones specified in the option.3 4# RUN: yaml2obj %s -o %t5 6## Specify all sections. The output file should be the same as the input.7# RUN: llvm-objcopy -j __TEXT,__text -j __DATA,__data -j __TEXT,__const %t %t28# RUN: cmp %t %t29 10## Specify one section. The output file should contain only that section.11# RUN: llvm-objcopy --only-section __TEXT,__text %t %t312# RUN: llvm-readobj --sections --section-data --macho-segment %t3 \13# RUN:   | FileCheck %s --check-prefix=ONLY-TEXT-SECTION14 15# ONLY-TEXT-SECTION:      Sections [16# ONLY-TEXT-SECTION-NEXT:   Section {17# ONLY-TEXT-SECTION-NEXT:     Index: 018# ONLY-TEXT-SECTION-NEXT:     Name: __text (5F 5F 74 65 78 74 00 00 00 00 00 00 00 00 00 00)19# ONLY-TEXT-SECTION-NEXT:     Segment: __TEXT (5F 5F 54 45 58 54 00 00 00 00 00 00 00 00 00 00)20# ONLY-TEXT-SECTION-NEXT:     Address: 0x021# ONLY-TEXT-SECTION-NEXT:     Size: 0x422# ONLY-TEXT-SECTION-NEXT:     Offset: 18423# ONLY-TEXT-SECTION-NEXT:     Alignment: 024# ONLY-TEXT-SECTION-NEXT:     RelocationOffset: 0x025# ONLY-TEXT-SECTION-NEXT:     RelocationCount: 026# ONLY-TEXT-SECTION-NEXT:     Type: Regular (0x0)27# ONLY-TEXT-SECTION-NEXT:     Attributes [ (0x800004)28# ONLY-TEXT-SECTION-NEXT:       PureInstructions (0x800000)29# ONLY-TEXT-SECTION-NEXT:       SomeInstructions (0x4)30# ONLY-TEXT-SECTION-NEXT:     ]31# ONLY-TEXT-SECTION-NEXT:     Reserved1: 0x032# ONLY-TEXT-SECTION-NEXT:     Reserved2: 0x033# ONLY-TEXT-SECTION-NEXT:     Reserved3: 0x034# ONLY-TEXT-SECTION-NEXT:     SectionData (35# ONLY-TEXT-SECTION-NEXT:       0000: AABBCCDD                             |....|36# ONLY-TEXT-SECTION-NEXT:     )37# ONLY-TEXT-SECTION-NEXT:   }38# ONLY-TEXT-SECTION-NEXT: ]39# ONLY-TEXT-SECTION-NEXT: Segment {40# ONLY-TEXT-SECTION-NEXT:   Cmd: LC_SEGMENT_6441# ONLY-TEXT-SECTION-NEXT:   Name:42# ONLY-TEXT-SECTION-NEXT:   Size: 15243# ONLY-TEXT-SECTION-NEXT:   vmaddr: 0x044# ONLY-TEXT-SECTION-NEXT:   vmsize: 0x445# ONLY-TEXT-SECTION-NEXT:   fileoff: 18446# ONLY-TEXT-SECTION-NEXT:   filesize: 447# ONLY-TEXT-SECTION-NEXT:   maxprot: rwx48# ONLY-TEXT-SECTION-NEXT:   initprot: rwx49# ONLY-TEXT-SECTION-NEXT:   nsects: 150# ONLY-TEXT-SECTION-NEXT:   flags: 0x051# ONLY-TEXT-SECTION-NEXT: }52 53## Remove all sections if the specified section name is not present in the input.54# RUN: llvm-objcopy --only-section __TEXT,__nonexistent %t %t4 2>&155# RUN: llvm-readobj --sections --section-data --macho-segment %t4 \56# RUN:   | FileCheck %s --check-prefix=NONEXISTENT-SECTION57 58# NONEXISTENT-SECTION:      Sections [59# NONEXISTENT-SECTION-NEXT: ]60# NONEXISTENT-SECTION-NEXT: Segment {61# NONEXISTENT-SECTION-NEXT:   Cmd: LC_SEGMENT_6462# NONEXISTENT-SECTION-NEXT:   Name:63# NONEXISTENT-SECTION-NEXT:   Size: 7264# NONEXISTENT-SECTION-NEXT:   vmaddr: 0x065# NONEXISTENT-SECTION-NEXT:   vmsize: 0x066# NONEXISTENT-SECTION-NEXT:   fileoff: 10467# NONEXISTENT-SECTION-NEXT:   filesize: 068# NONEXISTENT-SECTION-NEXT:   maxprot: rwx69# NONEXISTENT-SECTION-NEXT:   initprot: rwx70# NONEXISTENT-SECTION-NEXT:   nsects: 071# NONEXISTENT-SECTION-NEXT:   flags: 0x072# NONEXISTENT-SECTION-NEXT: }73 74## Use wildcard to specify all sections under the __TEXT segment.75# RUN: llvm-objcopy --only-section "__TEXT,*" %t %t5 2>&176# RUN: llvm-readobj --file-header --sections %t5 \77# RUN:   | FileCheck %s --check-prefix=WILDCARD78 79## Make sure that it doesn't care about the segment/section name separator ",".80# RUN: llvm-objcopy --only-section "__TEXT*" %t %t6 2>&181# RUN: cmp %t5 %t682 83# WILDCARD:      NumOfLoadCommands: 184# WILDCARD:      Sections [85# WILDCARD:        Index: 086# WILDCARD-NEXT:   Name: __text (5F 5F 74 65 78 74 00 00 00 00 00 00 00 00 00 00)87# WILDCARD:        Index: 188# WILDCARD-NEXT:   Name: __const (5F 5F 63 6F 6E 73 74 00 00 00 00 00 00 00 00 00)89# WILDCARD-NOT:    Index: 290# WILDCARD:      ]91 92--- !mach-o93FileHeader:94  magic:           0xFEEDFACF95  cputype:         0x0100000796  cpusubtype:      0x0000000397  filetype:        0x0000000198  ncmds:           199  sizeofcmds:      312100  flags:           0x00002000101  reserved:        0x00000000102LoadCommands:103  - cmd:             LC_SEGMENT_64104    cmdsize:         312105    segname:         ''106    vmaddr:          0107    vmsize:          12108    fileoff:         344109    filesize:        12110    maxprot:         7111    initprot:        7112    nsects:          3113    flags:           0114    Sections:115      - sectname:        __text116        segname:         __TEXT117        addr:            0x0000000000000000118        content:         'AABBCCDD'119        size:            4120        offset:          344121        align:           0122        reloff:          0x00000000123        nreloc:          0124        flags:           0x80000400125        reserved1:       0x00000000126        reserved2:       0x00000000127        reserved3:       0x00000000128      - sectname:        __data129        segname:         __DATA130        addr:            0x0000000000000004131        content:         'DDAADDAA'132        size:            4133        offset:          348134        align:           0135        reloff:          0x00000000136        nreloc:          0137        flags:           0x00000000138        reserved1:       0x00000000139        reserved2:       0x00000000140        reserved3:       0x00000000141      - sectname:        __const142        segname:         __TEXT143        addr:            0x0000000000000008144        content:         'EEFFEEFF'145        size:            4146        offset:          352147        align:           0148        reloff:          0x00000000149        nreloc:          0150        flags:           0x00000000151        reserved1:       0x00000000152        reserved2:       0x00000000153        reserved3:       0x00000000154