brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.6 KiB · cf34a9b Raw
78 lines · plain
1# REQUIRES: x862# RUN: rm -rf %t; split-file %s %t3 4# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/first.s -o %t/first.o5# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/second.s -o %t/second.o6 7# RUN: %lld -lSystem -init_offsets -undefined dynamic_lookup  %t/first.o %t/second.o -o %t/out8# RUN: llvm-otool -lv %t/out | FileCheck --check-prefix=FLAGS --implicit-check-not=__mod_init_func %s9# RUN: llvm-otool -l %t/out > %t/dump.txt10# RUN: llvm-objdump --macho --print-imm-hex --section=__TEXT,__stubs %t/out >> %t/dump.txt11# RUN: llvm-objdump --macho --syms %t/out >> %t/dump.txt12# RUN: llvm-objcopy --dump-section=__TEXT,__init_offsets=%t/section.bin %t/out13# RUN: echo "__TEXT,__init_offsets contents:" >> %t/dump.txt14# RUN: od -An -txI %t/section.bin >> %t/dump.txt15# RUN: FileCheck --check-prefix=CONTENT --implicit-check-not=_init_ptr %s < %t/dump.txt16 17## This test checks that:18## - __mod_init_func is replaced by __init_offsets.19## - __mod_init_func has type S_INIT_FUNC_OFFSETS.20## - initializers show up in the order their parent objects are specified on the21##   command line, and in the order they show up within __mod_init_func.22## - for undefined and dylib symbols, stubs are created, and the offsets point to those.23## - offsets are relative to __TEXT's address, they aren't an absolute virtual address.24## - symbols defined within __mod_init_func are ignored.25 26# FLAGS:      sectname __init_offsets27# FLAGS-NEXT:  segname __TEXT28# FLAGS-NEXT:     addr29# FLAGS-NEXT:     size 0x000000000000001030# FLAGS-NEXT:   offset31# FLAGS-NEXT:    align 2^2 (4)32# FLAGS-NEXT:   reloff 033# FLAGS-NEXT:   nreloc 034# FLAGS-NEXT:     type S_INIT_FUNC_OFFSETS35 36# CONTENT:      segname __TEXT37# CONTENT-NEXT: 0x[[#%x, TEXT:]]38 39# CONTENT:      Contents of (__TEXT,__stubs) section40# CONTENT-NEXT: [[#%x, ISNAN:]]: {{.*}} ## literal pool symbol address: ___isnan41# CONTENT-NEXT: [[#%x, UNDEF:]]: {{.*}} ## literal pool symbol address: _undefined42 43# CONTENT: SYMBOL TABLE:44# CONTENT: [[#%x, FIRST:]]  g F __TEXT,__text _first_init45# CONTENT: [[#%x, SECOND:]] g F __TEXT,__text _second_init46 47# CONTENT: __TEXT,__init_offsets contents:48# CONTENT: [[#%.8x, FIRST - TEXT]] [[#%.8x, ISNAN - TEXT]] [[#%.8x, UNDEF - TEXT]] [[#%.8x, SECOND - TEXT]]49 50#--- first.s51.globl _first_init, ___isnan, _main52.globl _init_ptr_153.text54_first_init:55  ret56_main:57  ret58 59.section __DATA,__mod_init_func,mod_init_funcs60_init_ptr_1:61.quad _first_init62.quad ___isnan63 64.subsections_via_symbols65 66#--- second.s67.globl _second_init, _undefined68.text69_second_init:70  ret71 72.section __DATA,__mod_init_func,mod_init_funcs73.quad _undefined74_init_ptr_2:75.quad _second_init76 77.subsections_via_symbols78