379 lines · plain
1## Tests that lld-macho can handle the case where personality symbols with the same name2## are both from a dylib and locally defined in an object file.3 4# REQUIRES: x865# RUN: rm -rf %t; split-file %s %t6# RUN: llvm-mc -emit-compact-unwind-non-canonical=true -filetype=obj -triple=x86_64-apple-darwin19.0.0 %t/user_2.s -o %t/user_2.o7# RUN: llvm-mc -emit-compact-unwind-non-canonical=true -filetype=obj -triple=x86_64-apple-darwin19.0.0 %t/user_3.s -o %t/user_3.o8 9## Test case for linking 3+ personaltiies (all globals) without crashing because all the non-canonical are DWARFs10# RUN: llvm-mc -emit-compact-unwind-non-canonical=false -filetype=obj -triple=x86_64-apple-darwin19.0.0 %t/user_4.s -o %t/user_4.o11 12# RUN: yaml2obj %t/combined.yaml > %t/combined.o13 14## Pre-condition: check that ___gxx_personality_v0 really is locally defined in combined.o before we proceed.15# RUN: llvm-nm %t/combined.o | grep '___gxx_personality_v0' | FileCheck %s --check-prefix=PRECHECK16# PRECHECK: {{.*}} t ___gxx_personality_v017# PRECHECK-NOT: {{.*}} U ___gxx_personality_v018# PRECHECK-NOT: {{.*}} T ___gxx_personality_v019 20## check that we can link with 4 personalities without crashing:21## ___gxx_personality_v0 (libc++.tbd), ___gxx_personality_v0(local), _personality_1, and _personality_222# RUN: %lld -lSystem -lc++ %t/user_2.o %t/combined.o -o %t/a.out23## ___gxx_personality_v0 (global), ___gxx_personality_v0(libc++.tbd), _personality_1, and _personality_224# RUN: %lld -lSystem -lc++ %t/user_3.o %t/user_2.o -o %t/b.out25## ___gxx_personality_v0 (global), ___gxx_personality_v0(local), _personality_1, and _personality_226# RUN: %lld -lSystem -dylib %t/user_3.o %t/combined.o %t/user_2.o -o %t/c.out27 28## check that we can link with 3+ personalities without crashing because29## non-canonical personalities are dwarf.30## This has ___gxx_personality_v0(global), ___gxx_personality_v0(local), and _personality_{1,2,3,4}31## Only the ___gxx_personality_v0(global) should have compact-unwind. The rest should have DWARFs.32# RUN: %lld -lSystem -lc++ %t/user_4.o %t/combined.o -o %t/d.out33 34## Postlink checks.35# RUN: llvm-nm %t/a.out | FileCheck %s --check-prefix=POSTCHECK36# POSTCHECK: {{.*}} U ___gxx_personality_v037# POSTCHECK: {{.*}} t ___gxx_personality_v038 39# RUN: llvm-objdump --macho --unwind-info --syms --indirect-symbols --bind %t/a.out | FileCheck %s --check-prefixes=A,CHECK -D#%x,OFF=0x10000000040# RUN: llvm-objdump --macho --unwind-info --syms --indirect-symbols --bind %t/b.out | FileCheck %s --check-prefixes=BC,CHECK -D#%x,OFF=0x10000000041# RUN: llvm-objdump --macho --unwind-info --syms --indirect-symbols --bind %t/c.out | FileCheck %s --check-prefixes=BC,C,CHECK -D#%x,OFF=042 43# RUN: llvm-objdump --macho --indirect-symbols --unwind-info --bind %t/d.out | FileCheck %s --check-prefixes=D -D#%x,OFF=0x10000000044 45# A: Indirect symbols for (__DATA_CONST,__got) 4 entries46# A-NEXT: address index name47# A: 0x[[#%x,GXX_PERSONALITY_LO:]] [[#]] ___gxx_personality_v048# A: 0x[[#%x,PERSONALITY_1:]] LOCAL49# A: 0x[[#%x,PERSONALITY_2:]] LOCAL50# A: 0x[[#%x,GXX_PERSONALITY_HI:]] LOCAL51 52# BC: Indirect symbols for (__DATA_CONST,__got)53# BC-NEXT: address index name54# BC: 0x[[#%x,GXX_PERSONALITY_LO:]] LOCAL55# C: 0x[[#%x,GXX_PERSONALITY_HI:]] LOCAL56# BC: 0x[[#%x,PERSONALITY_1:]] LOCAL57# BC: 0x[[#%x,PERSONALITY_2:]] LOCAL58# BC-EMPTY:59 60# CHECK: Personality functions: (count = 3)61# CHECK-DAG: personality[{{[0-9]+}}]: 0x{{0*}}[[#GXX_PERSONALITY_LO-OFF]]62# CHECK-DAG: personality[{{[0-9]+}}]: 0x{{0*}}[[#PERSONALITY_1-OFF]]63# CHECK-DAG: personality[{{[0-9]+}}]: 0x{{0*}}[[#PERSONALITY_2-OFF]]64 65# A: Bind table66# A-NEXT: segment section address type addend dylib symbol67# A-NEXT: __DATA_CONST __got 0x[[#GXX_PERSONALITY_LO-0]] pointer 0 libc++abi ___gxx_personality_v068 69 70# D: Indirect symbols for (__DATA_CONST,__got) 6 entries71# D-NEXT: address index name72# D: 0x[[#%x,GXX_PERSONALITY_HI:]] [[#]] ___gxx_personality_v073# D: 0x[[#%x,PERSONALITY_1:]] LOCAL74# D: 0x[[#%x,PERSONALITY_2:]] LOCAL75# D: 0x[[#%x,PERSONALITY_3:]] LOCAL76# D: 0x[[#%x,PERSONALITY_4:]] LOCAL77# D: 0x[[#%x,GXX_PERSONALITY_LO:]] LOCAL78 79# D: Contents of __unwind_info section:80# D: Personality functions: (count = 1)81 personality[1]: 0x{{0*}}[[#GXX_PERSONALITY_HI-OFF]]82 83# D: Bind table:84# D: segment section address type addend dylib symbol85# D: __DATA_CONST __got 0x[[#GXX_PERSONALITY_HI-0]] pointer 0 libc++abi ___gxx_personality_v086 87 88## Error cases.89## Check that dylib symbols are picked (which means without libc++, we'd get an undefined symbol error.90# RUN: not %lld -lSystem %t/user_2.o %t/combined.o -o /dev/null 2>&1 | FileCheck %s --check-prefix=ERRORCHECK91# ERRORCHECK: {{.*}} undefined symbol: ___gxx_personality_v092 93#--- user_4.s94.globl _main, _personality_1, _personality_2, _personality_3, _personality_495 96.text97 98_baz1:99 .cfi_startproc100 .cfi_personality 155, _personality_1101 .cfi_def_cfa_offset 16102 retq103 .cfi_endproc104 105_baz2:106 .cfi_startproc107 .cfi_personality 155, _personality_2108 .cfi_def_cfa_offset 16109 retq110 .cfi_endproc111 112_baz3:113 .cfi_startproc114 .cfi_personality 155, _personality_3115 .cfi_def_cfa_offset 16116 retq117 .cfi_endproc118 119 120_baz4:121 .cfi_startproc122 .cfi_personality 155, _personality_4123 .cfi_def_cfa_offset 16124 retq125 .cfi_endproc126 127_main:128 .cfi_startproc129 .cfi_personality 155, ___gxx_personality_v0130 .cfi_def_cfa_offset 16131 retq132 .cfi_endproc133 134_personality_1:135 retq136_personality_2:137 retq138_personality_3:139 retq140_personality_4:141 retq142 143#--- user_3.s144.globl _baz3145.private_extern ___gxx_personality_v0146 147.text148_baz3:149 .cfi_startproc150 .cfi_personality 155, ___gxx_personality_v0151 .cfi_def_cfa_offset 16152 retq153 .cfi_endproc154 155.text156.no_dead_strip ___gxx_personality_v0157___gxx_personality_v0:158 nop159 160.subsections_via_symbols161 162 163#--- user_2.s164.globl _main, _personality_1, _personality_2165 166.text167 168_bar:169 .cfi_startproc170 .cfi_personality 155, _personality_1171 .cfi_def_cfa_offset 16172 retq173 .cfi_endproc174 175_baz:176 .cfi_startproc177 .cfi_personality 155, _personality_2178 .cfi_def_cfa_offset 16179 retq180 .cfi_endproc181 182_main:183 .cfi_startproc184 .cfi_personality 155, ___gxx_personality_v0185 .cfi_def_cfa_offset 16186 retq187 .cfi_endproc188 189_personality_1:190 retq191_personality_2:192 retq193 194## This yaml was created from the combined.o object file described in this comment:195## https://reviews.llvm.org/D107533#2935217196#--- combined.yaml197--- !mach-o198FileHeader:199 magic: 0xFEEDFACF200 cputype: 0x1000007201 cpusubtype: 0x3202 filetype: 0x1203 ncmds: 4204 sizeofcmds: 384205 flags: 0x2000206 reserved: 0x0207LoadCommands:208 - cmd: LC_SEGMENT_64209 cmdsize: 312210 segname: ''211 vmaddr: 0212 vmsize: 152213 fileoff: 448214 filesize: 152215 maxprot: 7216 initprot: 7217 nsects: 3218 flags: 0219 Sections:220 - sectname: __text221 segname: __TEXT222 addr: 0x0223 size: 5224 offset: 0x1C0225 align: 2226 reloff: 0x0227 nreloc: 0228 flags: 0x80000400229 reserved1: 0x0230 reserved2: 0x0231 reserved3: 0x0232 content: 90909090C3233 - sectname: __eh_frame234 segname: __TEXT235 addr: 0x8236 size: 80237 offset: 0x1C8238 align: 3239 reloff: 0x258240 nreloc: 5241 flags: 0x0242 reserved1: 0x0243 reserved2: 0x0244 reserved3: 0x0245 content: 1400000000000000017A520001781001100C0708900100001800000000000000017A505200017810069B04000000100C070890011800000004000000F8FFFFFFFFFFFFFF0100000000000000000E1000246 relocations:247 - address: 0x2A248 symbolnum: 0249 pcrel: true250 length: 2251 extern: true252 type: 4253 scattered: false254 value: 0255 - address: 0x38256 symbolnum: 2257 pcrel: false258 length: 2259 extern: true260 type: 5261 scattered: false262 value: 0263 - address: 0x38264 symbolnum: 3265 pcrel: false266 length: 2267 extern: true268 type: 0269 scattered: false270 value: 0271 - address: 0x3C272 symbolnum: 3273 pcrel: false274 length: 3275 extern: true276 type: 5277 scattered: false278 value: 0279 - address: 0x3C280 symbolnum: 4281 pcrel: false282 length: 3283 extern: true284 type: 0285 scattered: false286 value: 0287 - sectname: __compact_unwind288 segname: __LD289 addr: 0x58290 size: 64291 offset: 0x218292 align: 3293 reloff: 0x280294 nreloc: 3295 flags: 0x2000000296 reserved1: 0x0297 reserved2: 0x0298 reserved3: 0x0299 content: '00000000000000000100000000000202000000000000000000000000000000000000000000000000010000000000020200000000000000000000000000000000'300 relocations:301 - address: 0x0302 symbolnum: 0303 pcrel: false304 length: 3305 extern: true306 type: 0307 scattered: false308 value: 0309 - address: 0x20310 symbolnum: 4311 pcrel: false312 length: 3313 extern: true314 type: 0315 scattered: false316 value: 0317 - address: 0x30318 symbolnum: 0319 pcrel: false320 length: 3321 extern: true322 type: 0323 scattered: false324 value: 0325 - cmd: LC_SYMTAB326 cmdsize: 24327 symoff: 664328 nsyms: 5329 stroff: 744330 strsize: 48331 - cmd: LC_BUILD_VERSION332 cmdsize: 32333 platform: 1334 minos: 659200335 sdk: 720896336 ntools: 1337 Tools:338 - tool: 3339 version: 39913472340 - cmd: LC_DATA_IN_CODE341 cmdsize: 16342 dataoff: 664343 datasize: 0344LinkEditData:345 NameList:346 - n_strx: 7347 n_type: 0x1E348 n_sect: 1349 n_desc: 32350 n_value: 0351 - n_strx: 29352 n_type: 0xE353 n_sect: 2354 n_desc: 0355 n_value: 8356 - n_strx: 29357 n_type: 0xE358 n_sect: 2359 n_desc: 0360 n_value: 32361 - n_strx: 39362 n_type: 0xE363 n_sect: 2364 n_desc: 0365 n_value: 60366 - n_strx: 2367 n_type: 0xF368 n_sect: 1369 n_desc: 0370 n_value: 4371 StringTable:372 - ' '373 - _foo374 - ___gxx_personality_v0375 - EH_Frame1376 - func.eh377 - ''378...379