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

Jez Ng via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 16 14:26:23 PDT 2021


int3 added a comment.

> Actually this diff doesn't change which symbol "wins" in the final output - (it's pretty inconsequential to that)

It changes which symbol "wins" as the personality symbol (as your "Prioritize Defined over others." comment indicates). ld64 always picks the dylib symbol; your diff seems to pick whichever symbol comes first:

  (base) ~/unwind: ld64.lld -arch "x86_64" -platform_version macos 10.15 11.0   -syslibroot "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk" -lSystem -lc++ combined.o user_2.o -o out-lld
  ld64.lld: warning: combined.o has version 11.0.0, which is newer than target minimum of 10.15
  ld64.lld: warning: user_2.o has version 11.0.0, which is newer than target minimum of 10.15
  (base) ~/unwind:  llvm-objdump --macho --bind --unwind-info out-lld
  out-lld:
  Contents of __unwind_info section:
    Version:                                   0x1
    Common encodings array section offset:     0x1c
    Number of common encodings in array:       0x3
    Personality function array section offset: 0x28
    Number of personality functions in array:  0x1
    Index array section offset:                0x2c
    Number of indices in array:                0x2
    Common encodings: (count = 3)
      encoding[0]: 0x12020000
      encoding[1]: 0x02020000
      encoding[2]: 0x00000000
    Personality functions: (count = 1)
      personality[1]: 0x00002000
    Top level indices: (count = 2)
      [0]: function offset=0x00000000, 2nd level page offset=0x00000044, LSDA offset=0x00000044
      [1]: function offset=0x00000439, 2nd level page offset=0x00000000, LSDA offset=0x00000044
    LSDA descriptors:
    Second level indices:
      Second level index[0]: offset in section=0x00000044, base function offset=0x00000000
        [0]: function offset=0x00000000, encoding=0x12020000
        [1]: function offset=0x00000001, encoding=0x02020000
        [2]: function offset=0x00000430, encoding=0x00000000
        [3]: function offset=0x00000438, encoding=0x12020000
  
  Bind table:
  segment  section            address    type       addend dylib            symbol
  __DATA_CONST __got              0x100002008 pointer         0 libc++           ___gxx_personality_v0

Note that the personality symbol does not match the dynamically bound address. (We should probably not be binding `___gxx_personality_v0` at all, but anyway...)

> user_1.o + defined.o is not the same thing as combined.o .

I understood that. My point is that it *should* be the same thing. I would rather we not try to handle this weird edge case of ld64 if possible.

> I believe -keep_private_externs (which isn't the default) will turn that off.

Nice, this seems to work in my local testing. @oontvoo, can you use that flag to work around the issue? Or are you trying to link some binary blob for which you don't have the source?


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