This is an archive of the discontinued LLVM Phabricator instance.

[lld-macho] Fix symbol relocs handling for compact unwind's functionAddress
ClosedPublic

Authored by int3 on Nov 11 2021, 11:09 AM.

Details

Summary

Clang seems to emit all functionAddress relocs as section relocs, but
ld -r can turn those relocs into symbol ones. It turns out that we
weren't handling that case correctly when the symbol was a weak def
whose definition did not prevail.

Diff Detail

Event Timeline

int3 created this revision.Nov 11 2021, 11:09 AM
Herald added a project: Restricted Project. · View Herald Transcript
int3 requested review of this revision.Nov 11 2021, 11:09 AM
Herald added a project: Restricted Project. · View Herald TranscriptNov 11 2021, 11:09 AM
int3 updated this revision to Diff 386602.Nov 11 2021, 11:14 AM

simplify test

int3 updated this revision to Diff 386656.Nov 11 2021, 1:48 PM

elaborate on comment

LG

lld/MachO/InputFiles.cpp
915

sorry, not 100% related to this, but if the same input file is repeated on the command line, does the pointer equality hold true? or do they count as separate files?

lld/test/MachO/weak-definition-gc.s
262

at this point is it worth implementing -r yet?
these yaml files are kind of annoying

473–481

do we need all these?

int3 added inline comments.Nov 11 2021, 4:58 PM
lld/MachO/InputFiles.cpp
915

separate files (there's a dup symbol test along those lines)

lld/test/MachO/weak-definition-gc.s
262

I mean, feel free to attempt it :P it's not a priority for me

473–481

looks like the empty strings can be deleted yeah. the other two are symbol names

int3 added inline comments.Nov 11 2021, 5:03 PM
lld/test/MachO/weak-definition-gc.s
262

also, it's not clear to me that implementing -r would remove the need for these YAML files, unless we want to reproduce all the quirks of ld64. We might very well find it easier to not convert section to symbol relocations in our own implementation.

int3 added a comment.Nov 11 2021, 5:05 PM

did you forget to stamp this? :)

oontvoo accepted this revision.Nov 11 2021, 5:06 PM

👍

This revision is now accepted and ready to land.Nov 11 2021, 5:06 PM
This revision was landed with ongoing or failed builds.Nov 11 2021, 7:53 PM
This revision was automatically updated to reflect the committed changes.