brintos

brintos / llvm-project-archived public Read only

0
0
Text · 17.0 KiB · 065dccb Raw
368 lines · plain
1# REQUIRES: x862# UNSUPPORTED: system-windows3# RUN: rm -rf %t; split-file %s %t4# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/test.s -o %t/test.o5# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/foo.s -o %t/foo.o6# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/no-debug.s -o %t/no-debug.o7## Set modtimes of the files for deterministic test output.8# RUN: env TZ=GMT touch -t "197001010000.16" %t/test.o9# RUN: env TZ=GMT touch -t "197001010000.32" %t/foo.o10# RUN: llvm-ar rcsU %t/foo.a %t/foo.o11 12# RUN: env ZERO_AR_DATE=0 %lld -lSystem %t/test.o %t/foo.o %t/no-debug.o -o %t/test13# RUN: llvm-objdump --section-headers %t/test > %t.out14# RUN: dsymutil -s %t/test >> %t.out15# RUN: FileCheck %s -DDIR=%t -DFOO_PATH=%t/foo.o \16# RUN:   -D#TEST_TIME=0x10 -D#FOO_TIME=0x20 --input-file %t.out17 18## Check that we emit the right modtime even when the object file is in an19## archive.20# RUN: env ZERO_AR_DATE=0 %lld -lSystem %t/test.o %t/foo.a %t/no-debug.o -o %t/test21# RUN: llvm-objdump --section-headers %t/test > %t.out22# RUN: dsymutil -s %t/test >> %t.out23# RUN: FileCheck %s -DDIR=%t -DFOO_PATH=%t/foo.a\(foo.o\) \24# RUN:   -D#TEST_TIME=0x10 -D#FOO_TIME=0x20 --input-file %t.out25 26## Check that we don't emit modtimes if ZERO_AR_DATE is set.27# RUN: env ZERO_AR_DATE=1 %lld -lSystem %t/test.o %t/foo.o %t/no-debug.o \28# RUN:     -o %t/test29# RUN: llvm-objdump --section-headers %t/test > %t.out30# RUN: dsymutil -s %t/test >> %t.out31# RUN: FileCheck %s -DDIR=%t -DFOO_PATH=%t/foo.o \32# RUN:   -D#TEST_TIME=0 -D#FOO_TIME=0 --input-file %t.out33# RUN: env %lld -lSystem %t/test.o %t/foo.a %t/no-debug.o \34# RUN:     -o %t/test35# RUN: llvm-objdump --section-headers %t/test > %t.out36# RUN: dsymutil -s %t/test >> %t.out37# RUN: FileCheck %s -DDIR=%t -DFOO_PATH=%t/foo.a\(foo.o\) \38# RUN:   -D#TEST_TIME=0 -D#FOO_TIME=0 --input-file %t.out39# RUN: env %lld -lSystem %t/test.o %t/no-debug.o \40# RUN:     -all_load %t/foo.a -o %t/test41# RUN: llvm-objdump --section-headers %t/test > %t.out42# RUN: dsymutil -s %t/test >> %t.out43# RUN: FileCheck %s -DDIR=%t -DFOO_PATH=%t/foo.a\(foo.o\) \44# RUN:   -D#TEST_TIME=0 -D#FOO_TIME=0 --input-file %t.out45# RUN: env %lld -lSystem %t/test.o %t/no-debug.o \46# RUN:     -force_load %t/foo.a -o %t/test47# RUN: llvm-objdump --section-headers %t/test > %t.out48# RUN: dsymutil -s %t/test >> %t.out49# RUN: FileCheck %s -DDIR=%t -DFOO_PATH=%t/foo.a\(foo.o\) \50# RUN:   -D#TEST_TIME=0 -D#FOO_TIME=0 --input-file %t.out51# RUN: env ZERO_AR_DATE=0 %lld -lSystem -reproducible %t/test.o %t/foo.o \52# RUN:     %t/no-debug.o -o %t/test53# RUN: llvm-objdump --section-headers %t/test > %t.out 54# RUN: dsymutil -s %t/test >> %t.out55# RUN: FileCheck %s -DDIR=%t -DFOO_PATH=%t/foo.o \56# RUN:   -D#TEST_TIME=0 -D#FOO_TIME=0 --input-file %t.out57 58## Check that we emit absolute paths to the object files in our OSO entries59## even if our inputs are relative paths.60# RUN: cd %t && env ZERO_AR_DATE=0 %lld -lSystem test.o foo.o no-debug.o -o test61# RUN: llvm-objdump --section-headers %t/test > %t.out62# RUN: dsymutil -s %t/test >> %t.out63# RUN: FileCheck %s -DDIR=%t -DFOO_PATH=%t/foo.o \64# RUN:   -D#TEST_TIME=0x10 -D#FOO_TIME=0x20 --input-file %t.out65 66## Check that we emit relative path to object files in OSO entries67## when -oso_prefix <path> is used.68# RUN: cd %t && env ZERO_AR_DATE=0 %lld -lSystem test.o foo.o no-debug.o -oso_prefix "%t" -o %t/test-rel69# RUN: dsymutil -s  %t/test-rel | grep 'N_OSO' | FileCheck %s  -D#TEST_TIME=0x10 -D#FOO_TIME=0x20 --check-prefix=REL-PATH70# RUN: cd %t && env ZERO_AR_DATE=0 %lld -lSystem test.o foo.o no-debug.o -oso_prefix "%t/" -o %t/test-rel71# RUN: dsymutil -s  %t/test-rel | grep 'N_OSO' | FileCheck %s  -D#TEST_TIME=0x10 -D#FOO_TIME=0x20 --check-prefix=REL-PATH-NO-SLASH72# RUN: cd %t && env ZERO_AR_DATE=0 %lld -lSystem test.o foo.o no-debug.o -oso_prefix "." -o %t/test-rel-dot73# RUN: dsymutil -s  %t/test-rel-dot | grep 'N_OSO' | FileCheck %s  -D#TEST_TIME=0x10 -D#FOO_TIME=0x20 --check-prefix=REL-DOT74# RUN: cd %t && env ZERO_AR_DATE=0 %lld -lSystem ./test.o ./foo.o ./no-debug.o -oso_prefix "." -o %t/test-rel-dot75# RUN: dsymutil -s  %t/test-rel-dot | grep 'N_OSO' | FileCheck %s  -D#TEST_TIME=0x10 -D#FOO_TIME=0x20 --check-prefix=REL-DOT-EXPLICIT76 77## Check that symlinks are not expanded when -oso_prefix . is used.78# RUN: mkdir -p %t/private/var/folders/tmp && ln -s private/var %t/var79# RUN: cp %t/test.o %t/foo.o %t/no-debug.o %t/private/var/folders/tmp80# RUN: env TZ=GMT touch -t "197001010000.16" %t/private/var/folders/tmp/test.o81# RUN: env TZ=GMT touch -t "197001010000.32" %t/private/var/folders/tmp/foo.o82# RUN: cd %t/var/folders/tmp && env ZERO_AR_DATE=0 %lld -lSystem test.o foo.o no-debug.o -oso_prefix "." -o test-rel-symlink83# RUN: dsymutil -s  %t/private/var/folders/tmp/test-rel-symlink | grep 'N_OSO' | FileCheck %s  -D#TEST_TIME=0x10 -D#FOO_TIME=0x20 --check-prefix=REL-DOT84# RUN: cd %t/var/folders/tmp && env ZERO_AR_DATE=0 %lld -lSystem ./test.o ./foo.o ./no-debug.o -oso_prefix "." -o test-rel-symlink85# RUN: dsymutil -s  %t/private/var/folders/tmp/test-rel-symlink | grep 'N_OSO' | FileCheck %s  -D#TEST_TIME=0x10 -D#FOO_TIME=0x20 --check-prefix=REL-DOT-EXPLICIT86 87## Check that we don't emit DWARF or stabs when -S is used88# RUN: %lld -lSystem test.o foo.o no-debug.o -S -o %t/test-no-debug89## grep returns an exit code of 1 if it cannot match the intended pattern. We90## expect to not find any entries which requires the exit code to be negated.91# RUN: llvm-nm -ap %t/test-no-debug | not grep -e ' - '92 93# RUN: cd %t && env ZERO_AR_DATE=0 %lld -lSystem test.o foo.a no-debug.o -o %t/test94# RUN: llvm-objdump --section-headers %t/test > %t.out95# RUN: dsymutil -s %t/test >> %t.out96# RUN: FileCheck %s -DDIR=%t -DFOO_PATH=%t/foo.a\(foo.o\) \97# RUN:     -D#TEST_TIME=0x10 -D#FOO_TIME=0x20 --input-file %t.out98 99# CHECK:       Sections:100# CHECK-NEXT:  Idx                Name101# CHECK-NEXT:  [[#TEXT_ID:]]      __text102# CHECK-NEXT:  [[#DATA_ID:]]      __data103# CHECK-NEXT:  [[#MORE_DATA_ID:]] more_data104# CHECK-NEXT:  [[#COMM_ID:]]      __common105# CHECK-NEXT:  [[#MORE_TEXT_ID:]] more_text106 107# CHECK:      (N_SO         ) 00                         0000   0000000000000000   '/tmp/test.cpp'108# CHECK-NEXT: (N_OSO        ) 03                         0001   [[#%.16x,TEST_TIME]] '[[DIR]]/test.o'109# REL-PATH:   (N_OSO        ) 03                         0001   [[#%.16x,TEST_TIME]] '/test.o'110# REL-PATH-NO-SLASH:  (N_OSO        ) 03                 0001   [[#%.16x,TEST_TIME]] 'test.o'111# REL-DOT:    (N_OSO        ) 03                         0001   [[#%.16x,TEST_TIME]] 'test.o'112# REL-DOT-EXPLICIT:    (N_OSO        ) 03                0001   [[#%.16x,TEST_TIME]] './test.o'113# CHECK-NEXT: (N_STSYM      ) [[#%.2d,MORE_DATA_ID + 1]] 0000   [[#%.16x,STATIC:]] '_static_var'114# CHECK-NEXT: (N_FUN        ) [[#%.2d,TEXT_ID + 1]]      0000   [[#%.16x,MAIN:]]   '_main'115# CHECK-NEXT: (N_FUN        ) 00                         0000   0000000000000006{{$}}116# CHECK-NEXT: (N_FUN        ) [[#%.2d,TEXT_ID + 1]]      0000   [[#%.16x,BAR:]]    '_bar'117# CHECK-NEXT: (N_FUN        ) 00                         0000   0000000000000000{{$}}118# CHECK-NEXT: (N_FUN        ) [[#%.2d,TEXT_ID + 1]]      0000   [[#%.16x,BAR2:]]   '_bar2'119# CHECK-NEXT: (N_FUN        ) 00                         0000   0000000000000001{{$}}120# CHECK-NEXT: (N_FUN        ) [[#%.2d,TEXT_ID + 1]]      0000   [[#%.16x,BAZ:]]    '_baz'121# CHECK-NEXT: (N_FUN        ) 00                         0000   0000000000000000{{$}}122# CHECK-NEXT: (N_FUN        ) [[#%.2d,TEXT_ID + 1]]      0000   [[#%.16x,BAZ2:]]   '_baz2'123# CHECK-NEXT: (N_FUN        ) 00                         0000   0000000000000002{{$}}124# CHECK-NEXT: (N_FUN        ) [[#%.2d,TEXT_ID + 1]]      0000   [[#%.16x,QUX:]]    '_qux'125# CHECK-NEXT: (N_FUN        ) 00                         0000   0000000000000003{{$}}126# CHECK-NEXT: (N_FUN        ) [[#%.2d,TEXT_ID + 1]]      0000   [[#%.16x,QUUX:]]   '_quux'127# CHECK-NEXT: (N_FUN        ) 00                         0000   0000000000000004{{$}}128# CHECK-NEXT: (N_GSYM       ) [[#%.2d,DATA_ID + 1]]      0000   [[#%.16x,GLOB:]]   '_global_var'129# CHECK-NEXT: (N_GSYM       ) [[#%.2d,COMM_ID + 1]]      0000   [[#%.16x,ZERO:]]   '_zero'130# CHECK-NEXT: (N_FUN        ) [[#%.2d,MORE_TEXT_ID + 1]] 0000   [[#%.16x,FUN:]]    '_fun'131# CHECK-NEXT: (N_FUN        ) 00                         0000   0000000000000001{{$}}132# CHECK-NEXT: (N_SO         ) 01                         0000   0000000000000000{{$}}133# CHECK-NEXT: (N_SO         ) 00                         0000   0000000000000000   '/foo.cpp'134# CHECK-NEXT: (N_OSO        ) 03                         0001   [[#%.16x,FOO_TIME]] '[[FOO_PATH]]'135# REL-PATH-NEXT:   (N_OSO        ) 03                    0001   [[#%.16x,FOO_TIME]] '/foo.o'136# REL-PATH-NO-SLASH-NEXT:   (N_OSO        ) 03           0001   [[#%.16x,FOO_TIME]] 'foo.o'137# REL-DOT-NEXT:    (N_OSO        ) 03                    0001   [[#%.16x,FOO_TIME]] 'foo.o'138# CHECK-NEXT: (N_FUN        ) [[#%.2d,TEXT_ID + 1]]      0000   [[#%.16x,FOO:]]    '_foo'139# CHECK-NEXT: (N_FUN        ) 00                         0000   0000000000000001{{$}}140# CHECK-NEXT: (N_SO         ) 01                         0000   0000000000000000{{$}}141# CHECK-DAG:  (     SECT    ) [[#%.2d,MORE_DATA_ID + 1]] 0000   [[#STATIC]]        '_static_var'142# CHECK-DAG:  (     SECT EXT) [[#%.2d,TEXT_ID + 1]]      0000   [[#MAIN]]          '_main'143# CHECK-DAG:  (     ABS  EXT) 00                         0000   {{[0-9af]+}}       '_abs'144# CHECK-DAG:  (     SECT EXT) [[#%.2d,TEXT_ID + 1]]      0000   [[#FOO]]           '_foo'145# CHECK-DAG:  (     SECT EXT) [[#%.2d,TEXT_ID + 1]]      0000   [[#BAR]]           '_bar'146# CHECK-DAG:  (     SECT EXT) [[#%.2d,TEXT_ID + 1]]      0000   [[#BAR2]]          '_bar2'147# CHECK-DAG:  (     SECT EXT) [[#%.2d,TEXT_ID + 1]]      0000   [[#BAZ]]           '_baz'148# CHECK-DAG:  (     SECT EXT) [[#%.2d,TEXT_ID + 1]]      0000   [[#BAZ2]]          '_baz2'149# CHECK-DAG:  (     SECT EXT) [[#%.2d,TEXT_ID + 1]]      0000   [[#QUX]]           '_qux'150# CHECK-DAG:  (     SECT EXT) [[#%.2d,TEXT_ID + 1]]      0000   [[#QUUX]]          '_quux'151# CHECK-DAG:  (     SECT EXT) [[#%.2d,DATA_ID + 1]]      0000   [[#GLOB]]          '_global_var'152# CHECK-DAG:  (     SECT EXT) [[#%.2d,COMM_ID + 1]]      0000   [[#ZERO]]          '_zero'153# CHECK-DAG:  (     SECT EXT) [[#%.2d,MORE_TEXT_ID + 1]] 0000   [[#FUN]]           '_fun'154# CHECK-DAG:  (     SECT EXT) [[#%.2d,TEXT_ID + 1]]      0000   {{[0-9a-f]+}}      '_no_debug'155# CHECK-DAG:  (       {{.*}}) {{[0-9]+}}                 0010   {{[0-9a-f]+}}      '__mh_execute_header'156# CHECK-DAG:  (       {{.*}}) {{[0-9]+}}                 0100   0000000000000000   'dyld_stub_binder'157# CHECK-EMPTY:158 159## Check that we don't attempt to emit rebase opcodes for the debug sections160## when building a PIE (since we have filtered the sections out).161# RUN: %lld -lSystem %t/test.o %t/foo.a %t/no-debug.o -o %t/test162# RUN: llvm-objdump --macho --rebase %t/test | FileCheck %s --check-prefix=PIE163# PIE:       Rebase table:164# PIE-NEXT:  segment  section            address     type165# PIE-EMPTY:166 167## Check that an absolute DW_AT_name does not have DW_AT_comp_dir prepended168## when forming N_SO.169# RUN: llvm-mc -filetype obj -triple=x86_64-apple-darwin %t/abs-path.s -o %t/abs-path.o170# RUN: %lld %t/abs-path.o -o %t/test171# RUN: llvm-objdump --section-headers %t/test > %t.out172# RUN: dsymutil -s %t/test >> %t.out173# RUN: FileCheck %s --check-prefix=ABS-PATH --input-file %t.out174# ABS-PATH:      (N_SO         ) 00      0000   0000000000000000   '/foo.cpp'175 176#--- test.s177 178## Make sure we don't create STABS entries for absolute symbols.179.globl _abs180_abs = 0x123181 182.section __DATA, __data183.globl _global_var184_global_var:185  .quad 123186 187.section __DATA, more_data188_static_var:189  .quad 123190 191.globl  _zero192.zerofill __DATA,__common,_zero,4,2193 194.text195.globl  _main, _bar, _bar2, _baz, _baz2, _qux, _quux196.alt_entry _baz197.alt_entry _qux198 199_bar:200_bar2:201  .space 1202 203_baz:204_baz2:205  .space 2206 207_main:208Lfunc_begin0:209  callq _foo210  retq211Lfunc_end0:212 213_qux:214  .space 3215 216_quux:217  .space 4218 219.section  __DWARF,__debug_str,regular,debug220  .asciz  "test.cpp"             ## string offset=0221  .asciz  "/tmp"                 ## string offset=9222.section  __DWARF,__debug_abbrev,regular,debug223Lsection_abbrev:224  .byte  1                       ## Abbreviation Code225  .byte  17                      ## DW_TAG_compile_unit226  .byte  1                       ## DW_CHILDREN_yes227  .byte  3                       ## DW_AT_name228  .byte  14                      ## DW_FORM_strp229  .byte  27                      ## DW_AT_comp_dir230  .byte  14                      ## DW_FORM_strp231  .byte  17                      ## DW_AT_low_pc232  .byte  1                       ## DW_FORM_addr233  .byte  18                      ## DW_AT_high_pc234  .byte  6                       ## DW_FORM_data4235  .byte  0                       ## EOM(1)236  .byte  0                       ## EOM(2)237  .byte  0                       ## EOM(3)238.section  __DWARF,__debug_info,regular,debug239.set Lset0, Ldebug_info_end0-Ldebug_info_start0 ## Length of Unit240  .long  Lset0241Ldebug_info_start0:242  .short  4                       ## DWARF version number243.set Lset1, Lsection_abbrev-Lsection_abbrev ## Offset Into Abbrev. Section244  .long  Lset1245  .byte  8                       ## Address Size (in bytes)246  .byte  1                       ## Abbrev [1] 0xb:0x48 DW_TAG_compile_unit247  .long  0                       ## DW_AT_name248  .long  9                       ## DW_AT_comp_dir249  .quad  Lfunc_begin0            ## DW_AT_low_pc250.set Lset3, Lfunc_end0-Lfunc_begin0     ## DW_AT_high_pc251  .long  Lset3252  .byte  0                       ## End Of Children Mark253Ldebug_info_end0:254 255.section OTHER,more_text,regular,pure_instructions256.globl _fun257_fun:258  ret259 260.subsections_via_symbols261 262#--- foo.s263.text264.globl  _foo265_foo:266Lfunc_begin0:267  retq268Lfunc_end0:269 270.section  __DWARF,__debug_str,regular,debug271  .asciz  "foo.cpp"              ## string offset=0272  .asciz  ""                     ## string offset=8273.section  __DWARF,__debug_abbrev,regular,debug274Lsection_abbrev:275  .byte  1                       ## Abbreviation Code276  .byte  17                      ## DW_TAG_compile_unit277  .byte  1                       ## DW_CHILDREN_yes278  .byte  3                       ## DW_AT_name279  .byte  14                      ## DW_FORM_strp280  .byte  27                      ## DW_AT_comp_dir281  .byte  14                      ## DW_FORM_strp282  .byte  17                      ## DW_AT_low_pc283  .byte  1                       ## DW_FORM_addr284  .byte  18                      ## DW_AT_high_pc285  .byte  6                       ## DW_FORM_data4286  .byte  0                       ## EOM(1)287  .byte  0                       ## EOM(2)288  .byte  0                       ## EOM(3)289.section  __DWARF,__debug_info,regular,debug290.set Lset0, Ldebug_info_end0-Ldebug_info_start0 ## Length of Unit291  .long  Lset0292Ldebug_info_start0:293  .short  4                       ## DWARF version number294.set Lset1, Lsection_abbrev-Lsection_abbrev ## Offset Into Abbrev. Section295  .long  Lset1296  .byte  8                       ## Address Size (in bytes)297  .byte  1                       ## Abbrev [1] 0xb:0x48 DW_TAG_compile_unit298  .long  0                       ## DW_AT_name299  .long  8                       ## DW_AT_comp_dir300  .quad  Lfunc_begin0            ## DW_AT_low_pc301.set Lset3, Lfunc_end0-Lfunc_begin0     ## DW_AT_high_pc302  .long  Lset3303  .byte  0                       ## End Of Children Mark304Ldebug_info_end0:305 306.section  __DWARF,__debug_aranges,regular,debug307ltmp1:308  .byte 0309 310.subsections_via_symbols311 312#--- no-debug.s313## This file has no debug info.314.text315.globl _no_debug316_no_debug:317  ret318 319#--- abs-path.s320.text321.globl  _main322_main:323Lfunc_begin0:324  retq325Lfunc_end0:326 327.section  __DWARF,__debug_str,regular,debug328  .asciz  "/foo.cpp"             ## string offset=0329  .asciz  "/tmp"                 ## string offset=9330.section  __DWARF,__debug_abbrev,regular,debug331Lsection_abbrev:332  .byte  1                       ## Abbreviation Code333  .byte  17                      ## DW_TAG_compile_unit334  .byte  1                       ## DW_CHILDREN_yes335  .byte  3                       ## DW_AT_name336  .byte  14                      ## DW_FORM_strp337  .byte  27                      ## DW_AT_comp_dir338  .byte  14                      ## DW_FORM_strp339  .byte  17                      ## DW_AT_low_pc340  .byte  1                       ## DW_FORM_addr341  .byte  18                      ## DW_AT_high_pc342  .byte  6                       ## DW_FORM_data4343  .byte  0                       ## EOM(1)344  .byte  0                       ## EOM(2)345  .byte  0                       ## EOM(3)346.section  __DWARF,__debug_info,regular,debug347.set Lset0, Ldebug_info_end0-Ldebug_info_start0 ## Length of Unit348  .long  Lset0349Ldebug_info_start0:350  .short  4                       ## DWARF version number351.set Lset1, Lsection_abbrev-Lsection_abbrev ## Offset Into Abbrev. Section352  .long  Lset1353  .byte  8                       ## Address Size (in bytes)354  .byte  1                       ## Abbrev [1] 0xb:0x48 DW_TAG_compile_unit355  .long  0                       ## DW_AT_name356  .long  9                       ## DW_AT_comp_dir357  .quad  Lfunc_begin0            ## DW_AT_low_pc358.set Lset3, Lfunc_end0-Lfunc_begin0     ## DW_AT_high_pc359  .long  Lset3360  .byte  0                       ## End Of Children Mark361Ldebug_info_end0:362 363.section  __DWARF,__debug_aranges,regular,debug364ltmp1:365  .byte 0366 367.subsections_via_symbols368