[PATCH] D107533: Handle encoding personalities of same names but different kinds.

Vy Nguyen via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 9 11:58:12 PDT 2021


oontvoo added a comment.

In D107533#2931939 <https://reviews.llvm.org/D107533#2931939>, @int3 wrote:

> Huh, interesting. I assume that the Defined symbols here are local symbols? Since global Defineds should overwrite the dylib symbols.

Yep! Local symbols (ie., 't' ) (more specifically private_extern ('T')  symbol that got changed to local symbol via `ld -r`)

I've tried to make the repro as less convoluted as I could:

**// defined.s **

  .private_extern ___gxx_personality_v0
  
  .text
  .no_dead_strip ___gxx_personality_v0	
  ___gxx_personality_v0:	
    .cfi_startproc
    .cfi_def_cfa_offset 16
    .cfi_endproc
    nop
  
  .subsections_via_symbols

**// user_1.s**

  .globl _foo
  .text
  .p2align 2
  _foo:
    .cfi_startproc
    .cfi_personality 155, ___gxx_personality_v0
    .cfi_def_cfa_offset 16
    ret
    .cfi_endproc
  
  .subsections_via_symbols

**// user_2.s**

  .globl _main
  
  .text
  .p2align 2
  _main:
    .cfi_startproc
    .cfi_personality 155, ___gxx_personality_v0
    .cfi_def_cfa_offset 16
    ret
    .cfi_endproc
  
  .subsections_via_symbols

**Link commands:**

  clang -fexceptions -c -o defined.o defined.s
  clang -fexceptions -c -o user_1.o user_1.s
  clang -fexceptions -c -o user_2.o user_2.s
  
  ##  concat defined.o and user_1.o with `ld -r`
  ## this will change  'T' ___gxx_personality_v0  ===> 't' ___gxx_personality_v0
  ld -r -o combined.o defined.o user_1.o
  
  ## finally link with lld-macho:
  ld64.lld.darwinnew   -arch "x86_64" -platform_version macos 10.15 11.0   -syslibroot "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk"  -lc++ -lSystem user_2.o combined.o      



> Can we have a test to verify that we're matching ld64's behavior?

maybe we could have lld-macho implement `-r` to make it easier to write tests like these ...

> P.S. I'm on semi-vacation till the middle of next week, will be a bit sporadic in responding

no worries! thanks!


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D107533/new/

https://reviews.llvm.org/D107533



More information about the llvm-commits mailing list