This is an archive of the discontinued LLVM Phabricator instance.

[lld-macho] Support non-pcrel section relocs
ClosedPublic

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

Diff Detail

Event Timeline

int3 created this revision.May 29 2020, 9:17 PM
Herald added a project: Restricted Project. · View Herald TranscriptMay 29 2020, 9:17 PM
smeenai requested changes to this revision.Jun 9 2020, 6:38 PM

The logic looks good; putting back in your queue for the comment about the test. (Please request review again if I'm just misunderstanding the test.)

lld/MachO/InputFiles.cpp
196

Super nit: even though it's not technically needed, for instances like this where there's a comment within an if (even though there's only a single actual statement), I prefer putting braces around it (and the else), to prevent any possible confusion.

lld/test/MachO/relocations.s
60

Are you missing the corresponding CHECK for this? It would also be nice to add a test with a non-zero offset.

This revision now requires changes to proceed.Jun 9 2020, 6:38 PM
int3 updated this revision to Diff 270604.Jun 13 2020, 11:13 PM
int3 marked 4 inline comments as done.

address comments

lld/MachO/InputFiles.cpp
196

I prefer that too, just wasn't sure what the prevailing style was supposed to be :)

lld/test/MachO/relocations.s
60

Are you missing the corresponding CHECK for this?

oh yeah good catch

It would also be nice to add a test with a non-zero offset.

L._str is at a non-zero offset in its section, which I think is the important case to test, but yeah I guess it wouldn't hurt to add another reloc whose source is also at a non-zero offset

smeenai accepted this revision.Jun 15 2020, 12:10 PM

LGTM

lld/test/MachO/relocations.s
60

Ah, I'd missed that, but yeah, the second reloc doesn't hurt.

This revision is now accepted and ready to land.Jun 15 2020, 12:10 PM
MaskRay accepted this revision.Jun 15 2020, 12:56 PM

Thanks!

lld/test/MachO/relocations.s
32

Rather than saying "This generates a pcrel symbol relocation",
it may be more helpful to just write the relocation type.

If I want to check whether lld-macho supports one particular relocation type, I'll grep the source. If the relocation type is literally mentioned in the test, it can help locate the test cases.

int3 marked an inline comment as done.Jun 15 2020, 2:13 PM
int3 added inline comments.
lld/test/MachO/relocations.s
32

The type doesn't indicate whether it's pcrel or symbol vs section, though, so those bits of info are still necessary. But good point about greppability, I'll add in the type

int3 updated this revision to Diff 270860.Jun 15 2020, 2:13 PM

add reloc types in comments

This revision was automatically updated to reflect the committed changes.