[llvm-commits] [PATCH] [lld] Move everything over to TargetInfo.

Nick Kledzik kledzik at apple.com
Tue Jan 22 17:00:34 PST 2013


On Jan 22, 2013, at 4:46 PM, Michael Spencer wrote:
>  As for OutputKind. I see 11 different types in mach-o/loader.h.
> 
>  I'm fine with adding them to OutputKind. The only ones that are actually Mach-O specific are:
> 
>  * MH_FVLIB - I assume this means a non-pic shared library. Controlling this should probably just be a flag.
>  * MH_PRELOAD
>  * MH_DSYM
>  * MH_KEXT_BUNDLE

Some of the values mach-o/loader.h are obsolete and some are overloaded.  ld64 currently uses:

	enum OutputKind { kDynamicExecutable, kStaticExecutable, kDynamicLibrary, 
                                           kDynamicBundle, kObjectFile, kDyld, kPreload, kKextBundle };



> ================
> Comment at: lib/ReaderWriter/MachO/WriterMachO.cpp:654
> @@ +653,3 @@
> +    return MH_DYLIB;
> +  case OutputKind::Relocatable:
> +    return MH_OBJECT;
> ----------------
> kledzik at apple.com wrote:
>> You dropped the "bundle" case
> Fixed.
> 
> ================
> Comment at: lib/ReaderWriter/MachO/WriterMachO.cpp:800-805
> @@ -798,8 +799,8 @@
>   // Add entry point load command to main executables
> -  if ( _options.addEntryPointLoadCommand() ) {
> +  if (_targetInfo.getLinkerOptions()._outputKind == OutputKind::Executable) {
>     _entryPointLoadCommand = new entry_point_command(is64);
>     this->addLoadCommand(_entryPointLoadCommand);
> -  }
> -  else if ( _options.addUnixThreadLoadCommand() ) {
> -    _threadLoadCommand = new thread_command(_options.cpuType(), is64);
> +  } else if (_targetInfo.getLinkerOptions()._outputKind ==
> +             OutputKind::Executable) {
> +    _threadLoadCommand = new thread_command(_targetInfo.getCPUType(), is64);
>     this->addLoadCommand(_threadLoadCommand);
> ----------------
> kledzik at apple.com wrote:
>> These if conditions are now incorrect.
> They have exactly the same semantics as what was there previously. I moved them into MachOTargetInfo with the same function names.

You optimized away the source level semantics.  Mach-o uses different load commands to specify the entry point depending on the target OS and the target min OS version.  addEntryPointLoadCommand() asks the options object if that load command should be added.  addUnixThreadLoadCommand() asks if the other load command should  be added.  The implementation of those methods look currently similar because there is no infrastructure yet to ask the min OS version being targeted.   We need those methods in the mach-o TargetInfo.

-Nick





More information about the llvm-commits mailing list