Page MenuHomePhabricator

[lld-macho] Put GOT into `__DATA` segment where appropriate
ClosedPublic

Authored by int3 on Oct 25 2021, 5:08 PM.

Details

Summary

We were previously always emitting the GOT into __DATA_CONST, even for
target platforms where it should end up in __DATA.

I stumbled onto this while trying to use the class-dump tool -- with
the wrong segment names, it fails to locate the ObjC runtime info and
therefore fails to dump any classes.

Diff Detail

Event Timeline

int3 created this revision.Oct 25 2021, 5:08 PM
Herald added a project: Restricted Project. · View Herald Transcript
int3 requested review of this revision.Oct 25 2021, 5:08 PM
Herald added a project: Restricted Project. · View Herald TranscriptOct 25 2021, 5:08 PM
oontvoo added inline comments.
lld/MachO/SyntheticSections.cpp
262

it's still not quite correct to unconditionally put it in non-const, though.
(there's the -data_const flag for one )

262

P.S: I dont actually have a strong opinion either way. But could we at least have a FIXME or note here for future work?

int3 marked an inline comment as done.Oct 25 2021, 5:37 PM
int3 added inline comments.
lld/MachO/SyntheticSections.cpp
262

that's already being done in initializeSectionRenameMap in Driver.cpp :)

the problem was that we would only rename from non-const to const, and not the other way around. So initializing the section to a const segment here meant that we would never emit it as non-const...

oontvoo accepted this revision.EditedOct 25 2021, 5:43 PM

LGTM

Looks like treat-undef-sym.s is failing . PTAL

lld/MachO/SyntheticSections.cpp
262

Ah, I see. Sorry for the noise then!

This revision is now accepted and ready to land.Oct 25 2021, 5:43 PM
This revision was landed with ongoing or failed builds.Oct 26 2021, 8:38 AM
This revision was automatically updated to reflect the committed changes.
int3 marked an inline comment as done.