+ // aliases sort before their target
+ bool leftIsAlias = left->isAlias();
+ if ( leftIsAlias ) {
+ for (ld::Fixup::iterator fit=left->fixupsBegin(); fit != left->fixupsEnd(); ++fit) {
+ const ld::Atom* target = NULL;
+ if ( fit->kind == ld::Fixup::kindNoneFollowOn ) {
+ switch ( fit->binding ) {
+ case ld::Fixup::bindingsIndirectlyBound:
+ target = _state.indirectBindingTable[fit->u.bindingIndex];
+ break;
+ case ld::Fixup::bindingDirectlyBound:
+ target = fit->u.target;
+ break;
+ default:
+ break;
+ }
+ if ( target == right )
+ return true; // left already before right
+ left = target; // sort as if alias was its target
+ break;
+ }
+ }
+ }
+ bool rightIsAlias = right->isAlias();
+ if ( rightIsAlias ) {
+ for (ld::Fixup::iterator fit=right->fixupsBegin(); fit != right->fixupsEnd(); ++fit) {
+ const ld::Atom* target = NULL;
+ if ( fit->kind == ld::Fixup::kindNoneFollowOn ) {
+ switch ( fit->binding ) {
+ case ld::Fixup::bindingsIndirectlyBound:
+ target = _state.indirectBindingTable[fit->u.bindingIndex];
+ break;
+ case ld::Fixup::bindingDirectlyBound:
+ target = fit->u.target;
+ break;
+ default:
+ break;
+ }
+ if ( target == left )
+ return false; // need to swap, alias is after target
+ right = target; // continue with sort as if right was target
+ break;
+ }
+ }
+ }
+