'unable to load command 0x2?' warnings under MacOS X

Bug #1018356 reported by Pavel Cherenkov
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
tarantool
Won't Fix
Undecided
Pavel Cherenkov

Bug Description

Non-static binaries, compiled with gcc-mp-4.6 (from mac ports) and linked with libbfd (also from ports), at initialization point, print out warnings like: 'unable to load command 0x24' or 'unable to load command 0x26', etc.

In most cases (observed with tarantool binaries under Mac OS X Lion), the command code is >= 0x20.

The message comes from bfd/mach-o.c (as in http://opensource.apple.com/source/gdb/gdb-967/src/bfd/mach-o.c):

  switch (command->type)
    {
    case BFD_MACH_O_LC_SEGMENT:
      if (bfd_mach_o_scan_read_segment_32 (abfd, command) != 0)
 return -1;
      break;
.....
    default:
      fprintf (stderr, "unable to read unknown load command 0x%lx\n",
        (unsigned long) command->type);
      break;
    }

The warning says that BFD cannot recognize the Mach-O section load command it has encountered.

Looking at bfd/mach-o.h (http://opensource.apple.com/source/cxxfilt/cxxfilt-9/cxxfilt/bfd/mach-o.h?txt) where known load commands are described, we find that commands there range from 0x1 to 0x18, yet nothing beyond.

Mac OS X (Lion) defines load constants in /usr/include/mach-o/loader.h (available if you've installed XCode), from 0x1 to 0x27. Therefore, the most logical explanation to seeing the warnings for load codes > 0x18 appears to be the lack of the said codes in BFD's own header.

This seems to place it as a BFD-specific issue that should eventually (when the codes are brought in sync) disappear.

Tags: darwin
Revision history for this message
Pavel Cherenkov (pcherenkov) wrote :

The latest (non-ported) release of GNU binutils is 2.22 and it *does* include the required code:

binutils-2.22/bfd/mach-o.c:
.............
    case BFD_MACH_O_LC_DYLD_INFO:
      if (bfd_mach_o_read_dyld_info (abfd, command) != 0)
        return -1;
      break;
    case BFD_MACH_O_LC_VERSION_MIN_MACOSX:
    case BFD_MACH_O_LC_VERSION_MIN_IPHONEOS:
      if (!bfd_mach_o_read_version_min (abfd, command))
        return -1;
      break;

binutils-2.22/include/mach-o/loader.h:

  BFD_MACH_O_LC_VERSION_MIN_IPHONEOS = 0x25, /* Minimal IOS version. */
  BFD_MACH_O_LC_FUNCTION_STARTS = 0x26, /* Compressed table of func start. */
  BFD_MACH_O_LC_DYLD_ENVIRONMENT = 0x27 /* Env variable string for dyld. */

However, the latest version is not *yet* in the mac ports:
Mac-mini-tarantool ~/tmp$ port list binutils
binutils @2.21 devel/binutils
Mac-mini-tarantool ~/tmp$ port list installed | grep binutils
binutils @2.21 devel/binutils
Mac-mini-tarantool ~/tmp$ port list outdated | grep binutils
Mac-mini-tarantool ~/tmp$

Changed in tarantool:
assignee: nobody → Pavel Cherenkov (pcherenkov)
Revision history for this message
Kostja Osipov (kostja) wrote :

Over a year without a fix, not worth bothering with.

Changed in tarantool:
status: New → Won't Fix
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.