134 lines · plain
1# REQUIRES: x862# RUN: rm -rf %t; split-file %s %t3# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/align-empty.s -o %t/align-empty.o4# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/align-4-0.s -o %t/align-4-0.o5# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/align-4-2.s -o %t/align-4-2.o6# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/align-16-0.s -o %t/align-16-0.o7# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/align-16-2.s -o %t/align-16-2.o8# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/align-16-4.s -o %t/align-16-4.o9# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/align-16-8.s -o %t/align-16-8.o10 11## Check that we preserve the alignment of cstrings. Alignment is determined12## not by section alignment but by the number of trailing zeros of the cstring's13## address in the input object file.14 15## The non-dedup case is not particularly interesting since the null bytes don't16## get dedup'ed, meaning that the output strings get their offsets "naturally"17## preserved.18 19# RUN: %lld -dylib --no-deduplicate-strings %t/align-empty.o %t/align-4-0.o %t/align-16-0.o -o %t/align-4-0-16-020# RUN: llvm-objdump --macho --section="__TEXT,__cstring" %t/align-4-0-16-0 | \21# RUN: FileCheck %s -D#OFF1=4 -D#OFF2=1622# RUN: %lld -dylib --no-deduplicate-strings %t/align-empty.o %t/align-16-0.o %t/align-4-0.o -o %t/align-16-0-4-023# RUN: llvm-objdump --macho --section="__TEXT,__cstring" %t/align-16-0-4-0 | \24# RUN: FileCheck %s -D#OFF1=16 -D#OFF2=2025 26# RUN: %lld -dylib --no-deduplicate-strings %t/align-empty.o %t/align-4-2.o %t/align-16-0.o -o %t/align-4-2-16-027# RUN: llvm-objdump --macho --section="__TEXT,__cstring" %t/align-4-2-16-0 | \28# RUN: FileCheck %s -D#OFF1=6 -D#OFF2=1629# RUN: %lld -dylib --no-deduplicate-strings %t/align-empty.o %t/align-16-0.o %t/align-4-2.o -o %t/align-16-0-4-230# RUN: llvm-objdump --macho --section="__TEXT,__cstring" %t/align-16-0-4-2 | \31# RUN: FileCheck %s -D#OFF1=16 -D#OFF2=2232 33# RUN: %lld -dylib --no-deduplicate-strings %t/align-empty.o %t/align-4-0.o %t/align-16-2.o -o %t/align-4-0-16-234# RUN: llvm-objdump --macho --section="__TEXT,__cstring" %t/align-4-0-16-2 | \35# RUN: FileCheck %s -D#OFF1=4 -D#OFF2=1836# RUN: %lld -dylib --no-deduplicate-strings %t/align-empty.o %t/align-16-2.o %t/align-4-0.o -o %t/align-16-2-4-037# RUN: llvm-objdump --macho --section="__TEXT,__cstring" %t/align-16-2-4-0 | \38# RUN: FileCheck %s -D#OFF1=18 -D#OFF2=2039 40# CHECK: Contents of (__TEXT,__cstring) section41# CHECK-NEXT: [[#%.16x,START:]] {{$}}42# CHECK: [[#%.16x,START+OFF1]] a{{$}}43# CHECK: [[#%.16x,START+OFF2]] a{{$}}44# CHECK-EMPTY:45 46## The dedup cases are more interesting...47 48## Same offset, different alignments => pick higher alignment49# RUN: %lld -dylib %t/align-empty.o %t/align-4-0.o %t/align-16-0.o -o %t/dedup-4-0-16-050# RUN: llvm-objdump --macho --section="__TEXT,__cstring" %t/dedup-4-0-16-0 | \51# RUN: FileCheck %s --check-prefix=DEDUP -D#OFF=1652# RUN: %lld -dylib %t/align-empty.o %t/align-16-0.o %t/align-4-0.o -o %t/dedup-16-0-4-053# RUN: llvm-objdump --macho --section="__TEXT,__cstring" %t/dedup-16-0-4-0 | \54# RUN: FileCheck %s --check-prefix=DEDUP -D#OFF=1655 56## 16 byte alignment vs 2 byte offset => align to 16 bytes57# RUN: %lld -dylib %t/align-empty.o %t/align-4-2.o %t/align-16-0.o -o %t/dedup-4-2-16-058# RUN: llvm-objdump --macho --section="__TEXT,__cstring" %t/dedup-4-2-16-0 | \59# RUN: FileCheck %s --check-prefix=DEDUP -D#OFF=1660# RUN: %lld -dylib %t/align-empty.o %t/align-16-0.o %t/align-4-2.o -o %t/dedup-16-0-4-261# RUN: llvm-objdump --macho --section="__TEXT,__cstring" %t/dedup-16-0-4-2 | \62# RUN: FileCheck %s --check-prefix=DEDUP -D#OFF=1663 64## 4 byte alignment vs 2 byte offset => align to 4 bytes65# RUN: %lld -dylib %t/align-empty.o %t/align-4-0.o %t/align-16-2.o -o %t/dedup-4-0-16-266# RUN: llvm-objdump --macho --section="__TEXT,__cstring" %t/dedup-4-0-16-2 | \67# RUN: FileCheck %s --check-prefix=DEDUP -D#OFF=468# RUN: %lld -dylib %t/align-empty.o %t/align-16-2.o %t/align-4-0.o -o %t/dedup-16-2-4-069# RUN: llvm-objdump --macho --section="__TEXT,__cstring" %t/dedup-16-2-4-0 | \70# RUN: FileCheck %s --check-prefix=DEDUP -D#OFF=471 72## Both inputs are 4-byte aligned, one via offset and the other via section alignment73# RUN: %lld -dylib %t/align-empty.o %t/align-4-0.o %t/align-16-4.o -o %t/dedup-4-0-16-474# RUN: llvm-objdump --macho --section="__TEXT,__cstring" %t/dedup-4-0-16-4 | \75# RUN: FileCheck %s --check-prefix=DEDUP -D#OFF=476# RUN: %lld -dylib %t/align-empty.o %t/align-16-4.o %t/align-4-0.o -o %t/dedup-16-4-4-077# RUN: llvm-objdump --macho --section="__TEXT,__cstring" %t/dedup-16-4-4-0 | \78# RUN: FileCheck %s --check-prefix=DEDUP -D#OFF=479 80## 8-byte offset vs 4-byte section alignment => align to 8 bytes81# RUN: %lld -dylib %t/align-empty.o %t/align-4-0.o %t/align-16-8.o -o %t/dedup-4-0-16-882# RUN: llvm-objdump --macho --section="__TEXT,__cstring" %t/dedup-4-0-16-8 | \83# RUN: FileCheck %s --check-prefix=DEDUP -D#OFF=884# RUN: %lld -dylib %t/align-empty.o %t/align-16-8.o %t/align-4-0.o -o %t/dedup-16-8-4-085# RUN: llvm-objdump --macho --section="__TEXT,__cstring" %t/dedup-16-8-4-0 | \86# RUN: FileCheck %s --check-prefix=DEDUP -D#OFF=887 88# DEDUP: Contents of (__TEXT,__cstring) section89# DEDUP-NEXT: [[#%.16x,START:]] {{$}}90# DEDUP: [[#%.16x,START+OFF]] a{{$}}91# DEDUP-EMPTY:92 93#--- align-empty.s94## We use this file to create an empty string at the start of every output95## file's .cstring section. This makes the test cases more interesting since LLD96## can't place the string "a" at the trivially-aligned zero offset.97.cstring98.p2align 299.asciz ""100 101#--- align-4-0.s102.cstring103.p2align 2104.asciz "a"105 106#--- align-4-2.s107.cstring108.p2align 2109.zero 0x2110.asciz "a"111 112#--- align-16-0.s113.cstring114.p2align 4115.asciz "a"116 117#--- align-16-2.s118.cstring119.p2align 4120.zero 0x2121.asciz "a"122 123#--- align-16-4.s124.cstring125.p2align 4126.zero 0x4127.asciz "a"128 129#--- align-16-8.s130.cstring131.p2align 4132.zero 0x8133.asciz "a"134