This is an archive of the discontinued LLVM Phabricator instance.

[llvm-readobj] Add support for MachO DataInCodeDataCommand
ClosedPublic

Authored by davide on Aug 17 2015, 8:14 AM.

Details

Summary

macho-dump has this. And some tests rely on it.
I ported it to llvm-readobj as part of the bigger project "let's deprecate macho-dump".
Example output:

% /exps/llvm2/build/./bin/llvm-mc -triple armv7-apple-darwin10 -filetype=obj -o - < /exps/llvm2/test/MC/MachO/ARM/data-in-code.s | /exps/llvm2/build/bin/llvm-readobj -macho-dice

File: <stdin>
Format: Mach-O arm
Arch: arm
AddressSize: 32bit
DataInCode {

Data offset: 300
Data size: 32
Data Regions [
  DICE {
    Index: 0
    Offset: 0
    Length: 4
    Kind: 1
  }
  DICE {
    Index: 1
    Offset: 4
    Length: 4
    Kind: 4
  }
  DICE {
    Index: 2
    Offset: 8
    Length: 2
    Kind: 3
  }
  DICE {
    Index: 3
    Offset: 10
    Length: 1
    Kind: 2
  }
]

}

Feedback really appreciated.

Diff Detail

Event Timeline

davide updated this revision to Diff 32301.Aug 17 2015, 8:14 AM
davide retitled this revision from to [llvm-readobj] Add support for MachO DataInCodeDataCommand.
davide updated this object.
davide added reviewers: grosbach, rafael, echristo.
davide added a subscriber: llvm-commits.
davide added a subscriber: davide.Aug 17 2015, 8:15 AM

+ Kevin, who's not on phab.

rafael accepted this revision.Aug 18 2015, 11:01 AM
rafael edited edge metadata.

LGTM with nits since this will be getting tests as it replaces macho-dump.

MachODumper.cpp
614

Regions or entries?

619

Entry (or Region) is probably better than DICE.

llvm-readobj.cpp
186

Name the option macho-data-in-code maybe?

This revision is now accepted and ready to land.Aug 18 2015, 11:01 AM

Thank you for reviewing, Rafael. I agree with -macho-data-in-code. About the difference between region/entries -- I don't have strong preferences, so I'll change as you say (I just blatantly copied what was used in macho-dump). Maybe grosbach or enderby have a different opinion.

This revision was automatically updated to reflect the committed changes.

I went forward and commited this as r245732.
If anybody has other opinions about the lexicon -- we can change it later.
I'll start converting macho-dump tests soon so this feature will get tested.

Thanks,

Davide