[llvm-commits] [patch] Identifying code sections in MCJIT
Tim Northover
t.p.northover at gmail.com
Wed Dec 12 07:33:16 PST 2012
> From the looks of it, MachO support could do with some work as some of it
> remains stubbed. A new function like ObjectFile::isCode() could be
> implemented instead. This would make use of the existing isText() on ELF,
> and on MachO check if the section name is __text or one of the special
> sections mentioned above.
Looking at the specification, I don't think we'd have to do anything
as ugly as guessing from the name. There's actually a section-level
equivalent to ELF's executable flag: S_ATTR_SOME_INSTRUCTIONS.
Of course, there's also a possible segment specification (as there is
in ELF actually): the "initprot" field. In the ELF world segments are
only created by a linker, so they won't be present in the MCJIT case.
It looks like MachO files always have segments, which means the
segment should probably take precedence in theory. I can't think of
any situation where LLVM would produce an object file where these
wouldn't be expected to match though.
However, I have rather limited access to MachO hardware, and even less
experience with it so we could really do with an expert weighing in
here. It may well be that the current implementation of isText is good
enough for all supported MachO uses, or at least as good as checking
the first symbol encountered in a section.
Tin.
More information about the llvm-commits
mailing list