This is an archive of the discontinued LLVM Phabricator instance.

[lld-macho] Handle GOT relocations of non-dylib symbols
ClosedPublic

Authored by int3 on May 29 2020, 9:22 PM.

Details

Summary

Turns out this case is actually really common -- it happens whenever there's
a reference to an extern variable that ends up statically linked.

Depends on D80856.

Diff Detail

Event Timeline

int3 created this revision.May 29 2020, 9:22 PM
Herald added a project: Restricted Project. · View Herald TranscriptMay 29 2020, 9:22 PM
MaskRay added inline comments.May 31 2020, 3:22 PM
lld/MachO/SyntheticSections.cpp
91

You can drop braces.

lld/test/MachO/local-got.s
2

test/ELF/local-got.s may not be the best name

If you can think of a better name, use that.

10

Align Contents like you did below

int3 marked an inline comment as done.Jun 2 2020, 3:43 PM
int3 added inline comments.
lld/test/MachO/local-got.s
2

I'm fine with the current name...

int3 updated this revision to Diff 268011.Jun 2 2020, 3:43 PM
int3 marked an inline comment as done.

address comments

int3 marked an inline comment as done.Jun 2 2020, 3:43 PM
int3 updated this revision to Diff 268066.Jun 2 2020, 11:46 PM

make sure to skip over non-dylib symbol entries when generating bind opcodes for GOT

smeenai accepted this revision.Jun 9 2020, 7:21 PM

Looks great!

lld/MachO/Target.h
53

getDylibSymbolVA needs to be updated on this line.

lld/test/MachO/local-got.s
2

How about got-reloc-for-local-symbol?

This revision is now accepted and ready to land.Jun 9 2020, 7:21 PM
int3 marked 2 inline comments as done.Jun 13 2020, 11:26 PM
int3 added inline comments.
lld/test/MachO/local-got.s
2

heh, I prefer local-got over got-reloc-for-local-symbol, it's much terser :p

int3 updated this revision to Diff 270606.Jun 13 2020, 11:27 PM

update comment

This revision was automatically updated to reflect the committed changes.