Fix for #4318 (Linker failure on OS X 10.6)

Authored by gwright@antiope.com <unknown> on Oct 26 2010, 8:51 AM.

Description

Fix for Trac #4318 (Linker failure on OS X 10.6)

This patch fixes two bugs in the Mach-O linker and adds debugging statements
to the same. The bugs:

  1. The test for symbol->n_value == 0 is removed and replaced by a test of the

flag field. Checking the n_value field was just wrong; the value of a
symbol should only be examined when allocating space for a common block,
in which case the n_value field gives the size of the block. This bug
led to an infrequently occuring linker crash.

I believe the behavior of the linker now agrees with the intent of the
sketchy Apple documentation.

  1. Jump islands were being filled with garbage instead of the the location

of the referenced symbol. This caused relocations of type X86_64_RELOC_GOT and
X86_64_RELOC_GOT_LOAD to eventually lead to crashes. The fix is simply to
look up the symbol.

Enough debug statements have been added to follow the operation of the Mach-O
linker while it loads modules. They are not yet as informative and well
organized as for ELF. Improving the debug statements will require some
reorganization of the code -- the Mach-O linker seems basically sound, but
is crying out for some refactoring and commenting.

Details

Committed
gwright@antiope.com <unknown>Oct 26 2010, 8:51 AM
Pushed
bgamariAug 25 2016, 1:39 PM
Parents
rGHCDIFF116134b1319e: Use removeDups to find top-level duplicate names findDupsEq is quadratic…
Branches
Unknown
Tags
Unknown
gwright@antiope.com <unknown> committed rGHCDIFF73dd6e846122: Fix for #4318 (Linker failure on OS X 10.6) (authored by gwright@antiope.com <unknown>).Oct 26 2010, 8:51 AM